org.apache.chemistry.opencmis.commons.enums.BaseTypeId Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.BaseTypeId. 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: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Create dispatch for AtomPub
 * 
 * @param context call context
 * @param properties the properties
 * @param folderId identifier of the parent folder
 * @param contentStream stream of the document to create
 * @param versioningState state of the version
 * @param objectInfos informations
 * 
 * @return the newly created object
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
		VersioningState versioningState, ObjectInfoHandler objectInfos) {
	debug("create " + folderId);
	validatePermission(folderId, context, Permission.WRITE);

	String typeId = getTypeId(properties);

	TypeDefinition type = types.getType(typeId);
	if (type == null)
		throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");

	String objectId = null;
	if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
		objectId = createDocument(context, properties, folderId, contentStream, versioningState);
		return compileObjectType(context, getDocument(objectId), null, false, false, objectInfos);
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		objectId = createFolder(context, properties, folderId);
		return compileObjectType(context, getFolder(objectId), null, false, false, objectInfos);
	} else {
		throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
	}
}
 
Example #2
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String createPolicy(
        String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get the parent folder
    getOrCreateFolderInfo(folderId, "Parent Folder");

    String objectTypeId = connector.getObjectTypeIdProperty(properties);
    connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_POLICY);

    // we should never get here - policies are not creatable!
    throw new CmisRuntimeException("Polcies cannot be created!");
}
 
Example #3
Source File: CMISMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isValidCmisObject(BaseTypeId scope, QName qname)
{
    switch (scope)
    {
    case CMIS_DOCUMENT:
        return isValidCmisDocument(qname);
    case CMIS_FOLDER:
        return isValidCmisFolder(qname);
    case CMIS_POLICY:
        return isValidCmisPolicy(qname);
    case CMIS_RELATIONSHIP:
        return isValidCmisRelationship(qname);
    case CMIS_SECONDARY:
        return isValidCmisSecondaryType(qname);
    case CMIS_ITEM:
        return isValidCmisItem(qname);
    }

    return false;
}
 
Example #4
Source File: CMISChangeLogDataExtractor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @return Returns <tt>true</tt> if items in the CMIS domain model
 * @see org.alfresco.repo.audit.extractor.DataExtractor#isSupported(java.io.Serializable)
 */
public boolean isSupported(Serializable data)
{
    if (data != null)
    {
        NodeRef nodeRef = getNodeRef(data);
        if (nodeRef != null)
        {
            QName typeQName = nodeService.getType(nodeRef);
            TypeDefinitionWrapper type = cmisDictionaryService.findNodeType(typeQName);

            return (type != null)
                    && (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT || type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER);
        }
    }
    return false;
}
 
Example #5
Source File: RuntimePropertyAccessorMapping.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Register an Action Evaluator
 * 
 * @param scope BaseTypeId
 * @param evaluator CMISActionEvaluator
 */
private void registerEvaluator(BaseTypeId scope, CMISActionEvaluator evaluator)
{
    Map<Action, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
    if (evaluators == null)
    {
        evaluators = new LinkedHashMap<Action, CMISActionEvaluator>();
        actionEvaluators.put(scope, evaluators);
    }
    if (evaluators.get(evaluator.getAction()) != null)
    {
        throw new AlfrescoRuntimeException("Already registered Action Evaluator " + evaluator.getAction()
                + " for scope " + scope);
    }
    evaluators.put(evaluator.getAction(), evaluator);

    if (logger.isDebugEnabled())
        logger.debug("Registered Action Evaluator: scope=" + scope + ", evaluator=" + evaluator);
}
 
Example #6
Source File: BaseTypeIdProperty.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
    if (nodeInfo.isFolder())
    {
        return BaseTypeId.CMIS_FOLDER.value();
    } 
    else if (nodeInfo.isRelationship())
    {
        return BaseTypeId.CMIS_RELATIONSHIP.value();
    }
    else if(nodeInfo.isItem())
    {
    	return BaseTypeId.CMIS_ITEM.value();
    }

    return BaseTypeId.CMIS_DOCUMENT.value();
}
 
Example #7
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public MutableFolderTypeDefinition createFolderTypeDefinition(Class<?> entityClass, Class<?> repoClass, CmisFolder metadata, CmisVersion cmisVersion, String parentId) {
	MutableFolderTypeDefinition folderType = new FolderTypeDefinitionImpl();
	folderType.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
	folderType.setParentTypeId(parentId);
	folderType.setIsControllableAcl(false);
	folderType.setIsControllablePolicy(false);
	folderType.setIsCreatable(repoClass != null);
	folderType.setDescription("Folder");
	folderType.setDisplayName("Folder");
	folderType.setIsFileable(isFileable(repoClass));
	folderType.setIsFulltextIndexed(false);
	folderType.setIsIncludedInSupertypeQuery(true);
	folderType.setLocalName("Folder");
	folderType.setLocalNamespace("");
	folderType.setIsQueryable(false);
	folderType.setQueryName("cmis:folder");
	folderType.setId(BaseTypeId.CMIS_FOLDER.value());
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
		typeMutability.setCanCreate(false);
		typeMutability.setCanUpdate(false);
		typeMutability.setCanDelete(false);
		folderType.setTypeMutability(typeMutability);
	}

	this.addBasePropertyDefinitions(folderType, entityClass, cmisVersion, parentId != null);
	this.addFolderPropertyDefinitions(folderType, cmisVersion, parentId != null);
	return folderType;
}
 
Example #8
Source File: AbstractTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void createActionEvaluators(PropertyAccessorMapping propertyAccessorMapping, BaseTypeId baseTypeId)
{
    if (propertyAccessorMapping != null)
    {
        actionEvaluators = propertyAccessorMapping.getActionEvaluators(baseTypeId);
    } else
    {
        actionEvaluators = Collections.emptyMap();
    }
}
 
Example #9
Source File: CMISStrictDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private RelationshipTypeDefintionWrapper createAssocDef(QName classQName)
{
	RelationshipTypeDefintionWrapper assocTypeDef = null;

    if(cmisMapping.isValidCmisRelationship(classQName))
    {
     // create appropriate kind of type definition
     AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
     String typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_RELATIONSHIP, classQName);
     assocTypeDef = new RelationshipTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, 
             typeId, dictionaryService, assocDef);
    }

    return assocTypeDef;
}
 
Example #10
Source File: CMISStrictDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create Type Definitions
 * 
 * @param classQName QName
 */
private AbstractTypeDefinitionWrapper createTypeDef(QName classQName)
{
	AbstractTypeDefinitionWrapper objectTypeDef = null;

    // skip items that are remapped to CMIS model
    if(!cmisMapping.isRemappedType(classQName))
    {
     // create appropriate kind of type definition
     ClassDefinition classDef = dictionaryService.getClass(classQName);
     String typeId = null;
     if (cmisMapping.isValidCmisDocument(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, classQName);
         objectTypeDef = new DocumentTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisFolder(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_FOLDER, classQName);
         objectTypeDef = new FolderTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.getCmisVersion().equals(CmisVersion.CMIS_1_1) && cmisMapping.isValidCmisSecondaryType(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_SECONDARY, classQName);
         objectTypeDef = new SecondaryTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisPolicy(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, classQName);
         objectTypeDef = new PolicyTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisItem(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_ITEM, classQName);
         objectTypeDef = new ItemTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
    }

    return objectTypeDef;
}
 
Example #11
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds a type to collection with inheriting base type properties
 * 
 * @param type the type
 * 
 * @return if the type has been added
 */
public boolean addType(TypeDefinition type) {
	if (type == null) {
		return false;
	}

	if (type.getBaseTypeId() == null) {
		return false;
	}

	// find base type
	TypeDefinition baseType = null;
	if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
		baseType = copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition());
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		baseType = copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition());
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
		baseType = copyTypeDefintion(types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
		baseType = copyTypeDefintion(types.get(POLICY_TYPE_ID).getTypeDefinition());
	} else {
		return false;
	}

	AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type);

	// copy property definition
	for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
		((AbstractPropertyDefinition<?>) propDef).setIsInherited(true);
		newType.addPropertyDefinition(propDef);
	}

	// add it
	addTypeInteral(newType);

	log.info("Added type '" + newType.getId() + "'.");

	return true;
}
 
