Skip to content

Commit

Permalink
Further renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 2, 2014
1 parent 6ea0d00 commit ab1c49b
Show file tree
Hide file tree
Showing 59 changed files with 147 additions and 147 deletions.
Expand Up @@ -53,7 +53,7 @@ public Model createModelForResource(final FedoraResource resource,
final UriInfo uriInfo, final IdentifierTranslator graphSubjects)
throws RepositoryException {
final Model model = ModelFactory.createDefaultModel();
final Resource s = graphSubjects.getGraphSubject(resource.getNode().getPath());
final Resource s = graphSubjects.getSubject(resource.getNode().getPath());

if (resource.getNode().isNodeType(
FedoraJcrTypes.FEDORA_RESOURCE)) {
Expand Down
Expand Up @@ -77,7 +77,7 @@ public void setUp() throws RepositoryException {
model = ModelFactory.createDefaultModel();
graphResource = model.createResource("/" + pathString);

when(graphSubjects.getGraphSubject(Matchers.anyString())).thenReturn(
when(graphSubjects.getSubject(Matchers.anyString())).thenReturn(
graphResource);
when(fedoraResource.getNode()).thenReturn(resourceNode);

Expand Down
Expand Up @@ -122,7 +122,7 @@ protected Response getDatastreamContentResponse(final Datastream ds, final Strin

return builder.type(ds.getMimeType()).header(
"Link",
subjects.getGraphSubject(ds.getNode().getPath()) +
subjects.getSubject(ds.getNode().getPath()) +
";rel=\"meta\"").header("Accept-Ranges",
"bytes").cacheControl(cc).lastModified(date).tag(etag)
.header("Content-Disposition", contentDisposition)
Expand Down
Expand Up @@ -245,7 +245,7 @@ public Response batchModify(@PathParam("path") final List<PathSegment> pathList,

final Model inputModel =
createDefaultModel().read(src,
subjects.getGraphSubject(resource.getNode().getPath()).toString(), format);
subjects.getSubject(resource.getNode().getPath()).toString(), format);

resource.replaceProperties(subjects, inputModel);
} else {
Expand Down Expand Up @@ -294,7 +294,7 @@ public Response batchModify(@PathParam("path") final List<PathSegment> pathList,
final HttpGraphSubjects subjects =
new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);

return created(new URI(subjects.getGraphSubject(path).getURI())).build();
return created(new URI(subjects.getSubject(path).getURI())).build();

} finally {
session.logout();
Expand Down
Expand Up @@ -152,7 +152,7 @@ public Response create(@PathParam("path")

session.save();
versionService.nodeUpdated(datastreamNode);
return created(new URI(subjects.getGraphSubject(datastreamNode.getNode(JCR_CONTENT).getPath()).getURI()))
return created(new URI(subjects.getSubject(datastreamNode.getNode(JCR_CONTENT).getPath()).getURI()))
.build();

} finally {
Expand Down Expand Up @@ -238,7 +238,7 @@ public Response modifyContent(@PathParam("path") final List<PathSegment> pathLis
uriInfo);

return created(
new URI(subjects.getGraphSubject(datastreamNode.getNode(JCR_CONTENT).getPath()).getURI()))
new URI(subjects.getSubject(datastreamNode.getNode(JCR_CONTENT).getPath()).getURI()))
.build();
}
return noContent().build();
Expand Down
Expand Up @@ -136,7 +136,7 @@ public Triple apply(final String identifier) {

try {
final Node s =
subjects.getGraphSubject(identifier).asNode();
subjects.getSubject(identifier).asNode();
return Triple.create(pidsResult, HAS_MEMBER_OF_RESULT
.asNode(), s);
} catch (final RepositoryException e) {
Expand Down
Expand Up @@ -94,7 +94,7 @@ public Response importObject(@PathParam("path") final List<PathSegment> pathList
serializers.getSerializer(format)
.deserialize(session, path, stream);
session.save();
return created(new URI(subjects.getGraphSubject(path).getURI())).build();
return created(new URI(subjects.getSubject(path).getURI())).build();
} finally {
session.logout();
}
Expand Down
Expand Up @@ -189,7 +189,7 @@ public RdfStream describe(@PathParam("path") final List<PathSegment> pathList,
final RdfStream rdfStream =
resource.getTriples(subjects).concat(
resource.getHierarchyTriples(subjects)).session(session)
.topic(subjects.getGraphSubject(resource.getNode().getPath())
.topic(subjects.getSubject(resource.getNode().getPath())
.asNode());
if (realLimit != NO_MEMBER_PROPERTIES) {
final Node firstPage =
Expand Down Expand Up @@ -363,7 +363,7 @@ public Response createOrReplaceObjectRdf(

final Model inputModel =
createDefaultModel().read(requestBodyStream,
graphSubjects.getGraphSubject(resource.getNode().getPath()).toString(), format);
graphSubjects.getSubject(resource.getNode().getPath()).toString(), format);

resource.replaceProperties(graphSubjects, inputModel);
}
Expand Down Expand Up @@ -493,7 +493,7 @@ public Response createObject(@PathParam("path")

final Model inputModel =
createDefaultModel().read(requestBodyStream,
subjects.getGraphSubject(result.getNode().getPath()).toString(), format);
subjects.getSubject(result.getNode().getPath()).toString(), format);

result.replaceProperties(subjects, inputModel);
} else if (result instanceof Datastream) {
Expand All @@ -520,9 +520,9 @@ public Response createObject(@PathParam("path")

final URI location;
if (result.hasContent()) {
location = new URI(subjects.getGraphSubject(result.getNode().getNode(JCR_CONTENT).getPath()).getURI());
location = new URI(subjects.getSubject(result.getNode().getNode(JCR_CONTENT).getPath()).getURI());
} else {
location = new URI(subjects.getGraphSubject(result.getNode().getPath()).getURI());
location = new URI(subjects.getSubject(result.getNode().getPath()).getURI());
}

return created(location).entity(location.toString()).build();
Expand Down Expand Up @@ -620,7 +620,7 @@ public Response copyObject(@PathParam("path") final List<PathSegment> path,
}

final String destination =
subjects.getPathFromGraphSubject(ResourceFactory.createResource(destinationUri));
subjects.getPathFromSubject(ResourceFactory.createResource(destinationUri));

if (destination == null) {
return status(SC_BAD_GATEWAY).entity("Destination was not a valid resource path").build();
Expand Down Expand Up @@ -685,7 +685,7 @@ public Response moveObject(@PathParam("path") final List<PathSegment> pathList,
new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);

final String destination =
subjects.getPathFromGraphSubject(ResourceFactory.createResource(destinationUri));
subjects.getPathFromSubject(ResourceFactory.createResource(destinationUri));

if (destination == null) {
return status(SC_BAD_GATEWAY).entity("Destination was not a valid resource path").build();
Expand Down
Expand Up @@ -108,7 +108,7 @@ public RdfStream getVersionList(@PathParam("path")
final FedoraResource resource = nodeService.getObject(session, path);

return resource.getVersionTriples(nodeTranslator()).session(session).topic(
nodeTranslator().getGraphSubject(resource.getNode().getPath()).asNode());
nodeTranslator().getSubject(resource.getNode().getPath()).asNode());
}

/**
Expand Down Expand Up @@ -186,7 +186,7 @@ public RdfStream getVersion(@PathParam("path")
}
final FedoraResource resource = new FedoraResourceImpl(node);
return resource.getTriples(nodeTranslator()).session(session).topic(
nodeTranslator().getGraphSubject(resource.getNode().getPath()).asNode());
nodeTranslator().getSubject(resource.getNode().getPath()).asNode());
}

/**
Expand Down
Expand Up @@ -120,7 +120,7 @@ public Response createWorkspace(@PathParam("path") final String path,
new HttpGraphSubjects(session.getRepository().login(path), FedoraNodes.class, uriInfo);


return created(new URI(subjects.getGraphSubject("/").getURI())).build();
return created(new URI(subjects.getSubject("/").getURI())).build();
} finally {
session.logout();
}
Expand Down
Expand Up @@ -69,7 +69,7 @@ public Model createModelForResource(final FedoraResource resource,

final Model model = createDefaultModel();

final Resource s = graphSubjects.getGraphSubject(resource.getNode().getPath());
final Resource s = graphSubjects.getSubject(resource.getNode().getPath());

if (resource.getNode().getPrimaryNodeType().isNodeType(ROOT)) {
addRepositoryStatements(uriInfo, model, s);
Expand Down
Expand Up @@ -96,7 +96,7 @@ public String getPathFromGraphSubject(@NotNull final String subjectUri) throws R
}

@Override
public Resource getGraphSubject(final String absPath) throws RepositoryException {
public Resource getSubject(final String absPath) throws RepositoryException {
if (absPath.contains("jcr:versionStorage")) {
final Node probableFrozenNode = internalSession.getNode(absPath);
if (probableFrozenNode.getPrimaryNodeType().getName().equals("nt:frozenNode")) {
Expand All @@ -106,7 +106,7 @@ public Resource getGraphSubject(final String absPath) throws RepositoryException
}
LOGGER.debug("{} was not a frozen node... no version-specific translation required", absPath);
}
return super.getGraphSubject(absPath);
return super.getSubject(absPath);
}

/**
Expand Down
Expand Up @@ -102,7 +102,7 @@ public void shouldDecorateModeRootNodesWithRepositoryWideLinks()
when(mockNode.getPrimaryNodeType()).thenReturn(mockNodeType);
when(mockNode.getPath()).thenReturn("/");

final Resource graphSubject = mockSubjects.getGraphSubject(mockNode.getPath());
final Resource graphSubject = mockSubjects.getSubject(mockNode.getPath());

final Model model =
testObj.createModelForResource(mockResource, uriInfo, mockSubjects);
Expand All @@ -123,7 +123,7 @@ public void shouldDecorateNodesWithLinksToVersionsAndExport()
when(mockNode.getPath()).thenReturn("/some/path/to/object");

when(mockSerializers.keySet()).thenReturn(of("a", "b"));
final Resource graphSubject = mockSubjects.getGraphSubject(mockNode.getPath());
final Resource graphSubject = mockSubjects.getSubject(mockNode.getPath());

final Model model =
testObj.createModelForResource(mockResource, uriInfo, mockSubjects);
Expand All @@ -141,7 +141,7 @@ public void shouldDecorateDatastreamsWithLinksToFixityChecks()
when(mockNode.getPrimaryNodeType()).thenReturn(mockNodeType);
when(mockNode.getPath()).thenReturn("/some/path/to/datastream");
when(mockSerializers.keySet()).thenReturn(new HashSet<String>());
final Resource graphSubject = mockSubjects.getGraphSubject(mockNode.getPath());
final Resource graphSubject = mockSubjects.getSubject(mockNode.getPath());

final Model model =
testObj.createModelForResource(mockResource, uriInfo, mockSubjects);
Expand All @@ -159,7 +159,7 @@ public void shouldDecorateRootNodeWithCorrectResourceURI()
when(mockSerializers.keySet()).thenReturn(of("a"));
when(mockNode.getPath()).thenReturn("/");

final Resource graphSubject = mockSubjects.getGraphSubject(mockNode.getPath());
final Resource graphSubject = mockSubjects.getSubject(mockNode.getPath());
final Model model =
testObj.createModelForResource(mockResource, uriInfo,
mockSubjects);
Expand All @@ -178,7 +178,7 @@ public void shouldDecorateOtherNodesWithCorrectResourceURI()
when(mockSerializers.keySet()).thenReturn(of("a"));
when(mockNode.getPath()).thenReturn("/some/path/to/object");

final Resource graphSubject = mockSubjects.getGraphSubject(mockNode.getPath());
final Resource graphSubject = mockSubjects.getSubject(mockNode.getPath());
final Model model =
testObj.createModelForResource(mockResource, uriInfo,
mockSubjects);
Expand Down
Expand Up @@ -71,7 +71,7 @@ public void testGetGraphSubject() throws RepositoryException {
final String uri = "http://localhost:8080/fcrepo/rest" + mockVersionableNode.getPath()
+ "/fcr:versions/" + mockFrozenNode.getIdentifier();

final Resource actual = testObj.getGraphSubject(mockFrozenNode.getPath());
final Resource actual = testObj.getSubject(mockFrozenNode.getPath());
assertEquals(uri, actual.getURI());
}

Expand Down Expand Up @@ -105,7 +105,7 @@ public void testGetGraphSubjectChildNode() throws RepositoryException {
when(mockWorkspace.getName()).thenReturn("default");
when(mockFrozenChildNode.getParent()).thenReturn(mockFrozenNode);

final Resource actual = testObj.getGraphSubject(mockFrozenChildNodePath);
final Resource actual = testObj.getSubject(mockFrozenChildNodePath);
assertEquals(uri, actual.getURI());
}

Expand All @@ -114,7 +114,7 @@ public void testGetGraphSubjectChildNode() throws RepositoryException {
public void testGetGraphSubjectForVersion() throws RepositoryException {
mockVersion(UUID.randomUUID().toString());

final Resource actual = testObj.getGraphSubject(mockFrozenNode.getPath());
final Resource actual = testObj.getSubject(mockFrozenNode.getPath());
assertEquals("http://localhost:8080/fcrepo/rest" + mockVersionableNode.getPath() + "/fcr:versions/"
+ mockFrozenNode.getIdentifier(), actual.getURI());
}
Expand All @@ -129,7 +129,7 @@ public void testGetNodeFromGraphSubjectForVersionByUUID() throws PathNotFoundExc
+ "/fcr:versions/" + mockFrozenNode.getIdentifier();
mockSubject(uri);

final String actual = testObj.getPathFromGraphSubject(mockSubject);
final String actual = testObj.getPathFromSubject(mockSubject);
assertEquals(mockFrozenNode.getPath(), actual);

}
Expand All @@ -153,7 +153,7 @@ public void testGetNodeFromGraphSubjectForVersionByLabel() throws PathNotFoundEx
+ "/fcr:versions/" + label;
mockSubject(uri);

final String actual = testObj.getPathFromGraphSubject(mockSubject);
final String actual = testObj.getPathFromSubject(mockSubject);
assertEquals(mockFrozenNode.getPath(), actual);
}

Expand All @@ -174,7 +174,7 @@ public void testGetNodeFromGraphSubjectForVersionChildByUUID() throws PathNotFou
when(mockSession.nodeExists(mockVersionChildNodePath)).thenReturn(true);
when(mockSession.getNode(mockVersionChildNodePath)).thenReturn(mockVersionChildNode);

final String actual = testObj.getPathFromGraphSubject(mockSubject);
final String actual = testObj.getPathFromSubject(mockSubject);
assertEquals(mockVersionChildNode.getPath(), actual);
}

Expand Down
Expand Up @@ -101,7 +101,7 @@ public HttpGraphSubjects(final Session session, final Class<?> relativeTo, final
}

@Override
public Resource getGraphSubject(final String absPath)
public Resource getSubject(final String absPath)
throws RepositoryException {
final URI result =
nodesBuilder.buildFromMap(getPathMap(absPath));
Expand All @@ -124,7 +124,7 @@ private static String getResourceURI(final Resource subject) {
}

@Override
public String getPathFromGraphSubject(final Resource subject) throws RepositoryException {
public String getPathFromSubject(final Resource subject) throws RepositoryException {
final String subjectUri = getResourceURI(subject);
if (subjectUri == null) {
return null;
Expand Down
Expand Up @@ -62,10 +62,10 @@ public void testGetGraphSubject() throws RepositoryException {
when(mockWorkspace.getName()).thenReturn("default");
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
when(mockNode.getSession()).thenReturn(mockSession);
Resource actual = testObj.getGraphSubject(mockNode.getPath());
Resource actual = testObj.getSubject(mockNode.getPath());
assertEquals(expected, actual.getURI());
when(mockNode.getPath()).thenReturn(testPath + "/jcr:content");
actual = testObj.getGraphSubject(mockNode.getPath());
actual = testObj.getSubject(mockNode.getPath());
assertEquals(expected + "/fcr:content", actual.getURI());
}

Expand All @@ -81,26 +81,26 @@ public void testGetNodeFromGraphSubject() throws PathNotFoundException,
when(mockSubject.getURI()).thenReturn(
"http://localhost:8080/fcrepo/rest" + testPath);
when(mockSubject.isURIResource()).thenReturn(true);
Node actual = mockSession.getNode(testObj.getPathFromGraphSubject(mockSubject));
Node actual = mockSession.getNode(testObj.getPathFromSubject(mockSubject));
verify(mockSession).getNode(testPath);
assertEquals(mockNode, actual);
// test a bad subject
when(mockSubject.getURI()).thenReturn(
"http://localhost:8080/fcrepo/rest2" + testPath + "/bad");
actual = mockSession.getNode(testObj.getPathFromGraphSubject(mockSubject));
actual = mockSession.getNode(testObj.getPathFromSubject(mockSubject));
assertEquals(null, actual);
// test a non-existent path
when(mockSubject.getURI()).thenReturn(
"http://localhost:8080/fcrepo/rest" + testPath + "/bad");
actual = mockSession.getNode(testObj.getPathFromGraphSubject(mockSubject));
actual = mockSession.getNode(testObj.getPathFromSubject(mockSubject));
assertEquals(null, actual);
// test a fcr:content path
when(mockSession.nodeExists(testPath + "/jcr:content")).thenReturn(true);
when(mockSubject.getURI())
.thenReturn(
"http://localhost:8080/fcrepo/rest" + testPath +
"/fcr:content");
actual = mockSession.getNode(testObj.getPathFromGraphSubject(mockSubject));
actual = mockSession.getNode(testObj.getPathFromSubject(mockSubject));
verify(mockSession).getNode(testPath + "/jcr:content");
}

Expand All @@ -110,7 +110,7 @@ public void testGetNodeFromGraphSubjectForNonJcrUrl() throws RepositoryException
when(mockWorkspace.getName()).thenReturn("default");
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);

assertNull(mockSession.getNode(testObj.getPathFromGraphSubject(createResource("http://localhost:8080/fcrepo/rest/abc/fcr:export?format=jcr/xml"))));
assertNull(mockSession.getNode(testObj.getPathFromSubject(createResource("http://localhost:8080/fcrepo/rest/abc/fcr:export?format=jcr/xml"))));
}

@Test
Expand Down Expand Up @@ -148,12 +148,12 @@ public void testGetContext() {

@Test
public void testGetPathFromGraphSubject() throws RepositoryException {
assertEquals("/abc", testObj.getPathFromGraphSubject(ResourceFactory.createResource("http://localhost:8080/fcrepo/rest/abc")));
assertEquals("/abc", testObj.getPathFromSubject(ResourceFactory.createResource("http://localhost:8080/fcrepo/rest/abc")));
}

@Test
public void testGetPathFromGraphSubjectForNonJcrUrl() throws RepositoryException {
assertNull(testObj.getPathFromGraphSubject(ResourceFactory.createResource("who-knows-what-this-is")));
assertNull(testObj.getPathFromSubject(ResourceFactory.createResource("who-knows-what-this-is")));
}

protected static UriInfo getUriInfoImpl(final String path) {
Expand Down

0 comments on commit ab1c49b

Please sign in to comment.