Search in sources :

Example 1 with NoHashAssembler

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);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) ByteArrayInputOutputStream(com.opentext.ia.sdk.support.io.ByteArrayInputOutputStream) ZipInputStream(java.util.zip.ZipInputStream) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) EncodedHash(com.opentext.ia.sdk.support.io.EncodedHash) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) Encoding(com.opentext.ia.sdk.support.io.Encoding) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ZipEntry(java.util.zip.ZipEntry) Iterator(java.util.Iterator) DataBuffer(com.opentext.ia.sdk.support.io.DataBuffer) Collection(java.util.Collection) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) XmlUtil(com.opentext.ia.sdk.support.xml.XmlUtil) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) IOUtils(org.apache.commons.io.IOUtils) HashFunction(com.opentext.ia.sdk.support.io.HashFunction) List(java.util.List) Element(org.w3c.dom.Element) NoHashAssembler(com.opentext.ia.sdk.support.io.NoHashAssembler) MemoryBuffer(com.opentext.ia.sdk.support.io.MemoryBuffer) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Collections(java.util.Collections) HashAssembler(com.opentext.ia.sdk.support.io.HashAssembler) Mockito.mock(org.mockito.Mockito.mock) NoHashAssembler(com.opentext.ia.sdk.support.io.NoHashAssembler) HashAssembler(com.opentext.ia.sdk.support.io.HashAssembler) NoHashAssembler(com.opentext.ia.sdk.support.io.NoHashAssembler) MemoryBuffer(com.opentext.ia.sdk.support.io.MemoryBuffer) DataBuffer(com.opentext.ia.sdk.support.io.DataBuffer) Test(org.junit.jupiter.api.Test)

Example 2 with NoHashAssembler

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);
}
Also used : OneSipPerDssPackagingInformationFactory(com.opentext.ia.sdk.sip.OneSipPerDssPackagingInformationFactory) PackagingInformationFactory(com.opentext.ia.sdk.sip.PackagingInformationFactory) DefaultPackagingInformationFactory(com.opentext.ia.sdk.sip.DefaultPackagingInformationFactory) DefaultPackagingInformationFactory(com.opentext.ia.sdk.sip.DefaultPackagingInformationFactory) SequentialDssIdSupplier(com.opentext.ia.sdk.sip.SequentialDssIdSupplier) ContentAssemblerDefault(com.opentext.ia.sdk.sip.ContentAssemblerDefault) NoHashAssembler(com.opentext.ia.sdk.support.io.NoHashAssembler) OneSipPerDssPackagingInformationFactory(com.opentext.ia.sdk.sip.OneSipPerDssPackagingInformationFactory)

Example 3 with NoHashAssembler

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);
}
Also used : MemoryBuffer(com.opentext.ia.sdk.support.io.MemoryBuffer) InputStream(java.io.InputStream) NoHashAssembler(com.opentext.ia.sdk.support.io.NoHashAssembler) DataBuffer(com.opentext.ia.sdk.support.io.DataBuffer)

Aggregations

NoHashAssembler (com.opentext.ia.sdk.support.io.NoHashAssembler)3 DataBuffer (com.opentext.ia.sdk.support.io.DataBuffer)2 MemoryBuffer (com.opentext.ia.sdk.support.io.MemoryBuffer)2 ContentAssemblerDefault (com.opentext.ia.sdk.sip.ContentAssemblerDefault)1 DefaultPackagingInformationFactory (com.opentext.ia.sdk.sip.DefaultPackagingInformationFactory)1 OneSipPerDssPackagingInformationFactory (com.opentext.ia.sdk.sip.OneSipPerDssPackagingInformationFactory)1 PackagingInformationFactory (com.opentext.ia.sdk.sip.PackagingInformationFactory)1 SequentialDssIdSupplier (com.opentext.ia.sdk.sip.SequentialDssIdSupplier)1 ByteArrayInputOutputStream (com.opentext.ia.sdk.support.io.ByteArrayInputOutputStream)1 EncodedHash (com.opentext.ia.sdk.support.io.EncodedHash)1 Encoding (com.opentext.ia.sdk.support.io.Encoding)1 HashAssembler (com.opentext.ia.sdk.support.io.HashAssembler)1 HashFunction (com.opentext.ia.sdk.support.io.HashFunction)1 XmlUtil (com.opentext.ia.sdk.support.xml.XmlUtil)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1