Search in sources :

Example 26 with NodeService

use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.

the class UIWorkflowSummary method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    WorkflowInstance wi = getValue();
    if (wi != null) {
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);
        // output surrounding table and style if necessary
        out.write("<table");
        if (this.getAttributes().get("style") != null) {
            out.write(" style=\"");
            out.write((String) this.getAttributes().get("style"));
            out.write("\"");
        }
        if (this.getAttributes().get("styleClass") != null) {
            out.write(" class=\"");
            out.write((String) this.getAttributes().get("styleClass"));
            out.write("\"");
        }
        out.write(">");
        // output the title and description
        out.write("<tr><td>");
        out.write(bundle.getString("title"));
        out.write(":</td><td>");
        out.write(wi.definition.title);
        if (wi.definition.description != null && wi.definition.description.length() > 0) {
            out.write("&nbsp;(");
            out.write(Utils.encode(wi.definition.description));
            out.write(")");
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("initiated_by"));
        out.write(":</td><td>");
        NodeService nodeService = getNodeService(context);
        if (wi.initiator != null) {
            if (nodeService.exists(wi.initiator)) {
                out.write(Utils.encode(User.getFullName(Repository.getServiceRegistry(context).getNodeService(), wi.initiator)));
            } else {
                out.write("&lt;");
                out.write(bundle.getString("unknown"));
                out.write("&gt;");
            }
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("started_on"));
        out.write(":</td><td>");
        if (wi.startDate != null) {
            out.write(Utils.getDateFormat(context).format(wi.startDate));
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("completed_on"));
        out.write(":</td><td>");
        if (wi.endDate != null) {
            out.write(Utils.getDateFormat(context).format(wi.endDate));
        } else {
            out.write("&lt;");
            out.write(bundle.getString("in_progress"));
            out.write("&gt;");
        }
        out.write("</td></tr></table>");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService) ResourceBundle(java.util.ResourceBundle) WorkflowInstance(org.alfresco.service.cmr.workflow.WorkflowInstance)

Example 27 with NodeService

use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.

the class UIContentSelector method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    // get the child associations currently on the node and any that have been added
    NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
    if (isDisabled()) {
    // TODO: if the component is disabled just show the current value as text
    } else {
        // start outer table
        out.write("<table border='0' cellspacing='4' cellpadding='0' class='");
        if (this.getAttributes().get("styleClass") != null) {
            out.write((String) this.getAttributes().get("styleClass"));
        } else {
            out.write("selector");
        }
        out.write("'");
        if (this.getAttributes().get("style") != null) {
            out.write(" style='");
            out.write((String) this.getAttributes().get("style"));
            out.write("'");
        }
        out.write(">");
        // show the search field
        out.write("<tr><td colspan='2'><input type='text' maxlength='1024' size='32' name='");
        out.write(getClientId(context) + FIELD_CONTAINS);
        out.write("'/>&nbsp;&nbsp;<input type='submit' value='");
        out.write(Application.getMessage(context, MSG_SEARCH));
        out.write("' onclick=\"");
        out.write(generateFormSubmit(context, ACTION_SEARCH));
        out.write("\"/></td></tr>");
        // show available options i.e. all content in repository
        renderAvailableOptions(context, out, nodeService);
        // close table
        out.write("</table>");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService)

Example 28 with NodeService

use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.

the class UILockIcon method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    // get the value and see if the image is locked
    NodeService nodeService = getNodeService(context);
    String lockUser = null;
    Object val = getValue();
    NodeRef ref = null;
    if (val instanceof NodeRef) {
        ref = (NodeRef) val;
        if (nodeService.exists(ref)) {
            LockStatus lockStatus = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getLockService().getLockStatus(ref);
            if (lockStatus == LockStatus.LOCK_OWNER || lockStatus == LockStatus.LOCKED)
                lockUser = (String) nodeService.getProperty(ref, ContentModel.PROP_LOCK_OWNER);
        }
    }
    final boolean locked = lockUser != null;
    final boolean lockedOwner = locked && (lockUser.equals(Application.getCurrentUser(context).getUserName()));
    this.encodeBegin(context, locked, lockedOwner, new String[] { lockUser });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) LockStatus(org.alfresco.service.cmr.lock.LockStatus) NodeService(org.alfresco.service.cmr.repository.NodeService)

Example 29 with NodeService

use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.

the class DisplayPathConverter method getAsString.

/**
 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
 */
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
    String result = "";
    if (value != null) {
        try {
            NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
            Path path = null;
            if (value instanceof NodeRef) {
                path = nodeService.getPath((NodeRef) value);
            } else if (value instanceof Path) {
                path = (Path) value;
            }
            if (path != null) {
                result = Repository.getNamePath(nodeService, path, null, "/", null);
            }
        } catch (AccessDeniedException accessErr) {
        // use default if this occurs
        } catch (InvalidNodeRefException nodeErr) {
        // use default if this occurs
        }
    }
    return result;
}
Also used : Path(org.alfresco.service.cmr.repository.Path) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) NodeService(org.alfresco.service.cmr.repository.NodeService) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 30 with NodeService

