Search in sources :

Example 6 with AssocChild

use of org.alfresco.rest.api.model.AssocChild in project records-management by Alfresco.

the class ApiNodesModelFactory method mapAssociations.

/**
 * Utility method that maps associations, applicable only for records
 *
 * @param rmNode
 * @param info
 * @param includeParam
 */
private void mapAssociations(RMNode rmNode, FileInfo info, List<String> includeParam) {
    if (includeParam.contains(RMNode.PARAM_INCLUDE_ASSOCIATION)) {
        NodeRef nodeRef = info.getNodeRef();
        ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
        if ((parentAssocRef == null) || (parentAssocRef.getParentRef() == null) || (!parentAssocRef.getParentRef().equals(rmNode.getParentId()))) {
            List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(nodeRef);
            for (ChildAssociationRef pAssocRef : parentAssocRefs) {
                if (pAssocRef.getParentRef().equals(rmNode.getParentId())) {
                    // for now, assume same parent/child cannot appear more than once (due to unique name)
                    parentAssocRef = pAssocRef;
                    break;
                }
            }
        }
        if (parentAssocRef != null) {
            QName assocTypeQName = parentAssocRef.getTypeQName();
            if ((assocTypeQName != null) && (!EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI()))) {
                AssocChild childAssoc = new AssocChild(assocTypeQName.toPrefixString(namespaceService), parentAssocRef.isPrimary());
                rmNode.setAssociation(childAssoc);
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) AssocChild(org.alfresco.rest.api.model.AssocChild) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 7 with AssocChild

use of org.alfresco.rest.api.model.AssocChild in project alfresco-remote-api by Alfresco.

the class NodesImpl method getFolderOrDocument.

@Override
public Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List<String> includeParam, Map<String, UserInfo> mapUserInfo) {
    if (mapUserInfo == null) {
        mapUserInfo = new HashMap<>(2);
    }
    if (includeParam == null) {
        includeParam = Collections.emptyList();
    }
    Node node;
    Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
    PathInfo pathInfo = null;
    if (includeParam.contains(PARAM_INCLUDE_PATH)) {
        ChildAssociationRef archivedParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
        pathInfo = lookupPathInfo(nodeRef, archivedParentAssoc);
    }
    if (nodeTypeQName == null) {
        nodeTypeQName = getNodeType(nodeRef);
    }
    if (parentNodeRef == null) {
        parentNodeRef = getParentNodeRef(nodeRef);
    }
    Type type = getType(nodeTypeQName, nodeRef);
    if (type == null) {
        // not direct folder (or file) ...
        // might be sub-type of cm:cmobject (or a cm:link pointing to cm:cmobject or possibly even another cm:link)
        node = new Node(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
        node.setIsFolder(false);
        node.setIsFile(false);
    } else if (type.equals(Type.DOCUMENT)) {
        node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
    } else if (type.equals(Type.FOLDER)) {
        node = new Folder(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
    } else {
        throw new RuntimeException("Unexpected - should not reach here: " + type);
    }
    if (includeParam.size() > 0) {
        node.setProperties(mapFromNodeProperties(properties, includeParam, mapUserInfo, EXCLUDED_NS, EXCLUDED_PROPS));
    }
    Set<QName> aspects = null;
    if (includeParam.contains(PARAM_INCLUDE_ASPECTNAMES)) {
        aspects = nodeService.getAspects(nodeRef);
        node.setAspectNames(mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS));
    }
    if (includeParam.contains(PARAM_INCLUDE_ISLINK)) {
        boolean isLink = isSubClass(nodeTypeQName, ContentModel.TYPE_LINK);
        node.setIsLink(isLink);
    }
    if (includeParam.contains(PARAM_INCLUDE_ISLOCKED)) {
        boolean isLocked = isLocked(nodeRef, aspects);
        node.setIsLocked(isLocked);
    }
    if (includeParam.contains(PARAM_INCLUDE_ISFAVORITE)) {
        boolean isFavorite = isFavorite(nodeRef);
        node.setIsFavorite(isFavorite);
    }
    if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS)) {
        // note: refactor when requirements change
        Map<String, String> mapPermsToOps = new HashMap<>(3);
        mapPermsToOps.put(PermissionService.DELETE, OP_DELETE);
        mapPermsToOps.put(PermissionService.ADD_CHILDREN, OP_CREATE);
        mapPermsToOps.put(PermissionService.WRITE, OP_UPDATE);
        mapPermsToOps.put(PermissionService.CHANGE_PERMISSIONS, OP_UPDATE_PERMISSIONS);
        List<String> allowableOperations = new ArrayList<>(3);
        for (Entry<String, String> kv : mapPermsToOps.entrySet()) {
            String perm = kv.getKey();
            String op = kv.getValue();
            if (perm.equals(PermissionService.ADD_CHILDREN) && Type.DOCUMENT.equals(type)) {
                // special case: do not return "create" (as an allowable op) for file/content types - note: 'type' can be null
                continue;
            } else if (perm.equals(PermissionService.DELETE) && (isSpecialNode(nodeRef, nodeTypeQName))) {
                // special case: do not return "delete" (as an allowable op) for specific system nodes
                continue;
            } else if (permissionService.hasPermission(nodeRef, perm) == AccessStatus.ALLOWED) {
                allowableOperations.add(op);
            }
        }
        node.setAllowableOperations((allowableOperations.size() > 0) ? allowableOperations : null);
    }
    if (includeParam.contains(PARAM_INCLUDE_PERMISSIONS)) {
        Boolean inherit = permissionService.getInheritParentPermissions(nodeRef);
        List<NodePermissions.NodePermission> inheritedPerms = new ArrayList<>(5);
        List<NodePermissions.NodePermission> setDirectlyPerms = new ArrayList<>(5);
        Set<String> settablePerms = null;
        boolean allowRetrievePermission = true;
        try {
            for (AccessPermission accessPerm : permissionService.getAllSetPermissions(nodeRef)) {
                NodePermissions.NodePermission nodePerm = new NodePermissions.NodePermission(accessPerm.getAuthority(), accessPerm.getPermission(), accessPerm.getAccessStatus().toString());
                if (accessPerm.isSetDirectly()) {
                    setDirectlyPerms.add(nodePerm);
                } else {
                    inheritedPerms.add(nodePerm);
                }
            }
            settablePerms = permissionService.getSettablePermissions(nodeRef);
        } catch (AccessDeniedException ade) {
            // ignore - ie. denied access to retrieve permissions, eg. non-admin on root (Company Home)
            allowRetrievePermission = false;
        }
        // returned only node info that he's allowed to see
        if (allowRetrievePermission) {
            NodePermissions nodePerms = new NodePermissions(inherit, inheritedPerms, setDirectlyPerms, settablePerms);
            node.setPermissions(nodePerms);
        }
    }
    if (includeParam.contains(PARAM_INCLUDE_ASSOCIATION)) {
        // Ugh ... can we optimise this and return the actual assoc directly (via FileFolderService/GetChildrenCQ) ?
        ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
        // note: parentAssocRef.parentRef can be null for -root- node !
        if ((parentAssocRef == null) || (parentAssocRef.getParentRef() == null) || (!parentAssocRef.getParentRef().equals(parentNodeRef))) {
            List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(nodeRef);
            for (ChildAssociationRef pAssocRef : parentAssocRefs) {
                if (pAssocRef.getParentRef().equals(parentNodeRef)) {
                    // for now, assume same parent/child cannot appear more than once (due to unique name)
                    parentAssocRef = pAssocRef;
                    break;
                }
            }
        }
        if (parentAssocRef != null) {
            QName assocTypeQName = parentAssocRef.getTypeQName();
            if ((assocTypeQName != null) && (!EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI()))) {
                AssocChild childAssoc = new AssocChild(assocTypeQName.toPrefixString(namespaceService), parentAssocRef.isPrimary());
                node.setAssociation(childAssoc);
            }
        }
    }
    node.setNodeType(nodeTypeQName.toPrefixString(namespaceService));
    node.setPath(pathInfo);
    return node;
}
Also used : Serializable(java.io.Serializable) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) NodePermissions(org.alfresco.rest.api.model.NodePermissions) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Node(org.alfresco.rest.api.model.Node) ArrayList(java.util.ArrayList) AssocChild(org.alfresco.rest.api.model.AssocChild) Document(org.alfresco.rest.api.model.Document) Folder(org.alfresco.rest.api.model.Folder) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean) QName(org.alfresco.service.namespace.QName) AccessPermission(org.alfresco.service.cmr.security.AccessPermission) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) VersionType(org.alfresco.service.cmr.version.VersionType) ActivityType(org.alfresco.repo.activities.ActivityType) PathInfo(org.alfresco.rest.api.model.PathInfo)

