Search in sources :

Example 11 with Extend

use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.

the class RatingServiceImpl method getRatingsByCurrentUser.

/*
     * (non-Javadoc)
     * @see org.alfresco.service.cmr.rating.RatingService#getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef)
     */
@Extend(traitAPI = RatingServiceTrait.class, extensionAPI = RatingServiceExtension.class)
public List<Rating> getRatingsByCurrentUser(NodeRef targetNode) {
    final String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
    List<ChildAssociationRef> children = getRatingNodeChildren(targetNode, null, fullyAuthenticatedUser);
    List<Rating> result = new ArrayList<Rating>(children.size());
    for (ChildAssociationRef child : children) {
        result.add(convertNodeRefToRating(fullyAuthenticatedUser, child.getChildRef()));
    }
    return result;
}
Also used : Rating(org.alfresco.service.cmr.rating.Rating) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Extend(org.alfresco.traitextender.Extend)

Example 12 with Extend

use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.

the class BehaviourFilterImpl method enableBehaviour.

@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public void enableBehaviour(QName className) {
    ParameterCheck.mandatory("className", className);
    if (logger.isDebugEnabled()) {
        logger.debug("Behaviour: ENABLE (" + AlfrescoTransactionSupport.getTransactionId() + "): " + className);
    }
    TransactionalResourceHelper.decrementCount(KEY_FILTER_COUNT, false);
    if (!TransactionalResourceHelper.isResourcePresent(KEY_CLASS_FILTERS)) {
        // Nothing was disabled
        return;
    }
    Map<ClassFilter, MutableInt> classFilters = TransactionalResourceHelper.getMap(KEY_CLASS_FILTERS);
    MutableInt filterNumber = null;
    for (ClassFilter classFilter : classFilters.keySet()) {
        if (classFilter.getClassName().equals(className)) {
            filterNumber = classFilters.get(classFilter);
            break;
        }
    }
    if (filterNumber == null) {
        // Class was not disabled
        return;
    } else if (filterNumber.intValue() <= 0) {
    // Can't go below zero for this
    } else {
        filterNumber.decrement();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("   Now: " + filterNumber);
    }
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) Extend(org.alfresco.traitextender.Extend)

Example 13 with Extend

use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.

the class BehaviourFilterImpl method isEnabled.

@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public boolean isEnabled(NodeRef nodeRef, QName className) {
    ParameterCheck.mandatory("nodeRef", nodeRef);
    ParameterCheck.mandatory("className", className);
    // Check the class (includes global) and instance, first
    if (!isEnabled(className) || !isEnabled(nodeRef)) {
        return false;
    }
    if (!TransactionalResourceHelper.isResourcePresent(KEY_INSTANCE_CLASS_FILTERS)) {
        // Nothing was disabled
        return true;
    }
    nodeRef = tenantService.getName(nodeRef);
    Map<NodeRef, Map<QName, MutableInt>> instanceClassFilters = TransactionalResourceHelper.getMap(KEY_INSTANCE_CLASS_FILTERS);
    Map<QName, MutableInt> classFilters = instanceClassFilters.get(nodeRef);
    if (classFilters == null) {
        // Instance classes were not disabled
        return true;
    }
    for (QName classCheck : classFilters.keySet()) {
        // Ignore if it is not part of the hierarchy we are requesting
        if (!dictionaryService.isSubClass(className, classCheck)) {
            continue;
        }
        MutableInt filter = classFilters.get(classCheck);
        if (filter != null && filter.intValue() > 0) {
            // Class was disabled
            return false;
        }
    }
    return true;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) MutableInt(org.apache.commons.lang3.mutable.MutableInt) HashMap(java.util.HashMap) Map(java.util.Map) Extend(org.alfresco.traitextender.Extend)

Example 14 with Extend

use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.

the class BehaviourFilterImpl method isEnabled.

@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public boolean isEnabled(QName className) {
    ParameterCheck.mandatory("className", className);
    // Check the global, first
    if (!isEnabled()) {
        return false;
    }
    if (!TransactionalResourceHelper.isResourcePresent(KEY_CLASS_FILTERS)) {
        // Nothing was disabled
        return true;
    }
    Map<ClassFilter, MutableInt> classFilters = TransactionalResourceHelper.getMap(KEY_CLASS_FILTERS);
    // Check this class to be disabled
    ClassFilter classFilter = getClassFilter(className);
    if (classFilter != null) {
        MutableInt filterNumber = classFilters.get(classFilter);
        if (filterNumber != null && filterNumber.intValue() > 0) {
            // the class is disabled
            return false;
        }
    }
    // Search for the super classes to be disabled with subclasses
    while (className != null) {
        classFilter = getClassFilter(className);
        if (classFilter != null && classFilter.isDisableSubClasses()) {
            MutableInt filterNumber = classFilters.get(classFilter);
            if (filterNumber != null && filterNumber.intValue() > 0) {
                // the class is disabled
                return false;
            }
        }
        // continue search
        // look up the hierarchy
        className = generaliseClass(className);
    }
    return true;
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) Extend(org.alfresco.traitextender.Extend)

Example 15 with Extend

use of org.alfresco.traitextender.Extend in project alfresco-repository by Alfresco.

the class WorkflowPackageImpl method getWorkflowIdsForContent.

/**
 * {@inheritDoc}
 */
@Extend(traitAPI = WorkflowPackageTrait.class, extensionAPI = WorkflowPackageExtension.class)
public List<String> getWorkflowIdsForContent(NodeRef packageItem) {
    ParameterCheck.mandatory("packageItem", packageItem);
    List<String> workflowIds = new ArrayList<String>();
    if (nodeService.exists(packageItem)) {
        List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(packageItem);
        for (ChildAssociationRef parentAssoc : parentAssocs) {
            NodeRef parentRef = parentAssoc.getParentRef();
            if (nodeService.hasAspect(parentRef, WorkflowModel.ASPECT_WORKFLOW_PACKAGE) && !nodeService.hasAspect(parentRef, ContentModel.ASPECT_ARCHIVED)) {
                String workflowInstance = (String) nodeService.getProperty(parentRef, WorkflowModel.PROP_WORKFLOW_INSTANCE_ID);
                if (workflowInstance != null && workflowInstance.length() > 0) {
                    workflowIds.add(workflowInstance);
                }
            }
        }
    }
    return workflowIds;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Extend(org.alfresco.traitextender.Extend)

Aggregations

Extend (org.alfresco.traitextender.Extend)75 NodeRef (org.alfresco.service.cmr.repository.NodeRef)47 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)25 QName (org.alfresco.service.namespace.QName)21 ArrayList (java.util.ArrayList)19 Pair (org.alfresco.util.Pair)15 HashSet (java.util.HashSet)10 Serializable (java.io.Serializable)9 MutableInt (org.apache.commons.lang3.mutable.MutableInt)9 HashMap (java.util.HashMap)8 LinkedHashSet (java.util.LinkedHashSet)8 ChildAssocRefQueryCallback (org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback)8 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)8 LockStatus (org.alfresco.service.cmr.lock.LockStatus)6 Version (org.alfresco.service.cmr.version.Version)6 NodeDAO (org.alfresco.repo.domain.node.NodeDAO)5 LockState (org.alfresco.repo.lock.mem.LockState)5 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)5 StoreRef (org.alfresco.service.cmr.repository.StoreRef)5 Map (java.util.Map)4