@Override
  protected String finishImpl(FacesContext context, String outcome) throws Exception {
    // find out what the parent type of the node being deleted
    Node node = this.browseBean.getActionSpace();
    NodeRef parent = null;
    ChildAssociationRef assoc = this.getNodeService().getPrimaryParent(node.getNodeRef());
    if (assoc != null) {
      // get the parent node
      parent = assoc.getParentRef();

      // if the parent type is a forum space then we need the dialog to go
      // back to the forums view otherwise it will use the default of 'browse',
      // this happens when a forum being used to discuss a node is deleted.
      QName parentType = this.getNodeService().getType(parent);
      if (parentType.equals(ForumModel.TYPE_FORUMS)) {
        this.reDisplayForums = true;
      }
    }

    // delete the forum itself
    outcome = super.finishImpl(context, outcome);

    // remove the discussable aspect if appropriate
    if (assoc != null && parent != null) {
      // get the association type
      QName type = assoc.getTypeQName();
      if (type.equals(ForumModel.ASSOC_DISCUSSION)) {
        // if the association type is the 'discussion' association we
        // need to remove the discussable aspect from the parent node
        this.getNodeService().removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE);
      }
    }

    return outcome;
  }
  /**
   * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
   */
  public boolean evaluate(final Node node) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    AVMService avmService = Repository.getServiceRegistry(facesContext).getAVMService();

    Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
    AVMNodeDescriptor nodeDesc = avmService.lookup(-1, p.getSecond());

    // don't allow action if its a 'layeredfolder' and a primary indirection
    return !(nodeDesc.getType() == AVMNodeType.LAYERED_DIRECTORY && nodeDesc.isPrimary());
  }
  /**
   * Checkout document to the same space as original one and then add the OFFLINE_EDITING property.
   */
  private void checkoutFile(Node node) {
    UserTransaction tx = null;
    FacesContext context = FacesContext.getCurrentInstance();

    if (node != null) {
      try {
        tx = Repository.getUserTransaction(context, false);
        tx.begin();

        if (logger.isDebugEnabled())
          logger.debug("Trying to checkout content node Id: " + node.getId());
        NodeRef workingCopyRef = null;

        // checkout the content to the current space
        workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef());
        getNodeService()
            .setProperty(workingCopyRef, ContentModel.PROP_WORKING_COPY_MODE, OFFLINE_EDITING);

        // set the working copy Node instance
        Node workingCopy = new Node(workingCopyRef);
        property.setWorkingDocument(workingCopy);

        // create content URL to the content download servlet with ID and
        // expected filename
        String url =
            DownloadContentServlet.generateDownloadURL(workingCopyRef, workingCopy.getName());

        workingCopy.getProperties().put("url", url);
        workingCopy
            .getProperties()
            .put("fileType32", FileTypeImageUtils.getFileTypeImage(workingCopy.getName(), false));

        // commit the transaction
        tx.commit();
      } catch (Throwable err) {
        try {
          if (tx != null) {
            tx.rollback();
          }
        } catch (Exception tex) {
        }

        Utils.addErrorMessage(
            Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_CHECKOUT)
                + err.getMessage(),
            err);
      }
    } else {
      logger.warn("WARNING: checkoutFile called without a current Document!");
    }
  }