use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class FormRestApiJsonPost_Test method testRemoveChildAssociationsFromNode.
/**
* This test method attempts to remove an existing child association between two
* existing nodes.
*/
public void testRemoveChildAssociationsFromNode() throws Exception {
List<NodeRef> associatedNodes;
checkOriginalChildAssocsBeforeChanges();
// Remove an association
JSONObject jsonPostData = new JSONObject();
String assocsToRemove = childDoc_B.toString();
jsonPostData.put(ASSOC_SYS_CHILDREN_REMOVED, assocsToRemove);
String jsonPostString = jsonPostData.toString();
sendRequest(new PostRequest(containingNodeUpdateUrl, jsonPostString, APPLICATION_JSON), 200);
// Check the now updated child associations via the node service
List<ChildAssociationRef> modifiedAssocs = nodeService.getChildAssocs(containerNodeRef);
assertEquals(1, modifiedAssocs.size());
// Extract the target nodeRefs to make them easier to examine
associatedNodes = new ArrayList<NodeRef>(5);
for (ChildAssociationRef assocRef : modifiedAssocs) {
associatedNodes.add(assocRef.getChildRef());
}
assertTrue(associatedNodes.contains(childDoc_A));
// The Rest API should also give us the modified assocs.
/*Response response = sendRequest(new GetRequest(containingNodeUpdateUrl), 200);
String jsonRspString = response.getContentAsString();
JSONObject jsonGetResponse = new JSONObject(jsonRspString);
JSONObject jsonData = (JSONObject)jsonGetResponse.get("data");
assertNotNull(jsonData);
JSONObject jsonFormData = (JSONObject)jsonData.get("formData");
assertNotNull(jsonFormData);
String jsonAssocs = (String)jsonFormData.get(ASSOC_SYS_CHILDREN);
// We expect exactly 1 assoc on the test node
assertEquals(1, jsonAssocs.split(",").length);
for (ChildAssociationRef assocRef : modifiedAssocs)
{
assertTrue(jsonAssocs.contains(assocRef.getChildRef().toString()));
}*/
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class InvitationWebScriptTest method makeAvatar.
public static String makeAvatar(final NodeService nodeService, final NodeRef person) {
nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null);
ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName, ContentModel.TYPE_CONTENT);
NodeRef avatar = assoc.getChildRef();
nodeService.createAssociation(person, avatar, ContentModel.ASSOC_AVATAR);
return "api/node/" + avatar + "/content/thumbnails/avatar";
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class NodeWebScripTest method createNode.
private NodeRef createNode(NodeRef parentNode, String nodeCmName, QName nodeType, String ownerUserName) {
QName childName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, nodeCmName);
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, nodeCmName);
ChildAssociationRef childAssoc = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, childName, nodeType, props);
return childAssoc.getChildRef();
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class NodeLocatorWebScriptTest method makeChildNode.
private NodeRef makeChildNode(NodeRef parent, QName type) {
QName qName = QName.createQName("", GUID.generate());
QName contains = ContentModel.ASSOC_CONTAINS;
ChildAssociationRef result = nodeService.createNode(parent, contains, qName, type);
return result.getChildRef();
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class PersonServiceTest method addTextContent.
private NodeRef addTextContent(NodeRef folderRef, String name, String textData) {
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
contentProps.put(ContentModel.PROP_NAME, name);
ChildAssociationRef association = nodeService.createNode(folderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps);
NodeRef content = association.getChildRef();
ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.setEncoding("UTF-8");
writer.putContent(textData);
return content;
}
Aggregations