use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method createFolder.
@Override
public String createFolder(String repositoryId, final Properties properties, String folderId, 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, "Folder");
// get name and type
final String name = connector.getNameProperty(properties, null);
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);
connector.checkChildObjectType(parentInfo, type.getTypeId());
// run transaction
FileInfo fileInfo = connector.getFileFolderService().create(parentInfo.getNodeRef(), name, type.getAlfrescoClass());
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.getActivityPoster().postFileFolderAdded(nodeRef);
String objectId = connector.createObjectId(nodeRef);
return objectId;
}
use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getTypeChildren.
@Override
public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// convert BigIntegers to int
int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
// set up the result
TypeDefinitionListImpl result = new TypeDefinitionListImpl();
List<TypeDefinition> list = new ArrayList<TypeDefinition>();
result.setList(list);
// get the types from the dictionary
List<TypeDefinitionWrapper> childrenList;
if (typeId == null) {
childrenList = connector.getOpenCMISDictionaryService().getBaseTypes(true);
} else {
TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
if (tdw == null) {
throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
}
childrenList = connector.getOpenCMISDictionaryService().getChildren(typeId);
// childrenList = tdw.getChildren();
}
// create result
if (max > 0) {
int lastIndex = (max + skip > childrenList.size() ? childrenList.size() : max + skip) - 1;
for (int i = skip; i <= lastIndex; i++) {
list.add(childrenList.get(i).getTypeDefinition(includePropertyDefinitions));
}
}
result.setHasMoreItems(childrenList.size() - skip > result.getList().size());
result.setNumItems(BigInteger.valueOf(childrenList.size()));
return result;
}
use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method applyAcl.
// --- ACL service ---
@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);
}
use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.
the class CMISChangeLogDataExtractor method isSupported.
/**
* @return Returns <tt>true</tt> if items in the CMIS domain model
* @see org.alfresco.repo.audit.extractor.DataExtractor#isSupported(java.io.Serializable)
*/
public boolean isSupported(Serializable data) {
if (data != null) {
NodeRef nodeRef = getNodeRef(data);
if (nodeRef != null) {
QName typeQName = nodeService.getType(nodeRef);
TypeDefinitionWrapper type = cmisDictionaryService.findNodeType(typeQName);
return (type != null) && (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT || type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER);
}
}
return false;
}
use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.
the class CMISTest method testACE3322.
/**
* ACE-3322
*/
@Test
public void testACE3322() {
final String[] types = { "cmis:document", "cmis:relationship", "cmis:folder", "cmis:item" };
CmisServiceCallback<String> callback = new CmisServiceCallback<String>() {
@Override
public String execute(CmisService cmisService) {
for (int i = 0; i < types.length; i++) {
List<TypeDefinitionWrapper> baseTypes = cmisDictionaryService.getBaseTypes();
assertNotNull(baseTypes);
checkDefs(baseTypes);
List<TypeDefinitionWrapper> children = cmisDictionaryService.getChildren(types[i]);
assertNotNull(children);
// Check that children were updated
checkDefs(children);
}
return "";
}
private void checkDefs(List<TypeDefinitionWrapper> defs) {
for (TypeDefinitionWrapper def : defs) {
assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDisplayName());
assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDescription());
// Check that property's display name and description were updated
for (PropertyDefinitionWrapper property : def.getProperties()) {
assertNotNull("Display name is null", property.getPropertyDefinition().getDisplayName());
assertNotNull("Description is null", property.getPropertyDefinition().getDescription());
}
}
}
};
withCmisService(callback, CmisVersion.CMIS_1_1);
}
Aggregations