Example 8 with AssocChild

use of org.alfresco.rest.api.model.AssocChild in project alfresco-remote-api by Alfresco.

the class NodeAssociationsApiTest method testCreateNodeWithAssocs.

/**
 * Test ability to create a node and optionally specify one or more associations (to other existing nodes) at time of create.
 *
 * @throws Exception
 */
@Test
public void testCreateNodeWithAssocs() throws Exception {
    // as user 1
    setRequestContext(user1);
    String myFolderNodeId = getMyNodeId();
    // create node with some assocs in a single call
    // create folder
    Node n = new Node();
    n.setName("f1");
    n.setNodeType(TYPE_CM_FOLDER);
    n.setAspectNames(Arrays.asList(ASPECT_CM_PREFERENCES));
    HttpResponse response = post(getNodeChildrenUrl(myFolderNodeId), toJsonAsStringNonNull(n), 201);
    String f1Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
    // create content node
    String o1Name = "o1";
    n = new Node();
    n.setName(o1Name);
    n.setNodeType(TYPE_CM_CONTENT);
    response = post(getNodeChildrenUrl(f1Id), toJsonAsStringNonNull(n), 201);
    String o1Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
    String o2Name = "o2";
    n = new Node();
    n.setName(o2Name);
    n.setNodeType(TYPE_CM_CONTENT);
    response = post(getNodeChildrenUrl(f1Id), toJsonAsStringNonNull(n), 201);
    String o2Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
    // create folder node with some assocs
    String f2Name = "f2";
    n = new Node();
    n.setName(f2Name);
    n.setNodeType(TYPE_CM_FOLDER);
    AssocChild secChild = new AssocChild(o1Id, ASSOC_TYPE_CM_CONTAINS);
    n.setSecondaryChildren(Collections.singletonList(secChild));
    AssocTarget tgt = new AssocTarget(o2Id, ASSOC_TYPE_CM_REFERENCES);
    n.setTargets(Collections.singletonList(tgt));
    response = post(getNodeChildrenUrl(myFolderNodeId), toJsonAsStringNonNull(n), 201);
    String f2Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
    String f3Id = createFolder(myFolderNodeId, "f3").getId();
    try {
        Paging paging = getPaging(0, 100);
        response = getAll(getNodeSecondaryChildrenUrl(f2Id), paging, null, 200);
        List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(o1Id, nodes.get(0).getId());
        response = getAll(getNodeTargetsUrl(f2Id), paging, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(o2Id, nodes.get(0).getId());
        // TODO test model with mandatory aspect
        // -ve test -  minor: error code if creating a cyclic child assoc (REPO-475)
        n = new Node();
        n.setName("my-folder");
        n.setNodeType(TYPE_CM_FOLDER);
        AssocChild assocChild = new AssocChild(myFolderNodeId, "cm:contains");
        n.setSecondaryChildren(Collections.singletonList(assocChild));
        post(getNodeChildrenUrl(myFolderNodeId), RestApiUtil.toJsonAsStringNonNull(n), 400);
        // -ve tests - missing targetId / childId or assocType
        n = new Node();
        n.setName("my-folder");
        n.setNodeType(TYPE_CM_FOLDER);
        assocChild = new AssocChild(null, ASSOC_TYPE_CM_CONTAINS);
        n.setSecondaryChildren(Collections.singletonList(assocChild));
        post(getNodeChildrenUrl(f3Id), RestApiUtil.toJsonAsStringNonNull(n), 400);
        n = new Node();
        n.setName("my-folder");
        n.setNodeType(TYPE_CM_FOLDER);
        assocChild = new AssocChild(f2Id, null);
        n.setSecondaryChildren(Collections.singletonList(assocChild));
        post(getNodeChildrenUrl(f3Id), RestApiUtil.toJsonAsStringNonNull(n), 400);
        n = new Node();
        n.setName("my-folder");
        n.setNodeType(TYPE_CM_FOLDER);
        tgt = new AssocTarget(null, ASSOC_TYPE_CM_REFERENCES);
        n.setTargets(Collections.singletonList(tgt));
        post(getNodeChildrenUrl(f3Id), RestApiUtil.toJsonAsStringNonNull(n), 400);
        n = new Node();
        n.setName("my-folder");
        n.setNodeType(TYPE_CM_FOLDER);
        tgt = new AssocTarget(f2Id, null);
        n.setTargets(Collections.singletonList(tgt));
        post(getNodeChildrenUrl(f3Id), RestApiUtil.toJsonAsStringNonNull(n), 400);
    } finally {
        // some cleanup
        setRequestContext(user1);
        deleteNode(f1Id, true, 204);
        deleteNode(f2Id, true, 204);
        deleteNode(f3Id, true, 204);
    }
}
Also used : Node(org.alfresco.rest.api.tests.client.data.Node) Paging(org.alfresco.rest.api.tests.client.PublicApiClient.Paging) AssocChild(org.alfresco.rest.api.model.AssocChild) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) AssocTarget(org.alfresco.rest.api.model.AssocTarget) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Example 9 with AssocChild

