Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix for rdfification
  • Loading branch information
cbeer committed May 23, 2013
1 parent d1d0e74 commit 87a1338
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 54 deletions.
Expand Up @@ -43,7 +43,6 @@
import org.fcrepo.FedoraObject;
import org.fcrepo.exception.InvalidChecksumException;
import org.fcrepo.serialization.BaseFedoraObjectSerializer;
import org.fcrepo.utils.NodeIterator;
import org.fcrepo.utils.PropertyIterator;
import org.slf4j.Logger;

Expand Down Expand Up @@ -90,8 +89,7 @@ public File serializeToFile(final Node node) throws RepositoryException,
bag.addFileAsTag(bagInfoTxtFile);
// get recordable properties
logger.trace("Retrieving properties to serialize...");
final Iterator<Property> properties =
new PropertyIterator(node.getProperties(prefixesInGlobForm()));
final Iterator<Property> properties = node.getProperties(prefixesInGlobForm());
// put 'em in a tag info file
logger.trace("Recording properties...");
final BagInfoTxt bagInfoTxt = bag.getBagInfoTxt();
Expand Down Expand Up @@ -124,10 +122,10 @@ public File serializeToFile(final Node node) throws RepositoryException,
}

// and recurse, to pick up datastream children
for (final Iterator<Node> i =
filter(new NodeIterator(node.getNodes()), isFedoraDatastream); i
for (final Iterator i =
filter(node.getNodes(), isFedoraDatastream); i
.hasNext();) {
final Node dsNode = i.next();
final Node dsNode = (Node)i.next();
logger.debug("Now recording child node: " + dsNode.getName());
bag.addFileToPayload(serializeToFile(dsNode));
}
Expand Down
Expand Up @@ -4,26 +4,15 @@
import java.io.UnsupportedEncodingException;
import java.util.concurrent.TimeUnit;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.fcrepo.jaxb.responses.access.ObjectDatastreams;
import org.fcrepo.jaxb.responses.access.ObjectProfile;
import org.fcrepo.jaxb.responses.management.DatastreamFixity;
import org.fcrepo.jaxb.responses.management.DatastreamProfile;
import org.fcrepo.utils.FedoraJcrTypes;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
Expand All @@ -37,23 +26,11 @@ public abstract class AbstractResourceIT {

protected Logger logger;

protected JAXBContext context;

protected String OBJECT_PATH = "objects";

@Before
public void setLogger() {
logger = LoggerFactory.getLogger(this.getClass());
}

@Before
public void setContext() throws JAXBException {
context =
JAXBContext.newInstance(ObjectProfile.class,
ObjectDatastreams.class, DatastreamProfile.class,
DatastreamFixity.class);
}

protected static final int SERVER_PORT = Integer.parseInt(System
.getProperty("test.port", "8080"));

Expand All @@ -78,15 +55,6 @@ protected static HttpPost postObjMethod(final String pid) {
return new HttpPost(serverAddress + "objects/" + pid);
}

protected static HttpPost
postObjMethod(final String pid, final String query) {
if (query.equals("")) {
return new HttpPost(serverAddress + "objects/" + pid);
} else {
return new HttpPost(serverAddress + "objects/" + pid + "?" + query);
}
}

protected static HttpPost postDSMethod(final String pid, final String ds,
final String content) throws UnsupportedEncodingException {
final HttpPost post =
Expand All @@ -96,11 +64,6 @@ protected static HttpPost postDSMethod(final String pid, final String ds,
return post;
}

protected static HttpPut putDSMethod(final String pid, final String ds) {
return new HttpPut(serverAddress + "objects/" + pid +
"/" + ds + "/fcr:content");
}

protected HttpResponse execute(final HttpUriRequest method)
throws ClientProtocolException, IOException {
logger.debug("Executing: " + method.getMethod() + " to " +
Expand All @@ -117,12 +80,4 @@ protected int getStatus(final HttpUriRequest method)
}
return result;
}

protected ObjectProfile getObject(final String pid)
throws ClientProtocolException, IOException, JAXBException {
final HttpGet get = new HttpGet(serverAddress + "objects/" + pid);
final HttpResponse resp = execute(get);
final Unmarshaller um = context.createUnmarshaller();
return (ObjectProfile) um.unmarshal(resp.getEntity().getContent());
}
}
Expand Up @@ -33,8 +33,10 @@ public void tryOneObject() throws ClientProtocolException, IOException {
new HttpPost(serverAddress + "objects/fcr:import?format=bagit");
importMethod.setEntity(new StringEntity(content));
assertEquals("Couldn't import!", 201, getStatus(importMethod));
final HttpGet httpGet = new HttpGet(serverAddress + "objects/BagIt1");
httpGet.setHeader("Accepts", "application/n3");
response =
client.execute(new HttpGet(serverAddress + "objects/BagIt1"));
client.execute(httpGet);
assertEquals("Couldn't find reimported object!", 200, response
.getStatusLine().getStatusCode());
response =
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/spring-test/repo.xml
Expand Up @@ -19,6 +19,7 @@


<bean class="org.fcrepo.services.ObjectService"/>
<bean class="org.fcrepo.services.NodeService"/>
<bean class="org.fcrepo.services.LowLevelStorageService"/>
<bean class="org.fcrepo.services.DatastreamService"/>

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/spring-test/rest.xml
Expand Up @@ -26,8 +26,8 @@
</entry>
</util:map>

<context:component-scan
base-package="org.fcrepo.api, org.fcrepo.serialization, org.fcrepo.exceptionhandlers"/>

<context:component-scan base-package="org.modeshape.web.jcr.rest, org.fcrepo.api, org.fcrepo.serialization, org.fcrepo.responses, org.fcrepo.exceptionhandlers"/>

<!-- Mints PIDs-->
<bean class="org.fcrepo.identifiers.UUIDPidMinter"/>
Expand Down

0 comments on commit 87a1338

Please sign in to comment.