Java Code Examples for org.alfresco.service.cmr.dictionary.ClassDefinition#isAspect()
The following examples show how to use
org.alfresco.service.cmr.dictionary.ClassDefinition#isAspect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExporterComponent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Is the property unexportable? */ private boolean isExcludedAspectProperty(QName[] excludeAspects, QName propertyQName) { PropertyDefinition propDef = dictionaryService.getProperty(propertyQName); if (propDef == null) { return false; } ClassDefinition classDef = propDef.getContainerClass(); if (classDef == null || !classDef.isAspect()) { return false; } return isExcludedAspect(excludeAspects, classDef.getName()); }
Example 2
Source File: ExporterComponent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Is the association unexportable? */ private boolean isExcludedAspectAssociation(QName[] excludeAspects, QName associationQName) { AssociationDefinition assocDef = dictionaryService.getAssociation(associationQName); if (assocDef == null) { return false; } ClassDefinition classDef = assocDef.getSourceClass(); if (classDef == null || !classDef.isAspect()) { return false; } return isExcludedAspect(excludeAspects, classDef.getName()); }
Example 3
Source File: ContentClassFilter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); DictionaryService dictionaryService = serviceRegistry.getDictionaryService(); aspects.clear(); types.clear(); for (QName contentClass : contentClasses) { ClassDefinition classDef = dictionaryService.getClass(contentClass); if (classDef == null) { continue; } if (classDef.isAspect()) { aspects.add(contentClass); if (!directOnly) { aspects.addAll(dictionaryService.getSubAspects(contentClass, true)); } } else { types.add(contentClass); if (!directOnly) { types.addAll(dictionaryService.getSubTypes(contentClass, true)); } } } initialised = true; }
Example 4
Source File: CopyServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Copies the properties for the node type or aspect onto the destination node. */ private void copyProperties( CopyDetails copyDetails, NodeRef targetNodeRef, QName classQName, Map<QName, CopyBehaviourCallback> callbacks) { ClassDefinition targetClassDef = dictionaryService.getClass(classQName); if (targetClassDef == null) { return; // Ignore unknown types } // First check if the aspect must be copied at all CopyBehaviourCallback callback = callbacks.get(classQName); if (callback == null) { throw new IllegalStateException("Source node class has no callback: " + classQName); } // Ignore if not present or if not scheduled for a copy if (!callback.getMustCopy(classQName, copyDetails)) { // Do nothing with this return; } // Compile the properties to copy, even if they are empty Map<QName, Serializable> classProperties = buildCopyProperties( copyDetails, Collections.singleton(classQName), callbacks); // We don't need permissions as we've just created the node if (targetClassDef.isAspect()) { internalNodeService.addAspect(targetNodeRef, classQName, classProperties); } else { internalNodeService.addProperties(targetNodeRef, classProperties); } }
Example 5
Source File: DictionaryComponent.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isSubClass(QName className, QName ofClassName) { // Validate arguments ParameterCheck.mandatory("className", className); ParameterCheck.mandatory("ofClassName", ofClassName); ClassDefinition classDef = getClass(className); if (classDef == null) { return false; } ClassDefinition ofClassDef = getClass(ofClassName); if (ofClassDef == null) { return false; } // Only check if both ends are either a type or an aspect boolean subClassOf = false; if (classDef.isAspect() == ofClassDef.isAspect()) { while (classDef != null) { if (classDef.equals(ofClassDef)) { subClassOf = true; break; } // No match yet, so go to parent class QName parentClassName = classDef.getParentName(); classDef = (parentClassName == null) ? null : getClass(parentClassName); } } return subClassOf; }
Example 6
Source File: SelectorPropertyContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
private void afterPropertiesSet_setupChangePolicies() { if (this.moveStoresOnChangeOptionPropertyName != null) { this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService, this.moveStoresOnChangeOptionPropertyName); PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName); final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService .getProperty(this.moveStoresOnChangeOptionPropertyQName); if (moveStoresOnChangeOptionPropertyDefinition == null || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName()) || moveStoresOnChangeOptionPropertyDefinition.isMultiValued()) { throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName + " is not a valid content model property of type single-valued d:boolean"); } } if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null) { this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT)); final ClassDefinition classDefinition = this.dictionaryService.getClass(this.selectorClassQName); if (classDefinition.isAspect()) { this.policyComponent.bindClassBehaviour(BeforeRemoveAspectPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "beforeRemoveAspect", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.EVERY_EVENT)); } } }
Example 7
Source File: PermissionModel.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private Set<PermissionReference> getAllPermissionsImpl(QName type, boolean exposedOnly) { Map<QName, Set<PermissionReference>> cache; if (exposedOnly) { cache = cachedTypePermissionsExposed; } else { cache = cachedTypePermissionsUnexposed; } Set<PermissionReference> permissions = cache.get(type); if (permissions == null) { boolean hadWriteLock = lock.isWriteLockedByCurrentThread(); if (!hadWriteLock) { lock.readLock().unlock(); lock.writeLock().lock(); } try { permissions = cache.get(type); if (permissions == null) { permissions = new LinkedHashSet<PermissionReference>(256, 1.0f); ClassDefinition cd = dictionaryService.getClass(type); if (cd != null) { if (cd.isAspect()) { addAspectPermissions(type, permissions, exposedOnly); } else { mergeGeneralAspectPermissions(permissions, exposedOnly); addTypePermissions(type, permissions, exposedOnly); } } permissions = Collections.unmodifiableSet(permissions); cache.put(type, permissions); } } finally { if (!hadWriteLock) { lock.readLock().lock(); lock.writeLock().unlock(); } } } return permissions; }
Example 8
Source File: VersionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void defaultOnCreateVersion( QName classRef, NodeRef nodeRef, Map<String, Serializable> versionProperties, PolicyScope nodeDetails) { ClassDefinition classDefinition = this.dictionaryService.getClass(classRef); if (classDefinition != null) { boolean wasMLAware = MLPropertyInterceptor.setMLAware(true); try { // Copy the properties (along with their aspect) Map<QName,PropertyDefinition> propertyDefinitions = classDefinition.getProperties(); for (QName propertyName : propertyDefinitions.keySet()) { Serializable propValue = this.nodeService.getProperty(nodeRef, propertyName); nodeDetails.addProperty(classRef, propertyName, propValue); } // Also copy the aspect with no properties in its definition if (classDefinition.isAspect() && !nodeDetails.getAspects().contains(classRef)) { nodeDetails.addAspect(classRef); } } finally { MLPropertyInterceptor.setMLAware(wasMLAware); } // Version the associations (child and target) Map<QName, AssociationDefinition> assocDefs = classDefinition.getAssociations(); // TODO: Need way of getting child assocs of a given type if (classDefinition.isContainer()) { List<ChildAssociationRef> childAssocRefs = this.nodeService.getChildAssocs(nodeRef); for (ChildAssociationRef childAssocRef : childAssocRefs) { if (assocDefs.containsKey(childAssocRef.getTypeQName())) { nodeDetails.addChildAssociation(classDefinition.getName(), childAssocRef); } } } // TODO: Need way of getting assocs of a given type List<AssociationRef> nodeAssocRefs = this.nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); for (AssociationRef nodeAssocRef : nodeAssocRefs) { if (assocDefs.containsKey(nodeAssocRef.getTypeQName())) { nodeDetails.addAssociation(classDefinition.getName(), nodeAssocRef); } } } }
Example 9
Source File: DbNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get any aspects that should be added given the type, properties and existing aspects. * Note that this <b>does not</b> included a search for properties required for the missing * aspects. * * @param classQName the type, aspect or association * @return Returns any aspects that should be added */ private Set<QName> getMissingAspects( Set<QName> existingAspects, Map<QName, Serializable> existingProperties, QName classQName) { // Copy incoming existing values so that we can modify appropriately existingAspects = new HashSet<QName>(existingAspects); ClassDefinition classDefinition = dictionaryService.getClass(classQName); if (classDefinition == null) { return Collections.emptySet(); } Set<QName> missingAspects = new HashSet<QName>(7); // Check that the aspect itself is present (only applicable for aspects) if (classDefinition.isAspect() && !existingAspects.contains(classQName)) { missingAspects.add(classQName); } // Find all aspects that should be present on the class List<AspectDefinition> defaultAspectDefs = classDefinition.getDefaultAspects(); for (AspectDefinition defaultAspectDef : defaultAspectDefs) { QName defaultAspect = defaultAspectDef.getName(); if (!existingAspects.contains(defaultAspect)) { missingAspects.add(defaultAspect); } } // Find all aspects that should be present given the existing properties for (QName existingPropQName : existingProperties.keySet()) { PropertyDefinition existingPropDef = dictionaryService.getProperty(existingPropQName); if (existingPropDef == null || !existingPropDef.getContainerClass().isAspect()) { continue; // Property is undefined or belongs to a class } QName existingPropDefiningType = existingPropDef.getContainerClass().getName(); if (!existingAspects.contains(existingPropDefiningType)) { missingAspects.add(existingPropDefiningType); } } // If there were missing aspects, recurse to find further missing aspects // Don't re-add ones we know about or we can end in infinite recursion. // Don't send any properties because we don't want to reprocess them each time Set<QName> allTypesAndAspects = new HashSet<QName>(13); allTypesAndAspects.add(classQName); allTypesAndAspects.addAll(existingAspects); allTypesAndAspects.addAll(missingAspects); Set<QName> missingAspectsCopy = new HashSet<QName>(missingAspects); for (QName missingAspect : missingAspectsCopy) { Set<QName> furtherMissingAspects = getMissingAspects( allTypesAndAspects, Collections.<QName, Serializable>emptyMap(), missingAspect); missingAspects.addAll(furtherMissingAspects); allTypesAndAspects.addAll(furtherMissingAspects); } // Done return missingAspects; }
Example 10
Source File: AssocSourceMultiplicityIntegrityEvent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Checks that the source multiplicity has not been violated for the * target of the association. */ protected void checkSourceMultiplicity( List<IntegrityRecord> eventResults, AssociationDefinition assocDef, QName assocTypeQName, NodeRef targetNodeRef) { // get the source multiplicity boolean mandatory = assocDef.isSourceMandatory(); boolean allowMany = assocDef.isSourceMany(); // do we need to check if (!mandatory && allowMany) { // it is not mandatory and it allows many on both sides of the assoc return; } // check the target of the association if this is a delete if (isDelete) { // get the class the association is defined for and see if it is an aspect ClassDefinition classDef = assocDef.getTargetClass(); if (classDef.isAspect()) { // see if the target node has the aspect applied, if it does not // there's no need to check multiplicity if (!this.nodeService.hasAspect(targetNodeRef, classDef.getName())) { return; } } } int actualSize = 0; if (assocDef.isChild()) { // check the parent assocs present List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs( targetNodeRef, assocTypeQName, RegexQNamePattern.MATCH_ALL); actualSize = parentAssocRefs.size(); } else { // check the source assocs present List<AssociationRef> sourceAssocRefs = nodeService.getSourceAssocs(targetNodeRef, assocTypeQName); actualSize = sourceAssocRefs.size(); } if ((mandatory && actualSize == 0) || (!allowMany && actualSize > 1)) { if (actualSize == 0) { // ALF-9591: Integrity check: Association source multiplicity checking is incorrect // At this point, there is no point worrying. There are no more associations // pointing *to* this node and therefore the checking of the source // multiplicity (a feature of the source type/aspect) is not relevant return; } String parentOrSourceStr = (assocDef.isChild() ? "parent" : "source"); IntegrityRecord result = new IntegrityRecord( "The association " + parentOrSourceStr + " multiplicity has been violated: \n" + " Target Node: " + targetNodeRef + "\n" + " Association: " + assocDef + "\n" + " Required " + parentOrSourceStr + " Multiplicity: " + getMultiplicityString(mandatory, allowMany) + "\n" + " Actual " + parentOrSourceStr + " Multiplicity: " + actualSize); eventResults.add(result); } }