X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FFileInfo.java;h=12250d6a4e80af39208655289f9517a38b9c0bb9;hb=03fac449ec81e88669169d671bb386eb93ac060d;hp=660f245013b36bcf9879d90ed4af69de4d20a7cf;hpb=8ada31c956ee02aef38627ba4deaaae3eecb623a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java index 660f24501..12250d6a4 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java @@ -2,8 +2,10 @@ package org.simantics.acorn.lru; import java.nio.file.Path; +import org.simantics.acorn.FileCache; +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; @@ -13,38 +15,33 @@ public class FileInfo extends LRUObject { private TByteArrayList bytes; // Stub - public FileInfo(LRU LRU, Path readDir, String id, int offset, int length) { - super(LRU, id, readDir, id.toString() + ".extFile", offset, length, false, false); + public FileInfo(LRU LRU, FileCache fileCache, Path readDir, String id, int offset, int length) throws AcornAccessVerificationException { + super(LRU, fileCache, id, readDir, id.toString() + ".extFile", offset, length, false, false); LRU.map(this); } // New - public FileInfo(LRU LRU, String id, int size) { - super(LRU, id, LRU.getDirectory(), id.toString() + ".extFile", true, true); + public FileInfo(LRU LRU, FileCache fileCache, String id, int size) throws AcornAccessVerificationException { + super(LRU, fileCache, 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; @@ -52,7 +49,6 @@ public class FileInfo extends LRUObject { segSize = Math.min(65535, bytes.size()); final long valueSize = bytes.size(); - final byte[] segment = bytes.toArray((int) segmentOffset, segSize); return new ResourceSegment() { @@ -82,18 +78,12 @@ public class FileInfo extends LRUObject { 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();