Search in sources :

Example 31 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method getTypeDefinition.

@Override
public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // find the type
    TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
    if (tdw == null) {
        throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
    }
    // return type definition
    return tdw.getTypeDefinition(true);
}
Also used : CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)

Example 32 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method applyAcl.

@Override
public Acl applyAcl(String repositoryId, String objectId, final Acl aces, AclPropagation aclPropagation) {
    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, aces);
    return connector.getACL(nodeRef, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 33 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method checkIn.

@Override
public void checkIn(String repositoryId, final Holder<String> objectId, final Boolean major, final Properties properties, final ContentStream contentStream, final String checkinComment, final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
    // only accept a PWC
    if (!info.isVariant(CMISObjectVariant.PWC)) {
        throw new CmisVersioningException("Object is not a PWC!");
    }
    // get object
    final NodeRef nodeRef = info.getNodeRef();
    final TypeDefinitionWrapper type = info.getType();
    // check in
    // update PWC
    connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.OBJECT_TYPE_ID });
    connector.applyPolicies(nodeRef, type, policies);
    connector.applyACL(nodeRef, type, addAces, removeAces);
    // handle content
    if (contentStream != null) {
        String mimeType = parseMimeType(contentStream);
        String encoding = getEncoding(contentStream.getStream(), mimeType);
        // write content
        ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
        writer.setMimetype(mimeType);
        writer.setEncoding(encoding);
        writer.putContent(contentStream.getStream());
    }
    // create version properties
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
    versionProperties.put(VersionModel.PROP_VERSION_TYPE, major ? VersionType.MAJOR : VersionType.MINOR);
    if (checkinComment != null) {
        versionProperties.put(VersionModel.PROP_DESCRIPTION, checkinComment);
    }
    // check in
    NodeRef newNodeRef = connector.getCheckOutCheckInService().checkin(nodeRef, versionProperties);
    connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), newNodeRef);
    objectId.setValue(connector.createObjectId(newNodeRef));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) Serializable(java.io.Serializable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) CmisVersioningException(org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Aggregations

TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)33 CMISNodeInfo (org.alfresco.opencmis.dictionary.CMISNodeInfo)13 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)13 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)13 NodeRef (org.alfresco.service.cmr.repository.NodeRef)12 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)11 ArrayList (java.util.ArrayList)10 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)9 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)9 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)9 Serializable (java.io.Serializable)8 QName (org.alfresco.service.namespace.QName)8 PropertyDefinitionWrapper (org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper)7 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)5 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 List (java.util.List)4 FileInfo (org.alfresco.service.cmr.model.FileInfo)4 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)4