Search in sources :

Example 11 with DictionaryService

use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.

the class EditUserDetailsDialog method finishImpl.

@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception {
    try {
        ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
        DictionaryService dd = services.getDictionaryService();
        Map<QName, Serializable> props = getNodeService().getProperties(getPerson().getNodeRef());
        for (String key : getPerson().getProperties().keySet()) {
            QName propQName = QName.createQName(key);
            if (dd.getProperty(propQName) == null || dd.getProperty(propQName).isProtected() == false) {
                props.put(propQName, (Serializable) getPerson().getProperties().get(key));
            }
        }
        // persist all property changes
        NodeRef personRef = getPerson().getNodeRef();
        this.getNodeService().setProperties(personRef, props);
        // save person description content field
        if (this.personDescription != null) {
            ContentService cs = services.getContentService();
            ContentWriter writer = cs.getWriter(personRef, ContentModel.PROP_PERSONDESC, true);
            writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
            writer.putContent(this.personDescription);
        }
        // setup user avatar association
        if (this.photoRef != null) {
            List<AssociationRef> refs = this.getNodeService().getTargetAssocs(personRef, ContentModel.ASSOC_AVATAR);
            // remove old association if it exists
            if (refs.size() == 1) {
                NodeRef existingRef = refs.get(0).getTargetRef();
                this.getNodeService().removeAssociation(personRef, existingRef, ContentModel.ASSOC_AVATAR);
            }
            // setup new association
            this.getNodeService().createAssociation(personRef, this.photoRef, ContentModel.ASSOC_AVATAR);
        }
        // if the above calls were successful, then reset Person Node in the session
        Application.getCurrentUser(context).reset();
    } catch (Throwable err) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_GENERIC), err.getMessage()), err);
        outcome = null;
        ReportedException.throwIfNecessary(err);
    }
    return outcome;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) Serializable(java.io.Serializable) ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) QName(org.alfresco.service.namespace.QName) ServiceRegistry(org.alfresco.service.ServiceRegistry) ContentService(org.alfresco.service.cmr.repository.ContentService) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef)

Example 12 with DictionaryService

use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.

the class UpdateDocEvaluator method evaluate.

/**
 * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
 */
public boolean evaluate(Node node) {
    DictionaryService dd = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDictionaryService();
    boolean isOfflineEditing = (EditOfflineDialog.OFFLINE_EDITING.equals(node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE)));
    return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) && ((node.isWorkingCopyOwner() && !isOfflineEditing) || (!node.isLocked() && !node.hasAspect(ContentModel.ASPECT_WORKING_COPY)));
}
Also used : DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService)

Example 13 with DictionaryService

use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.

the class EditDocOnlineCIFSEvaluator method evaluate.

/**
 * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
 */
public boolean evaluate(Node node) {
    FacesContext fc = FacesContext.getCurrentInstance();
    DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
    boolean result = false;
    // if the node is inline editable, the inline online editing should always be used
    if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT)) {
        Map<String, Object> props = node.getProperties();
        if ("cifs".equals(Application.getClientConfig(fc).getEditLinkType()) && (!node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) || props.get(ApplicationModel.PROP_EDITINLINE) == null || !((Boolean) props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue())) {
            if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY)) {
                result = (EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE)));
            } else {
                result = super.evaluate(node);
            }
        }
    }
    return result;
}
Also used : FacesContext(javax.faces.context.FacesContext) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService)

Example 14 with DictionaryService

use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.

the class EditDocOnlineHttpEvaluator method evaluate.

/**
 * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
 */
public boolean evaluate(Node node) {
    FacesContext fc = FacesContext.getCurrentInstance();
    DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
    boolean result = false;
    if (node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) {
    // this branch from EditDocHttpEvaluator
    // skip, result = false
    } else if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT)) {
        Map<String, Object> props = node.getProperties();
        if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && props.get(ApplicationModel.PROP_EDITINLINE) != null && ((Boolean) props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue())) {
            if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY)) {
                result = EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE));
            } else {
                result = super.evaluate(node);
            }
        }
    }
    return result;
}
Also used : FacesContext(javax.faces.context.FacesContext) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) Map(java.util.Map)

Example 15 with DictionaryService

use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.

the class EditDocOnlineWebDavEvaluator method evaluate.

/**
 * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
 */
public boolean evaluate(Node node) {
    FacesContext fc = FacesContext.getCurrentInstance();
    DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
    boolean result = false;
    // if the node is inline editable, the inline online editing should always be used
    if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT)) {
        Map<String, Object> props = node.getProperties();
        if ("webdav".equals(Application.getClientConfig(fc).getEditLinkType()) && (!node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) || props.get(ApplicationModel.PROP_EDITINLINE) == null || !((Boolean) props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue())) {
            if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY)) {
                result = (EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE)));
            } else {
                result = super.evaluate(node);
            }
        }
    }
    return result;
}
Also used : FacesContext(javax.faces.context.FacesContext) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService)

Aggregations

DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)29 FacesContext (javax.faces.context.FacesContext)12 NodeRef (org.alfresco.service.cmr.repository.NodeRef)11 QName (org.alfresco.service.namespace.QName)11 NodeService (org.alfresco.service.cmr.repository.NodeService)8 Node (org.alfresco.web.bean.repository.Node)8 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)6 SelectItem (javax.faces.model.SelectItem)5 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)5 Serializable (java.io.Serializable)4 ArrayList (java.util.ArrayList)4 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)4 QuickSort (org.alfresco.web.data.QuickSort)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ResponseWriter (javax.faces.context.ResponseWriter)3 UserTransaction (javax.transaction.UserTransaction)3 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)3