Search in sources :

Example 1 with AsyncTouchResult

use of org.apache.jackrabbit.core.data.AsyncTouchResult in project jackrabbit by apache.

the class S3Backend method touchAsync.

@Override
public void touchAsync(final DataIdentifier identifier, final long minModifiedDate, final AsyncTouchCallback callback) throws DataStoreException {
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        if (callback == null) {
            throw new IllegalArgumentException("callback parameter cannot be null in touchAsync");
        }
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        getAsyncWriteExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    touch(identifier, minModifiedDate);
                    callback.onSuccess(new AsyncTouchResult(identifier));
                } catch (DataStoreException e) {
                    AsyncTouchResult result = new AsyncTouchResult(identifier);
                    result.setException(e);
                    callback.onFailure(result);
                }
            }
        });
    } catch (Exception e) {
        callback.onAbort(new AsyncTouchResult(identifier));
        throw new DataStoreException("Cannot touch the record " + identifier.toString(), e);
    } finally {
        if (contextClassLoader != null) {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
        }
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) AsyncTouchResult(org.apache.jackrabbit.core.data.AsyncTouchResult) DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) AmazonServiceException(com.amazonaws.AmazonServiceException) IOException(java.io.IOException) AmazonClientException(com.amazonaws.AmazonClientException)

Example 2 with AsyncTouchResult

use of org.apache.jackrabbit.core.data.AsyncTouchResult in project jackrabbit-oak by apache.

the class S3Backend method touchAsync.

@Override
public void touchAsync(final DataIdentifier identifier, final long minModifiedDate, final AsyncTouchCallback callback) throws DataStoreException {
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        if (callback == null) {
            throw new IllegalArgumentException("callback parameter cannot be null in touchAsync");
        }
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        asyncWriteExecuter.execute(new Runnable() {

            @Override
            public void run() {
                try {
                    touch(identifier, minModifiedDate);
                    callback.onSuccess(new AsyncTouchResult(identifier));
                } catch (DataStoreException e) {
                    AsyncTouchResult result = new AsyncTouchResult(identifier);
                    result.setException(e);
                    callback.onFailure(result);
                }
            }
        });
    } catch (Exception e) {
        if (callback != null) {
            callback.onAbort(new AsyncTouchResult(identifier));
        }
        throw new DataStoreException("Cannot touch the record " + identifier.toString(), e);
    } finally {
        if (contextClassLoader != null) {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
        }
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) AsyncTouchResult(org.apache.jackrabbit.core.data.AsyncTouchResult) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException)

Aggregations

AmazonClientException (com.amazonaws.AmazonClientException)2 AmazonServiceException (com.amazonaws.AmazonServiceException)2 IOException (java.io.IOException)2 AsyncTouchResult (org.apache.jackrabbit.core.data.AsyncTouchResult)2 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)2