use of org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl in project copper-cms by PogeyanOSS.
the class ObjectActor method bulkUpdate.
private JSONArray bulkUpdate(PostRequest request) throws CmisInvalidArgumentException, CmisRuntimeException {
// get object ids and change tokens
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken = new ArrayList<BulkUpdateObjectIdAndChangeToken>();
List<String> objectIds = request.getObjectIds();
List<String> changeTokens = request.getChangeTokens();
if (CmisPropertyConverter.Impl.isNullOrEmpty(objectIds)) {
throw new CmisInvalidArgumentException("No object ids provided!");
}
int n = objectIds.size();
for (int i = 0; i < n; i++) {
String id = objectIds.get(i);
String changeToken = (changeTokens != null && changeTokens.size() > i ? changeTokens.get(i) : null);
if (changeToken != null && changeToken.length() == 0) {
changeToken = null;
}
objectIdAndChangeToken.add(new BulkUpdateObjectIdAndChangeTokenImpl(id, changeToken));
}
// get secondary type ids
List<String> addSecondaryTypes = request.getAddSecondaryTypes();
List<String> removeSecondaryTypes = request.getRemoveSecondaryTypes();
Properties properties = CmisPropertyConverter.Impl.createUpdateProperties(request.getPropertyData(), null, addSecondaryTypes, objectIds, request.getRepositoryId(), null);
List<BulkUpdateObjectIdAndChangeToken> result = CmisObjectService.Impl.bulkUpdateProperties(request.getRepositoryId(), objectIdAndChangeToken, properties, addSecondaryTypes, removeSecondaryTypes, null, request.getUserObject());
// return result
JSONArray jsonList = new JSONArray();
if (result != null) {
for (BulkUpdateObjectIdAndChangeToken oc : result) {
if (oc != null) {
jsonList.add(JSONConverter.convert(oc));
}
}
}
return jsonList;
}
Aggregations