]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java
Replace System.err and System.out with SLF4J Logging
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / lru / FileInfo.java
index 660f245013b36bcf9879d90ed4af69de4d20a7cf..0e1367f9954ee2f2aad677f7d89bd0b86fda620b 100644 (file)
@@ -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<String, FileInfo> {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(FileInfo.class);
        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;
@@ -52,7 +51,6 @@ public class FileInfo extends LRUObject<String, FileInfo> {
                                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<String, FileInfo> {
                                        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<String, FileInfo> {
                return true;
        }
 
+       @Override
+       public Logger getLogger() {
+           return LOGGER;
+       }
 }
\ No newline at end of file