Skip to content

Commit

Permalink
grizzly stuff, remove ref to non-existent test artifact, limit mixins…
Browse files Browse the repository at this point in the history
… to nt:folder and nt:file
  • Loading branch information
barmintor committed Apr 22, 2013
1 parent ae0898b commit 049b025
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 111 deletions.
1 change: 0 additions & 1 deletion pom.xml
Expand Up @@ -68,7 +68,6 @@
<artifactId>fcrepo-http-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
Expand Down
67 changes: 0 additions & 67 deletions src/main/java/gov/loc/cygwin/Cygpath.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/gov/loc/cygwin/CygwinException.java

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/java/org/fcrepo/federation/bagit/BagItConnector.java
@@ -1,7 +1,6 @@

package org.fcrepo.federation.bagit;

import static org.fcrepo.utils.FedoraJcrTypes.FEDORA_OBJECT;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA;
import static org.modeshape.jcr.api.JcrConstants.NT_FOLDER;
Expand All @@ -24,7 +23,6 @@
import javax.jcr.RepositoryException;

import org.apache.poi.util.TempFile;
import org.fcrepo.utils.FedoraJcrTypes;
import org.infinispan.schematic.document.Document;
import org.modeshape.connector.filesystem.FileSystemConnector;
import org.modeshape.jcr.JcrI18n;
Expand Down Expand Up @@ -161,11 +159,8 @@ public Document getDocumentById(String id) {
getLogger().debug(
"Determined document: " + id + " to be the projection root.");
writer.setPrimaryType(NT_FOLDER);
writer.addMixinType(FEDORA_OBJECT);
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
for (File child : file.listFiles()) {
// Only include as a datastream if we can access and read the file. Permissions might prevent us from
Expand Down Expand Up @@ -210,17 +205,12 @@ 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 {
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 @@ -235,22 +225,16 @@ public Document getDocumentById(String id) {
getLogger().debug("searching data dir " +
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()));
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 @@ -37,6 +37,8 @@ public void tryOneObject() throws ClientProtocolException, IOException {
final String objName = "BagItFed1";
final HttpResponse response =
client.execute(new HttpGet(serverAddress + "objects/" + objName));
String msg = EntityUtils.toString(response.getEntity());
System.out.println(msg);
assertEquals(response.getStatusLine().getReasonPhrase(), 200, response
.getStatusLine().getStatusCode());
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/org/fcrepo/federation/bagit/BagItConnectorIT.java
@@ -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 @@ -20,6 +21,7 @@
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.junit.runner.RunWith;
Expand Down Expand Up @@ -54,6 +56,18 @@ public void tryProgrammaticAccess() throws RepositoryException {
nodes = child.getNodes();
assertEquals("jcr:content", nodes.nextNode().getName());
FedoraObject obj = new FedoraObject(session, PathService.getObjectJcrNodePath("BagItFed1"));
final ObjectProfile objectProfile = new ObjectProfile();
objectProfile.pid = obj.getName();
objectProfile.objLabel = obj.getLabel();
objectProfile.objOwnerId = obj.getOwnerId();
objectProfile.objCreateDate = obj.getCreated();
objectProfile.objLastModDate = obj.getLastModified();
objectProfile.objSize = obj.getSize();
// objectProfile.objItemIndexViewURL =
// uriInfo.getAbsolutePathBuilder().path("datastreams").build();
objectProfile.objState = A;
objectProfile.objModels = obj.getModels();

}

}
2 changes: 1 addition & 1 deletion src/test/resources/bagit-node-types.cnd
Expand Up @@ -27,7 +27,7 @@
*/
<bagit = 'info:fedora/bagit/'>

[bagit:archive] > fedora:object, nt:folder mixin
[bagit:archive] > nt:folder mixin
/*
* Unfortunately, dashes don't appear to be allowed as property names
*/
Expand Down

0 comments on commit 049b025

Please sign in to comment.