Skip to content

Commit

Permalink
owner property is required for FedoraObject
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Apr 16, 2013
1 parent 61a2283 commit 3e17f10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/org/fcrepo/federation/bagit/BagItConnector.java
Expand Up @@ -206,14 +206,17 @@ public Document getDocumentById(String id) {
getLogger().debug(
"Determined document: " + id + " to be a datastream.");
writer.setPrimaryType(JcrConstants.NT_FILE);
writer.addMixinType(FedoraJcrTypes.FEDORA_OWNED);
writer.addMixinType(FedoraJcrTypes.FEDORA_DATASTREAM);
writer.addProperty(JCR_CREATED, factories().getDateFactory()
.create(file.lastModified()));
writer.addProperty(JCR_LAST_MODIFIED, factories().getDateFactory()
.create(file.lastModified()));
try {
writer.addProperty(JCR_CREATED_BY, Files
.getOwner(file.toPath()).getName());
String owner = Files
.getOwner(file.toPath()).getName();
writer.addProperty(JCR_CREATED_BY, owner);
writer.addProperty(FedoraJcrTypes.FEDORA_OWNERID, owner);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -229,12 +232,21 @@ public Document getDocumentById(String id) {
dataDir.getAbsolutePath());
writer.setPrimaryType(NT_FOLDER);
writer.addMixinType(FEDORA_OBJECT);
writer.addMixinType(FedoraJcrTypes.FEDORA_OWNED);
writer.addMixinType(BAGIT_ARCHIVE_TYPE);
writer.addProperty(JCR_CREATED, factories().getDateFactory()
.create(file.lastModified()));
writer.addProperty(JCR_LAST_MODIFIED, factories().getDateFactory()
.create(file.lastModified()));
writer.addProperty(JCR_CREATED_BY, null); // ignored
try {
String owner = Files
.getOwner(file.toPath()).getName();
writer.addProperty(JCR_CREATED_BY, owner); // required
writer.addProperty(FedoraJcrTypes.FEDORA_OWNERID, owner);
} catch (IOException e) {
throw new RuntimeException(e);
}
writer.addProperty(FedoraJcrTypes.DC_IDENTIFIER, id);
// get datastreams as children
for (File child : dataDir.listFiles()) {
// Only include as a datastream if we can access and read the file. Permissions might prevent us from
Expand Down Expand Up @@ -345,7 +357,7 @@ protected boolean isExcluded(File file) {
* @see #isContentNode(String)
* @see #fileFor(String)
*/
protected String idFor( File file ) { System.out.println( "idFor(\"" + file.getAbsolutePath());
protected String idFor( File file ) {
String path = file.getAbsolutePath();
if (!path.startsWith(directoryAbsolutePath)) {
if (m_directory.getAbsolutePath().equals(path)) {
Expand Down
@@ -1,6 +1,7 @@

package org.fcrepo.federation.bagit;

import static org.fcrepo.jaxb.responses.access.ObjectProfile.ObjectStates.A;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -17,6 +18,9 @@
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.fcrepo.FedoraObject;
import org.fcrepo.jaxb.responses.access.ObjectProfile;
import org.fcrepo.services.PathService;
import org.junit.Test;
import org.modeshape.jcr.api.Session;
import org.slf4j.Logger;
Expand All @@ -41,6 +45,7 @@ public void tryProgrammaticAccess() throws RepositoryException {
Node child = nodes.nextNode();
nodes = child.getNodes();
assertEquals("jcr:content", nodes.nextNode().getName());
FedoraObject obj = new FedoraObject(session, PathService.getObjectJcrNodePath("BagItFed1"));
}

@Test
Expand Down

0 comments on commit 3e17f10

Please sign in to comment.