Java Code Examples for org.alfresco.opencmis.mapping.CMISMapping#isValidCmisPolicy()
The following examples show how to use
org.alfresco.opencmis.mapping.CMISMapping#isValidCmisPolicy() .
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: PolicyTypeDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
public PolicyTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping propertyAccessorMapping, PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef) { this.dictionaryService = dictionaryService; alfrescoName = cmisClassDef.getName(); alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName); typeDef = new PolicyTypeDefinitionImpl(); typeDef.setBaseTypeId(BaseTypeId.CMIS_POLICY); typeDef.setId(typeId); typeDef.setLocalName(alfrescoName.getLocalName()); typeDef.setLocalNamespace(alfrescoName.getNamespaceURI()); if (BaseTypeId.CMIS_POLICY.value().equals(typeId)) { typeDef.setQueryName(ISO9075.encodeSQL(typeId)); typeDef.setParentTypeId(null); } else { typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName))); QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName()); if (parentQName == null) { typeDef.setParentTypeId(cmisMapping.getCmisTypeId(CMISMapping.ASPECTS_QNAME)); } else if (cmisMapping.isValidCmisPolicy(parentQName)) { typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, parentQName)); } else { throw new IllegalStateException("The CMIS type model should ignore aspects that inherit from excluded aspects"); } } typeDef.setDisplayName(null); typeDef.setDescription(null); typeDef.setIsCreatable(false); typeDef.setIsQueryable(true); typeDef.setIsFulltextIndexed(true); typeDef.setIsControllablePolicy(false); typeDef.setIsControllableAcl(false); typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery()); typeDef.setIsFileable(false); typeDefInclProperties = CMISUtils.copy(typeDef); setTypeDefinition(typeDef, typeDefInclProperties); createOwningPropertyDefinitions(cmisMapping, propertyAccessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef); createActionEvaluators(propertyAccessorMapping, BaseTypeId.CMIS_POLICY); }
Example 2
Source File: PolicyTypeDefintionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
@Override public List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry, DictionaryService dictionaryService) { String parentTypeId = typeDef.getParentTypeId(); // find parent if (typeDef.getParentTypeId() != null) { parent = registry.getTypeDefByTypeId(parentTypeId); // if(registry.getTenant() != null && parent != null && registry.getTypeDefByTypeId(parentTypeId, false) == null) // { // // this is a tenant registry and the parent is not defined locally so add this type as a child of it // registry.addChild(parent.getTypeId(), this); // } } else { if (!isBaseType()) { throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!"); } parent = null; } // find children Collection<QName> childrenNames = null; if (isBaseType()) { // add the "Aspects" type to the CMIS Policy type childrenNames = new ArrayList<QName>(); childrenNames.add(CMISMapping.ASPECTS_QNAME); } else if (getAlfrescoName().equals(CMISMapping.ASPECTS_QNAME)) { // add all root aspects to the "Aspects" type childrenNames = new ArrayList<QName>(); String aspectsTypeId = cmisMapping.getCmisTypeId(CMISMapping.ASPECTS_QNAME); for (AbstractTypeDefinitionWrapper tdw : registry.getTypeDefs(false)) { // TypeDefinitionWrapper parent = tdw.getParent(); // if(tdw.getTenantId().equals(parent.getTenantId())) // { // type and parent in same tenant // } String parentId = tdw.getTypeDefinition(false).getParentTypeId(); if ((parentId != null) && parentId.equals(aspectsTypeId)) { childrenNames.add(tdw.getAlfrescoName()); } } } else { // add all non-root aspects in this tenant to their parent childrenNames = dictionaryService.getSubAspects(cmisMapping.getAlfrescoClass(getAlfrescoName()), false); } List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>(); for (QName childName : childrenNames) { if (cmisMapping.isValidCmisPolicy(childName)) { TypeDefinitionWrapper child = registry.getTypeDefByQName(childName); if (child == null) { throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName + " for parent type " + getAlfrescoName() + "!"); } children.add(child); } else { logger.info("Not a policy: " + childName); } } return children; // registry.setChildren(typeDef.getId(), children); }