Example #1
0
 public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException {
   for (DB4OBlob db4oBlob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OBlob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oBlob.getId());
     byte[] blob = db4oBlob.getValue();
     ByteArrayInputStream in = new ByteArrayInputStream(blob);
     OutputStream out = handler.handleBlob(id, blob.length);
     if (out != null) {
       try {
         IOUtil.copyBinary(in, out, blob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
   for (DB4OClob db4oClob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OClob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oClob.getId());
     char[] clob = db4oClob.getValue();
     CharArrayReader in = new CharArrayReader(clob);
     Writer out = handler.handleClob(id, clob.length);
     if (out != null) {
       try {
         IOUtil.copyCharacter(in, out, clob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
 }
Example #2
0
  protected void writeRevision(InternalCDORevision revision, OMMonitor monitor) {
    Async async = null;
    monitor.begin(10);

    try {
      try {
        async = monitor.forkAsync();
        if (revision.isResourceNode()) {
          checkDuplicateResources(revision);
        }
      } finally {
        if (async != null) {
          async.stop();
        }
      }

      // TODO removal of previous version implies query, this should be optimized

      long start = System.currentTimeMillis();
      CDOID id = revision.getID();
      DB4OStore.removeRevision(getObjectContainer(), id);
      DB4ORevision primitiveRevision = DB4ORevision.getDB4ORevision(revision);
      writeObject(primitiveRevision, monitor);
      long end = System.currentTimeMillis();
      OM.LOG.debug("Writing revision " + id + " took: " + (end - start) + " milliseconds");
    } finally {
      monitor.done();
    }
  }
Example #3
0
 public void queryLobs(List<byte[]> ids) {
   for (Iterator<byte[]> it = ids.iterator(); it.hasNext(); ) {
     byte[] id = it.next();
     String key = HexUtil.bytesToHex(id);
     if (DB4OStore.getIdentifiableObject(getObjectContainer(), key) == null) {
       it.remove();
     }
   }
 }
Example #4
0
  public InternalCDORevision readRevisionByVersion(
      CDOID id, CDOBranchVersion branchVersion, int listChunk, CDORevisionCacheAdder cache) {
    DB4ORevision revision = DB4OStore.getRevision(getObjectContainer(), id);
    if (revision == null || revision.getVersion() != branchVersion.getVersion()) {
      return null;
    }

    return DB4ORevision.getCDORevision(getStore(), revision);
  }
Example #5
0
  public InternalCDORevision readRevision(
      CDOID id, CDOBranchPoint branchPoint, int listChunk, CDORevisionCacheAdder cache) {
    DB4ORevision lastRevision = DB4OStore.getRevision(getObjectContainer(), id);
    if (lastRevision == null) {
      // Revision does not exist. Return null to signal inexistent Revision
      return null;
    }

    return DB4ORevision.getCDORevision(getStore(), lastRevision);
  }
Example #6
0
  protected void writeRevisionDelta(
      InternalCDORevisionDelta revisionDelta, CDOBranch branch, long created) {
    CDOID id = revisionDelta.getID();
    InternalCDORevision revision =
        DB4ORevision.getCDORevision(getStore(), DB4OStore.getRevision(getObjectContainer(), id));
    InternalCDORevision newRevision = revision.copy();
    newRevision.adjustForCommit(branch, created);

    revisionDelta.apply(newRevision);
    writeRevision(newRevision, new Monitor());
  }
Example #7
0
  @Override
  protected void detachObjects(
      CDOID[] detachedObjects, CDOBranch branch, long timeStamp, OMMonitor monitor) {
    monitor.begin(detachedObjects.length);

    try {
      for (CDOID id : detachedObjects) {
        DB4OStore.removeRevision(getObjectContainer(), id);
        monitor.worked();
      }
    } finally {
      monitor.done();
    }
  }
Example #8
0
  public void loadLob(byte[] id, OutputStream out) throws IOException {
    String key = HexUtil.bytesToHex(id);
    IDB4OIdentifiableObject identifiableObject =
        DB4OStore.getIdentifiableObject(getObjectContainer(), key);
    if (identifiableObject == null) {
      throw new IOException("Lob not found: " + key);
    }

    if (identifiableObject instanceof DB4OBlob) {
      DB4OBlob blob = (DB4OBlob) identifiableObject;
      byte[] byteArray = blob.getValue();
      ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
      IOUtil.copyBinary(in, out, byteArray.length);
    } else {
      DB4OClob clob = (DB4OClob) identifiableObject;
      char[] charArray = clob.getValue();
      CharArrayReader in = new CharArrayReader(charArray);
      IOUtil.copyCharacter(in, new OutputStreamWriter(out), charArray.length);
    }
  }