X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FFileInfo.java;h=0e1367f9954ee2f2aad677f7d89bd0b86fda620b;hp=660f245013b36bcf9879d90ed4af69de4d20a7cf;hb=1dfeb7d5c49b1391cd9d877e1eddab18995cb151;hpb=976581876c7f7b734d57d1c70cf4b309006c8b52 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..0e1367f99 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,49 +2,48 @@ package org.simantics.acorn.lru; 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.list.array.TByteArrayList; public class FileInfo extends LRUObject { + private static final Logger LOGGER = LoggerFactory.getLogger(FileInfo.class); private TByteArrayList bytes; // Stub - public FileInfo(LRU LRU, Path readDir, String id, int offset, int length) { + public FileInfo(LRU 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 LRU, String id, int size) { + public FileInfo(LRU 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; @@ -52,7 +51,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 +80,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(); @@ -136,4 +128,8 @@ public class FileInfo extends LRUObject { return true; } + @Override + public Logger getLogger() { + return LOGGER; + } } \ No newline at end of file