本文整理汇总了Java中org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException类的典型用法代码示例。如果您正苦于以下问题:Java CmisConstraintException类的具体用法?Java CmisConstraintException怎么用?Java CmisConstraintException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CmisConstraintException类属于org.apache.chemistry.opencmis.commons.exceptions包,在下文中一共展示了CmisConstraintException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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!");
}
}
示例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!");
}
示例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);
}
示例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!");
}
}
示例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!");
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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!");
}
}
示例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;
}
示例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;
}
示例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!");
}
}
示例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);
}
}
}
示例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...
}
示例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);
}
}