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

Java CmisContentAlreadyExistsException类代码示例

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

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



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

示例1: renameFolder

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
public static void renameFolder(Session pSession, String pStrNodeRef, String pStrNewName) {
	mLog.debug("ENTER renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");

	Folder lFolder = (Folder) pSession.getObject(pStrNodeRef);

	Map<String, String> lMapProperties = new HashMap<String, String>();
	lMapProperties.put(PropertyIds.NAME, pStrNewName);

	try {
		lFolder.updateProperties(lMapProperties, true);
	} catch (CmisContentAlreadyExistsException e) {
		mLog.error("Impossibile aggiornare le proprietà del documento", e);
		throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
	}

	mLog.debug("EXIT renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:18,代码来源:AlfrescoHelper.java


示例2: testFileExistsException

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


示例3: createFolder

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
public static String createFolder(Session pSession, String pStrParentFolderId, String pStrFolderName) {

		String lStrFolderId = null;

		mLog.debug("Start createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, ")");

		// recupero la cartella padre
		Folder lFolder = (Folder) pSession.getObject(pStrParentFolderId);

		// creo la cartella
		Map<String, String> lMapProperties = new HashMap<String, String>();
		lMapProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
		lMapProperties.put(PropertyIds.NAME, pStrFolderName);
		Folder lFolderNew;
		try {
			lFolderNew = lFolder.createFolder(lMapProperties);
			lStrFolderId = lFolderNew.getId();

		} catch (CmisContentAlreadyExistsException e) {
			mLog.error("Il documento esiste già", e);
			throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
		}

		mLog.debug("End createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, "): return ",
		        lStrFolderId);

		return lStrFolderId;
	}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:29,代码来源:AlfrescoHelper.java


示例4: invoke

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable
{
    try
    {
        return mi.proceed();
    }
    catch (Exception e)
    {
        // We dig into the exception to see if there is anything of interest to CMIS
        Throwable cmisAffecting = ExceptionStackUtil.getCause(e, EXCEPTIONS_OF_INTEREST);
        
        if (cmisAffecting == null)
        {
            // The exception is not something that CMIS needs to handle in any special way
            if (e instanceof CmisBaseException)
            {
                throw (CmisBaseException) e;
            }
            else
            {
                throw new CmisRuntimeException(e.getMessage(), e);
            }
        }
        // All other exceptions are carried through with full stacks but treated as the exception of interest
        else if (cmisAffecting instanceof AuthenticationException)
        {
            throw new CmisPermissionDeniedException(cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof CheckOutCheckInServiceException)
        {
            throw new CmisVersioningException("Check out failed: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof FileExistsException)
        {
            throw new CmisContentAlreadyExistsException("An object with this name already exists: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof IntegrityException)
        {
            throw new CmisConstraintException("Constraint violation: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof AccessDeniedException)
        {
            throw new CmisPermissionDeniedException("Permission denied: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof NodeLockedException)
        {
            throw new CmisUpdateConflictException("Update conflict: " + cmisAffecting.getMessage(), e);
        }
        else
        {
            // We should not get here, so log an error but rethrow to have CMIS handle the original cause
            logger.error("Exception type not handled correctly: " + e.getClass().getName());
            throw new CmisRuntimeException(e.getMessage(), e);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:57,代码来源:AlfrescoCmisExceptionInterceptor.java


示例5: createDocumentFromSource

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
@Override
public String createDocumentFromSource(
        String repositoryId, String sourceId, final Properties properties,
        String folderId, VersioningState versioningState, 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, "Parent folder");

    // get source
    CMISNodeInfo info = getOrCreateNodeInfo(sourceId, "Source");

    // check source
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Source object is not a document!");
    }

    final NodeRef sourceNodeRef = info.getNodeRef();
    if (!info.isDocument())
    {
        throw new CmisConstraintException("Source object is not a document!");
    }
    
    // get name and type
    final String name = connector.getNameProperty(properties, info.getName());

    final TypeDefinitionWrapper type = info.getType();
    connector.checkChildObjectType(parentInfo, type.getTypeId());
    
    versioningState = getDocumentDefaultVersioningState(versioningState, type);

    try
    {
        FileInfo fileInfo = connector.getFileFolderService().copy(
                sourceNodeRef, parentInfo.getNodeRef(), name);
        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.extractMetadata(nodeRef);
        connector.createThumbnails(nodeRef, Collections.singleton("doclib"));

        connector.applyVersioningState(nodeRef, versioningState);
        
        connector.getActivityPoster().postFileFolderAdded(nodeRef);
        
        return connector.createObjectId(nodeRef);
    }
    catch (FileNotFoundException e)
    {
        throw new CmisContentAlreadyExistsException("An object with this name already exists!", e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:59,代码来源:AlfrescoCmisServiceImpl.java


示例6: setContentStream

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

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

    if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
    {
        throw new CmisStreamNotSupportedException("Content can only be set on private working copies or current versions.");
    }

    final NodeRef nodeRef = info.getNodeRef();

    if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
    {
        throw new CmisStreamNotSupportedException("Document type doesn't allow content!");
    }

    boolean existed = connector.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT) != null;
    if (existed && !overwriteFlag)
    {
        throw new CmisContentAlreadyExistsException("Content already exists!");
    }

    if ((contentStream == null) || (contentStream.getStream() == null))
    {
        throw new CmisInvalidArgumentException("No content!");
    }

    //ALF-21852 - Separated setContent and objectId.setValue in two different transactions because
    //after executing setContent, the new objectId is not visible.
    RetryingTransactionHelper helper = connector.getRetryingTransactionHelper();
    helper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            String mimeType = parseMimeType(contentStream);
            final File tempFile = copyToTempFile(contentStream);
            String encoding = getEncoding(tempFile, mimeType);

            try
            {
                ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
                writer.setMimetype(mimeType);
                writer.setEncoding(encoding);
                writer.putContent(tempFile);
            }
            finally
            {
                removeTempFile(tempFile);
            }

            connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
            return null;
        }
    }, false, true);

    String objId = helper.doInTransaction(new RetryingTransactionCallback<String>()
    {
        public String execute() throws Throwable
        {
            return connector.createObjectId(nodeRef);
        }
    }, true, true);

    objectId.setValue(objId);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:71,代码来源:AlfrescoCmisServiceImpl.java


示例7: createDocumentFromSource

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
@Override
public String createDocumentFromSource(
        String repositoryId, String sourceId, final Properties properties,
        String folderId, final VersioningState versioningState, 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, "Parent folder");

    // get source
    CMISNodeInfo info = getOrCreateNodeInfo(sourceId, "Source");

    // check source
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Source object is not a document!");
    }

    final NodeRef sourceNodeRef = info.getNodeRef();
    if (!info.isDocument())
    {
        throw new CmisConstraintException("Source object is not a document!");
    }

    // get name and type
    final String name = connector.getNameProperty(properties, info.getName());

    final TypeDefinitionWrapper type = info.getType();
    connector.checkChildObjectType(parentInfo, type.getTypeId());

    try
    {
        FileInfo fileInfo = connector.getFileFolderService().copy(
                sourceNodeRef, parentInfo.getNodeRef(), name);
        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.extractMetadata(nodeRef);
        connector.createThumbnails(nodeRef, Collections.singleton("doclib"));

        connector.applyVersioningState(nodeRef, versioningState);
        
        connector.getActivityPoster().postFileFolderAdded(nodeRef);
        
        return connector.createObjectId(nodeRef);
    }
    catch (FileNotFoundException e)
    {
        throw new CmisContentAlreadyExistsException("An object with this name already exists!", e);
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:57,代码来源:AlfrescoCmisServiceImpl.java


示例8: setContentStream

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

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

    if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
    {
        throw new CmisStreamNotSupportedException("Content can only be set ondocuments!");
    }

    final NodeRef nodeRef = info.getNodeRef();

    if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
    {
        throw new CmisStreamNotSupportedException("Document type doesn't allow content!");
    }

    boolean existed = connector.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT) != null;
    if (existed && !overwriteFlag)
    {
        throw new CmisContentAlreadyExistsException("Content already exists!");
    }

    if ((contentStream == null) || (contentStream.getStream() == null))
    {
        throw new CmisInvalidArgumentException("No content!");
    }

    // copy stream to temp file
    final File tempFile = copyToTempFile(contentStream);
    final Charset encoding = getEncoding(tempFile, contentStream.getMimeType());

    try
    {
        ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
        String mimeType = parseMimeType(contentStream);
        writer.setMimetype(mimeType);
        writer.setEncoding(encoding.name());
        writer.putContent(tempFile);
    }
    finally
    {
        removeTempFile(tempFile);
    }

    objectId.setValue(connector.createObjectId(nodeRef));

    connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:54,代码来源:AlfrescoCmisServiceImpl.java


示例9: changeContentStream

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
/**
 * CMIS setContentStream, deleteContentStream, and appendContentStream.
 */
public void changeContentStream(CallContext context, Holder<String> objectId, Boolean overwriteFlag,
        ContentStream contentStream, boolean append) {
    checkUser(context, true);

    if (objectId == null) {
        throw new CmisInvalidArgumentException("Id is not valid!");
    }

    // get the file
    File file = getFile(objectId.getValue());
    if (!file.isFile()) {
        throw new CmisStreamNotSupportedException("Not a file!");
    }

    // check overwrite
    boolean owf = FileBridgeUtils.getBooleanParameter(overwriteFlag, true);
    if (!owf && file.length() > 0) {
        throw new CmisContentAlreadyExistsException("Content already exists!");
    }

    OutputStream out = null;
    InputStream in = null;
    try {
        out = new BufferedOutputStream(new FileOutputStream(file, append), BUFFER_SIZE);

        if (contentStream == null || contentStream.getStream() == null) {
            // delete content
            out.write(new byte[0]);
        } else {
            // set content
            in = new BufferedInputStream(contentStream.getStream(), BUFFER_SIZE);

            byte[] buffer = new byte[BUFFER_SIZE];
            int b;
            while ((b = in.read(buffer)) > -1) {
                out.write(buffer, 0, b);
            }
        }
    } catch (Exception e) {
        throw new CmisStorageException("Could not write content: " + e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(out);
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:49,代码来源:FileBridgeRepository.java


示例10: setContentStream

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
/**
 * See CMIS 1.0 section 2.2.4.16 setContentStream
 *
 * @throws CmisStorageException
 */
public RegistryObject setContentStream(ContentStream contentStream, boolean overwriteFlag) {
    try {
        //Check for existing data
        Object dataObject = getNode().getContent();
        int length = 0;
        if (dataObject != null){
        	length = 1;
        }

        // check overwrite
        if (!overwriteFlag && length != 0) {
            throw new CmisContentAlreadyExistsException("Content already exists!");
        }

        RegistryVersionBase gregVersion = isVersionable() ? asVersion() : null;

        boolean autoCheckout = gregVersion != null && !gregVersion.isCheckedOut();
        RegistryVersionBase gregVersionContext = null;
        if (autoCheckout) {
            gregVersionContext = gregVersion.checkout();
        } else {
            gregVersionContext = gregVersion;
        }

        Resource resource = null;
        // write content, if available
        if(contentStream == null || contentStream.getStream() == null){

           resource = gregVersionContext.getNode();
           resource.setContent(null);
        } else{
        	//Sets the content stream
            resource = gregVersionContext.getNode();
        	resource.setContentStream(contentStream.getStream());
            //TODO MIME-Type --> DONE
        	//contentStream.getMimeType();
        }
        //put to registry
        String versionContextPath = gregVersionContext.getNode().getPath();
        getRepository().put(versionContextPath, resource);

        //set
        gregVersionContext.setNode(getRepository().get(versionContextPath));

        if (autoCheckout) {
            // auto versioning -> return new version created by checkin
            return gregVersionContext.checkin(null, null, "auto checkout");
        } else if (gregVersionContext != null) {
            // the node is checked out -> return pwc.
            return gregVersionContext.getPwc();
        } else {
            // non versionable -> return this
            return this;
        }
    }
    catch (RegistryException e) {
        log.error("Error occurred while setting content stream ", e);
        throw new CmisStorageException(e.getMessage());
    }

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:67,代码来源:RegistryDocument.java


示例11: changeContentStream

import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException; //导入依赖的package包/类
/**
 * CMIS setContentStream, deleteContentStream, and appendContentStream.
 */
public void changeContentStream(CallContext context,
		Holder<String> objectId, Boolean overwriteFlag,
		ContentStream contentStream, boolean append) {
	checkUser(context, true);

	if (objectId == null) {
		throw new CmisInvalidArgumentException("Id is not valid!");
	}

	// get the file
	File file = getFile(objectId.getValue());
	if (!file.isFile()) {
		throw new CmisStreamNotSupportedException("Not a file!");
	}

	// check overwrite
	boolean owf = FileBridgeUtils.getBooleanParameter(overwriteFlag, true);
	if (!owf && file.length() > 0) {
		throw new CmisContentAlreadyExistsException(
				"Content already exists!");
	}

	OutputStream out = null;
	InputStream in = null;
	try {
		out = new BufferedOutputStream(new FileOutputStream(file, append),
				BUFFER_SIZE);

		if (contentStream == null || contentStream.getStream() == null) {
			// delete content
			out.write(new byte[0]);
		} else {
			// set content
			in = new BufferedInputStream(contentStream.getStream(),
					BUFFER_SIZE);

			byte[] buffer = new byte[BUFFER_SIZE];
			int b;
			while ((b = in.read(buffer)) > -1) {
				out.write(buffer, 0, b);
			}
		}
	} catch (Exception e) {
		throw new CmisStorageException("Could not write content: "
				+ e.getMessage(), e);
	} finally {
		IOUtils.closeQuietly(out);
		IOUtils.closeQuietly(in);
	}
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:54,代码来源:FileBridgeRepository.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RemExpr类代码示例发布时间:2022-05-23
下一篇:
Java Loop类代码示例发布时间: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