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


Java CallContext类代码示例

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


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

示例1: createFolder

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * CMIS createFolder.
 */
public String createFolder(CallContext context, Properties properties, String folderId) {
    checkUser(context, true);

    // check properties
    checkNewProperties(properties, BaseTypeId.CMIS_FOLDER);

    // get parent File
    File parent = getFile(folderId);
    if (!parent.isDirectory()) {
        throw new CmisObjectNotFoundException("Parent is not a folder!");
    }

    // create the folder
    String name = FileBridgeUtils.getStringProperty(properties, PropertyIds.NAME);
    File newFolder = new File(parent, name);
    if (!newFolder.mkdir()) {
        throw new CmisStorageException("Could not create folder!");
    }

    return getId(newFolder);
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:25,代码来源:FileBridgeRepository.java

示例2: withCmisService

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion)
{
    CmisService cmisService = null;

    try
    {
        CallContext context = new SimpleCallContext("admin", "admin", cmisVersion);
        cmisService = factory.getService(context);
        T ret = callback.execute(cmisService);
        return ret;
    }
    finally
    {
        if(cmisService != null)
        {
            cmisService.close();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:CMISTest.java

示例3: create

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * Create* dispatch for AtomPub.
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
                         VersioningState versioningState, ObjectInfoHandler objectInfos) {
	log.debug("create({}, {})", properties, folderId);

	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);
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		objectId = createFolder(context, properties, folderId);
	} else {
		throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
	}

	return compileObjectType(context, getNode(objectId), null, false, false, objectInfos);
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:25,代码来源:CmisRepository.java

示例4: getObjectByPath

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * CMIS getObjectByPath.
 */
public ObjectData getObjectByPath(CallContext context, String folderPath, String filter, boolean includeAllowableActions,
                                  boolean includeACL, ObjectInfoHandler objectInfos) {
	log.debug("getObjectByPath({}, {}, {})", new Object[]{folderPath, filter, includeAllowableActions});

	// split filter
	Set<String> filterCollection = splitFilter(filter);

	// check path
	if (folderPath == null || !folderPath.startsWith("/")) {
		throw new CmisInvalidArgumentException("Invalid folder path!");
	}

	// get the document or folder
	Node node = getNode(folderPath);

	return compileObjectType(context, node, filterCollection, includeAllowableActions, includeACL, objectInfos);
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:21,代码来源:CmisRepository.java

示例5: compileObjectType

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * Compiles an object type object from a file or folder.
 */
private ObjectData compileObjectType(CallContext context, Node node, Set<String> filter, boolean includeAllowableActions,
                                     boolean includeAcl, ObjectInfoHandler objectInfos) {
	ObjectDataImpl result = new ObjectDataImpl();
	ObjectInfoImpl objectInfo = new ObjectInfoImpl();

	result.setProperties(compileProperties(node, filter, objectInfo));

	if (includeAllowableActions) {
		result.setAllowableActions(compileAllowableActions(node));
	}

	if (includeAcl) {
		result.setAcl(compileAcl(node));
		result.setIsExactAcl(true);
	}

	if (context.isObjectInfoRequired()) {
		objectInfo.setObject(result);
		objectInfos.addObjectInfo(objectInfo);
	}

	return result;
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:27,代码来源:CmisRepository.java

示例6: getService

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
@Override
public CmisService getService(CallContext context) {
	// authentication can go here
	String user = context.getUsername();
	String password = context.getPassword();
	log.debug("User: {}", user);
	log.debug("Password: {}", password);

	// if the authentication fails, throw a CmisPermissionDeniedException

	// create a new service object (can also be pooled or stored in a ThreadLocal)
	CmisServiceImpl service = new CmisServiceImpl(repository);

	// add the CMIS service wrapper
	// (The wrapper catches invalid CMIS requests and sets default values
	// for parameters that have not been provided by the client.)
	CmisServiceWrapper<CmisService> wrapperService = new CmisServiceWrapper<CmisService>(service, DEFAULT_MAX_ITEMS_TYPES,
			DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);

	// hand over the call context to the service object
	service.setCallContext(context);

	return wrapperService;
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:25,代码来源:CmisServiceFactory.java

示例7: create

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * Create* dispatch for AtomPub.
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
        VersioningState versioningState, ObjectInfoHandler objectInfos) {
    boolean userReadOnly = checkUser(context, true);

    String typeId = FileBridgeUtils.getObjectTypeId(properties);
    TypeDefinition type = typeManager.getInternalTypeDefinition(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);
    } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
        objectId = createFolder(context, properties, folderId);
    } else {
        throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
    }

    return compileObjectData(context, getFile(objectId), null, false, false, userReadOnly, objectInfos);
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:25,代码来源:FileBridgeRepository.java

示例8: deleteObject

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

示例9: deleteTree

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

示例10: compileObjectData

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * Compiles an object type object from a file or folder.
 */
private ObjectData compileObjectData(CallContext context, File file, Set<String> filter,
        boolean includeAllowableActions, boolean includeAcl, boolean userReadOnly, ObjectInfoHandler objectInfos) {
    ObjectDataImpl result = new ObjectDataImpl();
    ObjectInfoImpl objectInfo = new ObjectInfoImpl();

    result.setProperties(compileProperties(context, file, filter, objectInfo));

    if (includeAllowableActions) {
        result.setAllowableActions(compileAllowableActions(file, userReadOnly));
    }

    if (includeAcl) {
        result.setAcl(compileAcl(file));
        result.setIsExactAcl(true);
    }

    if (context.isObjectInfoRequired()) {
        objectInfo.setObject(result);
        objectInfos.addObjectInfo(objectInfo);
    }

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

示例11: checkUser

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * Checks if the user in the given context is valid for this repository and
 * if the user has the required permissions.
 */
private boolean checkUser(CallContext context, boolean writeRequired) {
    if (context == null) {
        throw new CmisPermissionDeniedException("No user context!");
    }

    Boolean readOnly = readWriteUserMap.get(context.getUsername());
    if (readOnly == null) {
        throw new CmisPermissionDeniedException("Unknown user!");
    }

    if (readOnly.booleanValue() && writeRequired) {
        throw new CmisPermissionDeniedException("No write permission!");
    }

    return readOnly.booleanValue();
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:21,代码来源:FileBridgeRepository.java

示例12: slflog

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * slf logging version with dual output to console and slf
 */
protected void slflog(String operation, String repositoryId) {
    if (repositoryId == null) {
        repositoryId = "<none>";
    }

    HttpServletRequest request = (HttpServletRequest) getCallContext().get(CallContext.HTTP_SERVLET_REQUEST);
    String userAgent = request.getHeader("User-Agent");
    if (userAgent == null) {
        userAgent = "<unknown>";
    }

    String binding = getCallContext().getBinding();

    LOG.info("Operation: {}, Repository ID: {}, Binding: {}, User Agent: {}", operation, repositoryId, binding,
            userAgent);
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:20,代码来源:CmisCustomPdfWatermarkServiceWrapper.java

示例13: acquireGregRepository

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * @param context  context with user data
 * @return
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException
 */
private Registry acquireGregRepository(CallContext context, String tenantDomain, String uName) throws RegistryException, AxisFault {


    UserRegistry userRegistry = null;
    try{
         PrivilegedCarbonContext.getThreadLocalCarbonContext().startTenantFlow();
         PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);

         RegistryService registryService =
                                  (RegistryService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(RegistryService.class);
         //userRegistry = registryService.getRegistry(username, password);
          userRegistry = registryService.getRegistry(uName, context.getPassword(), PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());


       }  catch (RegistryException e) {
         log.error("unable to create registry instance for the respective enduser", e);
       } finally {
        PrivilegedCarbonContext.getThreadLocalCarbonContext().endTenantFlow();

    }

       return userRegistry;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:29,代码来源:CMISServiceFactory.java

示例14: createFolder

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入依赖的package包/类
/**
 * CMIS createFolder.
 */
public String createFolder(CallContext context, Properties properties,
		String folderId) {
	checkUser(context, true);

	// check properties
	checkNewProperties(properties);

	// get parent File
	File parent = getFile(folderId);
	if (!parent.isDirectory()) {
		throw new CmisObjectNotFoundException("Parent is not a folder!");
	}

	// create the folder
	String name = FileBridgeUtils.getStringProperty(properties,
			PropertyIds.NAME);
	File newFolder = new File(parent, name);
	if (!newFolder.mkdir()) {
		throw new CmisStorageException("Could not create folder!");
	}

	return getId(newFolder);
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuide,代码行数:27,代码来源:FileBridgeRepository.java

示例15: deleteObject

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


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