@Override public ExportToWriterListener withTransform(ServerTransform transform) { super.withTransform(transform); return this; }
/** * Prepares each ExportListener created by a subclass before it's used to process a QueryBatch. Subclasses are * expected to call this with their own instance of ExportListener or a subclass of it. * * @param listener */ protected void prepareExportListener(ExportListener listener) { if (consistentSnapshot) { listener.withConsistentSnapshot(); } if (categories != null) { for (DocumentManager.Metadata category : categories) { listener.withMetadataCategory(category); } } if (nonDocumentFormat != null) { listener.withNonDocumentFormat(nonDocumentFormat); } if (transform != null) { listener.withTransform(transform); } }
public ExportToZipJob() { super(); addRequiredJobProperty("exportPath", "The path of the zip file to which selected records are exported", value -> setExportFile(new File(value))); addJobProperty("flattenUri", "Whether or not record URIs are flattened before being used as zip entry names; defaults to false", value -> getWriteToZipConsumer().setFlattenUri(Boolean.parseBoolean(value))); addJobProperty("transform", "The name of a REST transform to apply to each record before it is written to the zip file", value -> getExportListener().withTransform(new ServerTransform(value))); addJobProperty("uriPrefix", "Prefix to prepend to each URI it is used as an entry name; applied after a URI is optionally flattened", value -> getWriteToZipConsumer().setUriPrefix(value)); }
@Test public void testExportListenerException() { final AtomicInteger failureBatchCount = new AtomicInteger(); testListenerException( new ExportListener() .withTransform(new ServerTransform("thisTransformDoesntExist")) .onBatchFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) ); // there should be one failure sent to the ExportListener // onBatchFailure listener since the transform is invalid assertEquals(1, failureBatchCount.get()); }