Search in sources :

Example 1 with RemoteBlob

use of com.adaptris.interlok.cloud.RemoteBlob in project interlok by adaptris.

the class RemoteBlobIterableImpl method next.

@Override
public RemoteBlob next() {
    RemoteBlob ret = nextBlob;
    nextBlob = null;
    return ret;
}
Also used : RemoteBlob(com.adaptris.interlok.cloud.RemoteBlob)

Example 2 with RemoteBlob

use of com.adaptris.interlok.cloud.RemoteBlob in project interlok by adaptris.

the class FilesystemRetryStore method report.

@Override
public Iterable<RemoteBlob> report() throws InterlokException {
    List<RemoteBlob> result = new ArrayList<>();
    try {
        File target = validateDir(FsHelper.toFile(getBaseUrl()), false);
        File[] files = fsWorker.listFiles(target, DirectoryFileFilter.DIRECTORY);
        for (File msgId : files) {
            Optional.ofNullable(createForReport(msgId)).ifPresent((blob) -> result.add(blob));
        }
    } catch (Exception e) {
        throw ExceptionHelper.wrapInterlokException(e);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RemoteBlob(com.adaptris.interlok.cloud.RemoteBlob) File(java.io.File) InterlokException(com.adaptris.interlok.InterlokException) CoreException(com.adaptris.core.CoreException)

Example 3 with RemoteBlob

use of com.adaptris.interlok.cloud.RemoteBlob in project interlok by adaptris.

the class FilesystemRetryStoreTest method testCreateForReport.

@Test
public void testCreateForReport() throws Exception {
    FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(BaseCase.getConfiguration(TEST_BASE_URL));
    try {
        LifecycleHelper.initAndStart(store);
        AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
        store.write(msg);
        File retryStoreDir = FsHelper.toFile(BaseCase.getConfiguration(TEST_BASE_URL));
        File storedMsgDir = new File(retryStoreDir, msg.getUniqueId());
        RemoteBlob blob = FilesystemRetryStore.createForReport(storedMsgDir);
        assertNotNull(blob);
        assertEquals("hello".length(), blob.getSize());
        File randomDir = TempFileUtils.createTrackedDir(store);
        assertNull(FilesystemRetryStore.createForReport(randomDir));
        assertNull(FilesystemRetryStore.createForReport(null));
    } finally {
        LifecycleHelper.stopAndClose(store);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RemoteBlob(com.adaptris.interlok.cloud.RemoteBlob) File(java.io.File) Test(org.junit.Test)

Aggregations

RemoteBlob (com.adaptris.interlok.cloud.RemoteBlob)3 File (java.io.File)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 CoreException (com.adaptris.core.CoreException)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 InterlokException (com.adaptris.interlok.InterlokException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1