Search in sources :

Example 1 with StoredBlob

use of com.zimbra.cs.octosync.store.BlobStore.StoredBlob in project zm-mailbox by Zimbra.

the class PatchStore method acceptPatch.

/**
     * Accepts patch. Turns an IncomingPatch into a StoredPatch.
     *
     * @param ip The IncomingPatch instance to accept.
     * @param fileId The id of the file the patch creates.
     * @param version the version The version number of the file the patch creates.
     * @param manifest The patch manifest.
     *
     * @return StoredPatch instance.
     *
     * @throws IOException Signals that an I/O exception has occurred.
     * @throws ServiceException the service exception
     */
public StoredPatch acceptPatch(IncomingPatch ip, int fileId, int version) throws IOException, ServiceException {
    if (version > 1) {
        deletePatch(ip.getAccountId(), fileId);
    }
    IncomingBlob manifestBlob = blobStore.createIncoming(null);
    try {
        ip.getManifest().writeTo(manifestBlob.getAppendingOutputStream());
    } catch (IOException e) {
        blobStore.deleteIncoming(manifestBlob);
        throw e;
    }
    // ok, we got manifest written to a separate incoming blob here, now let's store both
    StoredBlob psb = blobStore.store(ip.patchBlob, getStoredPatchId(ip.getAccountId(), fileId, false), version);
    StoredBlob msb = null;
    try {
        msb = blobStore.store(manifestBlob, getStoredPatchId(ip.getAccountId(), fileId, true), version);
    } catch (IOException e) {
        blobStore.delete(psb, version);
        throw e;
    }
    StoredPatch sp = new StoredPatch(psb, msb, ip.getAccountId());
    psb.setContext(sp);
    return sp;
}
Also used : StoredBlob(com.zimbra.cs.octosync.store.BlobStore.StoredBlob) IOException(java.io.IOException) IncomingBlob(com.zimbra.cs.store.IncomingBlob)

Example 2 with StoredBlob

use of com.zimbra.cs.octosync.store.BlobStore.StoredBlob in project zm-mailbox by Zimbra.

the class PatchStore method deletePatch.

/**
     * Delete patch.
     *
     * @param accountId the account id
     * @param fileId the file id
     */
public void deletePatch(String accountId, int fileId) {
    try {
        StoredBlob psb = blobStore.get(getStoredPatchId(accountId, fileId, false));
        blobStore.delete(psb);
    } finally {
        StoredBlob msb = blobStore.get(getStoredPatchId(accountId, fileId, true));
        blobStore.delete(msb);
    }
}
Also used : StoredBlob(com.zimbra.cs.octosync.store.BlobStore.StoredBlob)

Aggregations

StoredBlob (com.zimbra.cs.octosync.store.BlobStore.StoredBlob)2 IncomingBlob (com.zimbra.cs.store.IncomingBlob)1 IOException (java.io.IOException)1