import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import org.simantics.acorn.ClusterManager;
+import org.simantics.acorn.exception.AcornAccessVerificationException;
+import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.db.Session;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.ClusterBase;
@Override
public int getClusterKeyByClusterUIDOrMake(ClusterUID clusterUID) {
- return impl.getClusterKeyByClusterUIDOrMakeWithoutMutex(clusterUID);
+ try {
+ return impl.getClusterKeyByClusterUIDOrMakeWithoutMutex(clusterUID);
+ } catch (IllegalAcornStateException | AcornAccessVerificationException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
}
}
- public ResourceSegment getResourceSegment(int resourceIndex, ClusterUID clusterUID, long offset, short size)
- throws DatabaseException {
+ public ResourceSegment getResourceSegment(int resourceIndex, ClusterUID clusterUID, long offset, short size) throws DatabaseException {
if (DEBUG)
System.out.println("DEBUG: getResourceSegment ri=" + resourceIndex + " cid=" + clusterUID + " offset=" + offset + " size=" + size);
- org.simantics.db.Database.Session.ResourceSegment t = impl.getResourceSegment(clusterUID.asBytes(), resourceIndex, offset, size);
- return new ResourceSegment(t.getValueSize(), t.getSegment());
-
+ try {
+ org.simantics.db.Database.Session.ResourceSegment t = impl.getResourceSegment(clusterUID.asBytes(), resourceIndex, offset, size);
+ return new ResourceSegment(t.getValueSize(), t.getSegment());
+ } catch (AcornAccessVerificationException | IllegalAcornStateException e) {
+ throw new DatabaseException(e);
+ }
}
protected byte[] getValueBig(ClusterBase cluster, int resourceIndex, int offset, int length) throws DatabaseException {
ClusterUID clusterUID = cluster.clusterUID;
- return impl.getResourceFile(clusterUID.asBytes(), resourceIndex);
-
+ try {
+ return impl.getResourceFile(clusterUID.asBytes(), resourceIndex);
+ } catch (AcornAccessVerificationException | IllegalAcornStateException e) {
+ throw new DatabaseException(e);
+ }
}
protected InputStream getValueStreamBig(ClusterBase cluster, final int resourceIndex, int offset, int length) throws DatabaseException {
@Override
public int read() throws IOException {
- if(left <= 0) throw new IllegalStateException();
+ if(left <= 0) return -1;
if(offset == _s.bytes.length) {
short slen = (short)Math.min(left, IMAX);