Skip to content

Commit

Permalink
Added node path information as a field in the atom message
Browse files Browse the repository at this point in the history
  • Loading branch information
osmandin committed Aug 28, 2013
1 parent 619a8b4 commit fd2ffb8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Expand Up @@ -128,6 +128,7 @@ public LegacyMethod(final Event jcrEvent, final Node resource)
jcrEvent.getUserID() == null ? "unknown" : jcrEvent.getUserID();
setUserId(userID);
setModified(new Date(jcrEvent.getDate()));
setPath(resource.getPath());
}

/**
Expand Down Expand Up @@ -287,6 +288,14 @@ public String getDsId() {
return getLabelledCategory(DSID_CATEGORY_LABEL);
}

/**
* Adds node path as a category
* @param path
*/
private void setPath(String path) {
setLabelledCategory("path", path);
}

protected String getBaseURL() {
StringBuilder url = new StringBuilder();
String host = System.getProperty("fcrepo.host", "localhost");
Expand Down
Expand Up @@ -127,6 +127,31 @@ public void testAtomStream() throws LoginException, RepositoryException,
assertEquals("Got wrong pid!", "test1", path);
assertEquals("Got wrong method!", "ingest", title);
}


@Test
public void testAtomStreamNodePath() throws LoginException, RepositoryException,
InterruptedException {
Session session = repository.login();
session.getRootNode().addNode("test1/sigma").addMixin(FEDORA_OBJECT);
session.save();

waitForEntry();

session.logout();

if (entry == null) fail("Waited a second, got no messages");
List<Category> categories = copyOf(entry.getCategories("xsd:string"));
entry = null;
String path = null;
for (Category cat : categories) {
if (cat.getLabel().equals("path")) {
logger.debug("Found Category with term: " + cat.getTerm());
path = cat.getTerm();
}
}
assertEquals("Got wrong path!", "/test1/sigma", path);
}

@Test
public void testDatastreamTerm() throws NoSuchNodeTypeException,
Expand Down

0 comments on commit fd2ffb8

Please sign in to comment.