public String renameNode(String newLabel)
      throws AccessDeniedException, ExchangeException, PathNotFoundException, RepositoryException {
    String returnValue;
    String parentPath = StringUtils.substringBeforeLast(this.getPath(), "/"); // $NON-NLS-1$
    newLabel = Path.getValidatedLabel(newLabel);

    // don't rename if it uses the same name as the current
    if (this.getPath().endsWith("/" + newLabel)) {
      return newLabel;
    }

    String dest = parentPath + "/" + newLabel; // $NON-NLS-1$
    if (getHierarchyManager().isExist(dest)) {
      newLabel = Path.getUniqueLabel(getHierarchyManager(), parentPath, newLabel);
      dest = parentPath + "/" + newLabel; // $NON-NLS-1$
    }
    this.deActivateNode(this.getPath());

    if (log.isInfoEnabled()) {
      log.info("Moving node from " + this.getPath() + " to " + dest); // $NON-NLS-1$ //$NON-NLS-2$
    }
    if (getHierarchyManager().isNodeData(this.getPath())) {
      Content parentPage = getHierarchyManager().getContent(parentPath);
      NodeData newNodeData = parentPage.createNodeData(newLabel);
      NodeData existingNodeData = getHierarchyManager().getNodeData(this.getPath());
      newNodeData.setValue(existingNodeData.getString());
      existingNodeData.delete();
      dest = parentPath;
    } else {
      // we can't rename a node. we must move
      // we must place the node at the same position
      Content current = getHierarchyManager().getContent(this.getPath());
      Content parent = current.getParent();
      String placedBefore = null;
      for (Iterator iter = parent.getChildren(current.getNodeTypeName()).iterator();
          iter.hasNext(); ) {
        Content child = (Content) iter.next();
        if (child.getHandle().equals(this.getPath())) {
          if (iter.hasNext()) {
            child = (Content) iter.next();
            placedBefore = child.getName();
          }
        }
      }

      getHierarchyManager().moveTo(this.getPath(), dest);

      // now set at the same place as before
      if (placedBefore != null) {
        parent.orderBefore(newLabel, placedBefore);
      }
    }

    Content newPage = getHierarchyManager().getContent(dest);
    returnValue = newLabel;
    newPage.updateMetaData();
    newPage.save();

    return returnValue;
  }
  private void writeComment(HttpServletRequest request, Content websiteNode)
      throws RepositoryException {

    Content commentsNode;
    if (websiteNode.hasContent("comments")) {
      commentsNode = websiteNode.getContent("comments");
    } else {
      commentsNode = websiteNode.createContent("comments");
    }

    HierarchyManager hierarchyManager = MgnlContext.getHierarchyManager(ContentRepository.WEBSITE);
    String label = Path.getUniqueLabel(hierarchyManager, commentsNode.getHandle(), "comment");

    Content commentNode = commentsNode.createContent(label);
    commentNode.setNodeData("name", request.getParameter("name"));
    commentNode.setNodeData("email", request.getParameter("email"));
    commentNode.setNodeData("text", request.getParameter("text"));
    commentNode.setNodeData("created", Calendar.getInstance());

    websiteNode.save();
  }
 public Content copyMoveNode(String source, String destination, boolean move)
     throws ExchangeException, RepositoryException {
   // todo: ??? generic -> RequestInterceptor.java
   if (getHierarchyManager().isExist(destination)) {
     String parentPath = StringUtils.substringBeforeLast(destination, "/"); // $NON-NLS-1$
     String label = StringUtils.substringAfterLast(destination, "/"); // $NON-NLS-1$
     label = Path.getUniqueLabel(getHierarchyManager(), parentPath, label);
     destination = parentPath + "/" + label; // $NON-NLS-1$
   }
   if (move) {
     if (destination.indexOf(source + "/") == 0) { // $NON-NLS-1$
       // todo: disable this possibility in javascript
       // move source into destinatin not possible
       return null;
     }
     this.deActivateNode(source);
     try {
       getHierarchyManager().moveTo(source, destination);
     } catch (Exception e) {
       // try to move below node data
       return null;
     }
   } else {
     // copy
     getHierarchyManager().copyTo(source, destination);
   }
   // SessionAccessControl.invalidateUser(this.getRequest());
   Content newContent = getHierarchyManager().getContent(destination);
   try {
     newContent.updateMetaData();
     newContent.getMetaData().setUnActivated();
   } catch (Exception e) {
     if (log.isDebugEnabled()) log.debug("Exception caught: " + e.getMessage(), e); // $NON-NLS-1$
   }
   newContent.save();
   return newContent;
 }