Search in sources :

Example 1 with FsException

use of com.adaptris.fs.FsException in project interlok by adaptris.

the class TraversingFsConsumer method handleFile.

private int handleFile(File originalFile) throws CoreException {
    int rc = 0;
    logFile(originalFile, "handleFile ");
    try {
        if (originalFile.getName().endsWith(getWipSuffix())) {
            log.debug("ignoring part-processed file [{}]", originalFile.getName());
        } else if (fileFilter != null && !fileFilter.accept(originalFile)) {
            log.trace("File [{}] doesn't match filter", originalFile.getName());
        } else {
            if (checkModified(originalFile) && isFileAccessible(originalFile)) {
                File wipFile = renameFile(originalFile);
                AdaptrisMessage msg = createAdaptrisMessage(wipFile);
                addStandardMetadata(msg, originalFile, wipFile);
                retrieveAdaptrisMessageListener().onAdaptrisMessage(msg);
                fsWorker.delete(wipFile);
                rc++;
            } else {
                log.trace("[{}] not deemed safe to process", originalFile.getName());
            }
        }
    } catch (FsException e) {
        throw new CoreException(e);
    } catch (IOException e) {
        throw new CoreException(e);
    }
    return rc;
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) FsException(com.adaptris.fs.FsException) IOException(java.io.IOException) File(java.io.File)

Example 2 with FsException

use of com.adaptris.fs.FsException in project interlok by adaptris.

the class LargeFsConsumer method processFile.

@Override
protected int processFile(File originalFile) throws CoreException {
    int rc = 0;
    try {
        if (originalFile.getName().endsWith(getWipSuffix())) {
            log.debug("ignoring part-processed file [{}]", originalFile.getName());
        } else {
            if (checkModified(originalFile) && isFileAccessible(originalFile)) {
                File wipFile = renameFile(originalFile);
                AdaptrisMessage msg = decode(wipFile);
                addStandardMetadata(msg, originalFile, wipFile);
                retrieveAdaptrisMessageListener().onAdaptrisMessage(msg);
                rc++;
                tracker.track(wipFile, msg, FileDeleteStrategy.FORCE);
            } else {
                log.trace("{} not deemed safe to process", originalFile.getName());
            }
        }
    } catch (FsException | IOException e) {
        throw new CoreException(e);
    }
    return rc;
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) FsException(com.adaptris.fs.FsException) IOException(java.io.IOException) File(java.io.File)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 CoreException (com.adaptris.core.CoreException)2 FsException (com.adaptris.fs.FsException)2 File (java.io.File)2 IOException (java.io.IOException)2