当前位置: 首页>>代码示例>>Java>>正文


Java CmisBaseException类代码示例

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


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

示例1: openSession

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@Override
@PostConstruct
public void openSession() {
    Map<String, String> parameter = new HashMap<>();

    String alfrescoCmisUrl = alfrescoServerProtocol + "://" + alfrescoServerUrl +cmisEntryPoint;
    parameter.put(SessionParameter.BROWSER_URL, alfrescoCmisUrl);
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
    parameter.put(SessionParameter.USER,username);
    parameter.put(SessionParameter.PASSWORD,password);

    try {
        SessionFactory factory = SessionFactoryImpl.newInstance();
        session = factory.getRepositories(parameter).get(0).createSession();
    }
    catch (CmisBaseException ex) {
        logger.debug("Exception"+ ex.getMessage());
        throw new ConnectionException();
    }
}
 
开发者ID:david-ciamberlano,项目名称:website-inventor,代码行数:21,代码来源:AlfrescoRemoteConnection.java

示例2: getTracks

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
/**
 * Returns tracks of an album.
 * 
 * @param session
 *          OpenCMIS session
 * @param albumObject
 *          the album object
 * @return a list of track documents, or an empty list if the object
 *         is not an album or the album has no tracks
 */
public static List<Document> getTracks(Session session,
		CmisObject albumObject) {
	List<Document> tracks = new ArrayList<Document>();

	@SuppressWarnings("unchecked")
	List<String> trackIds = (List<String>) albumObject
			.getPropertyValue(IdMapping
					.getRepositoryPropertyId("cmisbook:tracks"));

	if (trackIds != null) {
		for (String trackId : trackIds) {
			try {
				CmisObject track = session.getObject(trackId,
						CMISHelper.FULL_OPERATION_CONTEXT);
				if (track instanceof Document) {
					tracks.add((Document) track);
				}
			} catch (CmisBaseException cbe) {
				// ignore
			}
		}
	}

	return tracks;
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:36,代码来源:TheBlendHelper.java

示例3: getCmisObjectByPath

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
public static CmisObject getCmisObjectByPath(final Session session,
		final String path, final OperationContext context,
		final String what) throws TheBlendException {
	if (session == null) {
		throw new IllegalArgumentException("Session must be set!");
	}

	if (path == null || !path.startsWith("/")) {
		throw new TheBlendException("Invalid path to " + what + "!");
	}

	OperationContext oc = context;
	if (oc == null) {
		oc = session.getDefaultContext();
	}

	try {
		return session.getObjectByPath(path, oc);
	} catch (CmisObjectNotFoundException onfe) {
		throw new TheBlendException("The " + what + " does not exist!",
				onfe);
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Could not retrieve the " + what
				+ ":" + cbe.getMessage(), cbe);
	}
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:27,代码来源:CMISHelper.java

示例4: bulkUpdateProperties

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
/**
 * CMIS bulkUpdateProperties.
 */
public List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(CallContext context,
        List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken, Properties properties,
        ObjectInfoHandler objectInfos) {
    checkUser(context, true);

    if (objectIdAndChangeToken == null) {
        throw new CmisInvalidArgumentException("No object ids provided!");
    }

    List<BulkUpdateObjectIdAndChangeToken> result = new ArrayList<BulkUpdateObjectIdAndChangeToken>();

    for (BulkUpdateObjectIdAndChangeToken oid : objectIdAndChangeToken) {
        if (oid == null) {
            // ignore invalid ids
            continue;
        }
        try {
            Holder<String> oidHolder = new Holder<String>(oid.getId());
            updateProperties(context, oidHolder, properties, objectInfos);

            result.add(new BulkUpdateObjectIdAndChangeTokenImpl(oid.getId(), oidHolder.getValue(), null));
        } catch (CmisBaseException e) {
            // ignore exceptions - see specification
        }
    }

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

示例5: handleCmisBaseError

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@ExceptionHandler(CmisBaseException.class)
public ModelAndView handleCmisBaseError(HttpServletRequest req, CmisObjectNotFoundException exc) {
    ModelAndView mav = new ModelAndView();
    mav.addObject("Invalid Page", exc.getMessage());
    mav.addObject("exception", exc);
    mav.addObject("utl",req.getRequestURL());
    mav.setViewName("error");

    return mav;
}
 
开发者ID:david-ciamberlano,项目名称:website-inventor,代码行数:11,代码来源:MainController.java

示例6: getSession

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
public Session getSession() {

        if (session == null) {

            try {
                openSession();
            }
            catch (CmisBaseException e) {
                return null;
            }
        }

        return session;
    }
 
开发者ID:david-ciamberlano,项目名称:website-inventor,代码行数:15,代码来源:AlfrescoRemoteConnection.java

示例7: bulkUpdateProperties

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
/**
 * CMIS bulkUpdateProperties.
 */
public List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(
		CallContext context,
		List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken,
		Properties properties, ObjectInfoHandler objectInfos) {
	checkUser(context, true);

	if (objectIdAndChangeToken == null) {
		throw new CmisInvalidArgumentException("No object ids provided!");
	}

	List<BulkUpdateObjectIdAndChangeToken> result = new ArrayList<BulkUpdateObjectIdAndChangeToken>();

	for (BulkUpdateObjectIdAndChangeToken oid : objectIdAndChangeToken) {
		if (oid == null) {
			// ignore invalid ids
			continue;
		}
		try {
			Holder<String> oidHolder = new Holder<String>(oid.getId());
			updateProperties(context, oidHolder, properties, objectInfos);

			result.add(new BulkUpdateObjectIdAndChangeTokenImpl(
					oid.getId(), oidHolder.getValue(), null));
		} catch (CmisBaseException e) {
			// ignore exceptions - see specification
		}
	}

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

示例8: doPost

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
/**
 * Creates a folder.
 */
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	String parentId = getRequiredStringParameter(request, PARAM_PARENT);
	String typeId = getRequiredStringParameter(request, PARAM_TYPE_ID);
	String name = getStringParameter(request, PARAM_NAME);

	if (name == null || name.length() == 0) {
		redirect(HTMLHelper.encodeUrlWithId(request, "browse", parentId),
				request, response);
		return;
	}

	// fetch the parent folder
	Folder parent = CMISHelper.getFolder(session, parentId,
			CMISHelper.LIGHT_OPERATION_CONTEXT, "parent folder");

	// set name and type of the new folder
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put(PropertyIds.NAME, name);
	properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);

	// create the folder
	try {
		parent.createFolder(properties);
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Could not create folder: "
				+ cbe.getMessage(), cbe);
	}

	redirect(HTMLHelper.encodeUrlWithId(request, "browse", parentId),
			request, response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:38,代码来源:BrowseServlet.java

示例9: getCmisObject

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
/**
 * Gets a CMIS object from the repository.
 * 
 * @param session
 *          the OpenCMIS session
 * @param id
 *          the id of the object
 * @param context
 *          the Operation Context
 * @param what
 *          string that describes the object, used for error
 *          messages
 * @return the CMIS object
 * @throws TheBlendException
 */
public static CmisObject getCmisObject(final Session session,
		final String id, final OperationContext context,
		final String what) throws TheBlendException {
	if (session == null) {
		throw new IllegalArgumentException("Session must be set!");
	}

	if (id == null || id.length() == 0) {
		throw new TheBlendException("Invalid id for " + what + "!");
	}

	OperationContext oc = context;
	if (oc == null) {
		oc = session.getDefaultContext();
	}

	try {
		return session.getObject(id, oc);
	} catch (CmisObjectNotFoundException onfe) {
		throw new TheBlendException("The " + what + " does not exist!",
				onfe);
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Could not retrieve the " + what
				+ ":" + cbe.getMessage(), cbe);
	}
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:42,代码来源:CMISHelper.java

示例10: invoke

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的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

示例11: doPost

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	String id = getRequiredStringParameter(request, PARAM_ID);
	boolean allVersions = getBooleanParameter(request,
			PARAM_ALL_VERSIONS, false);
	String parentId = null;

	// fetch and delete the object
	try {
		CmisObject cmisObject = CMISHelper.getCmisObject(session, id,
				CMISHelper.LIGHT_OPERATION_CONTEXT, "object");

		// get the (first) parent folder, if one exists
		// we want to redirect to the parents browse page later
		if (cmisObject instanceof FileableCmisObject) {
			List<Folder> parents = ((FileableCmisObject) cmisObject)
					.getParents();
			if (parents.size() > 0) {
				parentId = parents.get(0).getId();
			}
		}

		if (cmisObject instanceof Folder) {
			List<String> failedToDelete = ((Folder) cmisObject)
					.deleteTree(true, UnfileObject.DELETE, true);

			if (failedToDelete != null && !failedToDelete.isEmpty()) {
				throw new TheBlendException("Deletion failed!");
			}
		} else {
			cmisObject.delete(allVersions);
		}
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Deletion failed: "
				+ cbe.getMessage(), cbe);
	}

	if (parentId == null) {
		// show dashbord page
		redirect("dashboard", request, response);
	} else {
		// show browse page
		redirect(
				HTMLHelper.encodeUrlWithId(request, "browse", parentId),
				request, response);
	}
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:51,代码来源:DeleteServlet.java

示例12: doPost

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	String id = getRequiredStringParameter(request, PARAM_ID);
	String what = getRequiredStringParameter(request,
			PARAM_ARTWORK_WHAT);

	Document artwork = null;
	String artworkId = null;

	if (what.equalsIgnoreCase("id")) {
		artworkId = getStringParameter(request, PARAM_ARTWORK_ID);
		artwork = CMISHelper.getDocumet(session, artworkId,
				CMISHelper.FULL_OPERATION_CONTEXT, "document");
	} else if (what.equalsIgnoreCase("path")) {
		String artworkPath = getStringParameter(request,
				PARAM_ARTWORK_PATH);
		artwork = CMISHelper.getDocumetByPath(session, artworkPath,
				CMISHelper.FULL_OPERATION_CONTEXT, "document");
		artworkId = artwork.getId();
	} else if (what.equalsIgnoreCase("remove")) {
		artworkId = null;
	} else {
		throw new TheBlendException("What?", null);
	}

	// check artwork
	if (artwork != null) {
		String artworkMimeType = artwork.getContentStreamMimeType();

		if (artworkMimeType == null) {
			throw new TheBlendException("Artwork has no content!");
		}

		if (!artworkMimeType.toLowerCase().startsWith("image/")) {
			throw new TheBlendException("Artwork in not an image!");
		}
	}

	ObjectId newId = session.createObjectId(id);

	// fetch the document object
	Document doc = CMISHelper.getDocumet(session, id,
			CMISHelper.FULL_OPERATION_CONTEXT, "document");

	// update the artwork property
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put(
			IdMapping.getRepositoryPropertyId("cmisbook:artwork"),
			artworkId);

	try {
		CmisObject newObject = doc.updateProperties(properties);
		newId = newObject;
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Could not update artwork id!", cbe);
	}

	redirect(
			HTMLHelper.encodeUrlWithId(request, "show", newId.getId()),
			request, response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:65,代码来源:ArtworkServlet.java

示例13: doPost

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	String id = getRequiredStringParameter(request, PARAM_ID);
	String newname = getRequiredStringParameter(request, PARAM_NEWNAME);
	String parentId = null;

	// fetch the object
	CmisObject cmisObject = CMISHelper.getCmisObject(session, id,
			CMISHelper.LIGHT_OPERATION_CONTEXT, "object");

	// get the (first) parent folder, if one exists
	// we want to redirect to the parents browse page later
	if (cmisObject instanceof FileableCmisObject) {
		List<Folder> parents = ((FileableCmisObject) cmisObject)
				.getParents();
		if (parents.size() > 0) {
			parentId = parents.get(0).getId();
		}
	}

	// rename the object
	try {
		// update the cmis:name property
		Map<String, Object> properties = new HashMap<String, Object>();
		properties.put(PropertyIds.NAME, newname);

		cmisObject.updateProperties(properties);

	} catch (CmisObjectNotFoundException onfe) {
		throw new TheBlendException("Object doesn't exist!", onfe);
	} catch (CmisNameConstraintViolationException ncve) {
		throw new TheBlendException("The new name is invalid or "
				+ "an object with this name "
				+ "already exists in this folder!", ncve);
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Rename failed: " + cbe.getMessage(),
				cbe);
	}

	if (parentId == null) {
		// show dashbord page
		redirect("dashboard", request, response);
	} else {
		// show browse page
		redirect(HTMLHelper.encodeUrlWithId(request, "browse", parentId),
				request, response);
	}
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:52,代码来源:RenameServlet.java

示例14: doPost

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	// find out what to do
	int action = getIntParameter(request, PARAM_ACTION, 0);
	if (action < 1 && action > 3) {
		throw new TheBlendException("Unknown action!");
	}

	ObjectId newId = null;

	if (action == 1) {
		// create new album
		newId = createAlbum(session, request);
	} else {
		// album update, get its id
		String id = getRequiredStringParameter(request, PARAM_ID);

		// fetch the album object
		Document album = CMISHelper.getDocumet(session, id,
				CMISHelper.FULL_OPERATION_CONTEXT, "album");

		// check if the object has the cmisbook:tracks property
		if (!album
				.getType()
				.getPropertyDefinitions()
				.containsKey(
						IdMapping.getRepositoryPropertyId("cmisbook:tracks"))) {
			error("Document has no cmisbook:tracks property!", null,
					request, response);
			return;
		}

		List<String> tracks = null;
		if (action == 2) {
			// update track list
			tracks = getTrackList(request);
		} else if (action == 3) {
			// add track to album
			List<String> orgTracks = album.getPropertyValue(IdMapping
					.getRepositoryPropertyId("cmisbook:tracks"));
			tracks = addTrack(session, request, orgTracks);
		}

		// update the track list
		Map<String, Object> properties = new HashMap<String, Object>();
		properties.put(
				IdMapping.getRepositoryPropertyId("cmisbook:tracks"),
				tracks);

		try {
			CmisObject newObject = album.updateProperties(properties);
			newId = newObject;
		} catch (CmisBaseException cbe) {
			throw new TheBlendException("Could not update track list!",
					cbe);
		}
	}

	// return to album page
	redirect(
			HTMLHelper.encodeUrlWithId(request, "album", newId.getId()),
			request, response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:67,代码来源:AlbumServlet.java

示例15: doGet

import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; //导入依赖的package包/类
protected void doGet(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException, TheBlendException {

	String id = getRequiredStringParameter(request, PARAM_ID);

	// fetch the document object
	Document doc = CMISHelper.getDocumet(session, id,
			CMISHelper.FULL_OPERATION_CONTEXT, "document");

	// refresh
	try {
		// refresh only if the document hasn't been fetched or
		// refreshed within the last minute
		doc.refreshIfOld(60 * 1000);
	} catch (CmisObjectNotFoundException onfe) {
		throw new TheBlendException("Document doesn't exist anymore!",
				onfe);
	} catch (CmisBaseException cbe) {
		throw new TheBlendException("Could not retrieve the document!",
				cbe);
	}

	request.setAttribute(ATTR_DOCUMENT, doc);

	// check if the object is versionable
	request.setAttribute(ATTR_VERSIONS, null);
	DocumentType doctype = (DocumentType) doc.getType();
	if (doctype.isVersionable() == null) {
		// the repository did not indicate if this document type
		// supports
		// versioning -> not spec compliant
		// we assume it is not versionable
	} else if (doctype.isVersionable().booleanValue()) {
		List<Document> versions = doc
				.getAllVersions(CMISHelper.VERSION_OPERATION_CONTEXT);
		request.setAttribute(ATTR_VERSIONS, versions);
	}

	// get the if of the artwork document, if it exists
	String artworkId = TheBlendHelper.getArtworkId(session, doc);
	request.setAttribute(ATTR_ARTWORK, artworkId);

	// if this is an album, get the tracks
	if (doc
			.getType()
			.getPropertyDefinitions()
			.containsKey(
					IdMapping.getRepositoryPropertyId("cmisbook:tracks"))) {
		List<Document> tracks = TheBlendHelper.getTracks(session, doc);
		request.setAttribute(ATTR_TRACKS, tracks);
	}

	// show browse page
	dispatch("show.jsp", doc.getName() + " .The Blend.", request,
			response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:58,代码来源:ShowServlet.java


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