Example #12
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CmisFunctionEvaluationContext getCMISFunctionEvaluationContext(CMISQueryMode mode, CmisVersion cmisVersion, String alternativeDictionary)
{
    BaseTypeId[] validScopes = (mode == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
    CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
    functionContext.setCmisDictionaryService(getCMISDictionary(alternativeDictionary, cmisVersion));
    functionContext.setValidScopes(validScopes);
    return functionContext;
}
 
Example #13
Source File: CMISMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the CMIS Type Id given the Alfresco QName for the type in any
 * Alfresco model
 * 
 * @param scope BaseTypeId
 * @param typeQName QName
 * @return String
 */
public String getCmisTypeId(BaseTypeId scope, QName typeQName)
{
    String typeId = mapAlfrescoQNameToTypeId.get(typeQName);
    if (typeId == null)
    {
        String p = null;
        switch (scope)
        {
        case CMIS_DOCUMENT:
            p = "D";
            break;
        case CMIS_FOLDER:
            p = "F";
            break;
        case CMIS_RELATIONSHIP:
            p = "R";
            break;
        case CMIS_SECONDARY:
            p = "P";
            break;
        case CMIS_POLICY:
            p = "P";
            break;
        case CMIS_ITEM:
            p = "I";
            break;
        default:
            throw new CmisRuntimeException("Invalid base type!");
        }

        return p + ":" + typeQName.toPrefixString(namespaceService);
    } 
    else
    {
        return typeId;
    }
}
 
Example #14
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public MutableDocumentTypeDefinition createDocumentTypeDefinition(Class<?> entityClass, Class<?> repoClass, Class<?> storeClass, CmisDocument metadata, CmisVersion cmisVersion, String parentId) {
	MutableDocumentTypeDefinition documentType = new DocumentTypeDefinitionImpl();
	documentType.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
	documentType.setParentTypeId(parentId);
	documentType.setIsControllableAcl(false);
	documentType.setIsControllablePolicy(false);
	documentType.setIsCreatable(repoClass != null);
	documentType.setDescription("Document");
	documentType.setDisplayName("Document");
	documentType.setIsFileable(isFileable(repoClass));
	documentType.setIsFulltextIndexed(isFulltextIndexed(repoClass));
	documentType.setIsIncludedInSupertypeQuery(true);
	documentType.setLocalName("Document");
	documentType.setLocalNamespace("");
	documentType.setIsQueryable(false);
	documentType.setQueryName("cmis:document");
	documentType.setId(BaseTypeId.CMIS_DOCUMENT.value());
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
		typeMutability.setCanCreate(false);
		typeMutability.setCanUpdate(false);
		typeMutability.setCanDelete(false);
		documentType.setTypeMutability(typeMutability);
	}

	documentType.setIsVersionable(isVersionable(repoClass));
	documentType.setContentStreamAllowed((storeClass != null) ? ContentStreamAllowed.ALLOWED : ContentStreamAllowed.NOTALLOWED);

	this.addBasePropertyDefinitions(documentType, entityClass, cmisVersion, parentId != null);
	this.addDocumentPropertyDefinitions(documentType, repoClass, storeClass, cmisVersion, parentId != null);
	return documentType;
}
 
Example #15
Source File: DbCmisQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ResultSet executeQueryImpl(SearchParameters searchParameters)
    {
        CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
        options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);

        CapabilityJoin joinSupport = CapabilityJoin.INNERANDOUTER;
        BaseTypeId[] validScopes = CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
        CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
        functionContext.setCmisDictionaryService(cmisDictionaryService);
        functionContext.setValidScopes(validScopes);

        CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
        org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new DBQueryModelFactory(), functionContext);

// TODO: Remove as this appears to be dead code
//        // build lucene query
//        Set<String> selectorGroup = null;
//        if (queryModelQuery.getSource() != null)
//        {
//            List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
//            if (selectorGroups.size() == 0)
//            {
//                throw new UnsupportedOperationException("No selectors");
//            }
//            if (selectorGroups.size() > 1)
//            {
//                throw new UnsupportedOperationException("Advanced join is not supported");
//            }
//            selectorGroup = selectorGroups.get(0);
//        }
//
        QueryEngineResults results = queryEngine.executeQuery(queryModelQuery, options, functionContext);
        ResultSet resultSet = results.getResults().values().iterator().next();
        return resultSet;
    }
 
