protected CmisTestResult assertNotAllowableAction(CmisObject object, Action action, CmisTestResult success, CmisTestResult failure) { AllowableActions allowableActions = object.getAllowableActions(); if (allowableActions != null && allowableActions.getAllowableActions() != null) { if (!allowableActions.getAllowableActions().contains(action)) { return success; } } return failure; }
extensions.put(ExtensionLevel.ALLOWABLE_ACTIONS, objectData.getAllowableActions().getExtensions()); } else { allowableActions = null;
extensions.put(ExtensionLevel.ALLOWABLE_ACTIONS, objectData.getAllowableActions().getExtensions()); } else { allowableActions = null;
protected CmisTestResult assertAllowableAction(CmisObject object, Action action, CmisTestResult success, CmisTestResult failure) { AllowableActions allowableActions = object.getAllowableActions(); if (allowableActions != null && allowableActions.getAllowableActions() != null) { if (allowableActions.getAllowableActions().contains(action)) { return success; } } return failure; }
@Override public boolean hasAllowableAction(Action action) { if (action == null) { throw new IllegalArgumentException("Action must be set!"); } AllowableActions currentAllowableActions = getAllowableActions(); if (currentAllowableActions == null || currentAllowableActions.getAllowableActions() == null) { throw new IllegalStateException("Allowable Actions are not available!"); } return currentAllowableActions.getAllowableActions().contains(action); }
@Override public boolean hasAllowableAction(Action action) { if (action == null) { throw new IllegalArgumentException("Action must be set!"); } AllowableActions currentAllowableActions = getAllowableActions(); if (currentAllowableActions == null || currentAllowableActions.getAllowableActions() == null) { throw new IllegalStateException("Allowable Actions are not available!"); } return currentAllowableActions.getAllowableActions().contains(action); }
public static void writeAllowableActions(XMLStreamWriter writer, CmisVersion cmisVersion, boolean root, AllowableActions source) throws XMLStreamException { if (source == null) { return; } if (root) { writer.writeStartElement(PREFIX_CMIS, "allowableActions", NAMESPACE_CMIS); writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS); } else { writer.writeStartElement(PREFIX_CMIS, TAG_OBJECT_ALLOWABLE_ACTIONS, NAMESPACE_CMIS); } if (source.getAllowableActions() != null) { for (Action action : Action.values()) { if (source.getAllowableActions().contains(action)) { if (action == Action.CAN_CREATE_ITEM && cmisVersion == CmisVersion.CMIS_1_0) { LOG.warn("Receiver only understands CMIS 1.0 but the Allowable Actions contain the canCreateItem action. " + "The canCreateItem action has been removed from the Allowable Actions."); continue; } XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, action.value(), Boolean.TRUE); } } } writeExtensions(writer, source); writer.writeEndElement(); }
private boolean needsCheckOut(Document doc) { DocumentTypeDefinition type = (DocumentTypeDefinition) doc.getType(); PropertyDefinition<?> secTypeIdsPropDef = type.getPropertyDefinitions().get( PropertyIds.SECONDARY_OBJECT_TYPE_IDS); return secTypeIdsPropDef.getUpdatability() == Updatability.WHENCHECKEDOUT || (!doc.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES) && Boolean.TRUE .equals(type.isVersionable())); }
/** * Converts allowable actions. */ public static JSONObject convert(final AllowableActions allowableActions) { if (allowableActions == null) { return null; } JSONObject result = new JSONObject(); Set<Action> actionSet = allowableActions.getAllowableActions(); for (Action action : Action.values()) { result.put(action.value(), actionSet.contains(action)); } convertExtension(allowableActions, result); return result; }
public static void writeAllowableActions(XmlSerializer writer, CmisVersion cmisVersion, boolean root, AllowableActions source) throws IOException { if (source == null) { return; } if (root) { writer.startTag(NAMESPACE_CMIS, "allowableActions"); writer.attribute("", PREFIX_CMIS, NAMESPACE_CMIS); } else { writer.startTag(NAMESPACE_CMIS, TAG_OBJECT_ALLOWABLE_ACTIONS); } if (source.getAllowableActions() != null) { for (Action action : Action.values()) { if (source.getAllowableActions().contains(action)) { if (action == Action.CAN_CREATE_ITEM && cmisVersion == CmisVersion.CMIS_1_0) { LOG.warn("Receiver only understands CMIS 1.0 but the Allowable Actions contain the canCreateItem action. " + "The canCreateItem action has been removed from the Allowable Actions."); continue; } XMLUtils.write(writer, PREFIX_CMIS, NAMESPACE_CMIS, action.value(), Boolean.TRUE); } } } writeExtensions(writer, source); writer.endTag(NAMESPACE_CMIS, TAG_OBJECT_ALLOWABLE_ACTIONS); }
/** * Converts allowable actions. */ public static JSONObject convert(final AllowableActions allowableActions) { if (allowableActions == null) { return null; } JSONObject result = new JSONObject(); Set<Action> actionSet = allowableActions.getAllowableActions(); for (Action action : Action.values()) { result.put(action.value(), actionSet.contains(action)); } convertExtension(allowableActions, result); return result; }
if (allowableActions.getAllowableActions() != null) { Set<Action> set = allowableActions.getAllowableActions();
private void runUpdateFolderTest(Session session, Folder testFolder) { Folder folder = createFolder(session, testFolder, "folder1"); try { if (folder.getChangeToken() == null) { addResult(createResult(SKIPPED, "Repository does not provide change tokens for folders. Test skipped!")); return; } if (!folder.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)) { addResult(createResult(SKIPPED, "Folder name can't be changed. Test skipped!")); return; } // the first update should succeed Map<String, Object> properties2 = new HashMap<String, Object>(); properties2.put(PropertyIds.NAME, "folder2"); folder.updateProperties(properties2, false); try { Map<String, Object> properties3 = new HashMap<String, Object>(); properties3.put(PropertyIds.NAME, "folder3"); folder.updateProperties(properties3, false); addResult(createResult(FAILURE, "Updating properties a second time with the same change token " + "should result in an UpdateConflict exception!")); } catch (CmisUpdateConflictException e) { // expected exception } } finally { deleteObject(folder); } }
addResult(results, assertEqualSet(expected.getAllowableActions(), actual.getAllowableActions(), null, f));
private void runAddChildFolderTest(Session session, Folder testFolder) { Folder folder = createFolder(session, testFolder, "folder1"); try { if (folder.getChangeToken() == null) { addResult(createResult(SKIPPED, "Repository does not provide change tokens for folders. Test skipped!")); return; } if (!folder.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)) { addResult(createResult(SKIPPED, "Folder name can't be changed. Test skipped!")); return; } createDocument(session, folder, "doc1", "content"); try { Map<String, Object> properties2 = new HashMap<String, Object>(); properties2.put(PropertyIds.NAME, "folder2"); folder.updateProperties(properties2, false); } catch (CmisUpdateConflictException e) { addResult(createResult(WARNING, "Adding a child to a folder changes the change token of the folder. " + "CMIS clients might not expect that.")); } } finally { deleteObject(folder); } } }
PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME); if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT || !doc.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)) { addResult(createResult(SKIPPED, "Document name can't be changed. Test skipped!")); return;
PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME); if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT || (!doc1.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES) && Boolean.TRUE .equals(type.isVersionable()))) { workDoc = (Document) session.getObject(doc1.checkOut(), SELECT_ALL_NO_CACHE_OC);
if (!doc.getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM)) { addResult(createResult(SKIPPED, "Document content can't be changed. Test skipped!")); return;
@Override public Void execute(CmisService cmisService) { try { // check allowable actions ObjectData originalDoc = cmisService.getObject(testContext.getRepositoryId(), objectData.getId(), null, true, IncludeRelationships.NONE, null, false, true, null); AllowableActions allowableActions = originalDoc.getAllowableActions(); assertNotNull(allowableActions); assertFalse(allowableActions.getAllowableActions().contains(Action.CAN_DELETE_OBJECT)); // try to cancel the checkout cmisService.deleteObjectOrCancelCheckOut(testContext.getRepositoryId(), objectData.getId(), Boolean.TRUE, null); fail(); } catch(CmisConstraintException e) { // expected } return null; } });
|| (object.getAllowableActions().getAllowableActions() == null)) { addResult(results, createResult(FAILURE, "Object has no allowable actions!")); } else { Set<Action> actions = object.getAllowableActions().getAllowableActions(); .getAllowableActions(session.getRepositoryInfo().getId(), object.getId(), null); if (allowableActions.getAllowableActions() == null) { addResult(results, createResult(FAILURE, "getAllowableActions() didn't returned allowable actions!")); f = createResult(FAILURE, "Object allowable actions don't match the allowable actions returned by getAllowableActions()!"); addResult(results, assertEqualSet(object.getAllowableActions().getAllowableActions(), allowableActions.getAllowableActions(), null, f));