public JcrNode nodeForPath(BrixNode baseNode, Path path) { return nodeForPath(baseNode, path.toString()); }
/** * {@inheritDoc} */ public Path getUriPathForNode(Path nodePath, Brix brix) { Path uriPath = prefix; if (!nodePath.isRoot()) { // nodePath is not root, we have to append it to prefix uriPath = prefix.append(nodePath.toRelative(Path.ROOT)); } if(nodePath.toString().endsWith(SitePlugin.BRIX_INDEX_PAGE)) { final String orgUrl = nodePath.toString(); String url = orgUrl.substring(0, orgUrl.length() - SitePlugin.BRIX_INDEX_PAGE.length()); uriPath = new Path(url); } return uriPath; }
private Url encode(BrixNode node, PageParameters parameters, PageInfo info) { return encode(getUriPathForNode(node).toString(), parameters, info); }
public String getNodeURL() { try { // BrixRequestCycleProcessor processor = new // BrixRequestCycleProcessor(Brix.get()); // return // processor.getUriPathForNode(nodeModel.getObject()).toString(); return SitePlugin.get().getUriPathForNode(nodeModel.getObject()).toString(); } finally { nodeModel.detach(); } }
@Override protected void onPathClicked(Path path) { BrixNode node = (BrixNode) getNode().getSession().getItem(path.toString()); selectNode(node, false); } });
@SuppressWarnings("unchecked") public void validate(IValidatable validatable) { Object o = validatable.getValue(); if (o != null) { JcrNode node = nodeModel.getObject(); Path path = null; if (o instanceof Path) { path = (Path) o; } else { path = new Path(o.toString()); } if (!path.isAbsolute()) { Path parent = new Path(node.getPath()); if (!((BrixNode) node).isFolder()) parent = parent.parent(); path = parent.append(path); } else { path = new Path(SitePlugin.get().toRealWebNodePath(path.toString())); } if (node.getSession().itemExists(path.toString()) == false) { ValidationError error = new ValidationError(); error.setMessage("Node ${path} could not be found"); error.addKey("NodePathValidator"); error.getVariables().put("path", path.toString()); validatable.error(error); } } } }
private String getCommonParentPath(List<JcrNode> nodes) { Path current = null; String sitePath = SitePlugin.get().getSiteRootPath(); for (JcrNode node : nodes) { if (node.getPath().startsWith(sitePath) && node instanceof GlobalContainerNode == false) { if (current == null) { current = new Path(node.getPath()).parent(); } else { Path another = new Path(node.getPath()).parent(); Path common = Path.ROOT; Iterator<String> i1 = current.iterator(); Iterator<String> i2 = another.iterator(); while (i1.hasNext() && i2.hasNext()) { String s1 = i1.next(); String s2 = i2.next(); if (Objects.equal(s1, s2)) { common = common.append(new Path(s1)); } else { break; } } current = common; } } } if (current == null) { current = Path.ROOT; } return current.toString(); }
public String toRealWebNodePath(String nodePath) { Path prefix = new Path(getSiteRootPath()); Path path = new Path(nodePath); if (path.isRoot()) { path = new Path("."); } else if (path.isAbsolute()) { path = path.toRelative(new Path("/")); } return prefix.append(path).toString(); }
public String fromRealWebNodePath(String nodePath) { Path prefix = new Path(getSiteRootPath()); Path path = new Path(nodePath); if (path.equals(prefix)) { path = new Path("/"); } else if (path.isDescendantOf(prefix)) { path = path.toRelative(prefix); } if (!path.isAbsolute()) { path = new Path("/").append(path); } return path.toString(); }
private void createFolder() { final JcrNode parent = (JcrNode) getModelObject(); final Path path = new Path(parent.getPath()); final Path newPath = path.append(new Path(name)); final JcrSession session = parent.getSession(); if (session.itemExists(newPath.toString())) { class ModelObject implements Serializable { @SuppressWarnings("unused") public String path = SitePlugin.get().fromRealWebNodePath(newPath.toString()); } ; String error = getString("resourceExists", new Model<ModelObject>(new ModelObject())); error(error); } else { FolderNode node = (FolderNode) parent.addNode(name, "nt:folder"); parent.save(); SitePlugin.get().selectNode(this, node, true); } } }
public JcrNode nodeForPath(BrixNode baseNode, String path) { Path realPath = new Path(SitePlugin.get().toRealWebNodePath(path)); if (realPath.isAbsolute() == false) { Path base = new Path(baseNode.getPath()); if (!baseNode.isFolder()) { base = base.parent(); } realPath = base.append(realPath); } String strPath = realPath.toString(); if (baseNode.getSession().itemExists(strPath) == false) { return null; } else { return ((JcrNode) baseNode.getSession().getItem(strPath)); } }
final String jcrPath = SitePlugin.get().toRealWebNodePath(nodePath.toString());
private BrixPageParameters createBrixPageParams(Url url, Path path) { BrixPageParameters parameters = new BrixPageParameters(); Path nodePath = path; Path requestPath = new Path("/" + url.getPath()); if (nodePath.isAncestorOf(requestPath)) { Path remaining = new Path(requestPath.toString(), false).toRelative(nodePath); int i = 0; for (String s : remaining) { parameters.set(i, urlDecode(s)); ++i; } } for (QueryParameter parameter : url.getQueryParameters()) { String parameterName = parameter.getName(); if (PageComponentInfo.parse(parameterName) == null) { parameters.add(parameterName, parameter.getValue()); } } return parameters; }
if (handler != null || path.toString().equals(".")) { break;