use of org.alfresco.rest.api.model.AssocChild in project alfresco-remote-api by Alfresco.

the class NodeAssociationsApiTest method testDeleteAndRestoreNodeWithAssocs.

/**
 * Test ability to delete a node with associations (to and from the node) and then restore it.
 * Only the primary parent/child assoc(s) for the deleted node(s) is/are restored.
 *
 * @throws Exception
 */
@Test
public void testDeleteAndRestoreNodeWithAssocs() throws Exception {
    // as user 1 ...
    setRequestContext(user1);
    String f1Id = null;
    String f2Id = null;
    String f3Id = null;
    try {
        String myFolderNodeId = getMyNodeId();
        // create primary parent-child hierarchy
        f1Id = createFolder(myFolderNodeId, "f1").getId();
        String f1bId = createFolder(f1Id, "f1b").getId();
        String f1cId = createFolder(f1bId, "f1c").getId();
        String f1dId = createFolder(f1cId, "f1d").getId();
        String c1eId = createTextFile(f1dId, "c1e", "some text content").getId();
        f2Id = createFolder(myFolderNodeId, "f2").getId();
        f3Id = createFolder(myFolderNodeId, "f3").getId();
        HttpResponse response = getAll(getNodeParentsUrl(f1bId), null, null, 200);
        List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1Id, nodes.get(0).getId());
        response = getAll(getNodeParentsUrl(f1dId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1cId, nodes.get(0).getId());
        response = getAll(getNodeSourcesUrl(c1eId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        // add some secondary parent/child assocs outside of the hierarchy
        AssocChild secChild = new AssocChild(f1bId, ASSOC_TYPE_CM_CONTAINS);
        post(getNodeSecondaryChildrenUrl(f2Id), toJsonAsStringNonNull(secChild), 201);
        secChild = new AssocChild(f1bId, ASSOC_TYPE_CM_CONTAINS);
        post(getNodeSecondaryChildrenUrl(f3Id), toJsonAsStringNonNull(secChild), 201);
        secChild = new AssocChild(f1dId, ASSOC_TYPE_CM_CONTAINS);
        post(getNodeSecondaryChildrenUrl(f2Id), toJsonAsStringNonNull(secChild), 201);
        secChild = new AssocChild(f1dId, ASSOC_TYPE_CM_CONTAINS);
        post(getNodeSecondaryChildrenUrl(f3Id), toJsonAsStringNonNull(secChild), 201);
        // also add a secondary parent/child assoc within the hierarchy
        secChild = new AssocChild(f1dId, ASSOC_TYPE_CM_CONTAINS);
        post(getNodeSecondaryChildrenUrl(f1bId), toJsonAsStringNonNull(secChild), 201);
        // add some peer assocs outside of the hierarchy
        AssocTarget tgt = new AssocTarget(c1eId, ASSOC_TYPE_CM_REFERENCES);
        post(getNodeTargetsUrl(f2Id), toJsonAsStringNonNull(tgt), 201);
        tgt = new AssocTarget(c1eId, ASSOC_TYPE_CM_PARTS);
        post(getNodeTargetsUrl(f3Id), toJsonAsStringNonNull(tgt), 201);
        // also add a peer assoc within the hierarchy
        tgt = new AssocTarget(c1eId, ASSOC_TYPE_CM_PARTS);
        post(getNodeTargetsUrl(f1cId), toJsonAsStringNonNull(tgt), 201);
        // double-check the secondary parent/child assocs
        response = getAll(getNodeParentsUrl(f1bId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(3, nodes.size());
        response = getAll(getNodeParentsUrl(f1dId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(4, nodes.size());
        response = getAll(getNodeSecondaryChildrenUrl(f2Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(2, nodes.size());
        List<String> nodeIds = Arrays.asList(new String[] { nodes.get(0).getId(), nodes.get(1).getId() });
        assertTrue(nodeIds.contains(f1bId));
        assertTrue(nodeIds.contains(f1dId));
        response = getAll(getNodeSecondaryChildrenUrl(f3Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(2, nodes.size());
        nodeIds = Arrays.asList(new String[] { nodes.get(0).getId(), nodes.get(1).getId() });
        assertTrue(nodeIds.contains(f1bId));
        assertTrue(nodeIds.contains(f1dId));
        response = getAll(getNodeSecondaryChildrenUrl(f1bId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1dId, nodes.get(0).getId());
        // double-check the peer assocs
        response = getAll(getNodeSourcesUrl(c1eId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(3, nodes.size());
        response = getAll(getNodeTargetsUrl(f2Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(c1eId, nodes.get(0).getId());
        response = getAll(getNodeTargetsUrl(f3Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(c1eId, nodes.get(0).getId());
        response = getAll(getNodeTargetsUrl(f1cId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(c1eId, nodes.get(0).getId());
        // ... delete to trashcan/archive ...
        deleteNode(f1bId);
        getSingle(NodesEntityResource.class, f1bId, null, 404);
        response = getAll(getNodeTargetsUrl(f2Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        response = getAll(getNodeTargetsUrl(f3Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        // ... and then restore again ...
        post(URL_DELETED_NODES + "/" + f1bId + "/restore", null, null, 200);
        // check primary parent-child hierarchy is restored
        // but not the secondary parents or peer assocs of the deleted nodes (outside or within the hierarchy)
        response = getSingle(NodesEntityResource.class, f1bId, null, 200);
        Node nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
        assertEquals(f1Id, nodeResp.getParentId());
        response = getSingle(NodesEntityResource.class, f1cId, null, 200);
        nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
        assertEquals(f1bId, nodeResp.getParentId());
        response = getSingle(NodesEntityResource.class, f1dId, null, 200);
        nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
        assertEquals(f1cId, nodeResp.getParentId());
        // secondary child assocs have not been restored
        response = getAll(getNodeParentsUrl(f1bId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1Id, nodes.get(0).getId());
        response = getAll(getNodeParentsUrl(f1cId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1bId, nodes.get(0).getId());
        response = getAll(getNodeParentsUrl(f1dId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        assertEquals(f1cId, nodes.get(0).getId());
        response = getAll(getNodeSecondaryChildrenUrl(f2Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        response = getAll(getNodeSecondaryChildrenUrl(f3Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        // peer assocs have not been restored
        response = getAll(getNodeSourcesUrl(c1eId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        response = getAll(getNodeTargetsUrl(f1cId), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        response = getAll(getNodeTargetsUrl(f2Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        response = getAll(getNodeTargetsUrl(f3Id), null, null, 200);
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
    } finally {
        // some cleanup
        setRequestContext(user1);
        if (f1Id != null) {
            deleteNode(f1Id, true, 204);
        }
        if (f2Id != null) {
            deleteNode(f2Id, true, 204);
        }
        if (f3Id != null) {
            deleteNode(f3Id, true, 204);
        }
    }
}
Also used : Node(org.alfresco.rest.api.tests.client.data.Node) AssocChild(org.alfresco.rest.api.model.AssocChild) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) NodesEntityResource(org.alfresco.rest.api.nodes.NodesEntityResource) AssocTarget(org.alfresco.rest.api.model.AssocTarget) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Aggregations

AssocChild (org.alfresco.rest.api.model.AssocChild)9 ArrayList (java.util.ArrayList)4 AbstractSingleNetworkSiteTest (org.alfresco.rest.AbstractSingleNetworkSiteTest)4 HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)4 Node (org.alfresco.rest.api.tests.client.data.Node)4 QName (org.alfresco.service.namespace.QName)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)3 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 AssocTarget (org.alfresco.rest.api.model.AssocTarget)2 Node (org.alfresco.rest.api.model.Node)2 Document (org.alfresco.rest.api.tests.client.data.Document)2 Serializable (java.io.Serializable)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ActivityType (org.alfresco.repo.activities.ActivityType)1 FilterPropBoolean (org.alfresco.repo.node.getchildren.FilterPropBoolean)1 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)1