import java.nio.file.Path;
+import org.simantics.acorn.exception.AcornAccessVerificationException;
+import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.db.Database.Session.ResourceSegment;
-import org.simantics.db.server.ProCoreException;
import org.simantics.utils.datastructures.Pair;
import gnu.trove.list.array.TByteArrayList;
private TByteArrayList bytes;
// Stub
- public FileInfo(LRU<String, FileInfo> LRU, Path readDir, String id, int offset, int length) {
+ public FileInfo(LRU<String, FileInfo> LRU, Path readDir, String id, int offset, int length) throws AcornAccessVerificationException {
super(LRU, id, readDir, id.toString() + ".extFile", offset, length, false, false);
LRU.map(this);
}
// New
- public FileInfo(LRU<String, FileInfo> LRU, String id, int size) {
+ public FileInfo(LRU<String, FileInfo> LRU, String id, int size) throws AcornAccessVerificationException {
super(LRU, id, LRU.getDirectory(), id.toString() + ".extFile", true, true);
this.bytes = new TByteArrayList(size);
LRU.insert(this, accessTime);
}
- public byte[] getResourceFile() {
+ public byte[] getResourceFile() throws AcornAccessVerificationException, IllegalAcornStateException {
if(VERIFY) verifyAccess();
makeResident();
return bytes.toArray();
-
}
- public ResourceSegment getResourceSegment(final byte[] clusterUID,
- final int resourceIndex, final long segmentOffset, short segmentSize)
- throws ProCoreException {
+ public ResourceSegment getResourceSegment(final byte[] clusterUID, final int resourceIndex, final long segmentOffset, short segmentSize) throws AcornAccessVerificationException, IllegalAcornStateException {
if(VERIFY) verifyAccess();
makeResident();
-
try {
-
int segSize = segmentSize;
if (segSize < 0)
segSize += 65536;
segSize = Math.min(65535, bytes.size());
final long valueSize = bytes.size();
-
final byte[] segment = bytes.toArray((int) segmentOffset, segSize);
return new ResourceSegment() {
return clusterUID;
}
};
-
} catch (Throwable t) {
-
- t.printStackTrace();
-
+ throw new IllegalAcornStateException(t);
}
-
- throw new UnsupportedOperationException();
-
}
- public void updateData(byte[] newBytes, long offset, long pos, long size) {
+ public void updateData(byte[] newBytes, long offset, long pos, long size) throws AcornAccessVerificationException, IllegalAcornStateException {
if(VERIFY) verifyAccess();
makeResident();