Example #16
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void compileObjectMetadata(ObjectInfoImpl objectInfo, TypeDefinition type) {

		if (type.getId().equals(BaseTypeId.CMIS_FOLDER.value())) {
			objectInfo.setBaseType(BaseTypeId.CMIS_FOLDER);
			objectInfo.setTypeId(BaseTypeId.CMIS_FOLDER.value());
			objectInfo.setContentType(null);
			objectInfo.setFileName(null);
			objectInfo.setHasAcl(true);
			objectInfo.setHasContent(false);
			objectInfo.setVersionSeriesId(null);
			objectInfo.setIsCurrentVersion(true);
			objectInfo.setRelationshipSourceIds(null);
			objectInfo.setRelationshipTargetIds(null);
			objectInfo.setRenditionInfos(null);
			objectInfo.setSupportsDescendants(true);
			objectInfo.setSupportsFolderTree(true);
			objectInfo.setSupportsPolicies(false);
			objectInfo.setSupportsRelationships(false);
			objectInfo.setWorkingCopyId(null);
			objectInfo.setWorkingCopyOriginalId(null);
		} else {
			objectInfo.setBaseType(BaseTypeId.CMIS_DOCUMENT);
			objectInfo.setTypeId(BaseTypeId.CMIS_DOCUMENT.value());
			objectInfo.setHasAcl(true);
			objectInfo.setHasContent(true);
			objectInfo.setHasParent(true);
			objectInfo.setVersionSeriesId(null);
			objectInfo.setIsCurrentVersion(true);
			objectInfo.setRelationshipSourceIds(null);
			objectInfo.setRelationshipTargetIds(null);
			objectInfo.setRenditionInfos(null);
			objectInfo.setSupportsDescendants(false);
			objectInfo.setSupportsFolderTree(false);
			objectInfo.setSupportsPolicies(false);
			objectInfo.setSupportsRelationships(false);
			objectInfo.setWorkingCopyId(null);
			objectInfo.setWorkingCopyOriginalId(null);
		}
	}
 
Example #17
Source File: CmisServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
@HasPermission(type = DefaultPermission.class, action = "clone_content_cmis")
public void cloneContent(@ProtectedResourceId(SITE_ID_RESOURCE_ID) String siteId, String cmisRepoId, String cmisPath,
                         @ProtectedResourceId(PATH_RESOURCE_ID) String studioPath)
        throws StudioPathNotFoundException, CmisRepositoryNotFoundException, CmisUnavailableException, CmisTimeoutException, CmisPathNotFoundException, ServiceLayerException {
    if (!contentService.contentExists(siteId, studioPath))
        throw new StudioPathNotFoundException("Studio repository path does not exist for site " + siteId +
                " (path: " + studioPath + ")");
    List<CmisContentItemTO> toRet = new ArrayList<CmisContentItemTO>();
    DataSourceRepository repositoryConfig = getConfiguration(siteId, cmisRepoId);
    if (repositoryConfig != null) {
        logger.debug("Create new CMIS session");
        Session session = createCMISSession(repositoryConfig);
        if (session != null) {
            String contentPath = Paths.get(repositoryConfig.getBasePath(), cmisPath).toString();
            logger.debug("Find object for CMIS path: " + contentPath);
            CmisObject cmisObject = session.getObjectByPath(contentPath);
            if (cmisObject != null) {
                if (BaseTypeId.CMIS_FOLDER.equals(cmisObject.getBaseTypeId())) {
                    throw new CmisPathNotFoundException();
                } else if (CMIS_DOCUMENT.equals(cmisObject.getBaseTypeId())) {
                    org.apache.chemistry.opencmis.client.api.Document cmisDoc =
                            (org.apache.chemistry.opencmis.client.api.Document)cmisObject;
                    String fileName = cmisDoc.getName();
                    String savePath = studioPath + FILE_SEPARATOR + fileName;
                    ContentStream cs = cmisDoc.getContentStream();
                    logger.debug("Save CMIS file to: " + savePath);
                    contentService.writeContent(siteId, savePath, cs.getStream());
                }
            } else {
                throw new CmisPathNotFoundException();
            }
        } else {
            throw new CmisUnauthorizedException();
        }
    }
}
 
Example #18
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createFolder(String repositoryId, final Properties properties, String folderId,
        final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get the parent folder node ref
    final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");

    // get name and type
    final String name = connector.getNameProperty(properties, null);
    final String objectTypeId = connector.getObjectTypeIdProperty(properties);
    final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);

    connector.checkChildObjectType(parentInfo, type.getTypeId());

    // run transaction
    FileInfo fileInfo = connector.getFileFolderService().create(
            parentInfo.getNodeRef(), name, type.getAlfrescoClass());
    NodeRef nodeRef = fileInfo.getNodeRef();

    connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
    connector.applyPolicies(nodeRef, type, policies);
    connector.applyACL(nodeRef, type, addAces, removeAces);
    
    connector.getActivityPoster().postFileFolderAdded(nodeRef);

    String objectId = connector.createObjectId(nodeRef);
    return objectId;
}
 
