// store and retrieve content
DigitalObject resDo = dom.store(PERMANENT_URI_PATH, object, true);
// this is a content resolver link
DigitalObjectContent resolverLink = Content.byReference(
URI.create((DOJCRManager.getResolverPath() + resDo.getPermanentUri()))
.toURL());
// the content of the resContentByValueObject after store method should be
// a content resolver link
assertEquals(resDo.getContent(), resolverLink);
// this is a digital object we expect after store method.
// we have to add the permanent URI and content after store method to
// check for equality
DigitalObject expectedStoreDigitalObject = new DigitalObject.Builder(object)
.content(resolverLink).permanentUri(resDo.getPermanentUri()).build();
// check if resDo has an ingest event
assertTrue(DigitalObjectUtils.hasEvent(resDo, JcrDigitalObjectManagerImpl.INGEST_EVENT));
// add an ingest event from resDo to the expectedStoreDigitalObject
Event ingestEvent = DigitalObjectUtils.getEventBySummary(
resDo, JcrDigitalObjectManagerImpl.INGEST_EVENT);
expectedStoreDigitalObject = DigitalObjectUtils.addEvent(expectedStoreDigitalObject, ingestEvent);
// except content and permanent URI resDo and expectedStoreDigitalObject
// should be equal
assertEquals(resDo, expectedStoreDigitalObject);
DigitalObject retObject =
dom.retrieve(resDo.getPermanentUri(), true);
// this is a digital object we expect after retrieve method with includeContent = true.
// we need an injection of the generated permanent URI in object to
// correctly process assertEquals method.
DigitalObject expectedRetrieveTrueDigitalObject =
new DigitalObject.Builder(object).permanentUri(resDo.getPermanentUri()).build();
// contents of retObjectWithContent and expectedRetrieveTrueDigitalObject should be equal
// after retrieve method called with includeContent = true
assertEquals(retObject.getContent(), expectedRetrieveTrueDigitalObject.getContent());
// the content of the retObjectWithContent after retrieve method with includeContent = true
// should be a content stored in JCR
assertEquals(retObject.getContent(), c1);
// add an ingest event from resContentByValueObject to the expectedRetrieveTrueDigitalObject
expectedRetrieveTrueDigitalObject =
DigitalObjectUtils.addEvent(expectedRetrieveTrueDigitalObject, ingestEvent);
// except permanent URI retObjectWithContent and expectedRetrieveTrueDigitalObject
// should be equal
assertEquals(retObject, expectedRetrieveTrueDigitalObject);
DigitalObjectContent c2 = dom.retrieveContent(resDo.getPermanentUri());
assertTrue(c2.length()>0);
assertEquals(c1, c2);
InputStream contentStream=dom.retrieveContentAsStream(resDo.getPermanentUri());
try {
assertNotNull(contentStream);