public void initWorkspace(Workspace workspace, JcrSession workspaceSession) {
    JcrNode root = (JcrNode) workspaceSession.getItem(brix.getRootPath());
    JcrNode pluginRoot = null;
    if (root.hasNode(getRootNodeName())) {
      pluginRoot = root.getNode(getRootNodeName());
    } else {
      pluginRoot = root.addNode(getRootNodeName(), SimpleFolderNode.JCR_PRIMARY_TYPE);
    }

    if (pluginRoot != null) {
      if (!pluginRoot.isNodeType(BrixNode.JCR_TYPE_BRIX_NODE)) {
        pluginRoot.addMixin(BrixNode.JCR_TYPE_BRIX_NODE);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Resolves uri path to a {@link BrixNode}. By default this method uses {@link
   * BrixConfig#getMapper()} to map the uri to a node path.
   *
   * @param uriPath uri path
   * @return node that maps to the <code>uriPath</code> or <code>null</code> if none
   */
  public BrixNode getNodeForUriPath(final Path uriPath) {
    BrixNode node = null;

    // create desired nodepath
    final Path nodePath =
        brix.getConfig().getMapper().getNodePathForUriPath(uriPath.toAbsolute(), brix);

    if (nodePath != null) {
      // allow site plugin to translate the node path into an actual jcr
      // path
      final String jcrPath = SitePlugin.get().toRealWebNodePath(nodePath.toString());

      // retrieve jcr session
      final String workspace = getWorkspace();
      final JcrSession session = brix.getCurrentSession(workspace);

      if (session.itemExists(jcrPath)) {
        // node exists, return it
        node = (BrixNode) session.getItem(jcrPath);
      }
    }

    return node;
  }
 public BrixNode getRootNode(String workspaceID) {
   JcrSession workspaceSession = getBrix().getCurrentSession(workspaceID);
   return (BrixNode) workspaceSession.getItem(getRootNodePath());
 }