Example #19
Source File: CmisUtils.java    From iaf with Apache License 2.0 5 votes vote down vote up
private static XmlBuilder changesOnType2xml(List<BaseTypeId> list) {
	XmlBuilder changesOnTypeXml = new XmlBuilder("changesOnTypes");
	for (BaseTypeId baseTypeId : list) {
		changesOnTypeXml.addSubElement(CmisUtils.buildXml("type", baseTypeId.name()));
	}

	return changesOnTypeXml;
}
 
Example #20
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the definition after it has checked if the type can be used for
 * object creation.
 */
public TypeDefinitionWrapper getTypeForCreate(String cmisTypeId, BaseTypeId baseTypeId)
{
    TypeDefinitionWrapper type = getType(cmisTypeId);
    if ((type == null) || (type.getBaseTypeId() != baseTypeId))
    {
        switch (baseTypeId)
        {
        case CMIS_DOCUMENT:
            throw new CmisConstraintException("Type is not a document type!");
        case CMIS_FOLDER:
            throw new CmisConstraintException("Type is not a folder type!");
        case CMIS_RELATIONSHIP:
            throw new CmisConstraintException("Type is not a relationship type!");
        case CMIS_POLICY:
            throw new CmisConstraintException("Type is not a policy type!");
        case CMIS_ITEM:
            throw new CmisConstraintException("Type is not an item type!");
        }
    }

    if (!type.getTypeDefinition(false).isCreatable())
    {
        throw new CmisConstraintException("Type is not creatable!");
    }

    return type;
}
 
