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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations