};
}
-// @Override
-// public Content get() {
-// return new DomContent(this, document.getDocumentElement());
-// }
-
-// public Element createElement(String name) {
-// return document.createElementNS(null, name);
-//
-// }
-
@Override
public ProvidedContent get(ProvidedSession session, String relativePath) {
if ("".equals(relativePath))
if (nodes.getLength() > 1)
throw new IllegalArgumentException("Multiple content found for " + relativePath + " under " + mountPath);
if (nodes.getLength() == 0)
- throw new ContentNotFoundException("Path " + relativePath + " under " + mountPath + " was not found");
+ throw new ContentNotFoundException(session, mountPath + "/" + relativePath,
+ "Path " + relativePath + " under " + mountPath + " was not found");
Element element = (Element) nodes.item(0);
return new DomContent(session, this, element);
}
protected NodeList findContent(String relativePath) {
if (relativePath.startsWith("/"))
throw new IllegalArgumentException("Relative path cannot start with /");
- String xPathExpression = '/' + relativePath;
- if ("/".equals(mountPath))
- xPathExpression = "/" + CrName.root.qName() + xPathExpression;
+ String xPathExpression;
+ if (Content.ROOT_PATH.equals(mountPath)) {// repository root
+ xPathExpression = "/" + CrName.root.get() + '/' + relativePath;
+ } else {
+ String documentNodeName = document.getDocumentElement().getNodeName();
+ xPathExpression = '/' + documentNodeName + '/' + relativePath;
+ }
try {
NodeList nodes = (NodeList) xPath.get().evaluate(xPathExpression, document, XPathConstants.NODESET);
return nodes;
return nodes.getLength() != 0;
}
+ @Override
public void persist(ProvidedSession session) {
if (mountPath != null) {
Content mountPoint = session.getMountPoint(mountPath);