use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.

the class UIClipboardShelfItem method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    List<ClipboardItem> items = getCollections();
    out.write(SHELF_START);
    if (items.size() != 0) {
        DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
        NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
        ResourceBundle bundle = Application.getBundle(context);
        for (int i = 0; i < items.size(); i++) {
            ClipboardItem item = items.get(i);
            // check that the item has not been deleted since added to the clipboard
            if (nodeService.exists(item.getNodeRef()) == false) {
                // remove from clipboard
                items.remove(i--);
                continue;
            }
            // start row with cut/copy state icon
            out.write("<tr><td width=16>");
            if (item.getMode() == ClipboardStatus.COPY) {
                out.write(Utils.buildImageTag(context, WebResources.IMAGE_COPY, 14, 16, bundle.getString(MSG_COPY), null, "absmiddle"));
            } else {
                out.write(Utils.buildImageTag(context, WebResources.IMAGE_CUT, 13, 16, bundle.getString(MSG_CUT), null, "absmiddle"));
            }
            out.write("</td><td width=16>");
            boolean isFolder = (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER));
            if (isFolder) {
                // start row with correct node icon
                String icon = (String) item.getIcon();
                if (icon != null) {
                    icon = "/images/icons/" + icon + "-16.gif";
                } else {
                    icon = WebResources.IMAGE_SPACE;
                }
                out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
            } else {
                String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
                out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
            }
            // output cropped item label - we also output with no breaks, this is ok
            // as the copped label will ensure a sensible maximum width
            out.write("</td><td width=100%><nobr>&nbsp;");
            if (isFolder) {
                out.write(Utils.cropEncode(item.getName()));
            } else {
                // output as a content download link
                out.write("<a href='");
                out.write(context.getExternalContext().getRequestContextPath());
                out.write(generateBrowserURL(dd, nodeService, item));
                out.write("' target='new'>");
                out.write(Utils.cropEncode(item.getName()));
                out.write("</a>");
            }
            // output actions
            out.write("</nobr></td><td align=right><nobr>");
            out.write(buildActionLink(ACTION_REMOVE_ITEM, i, bundle.getString(MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
            out.write("&nbsp;");
            out.write(buildActionLink(ACTION_PASTE_ITEM, i, bundle.getString(MSG_PASTE_ITEM), WebResources.IMAGE_PASTE));
            if (item.supportsLink() && item.getMode() == ClipboardStatus.COPY && dd.isSubClass(item.getType(), ContentModel.TYPE_LINK) == false) {
                out.write("&nbsp;");
                out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
            }
            // end actions cell and end row
            out.write("</nobr></td></tr>");
        }
        // output general actions if any clipboard items are present
        out.write("<tr><td colspan=4 style='padding-top:3px' align='center'><nobr>");
        out.write(buildActionLink(ACTION_PASTE_ALL, -1, bundle.getString(MSG_PASTE_ALL), null));
        out.write("&nbsp;|&nbsp;");
        out.write(buildActionLink(ACTION_REMOVE_ALL, -1, bundle.getString(MSG_REMOVE_ALL), null));
        out.write("</nobr></td><td></td></tr>");
    }
    out.write(SHELF_END);
}
Also used : ClipboardItem(org.alfresco.web.bean.clipboard.ClipboardItem) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService) ResourceBundle(java.util.ResourceBundle)

Aggregations

NodeService (org.alfresco.service.cmr.repository.NodeService)53 NodeRef (org.alfresco.service.cmr.repository.NodeRef)36 QName (org.alfresco.service.namespace.QName)15 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)11 ResponseWriter (javax.faces.context.ResponseWriter)10 IOException (java.io.IOException)8 UserTransaction (javax.transaction.UserTransaction)8 ServiceRegistry (org.alfresco.service.ServiceRegistry)8 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)8 Serializable (java.io.Serializable)7 HashMap (java.util.HashMap)7 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)7 PermissionService (org.alfresco.service.cmr.security.PermissionService)7 PersonService (org.alfresco.service.cmr.security.PersonService)7 SearchService (org.alfresco.service.cmr.search.SearchService)6 ArrayList (java.util.ArrayList)5 ResourceBundle (java.util.ResourceBundle)5 FileInfo (org.alfresco.service.cmr.model.FileInfo)5 Path (org.alfresco.service.cmr.repository.Path)5 TransactionService (org.alfresco.service.transaction.TransactionService)5