use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getAcl.
@SuppressWarnings("unchecked")
@Override
public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
if (info.isVariant(CMISObjectVariant.ASSOC)) {
return new AccessControlListImpl(Collections.EMPTY_LIST);
}
// get the ACL
return connector.getACL(info.getCurrentNodeNodeRef(), onlyBasicPermissions);
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method bulkUpdateProperties.
@Override
public List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(final String repositoryId, List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeTokens, final Properties properties, final List<String> addSecondaryTypeIds, final List<String> removeSecondaryTypeIds, ExtensionsData extension) {
checkRepositoryId(repositoryId);
if (objectIdAndChangeTokens.size() > connector.getBulkMaxItems()) {
throw new CmisConstraintException("Bulk update not supported for more than " + connector.getBulkMaxItems() + " objects.");
}
// MNT-16376 We need the CMIS call context from this thread to set
// to the working threads below, in order to correctly identify
// the CMIS version protocol used for this CMIS call
final CallContext cmisCallContext = AlfrescoCmisServiceCall.get();
// WorkProvider
class WorkProvider implements BatchProcessWorkProvider<BulkEntry> {
private final Iterator<BulkUpdateObjectIdAndChangeToken> iterator;
private final int size;
private final int batchSize;
private BulkUpdateContext context;
public WorkProvider(List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeTokens, BulkUpdateContext context, int batchSize) {
this.iterator = objectIdAndChangeTokens.iterator();
this.size = objectIdAndChangeTokens.size();
this.context = context;
this.batchSize = batchSize;
}
@Override
public synchronized int getTotalEstimatedWorkSize() {
return size;
}
@Override
public synchronized Collection<BulkEntry> getNextWork() {
Collection<BulkEntry> results = new ArrayList<BulkEntry>(batchSize);
while (results.size() < batchSize && iterator.hasNext()) {
results.add(new BulkEntry(context, iterator.next(), properties, addSecondaryTypeIds, removeSecondaryTypeIds, getContext().isObjectInfoRequired()));
}
return results;
}
}
BulkUpdateContext context = new BulkUpdateContext(objectIdAndChangeTokens.size());
RetryingTransactionHelper helper = connector.getRetryingTransactionHelper();
final String runAsUser = AuthenticationUtil.getRunAsUser();
// Worker
BatchProcessWorker<BulkEntry> worker = new BatchProcessWorker<BulkEntry>() {
@Override
public void process(final BulkEntry entry) throws Throwable {
entry.update();
}
public String getIdentifier(BulkEntry entry) {
return entry.getObjectIdAndChangeToken().getId();
}
@Override
public void beforeProcess() throws Throwable {
// Authentication
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(runAsUser);
AlfrescoCmisServiceCall.set(cmisCallContext);
}
@Override
public void afterProcess() throws Throwable {
// Clear authentication
AuthenticationUtil.popAuthentication();
}
};
// Processor
BatchProcessor<BulkEntry> processor = new BatchProcessor<BulkEntry>("CMISbulkUpdateProperties", helper, new WorkProvider(objectIdAndChangeTokens, context, connector.getBulkBatchSize()), connector.getBulkWorkerThreads(), connector.getBulkBatchSize(), null, logger, 100);
processor.process(worker, true);
for (CMISNodeInfo info : context.getSuccesses()) {
NodeRef nodeRef = info.getNodeRef();
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
}
return context.getChanges();
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo 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.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getObjectInfo.
protected ObjectInfo getObjectInfo(String repositoryId, String objectId, String filter, IncludeRelationships includeRelationships) {
ObjectInfo info = objectInfoMap.get(objectId);
if (info == null) {
CMISNodeInfo nodeInfo = getOrCreateNodeInfo(objectId);
if (nodeInfo.getObjectVariant() == CMISObjectVariant.INVALID_ID || nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_EXISTING || nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_A_CMIS_OBJECT || nodeInfo.getObjectVariant() == CMISObjectVariant.PERMISSION_DENIED) {
info = null;
} else {
// object info has not been found -> create one
try {
if (filter == null) {
filter = MIN_FILTER;
} else if (!filter.equals("*")) {
filter = filter + "," + MIN_FILTER;
}
// get the object and its info
ObjectData object = connector.createCMISObject(nodeInfo, filter, false, includeRelationships, null, false, false);
info = getObjectInfoIntern(repositoryId, object);
// add object info
objectInfoMap.put(objectId, info);
} catch (Exception e) {
e.printStackTrace();
info = null;
}
}
}
return info;
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getProperties.
@Override
public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired) {
getObjectInfo(repositoryId, info.getObjectId(), IncludeRelationships.NONE);
}
if (info.isVariant(CMISObjectVariant.ASSOC)) {
return connector.getAssocProperties(info, filter);
} else {
return connector.getNodeProperties(info, filter);
}
}
Aggregations