use of com.opentext.ia.sdk.support.io.NoHashAssembler in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenAssemblingSips method shouldMeasurePdiSizeBeforeEnd.
@Test
void shouldMeasurePdiSizeBeforeEnd() throws IOException {
long pdiSize = randomInt(13, 313);
DataBuffer pdiBuffer = new MemoryBuffer() {
@Override
public long length() {
return pdiSize;
}
};
HashAssembler noHashAssembler = new NoHashAssembler();
Assembler<HashedContents<Object>> pdiAssembler = mock(Assembler.class);
SipAssembler<Object> sipAssembler = new SipAssembler<>(new DefaultPackagingInformationFactory(somePackagingInformation()), pdiAssembler, noHashAssembler, () -> pdiBuffer, ContentAssembler.noDedup(domainObject -> Collections.emptyIterator(), noHashAssembler));
sipAssembler.start(new MemoryBuffer());
sipAssembler.add(new Object());
SipMetrics metrics = sipAssembler.getMetrics();
assertEquals(pdiSize, metrics.pdiSize(), SipMetrics.SIZE_PDI);
}
use of com.opentext.ia.sdk.support.io.NoHashAssembler in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class ActiveArchiver method newSipAssembler.
private static <D> SipAssembler<D> newSipAssembler(PackagingInformation prototype, String dssPrefix, PdiAssembler<D> pdiAssembler, DigitalObjectsExtraction<D> contentsExtraction) {
PackagingInformationFactory factory = new OneSipPerDssPackagingInformationFactory(new DefaultPackagingInformationFactory(prototype), new SequentialDssIdSupplier(dssPrefix, 1));
ContentAssembler<D> contentsAssembler = new ContentAssemblerDefault<>(contentsExtraction, new NoHashAssembler());
return SipAssembler.forPdiAndContent(factory, pdiAssembler, contentsAssembler);
}
use of com.opentext.ia.sdk.support.io.NoHashAssembler in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class SipAssembler method addPackagingInformation.
private void addPackagingInformation() throws IOException {
DataBuffer buffer = new MemoryBuffer();
packagingInformationAssembler.start(buffer);
packagingInformationAssembler.add(packagingInformation());
packagingInformationAssembler.end();
long packagingInformationSize = buffer.length();
try (InputStream stream = buffer.openForReading()) {
zip.addEntry(PACKAGING_INFORMATION_ENTRY, stream, new NoHashAssembler());
}
metrics.set(SipMetrics.SIZE_SIP, metrics.get(SipMetrics.SIZE_DIGITAL_OBJECTS) + metrics.get(SipMetrics.SIZE_PDI) + packagingInformationSize);
}
Aggregations