Example #21
Source File: CMISQueryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Pair<Query, QueryEngineResults> executeQueryUsingEngine(QueryEngine queryEngine, CMISQueryOptions options)
{
    CapabilityJoin joinSupport = getJoinSupport();
    if (options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
    {
        joinSupport = CapabilityJoin.INNERANDOUTER;
    }

    // TODO: Refactor to avoid duplication of valid scopes here and in
    // CMISQueryParser

    BaseTypeId[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES
            : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
    CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
    functionContext.setCmisDictionaryService(cmisDictionaryService);
    functionContext.setNodeService(nodeService);
    functionContext.setValidScopes(validScopes);

    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
    QueryConsistency queryConsistency = options.getQueryConsistency();
    if (queryConsistency == QueryConsistency.DEFAULT)
    {
    	options.setQueryConsistency(QueryConsistency.EVENTUAL);
    }
    
    Query query = parser.parse(queryEngine.getQueryModelFactory(), functionContext);
    QueryEngineResults queryEngineResults = queryEngine.executeQuery(query, options, functionContext);
    
    return new Pair<Query, QueryEngineResults>(query, queryEngineResults);
}
 
Example #22
Source File: CmisUtils.java    From iaf with Apache License 2.0 5 votes vote down vote up
private static List<BaseTypeId> xml2changesOnType(Element cmisResult) {
	List<BaseTypeId> baseTypeIds = new ArrayList<BaseTypeId>();

	Element changesOnType = XmlUtils.getFirstChildTag(cmisResult, "changesOnTypes");
	if(changesOnType != null) {
		for (Node type : XmlUtils.getChildTags(cmisResult, "type")) {
			String value = XmlUtils.getStringValue((Element) type);
			if(StringUtils.isNotEmpty(value))
				baseTypeIds.add(BaseTypeId.valueOf(value));
		}
	}
	return baseTypeIds;
}
 
Example #23
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param target
 */
private static void listFolder(int depth, Folder target) {
	String indent = StringUtils.repeat("\t", depth);
	for (Iterator<CmisObject> it = target.getChildren().iterator(); it.hasNext();) {
		CmisObject o = it.next();
		if (BaseTypeId.CMIS_DOCUMENT.equals(o.getBaseTypeId())) {
			System.out.println(indent + "[Docment] " + o.getName());
		} else if (BaseTypeId.CMIS_FOLDER.equals(o.getBaseTypeId())) {
			System.out.println(indent + "[Folder] " + o.getName());
			listFolder(++depth, (Folder) o);
		}
	}

}
 
Example #24
Source File: RuntimePropertyAccessorMapping.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the Action Evaluators applicable for the given CMIS Scope
 * 
 * @param scope BaseTypeId
 */
public Map<Action, CMISActionEvaluator> getActionEvaluators(BaseTypeId scope)
{
    Map<Action, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
    if (evaluators == null)
    {
        evaluators = Collections.emptyMap();
    }
    return evaluators;
}
 
Example #25
Source File: CmisTestObject.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public BaseTypeId getBaseTypeId() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #26
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 4 votes vote down vote up
static AllowableActions compileAllowableActions(TypeDefinition type, Object object, boolean isRoot, boolean isPrincipalReadOnly) {
	AllowableActionsImpl result = new AllowableActionsImpl();

	Set<Action> aas = EnumSet.noneOf(Action.class);

	addAction(aas, Action.CAN_GET_OBJECT_PARENTS, false /*!isRoot*/);
	addAction(aas, Action.CAN_GET_PROPERTIES, true);
	addAction(aas, Action.CAN_UPDATE_PROPERTIES, !isPrincipalReadOnly /*&& !isReadOnly*/);
	addAction(aas, Action.CAN_MOVE_OBJECT, false /*!userReadOnly && !isRoot*/);
	addAction(aas, Action.CAN_DELETE_OBJECT, !isPrincipalReadOnly && !isRoot /*!userReadOnly && !isReadOnly && !isRoot*/);
	addAction(aas, Action.CAN_GET_ACL, false /*true*/);

	boolean folder = type.getId().equals(BaseTypeId.CMIS_FOLDER.value());
	if (folder) {
		addAction(aas, Action.CAN_GET_DESCENDANTS, false);
		addAction(aas, Action.CAN_GET_CHILDREN, true);
		addAction(aas, Action.CAN_GET_FOLDER_PARENT, !isRoot);
		addAction(aas, Action.CAN_GET_FOLDER_TREE, true);
		addAction(aas, Action.CAN_CREATE_DOCUMENT, !isPrincipalReadOnly);
		addAction(aas, Action.CAN_CREATE_FOLDER, !isPrincipalReadOnly);
		addAction(aas, Action.CAN_DELETE_TREE, !isPrincipalReadOnly /*&& !isReadOnly*/);
	} else {
		ContentStreamAllowed allowed = ((DocumentTypeDefinition)type).getContentStreamAllowed();
		if (allowed == ContentStreamAllowed.ALLOWED || allowed == ContentStreamAllowed.REQUIRED) {
			addAction(aas, Action.CAN_GET_CONTENT_STREAM, contentLength(object) > 0);
			addAction(aas, Action.CAN_SET_CONTENT_STREAM, !isPrincipalReadOnly /*&& !isReadOnly*/);
			addAction(aas, Action.CAN_DELETE_CONTENT_STREAM, !isPrincipalReadOnly /*&& !isReadOnly*/);
			addAction(aas, Action.CAN_GET_ALL_VERSIONS, true);
		}

		if (((DocumentTypeDefinition)type).isVersionable()) {
			addAction(aas, Action.CAN_CHECK_IN, true);
			addAction(aas, Action.CAN_CHECK_OUT, true);
			addAction(aas, Action.CAN_CANCEL_CHECK_OUT, true);
		}
	}

	result.setAllowableActions(aas);

	return result;
}
 
Example #27
Source File: CmisUtils.java    From iaf with Apache License 2.0 4 votes vote down vote up
public static TypeDefinition xml2TypeDefinition(Element typeXml, CmisVersion cmisVersion) {
	String id = typeXml.getAttribute("id");
	String description = typeXml.getAttribute("description");
	String displayName = typeXml.getAttribute("displayName");
	String localName = typeXml.getAttribute("localName");
	String localNamespace = typeXml.getAttribute("localNamespace");
	String baseTypeId = typeXml.getAttribute("baseTypeId");
	String parentId = typeXml.getAttribute("parentTypeId");
	String queryName = typeXml.getAttribute("queryName");

	TypeDefinitionFactory factory = TypeDefinitionFactory.newInstance();
	MutableTypeDefinition definition = null;

	if(BaseTypeId.CMIS_DOCUMENT.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBaseDocumentTypeDefinition(cmisVersion);
	}
	else if(BaseTypeId.CMIS_FOLDER.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBaseFolderTypeDefinition(cmisVersion);
	}
	else if(BaseTypeId.CMIS_ITEM.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBaseItemTypeDefinition(cmisVersion);
	}
	else if(BaseTypeId.CMIS_POLICY.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBasePolicyTypeDefinition(cmisVersion);
	}
	else if(BaseTypeId.CMIS_RELATIONSHIP.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBaseRelationshipTypeDefinition(cmisVersion);
	}
	else if(BaseTypeId.CMIS_SECONDARY.equals(BaseTypeId.fromValue(baseTypeId))) {
		definition = factory.createBaseSecondaryTypeDefinition(cmisVersion);
	}
	definition.setDescription(description);
	definition.setDisplayName(displayName);
	definition.setId(id);
	definition.setLocalName(localName);
	definition.setLocalNamespace(localNamespace);
	definition.setParentTypeId(parentId);
	definition.setQueryName(queryName);

	Element propertyDefinitions = XmlUtils.getFirstChildTag(typeXml, "propertyDefinitions");
	Collection<Node> propertyDefinitionList = XmlUtils.getChildTags(propertyDefinitions, "propertyDefinition");
	if(propertyDefinitionList != null) {
		for (Node node : propertyDefinitionList) {
			definition.addPropertyDefinition(CmisUtils.xml2PropertyDefinition((Element) node));
		}
	}

	definition.setIsControllableAcl(CmisUtils.parseBooleanAttr(typeXml, "controllableACL"));
	definition.setIsControllablePolicy(CmisUtils.parseBooleanAttr(typeXml, "controllablePolicy"));
	definition.setIsCreatable(CmisUtils.parseBooleanAttr(typeXml, "creatable"));
	definition.setIsFileable(CmisUtils.parseBooleanAttr(typeXml, "fileable"));
	definition.setIsFulltextIndexed(CmisUtils.parseBooleanAttr(typeXml, "fulltextIndexed"));
	definition.setIsIncludedInSupertypeQuery(CmisUtils.parseBooleanAttr(typeXml, "includedInSupertypeQuery"));
	definition.setIsQueryable(CmisUtils.parseBooleanAttr(typeXml, "queryable"));

	Element typeMutabilityXml = XmlUtils.getFirstChildTag(typeXml, "typeMutability");
	if(typeMutabilityXml != null) {
		definition.setTypeMutability(CmisUtils.xml2typeMutability(typeMutabilityXml));
	}

	return definition;
}
 
Example #28
Source File: CmisFunctionEvaluationContext.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param validScopes
 *            the valid scopes to set
 */
public void setValidScopes(BaseTypeId[] validScopes)
{
    this.validScopes = validScopes;
}
 
Example #29
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping,
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, AssociationDefinition cmisAssocDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisAssocDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new RelationshipTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    typeDef.setQueryName(cmisMapping.buildPrefixEncodedString(alfrescoName));
    typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(true);
    typeDef.setIsQueryable(false);
    typeDef.setIsFulltextIndexed(false);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(true);
    typeDef.setIsFileable(false);

    ArrayList<String> both = new ArrayList<String>(2);
    both.add(BaseTypeId.CMIS_DOCUMENT.value());
    both.add(BaseTypeId.CMIS_FOLDER.value());
    
    String sourceTypeId = cmisMapping.getCmisTypeId(cmisMapping
            .getCmisType(cmisAssocDef.getSourceClass().getName()));
    if (sourceTypeId != null)
    {
        typeDef.setAllowedSourceTypes(Collections.singletonList(sourceTypeId));
    }
    else
    {
        typeDef.setAllowedSourceTypes(both);
    }

    String targetTypeId = cmisMapping.getCmisTypeId(cmisMapping
            .getCmisType(cmisAssocDef.getTargetClass().getName()));
    if (targetTypeId != null)
    {
        typeDef.setAllowedTargetTypes(Collections.singletonList(targetTypeId));
    }
    else
    {
        typeDef.setAllowedTargetTypes(both);
    }

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_RELATIONSHIP);
}
 
Example #30
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping,
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new RelationshipTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
        typeDef.setIsCreatable(false);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());
        typeDef.setIsCreatable(true);
    }
    
    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsQueryable(false);
    typeDef.setIsFulltextIndexed(false);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(true);
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_RELATIONSHIP);
}