• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CmisConstraintException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException的典型用法代码示例。如果您正苦于以下问题:Java CmisConstraintException类的具体用法?Java CmisConstraintException怎么用?Java CmisConstraintException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CmisConstraintException类属于org.apache.chemistry.opencmis.commons.exceptions包,在下文中一共展示了CmisConstraintException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkChildObjectType

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * Checks if a child of a given type can be added to a given folder.
 */
@SuppressWarnings("unchecked")
public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{
    TypeDefinitionWrapper targetType = folderInfo.getType();
    PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
            .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
    List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
            folderInfo);

    if ((childTypes == null) || childTypes.isEmpty())
    {
        return;
    }

    if (!childTypes.contains(childType))
    {
        throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:CMISConnector.java


示例2: removePolicy

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@Override
public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // what kind of object is it?
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    TypeDefinitionWrapper type = info.getType();
    if (type == null)
    {
        throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
    }

    throw new CmisConstraintException("Object is not policy controllable!");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:AlfrescoCmisServiceImpl.java


示例3: applyAcl

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@Override
public Acl applyAcl(
        String repositoryId, String objectId, final Acl addAces, final Acl removeAces,
        AclPropagation aclPropagation, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // We are spec compliant if we just let it through and the tck will not fail

    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    // relationships don't have ACLs
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }

    final NodeRef nodeRef = info.getCurrentNodeNodeRef();
    final TypeDefinitionWrapper type = info.getType();

    connector.applyACL(nodeRef, type, addAces, removeAces);

    return connector.getACL(nodeRef, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:AlfrescoCmisServiceImpl.java


示例4: checkChildObjectType

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * Checks if a child of a given type can be added to a given folder.
 */
@SuppressWarnings("unchecked")
public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{
    TypeDefinitionWrapper targetType = folderInfo.getType();
    PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
            .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
    List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
            folderInfo);

    if ((childTypes == null) || childTypes.isEmpty())
    {
        return;
    }
    
    if (!childTypes.contains(childType))
    {
        throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:CMISConnector.java


示例5: deleteObject

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * CMIS deleteObject.
 */
public void deleteObject(CallContext context, String objectId) {
    checkUser(context, true);

    // get the file or folder
    File file = getFile(objectId);
    if (!file.exists()) {
        throw new CmisObjectNotFoundException("Object not found!");
    }

    // check if it is a folder and if it is empty
    if (!isFolderEmpty(file)) {
        throw new CmisConstraintException("Folder is not empty!");
    }

    // delete file
    if (!file.delete()) {
        throw new CmisStorageException("Deletion failed!");
    }
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:23,代码来源:FileBridgeRepository.java


示例6: deleteTree

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * CMIS deleteTree.
 */
public FailedToDeleteData deleteTree(CallContext context, String folderId, Boolean continueOnFailure) {
    checkUser(context, true);

    boolean cof = FileBridgeUtils.getBooleanParameter(continueOnFailure, false);

    // get the file or folder
    File file = getFile(folderId);

    FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
    result.setIds(new ArrayList<String>());

    // if it is a folder, remove it recursively
    if (file.isDirectory()) {
        deleteFolder(file, cof, result);
    } else {
        throw new CmisConstraintException("Object is not a folder!");
    }

    return result;
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:24,代码来源:FileBridgeRepository.java


示例7: checkout

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * See CMIS 1.0 section 2.2.7.1 checkOut
 *
 * @throws CmisRuntimeException
 */
public RegistryPrivateWorkingCopy checkout() {
    Resource node = getNode();
    try {
        if (isCheckedOut(node)) {
            throw new CmisConstraintException("Document is already checked out " + node.getId());
        }

        return getPwc(checkout(getRepository(), node));
    }
    catch (RegistryException e) {
        String msg = "Failed checkout the node with path " + node.getPath();
        log.error(msg, e);
        throw new CmisRuntimeException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:RegistryVersionBase.java


示例8: delete

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * See CMIS 1.0 section 2.2.4.14 deleteObject
 *
 * @throws CmisRuntimeException
 */
@Override
public void delete(boolean allVersions, boolean isPwc) {
    try {
        if (getNode().getChildCount()>0) {
            throw new CmisConstraintException("Folder is not empty!");
        } else {
            super.delete(allVersions, isPwc);
        }
    }
    catch (RegistryException e) {
        String msg = "Failed to delete the object " + getNode().getPath();
        log.error(msg, e);
        throw new CmisRuntimeException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:RegistryFolder.java


示例9: deleteObject

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * CMIS deleteObject.
 */
public void deleteObject(CallContext context, String objectId) {
	checkUser(context, true);

	// get the file or folder
	File file = getFile(objectId);
	if (!file.exists()) {
		throw new CmisObjectNotFoundException("Object not found!");
	}

	// check if it is a folder and if it is empty
	if (!isFolderEmpty(file)) {
		throw new CmisConstraintException("Folder is not empty!");
	}

	// delete file
	if (!file.delete()) {
		throw new CmisStorageException("Deletion failed!");
	}
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:23,代码来源:FileBridgeRepository.java


示例10: deleteTree

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * CMIS deleteTree.
 */
public FailedToDeleteData deleteTree(CallContext context, String folderId,
		Boolean continueOnFailure) {
	checkUser(context, true);

	boolean cof = FileBridgeUtils.getBooleanParameter(continueOnFailure,
			false);

	// get the file or folder
	File file = getFile(folderId);

	FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
	result.setIds(new ArrayList<String>());

	// if it is a folder, remove it recursively
	if (file.isDirectory()) {
		deleteFolder(file, cof, result);
	} else {
		throw new CmisConstraintException("Object is not a folder!");
	}

	return result;
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:26,代码来源:FileBridgeRepository.java


示例11: getTypeForCreate

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:CMISConnector.java


示例12: checkDocumentTypeForContent

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
private void checkDocumentTypeForContent(TypeDefinitionWrapper type)
{
    if (type == null)
    {
        throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
    }
    if (!(type instanceof DocumentTypeDefinitionWrapper))
    {
        throw new CmisStreamNotSupportedException("Object is not a document!");
    }
    if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
    {
        throw new CmisConstraintException("Document cannot have content!");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:CMISConnector.java


示例13: applyACL

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * Sets the given ACL.
 */
public void applyACL(NodeRef nodeRef, TypeDefinitionWrapper type, Acl aces)
{
    boolean hasAces = (aces != null) && (aces.getAces() != null) && !aces.getAces().isEmpty();

    if (!hasAces && !permissionService.getInheritParentPermissions(nodeRef))
    {
        return;
    }

    if (!type.getTypeDefinition(false).isControllableAcl())
    {
        throw new CmisConstraintException("Object is not ACL controllable!");
    }

    // remove all permissions
    permissionService.deletePermissions(nodeRef);

    // set new permissions
    for (Ace ace : aces.getAces())
    {
        String principalId = ace.getPrincipalId();
        if (CMIS_USER.equals(principalId))
        {
            principalId = AuthenticationUtil.getFullyAuthenticatedUser();
        }

        List<String> permissions = translatePermissionsFromCMIS(ace.getPermissions());
        for (String permission : permissions)
        {
            permissionService.setPermission(nodeRef, principalId, permission, true);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:CMISConnector.java


示例14: applyPolicies

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
public void applyPolicies(NodeRef nodeRef, TypeDefinitionWrapper type, List<String> policies)
{
    if ((policies == null) || (policies.isEmpty()))
    {
        return;
    }

    if (!type.getTypeDefinition(false).isControllablePolicy())
    {
        throw new CmisConstraintException("Object is not policy controllable!");
    }

    // nothing else to do...
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:CMISConnector.java


示例15: checkOut

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@Override
public void checkOut(
        String repositoryId, final Holder<String> objectId, ExtensionsData extension,
        final Holder<Boolean> contentCopied)
{
    checkRepositoryId(repositoryId);

    CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");

    // Check for current version
    if (info.isVariant(CMISObjectVariant.CURRENT_VERSION))
    {
        // Good
    }
    else if (info.isVariant(CMISObjectVariant.VERSION))
    {
        throw new CmisInvalidArgumentException("Can't check out an old version of a document");
    }
    else {   
        throw new CmisInvalidArgumentException("Only documents can be checked out! Object was a " + info.getObjectVariant().toString());
    }

    // get object
    final NodeRef nodeRef = info.getNodeRef();

    if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable())
    {
        throw new CmisConstraintException("Document is not versionable!");
    }
    
    // check out
    NodeRef pwcNodeRef = connector.getCheckOutCheckInService().checkout(nodeRef);
    CMISNodeInfo pwcNodeInfo = createNodeInfo(pwcNodeRef);
    objectId.setValue(pwcNodeInfo.getObjectId());

    if (contentCopied != null)
    {
        contentCopied.setValue(connector.getFileFolderService().getReader(pwcNodeRef) != null);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:AlfrescoCmisServiceImpl.java


示例16: removeObjectFromFolder

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@Override
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get node ref
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    if (!info.isDocument())
    {
        throw new CmisInvalidArgumentException("Object is not a document!");
    }

    final NodeRef nodeRef = info.getNodeRef();

    // get the folder node ref
    final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();

    // check primary parent
    if (connector.getNodeService().getPrimaryParent(nodeRef).getParentRef().equals(folderNodeRef))
    {
        throw new CmisConstraintException(
                "Unfiling from primary parent folder is not supported! Use deleteObject() instead.");
    }

    connector.getNodeService().removeChild(folderNodeRef, nodeRef);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:AlfrescoCmisServiceImpl.java


示例17: testIntegrityException

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@Test
public void testIntegrityException() throws Throwable
{
    Exception e = new IntegrityException(null);
    Class<?> toCatch = CmisConstraintException.class;
    
    doMockCall(e, toCatch);
    doMockCall(new RuntimeException(new RuntimeException(e)), toCatch);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:AlfrescoCmisExceptionInterceptorTest.java


示例18: setProperiesToObject

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
private void setProperiesToObject(CmisService cmisService, String repositoryId, String objectIdStr, String propertyStr, BigInteger bigIntValue) throws CmisConstraintException{
    Properties properties = cmisService.getProperties(repositoryId, objectIdStr, null, null);
    PropertyIntegerImpl pd = (PropertyIntegerImpl)properties.getProperties().get(propertyStr);
    pd.setValue(bigIntValue);
    
    Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>();
    propsList.add(pd);
    
    Properties newProps = new PropertiesImpl(propsList);
    
    cmisService.updateProperties(repositoryId, new Holder<String>(objectIdStr), null, newProps, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:CMISTest.java


示例19: insert

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
@POST
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
public Response insert(RelationBean pRelationBean, @Context
	    HttpServletRequest pRequest) {
	Session lSession = Util.getUserAlfrescoSession(httpRequest);

	Relationship lRelationship = null;
	try{
		lRelationship =
				AlfrescoHelper.createRelation(lSession, pRelationBean.getTypeId(), pRelationBean.getSourceId(), pRelationBean.getTargetId());
	} catch (Exception e) {
		if(e instanceof CmisConstraintException ){
			//Prendo il resourceBundle per le label degli errori
			final Locale lLocale = LocaleUtil.getLocale(pRequest.getSession());
			ResourceBundle lResourceBundle = null;
           	if(lLocale != null){
           		lResourceBundle = ResourceBundle.getBundle("ApplicationResources",lLocale);
           	} else {
           		lResourceBundle = ResourceBundle.getBundle("ApplicationResources");
           	}
			
			return Response.status(422).entity(new MessageBean(lResourceBundle.getString("js.error.integrity"))).build(); 
		} else {
			throw e;
		}
	}
	

	return Response.ok(lRelationship).build();
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:31,代码来源:Relation.java


示例20: getTypeForCreate

import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:32,代码来源:CMISConnector.java



注:本文中的org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CapeConfig类代码示例发布时间:2022-05-23
下一篇:
Java BidResponse类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap