Search in sources :

Example 16 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class BaseActionWizard method getUsers.

/**
 * @return the List of users in the system wrapped in SelectItem objects
 */
public List<SelectItem> getUsers() {
    if (this.users == null) {
        List<Node> userNodes = Repository.getUsers(FacesContext.getCurrentInstance(), this.getNodeService(), this.getPersonService());
        this.users = new ArrayList<SelectItem>();
        for (Node user : userNodes) {
            String email = (String) user.getProperties().get("email");
            if (email != null && email.length() > 0) {
                this.users.add(new SelectItem(email, (String) user.getProperties().get("fullName")));
            }
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.users, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.users;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem) Node(org.alfresco.web.bean.repository.Node)

Example 17 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class EditCategoryDialog method init.

@Override
public void init(Map<String, String> parameters) {
    this.isFinished = false;
    this.categoryFlag = false;
    // retrieve parameters
    categoryRef = parameters.get(CategoriesDialog.PARAM_CATEGORY_REF);
    // make sure nodeRef was supplied
    ParameterCheck.mandatoryString(CategoriesDialog.PARAM_CATEGORY_REF, categoryRef);
    // create the node
    this.category = new Node(new NodeRef(categoryRef));
    setActionCategory(category);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node)

Example 18 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class EditNodeCategoriesDialog method init.

// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters) {
    super.init(parameters);
    // reset variables
    this.categories = null;
    this.addedCategory = null;
    // retrieve parameters
    String nodeRef = parameters.get("nodeRef");
    // make sure nodeRef was supplied
    ParameterCheck.mandatoryString("nodeRef", nodeRef);
    // create the node
    this.node = new Node(new NodeRef(nodeRef));
    // determine description for dialog
    FacesContext context = FacesContext.getCurrentInstance();
    if (getDictionaryService().isSubClass(this.node.getType(), ContentModel.TYPE_FOLDER)) {
        this.description = Application.getMessage(context, "editcategory_space_description");
    } else {
        this.description = Application.getMessage(context, "editcategory_description");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FacesContext(javax.faces.context.FacesContext) Node(org.alfresco.web.bean.repository.Node)

Example 19 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class CCCheckoutFileDialog method checkoutFile.

/**
 * Action called upon completion of the Check Out file page
 */
public String checkoutFile(FacesContext context, String outcome) {
    boolean checkoutSuccessful = false;
    final Node node = property.getDocument();
    if (node != null) {
        try {
            if (logger.isDebugEnabled())
                logger.debug("Trying to checkout content node Id: " + node.getId());
            // checkout the node content to create a working copy
            if (logger.isDebugEnabled()) {
                logger.debug("Checkout copy location: " + property.getCopyLocation());
                logger.debug("Selected Space Id: " + property.getSelectedSpaceId());
            }
            NodeRef workingCopyRef = null;
            if (property.getCopyLocation().equals(CCProperties.COPYLOCATION_OTHER) && property.getSelectedSpaceId() != null) {
                // checkout to a arbituary parent Space
                NodeRef destRef = property.getSelectedSpaceId();
                ChildAssociationRef childAssocRef = getNodeService().getPrimaryParent(destRef);
                workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef(), destRef, ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
            } else {
                // checkout the content to the current space
                workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef());
                // in the resources panel in the manage task dialog
                if (property.isWorkflowAction() && property.getWorkflowTaskId() != null && (property.getWorkflowTaskId().equals("null") == false)) {
                    WorkflowTask task = property.getWorkflowService().getTaskById(property.getWorkflowTaskId());
                    if (task != null) {
                        NodeRef workflowPackage = (NodeRef) task.properties.get(WorkflowModel.ASSOC_PACKAGE);
                        if (workflowPackage != null) {
                            getNodeService().addChild(workflowPackage, workingCopyRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String) getNodeService().getProperty(workingCopyRef, ContentModel.PROP_NAME))));
                            if (logger.isDebugEnabled())
                                logger.debug("Added working copy to workflow package: " + workflowPackage);
                        }
                    }
                }
            }
            // 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
            // the myfile part will be ignored by the servlet but gives the
            // browser a hint
            String url = DownloadContentServlet.generateDownloadURL(workingCopyRef, workingCopy.getName());
            workingCopy.getProperties().put("url", url);
            workingCopy.getProperties().put("fileType32", FileTypeImageUtils.getFileTypeImage(workingCopy.getName(), false));
            // mark as successful
            checkoutSuccessful = true;
        } catch (Throwable err) {
            Utils.addErrorMessage(Application.getMessage(context, MSG_ERROR_CHECKOUT) + err.getMessage(), err);
            ReportedException.throwIfNecessary(err);
        }
    } else {
        logger.warn("WARNING: checkoutFile called without a current Document!");
    }
    // determine which page to show next if the checkout was successful.
    if (checkoutSuccessful) {
        // already disappeared!
        if (getNodeService().exists(property.getWorkingDocument().getNodeRef())) {
            // go to the page that allows the user to download the content
            // for editing
            // "checkoutFileLink";
            outcome = "dialog:checkoutFileLink";
        // //checkout-file-link.jsp
        // currentAction = Action.CHECKOUT_FILE_LINK;
        } else {
            // show a page telling the user that the content has already
            // been checked in
            // "workingCopyMissing";
            outcome = "dialog:workingCopyMissing";
        // //
        // working-copy-missing.jsp
        // currentAction = Action.WORKING_COPY_MISSING;
        }
    }
    return outcome;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 20 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class EditContentPropertiesCommand method execute.

/**
 * @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
 */
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
    ServletContext sc = (ServletContext) properties.get(PROP_SERVLETCONTEXT);
    ServletRequest req = (ServletRequest) properties.get(PROP_REQUEST);
    ServletResponse res = (ServletResponse) properties.get(PROP_RESPONSE);
    FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
    BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
    // setup context from url args in properties map
    String strNodeRef = (String) properties.get(PROP_NODEREF);
    ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
    browseBean.setDocument(new Node(new NodeRef(strNodeRef)));
    NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
    navigationHandler.handleNavigation(fc, null, "dialog:editContentProperties");
    String viewId = fc.getViewRoot().getViewId();
    try {
        sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
    } catch (Exception e) {
        throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
    }
    return null;
}
Also used : ServletRequest(javax.servlet.ServletRequest) ServletResponse(javax.servlet.ServletResponse) FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) BrowseBean(org.alfresco.web.bean.BrowseBean) Node(org.alfresco.web.bean.repository.Node) ServletContext(javax.servlet.ServletContext) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) NavigationHandler(javax.faces.application.NavigationHandler) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Aggregations

Node (org.alfresco.web.bean.repository.Node)145 NodeRef (org.alfresco.service.cmr.repository.NodeRef)81 FacesContext (javax.faces.context.FacesContext)44 MapNode (org.alfresco.web.bean.repository.MapNode)38 UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)28 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)26 UserTransaction (javax.transaction.UserTransaction)22 QName (org.alfresco.service.namespace.QName)22 NodePropertyComparator (org.alfresco.web.ui.common.NodePropertyComparator)18 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)17 ArrayList (java.util.ArrayList)10 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)8 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)8 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)7 TransientNode (org.alfresco.web.bean.repository.TransientNode)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AbortProcessingException (javax.faces.event.AbortProcessingException)6 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)6