Search in sources :

Example 31 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class QueriesSitesApiTest method getNodeRef.

private NodeRef getNodeRef(String createdSiteId) {
    AuthenticationUtil.setFullyAuthenticatedUser(user1);
    // The following call to siteService.getSite(createdSiteId).getNodeRef() returns a NodeRef like:
    // workspace://SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
    // We call tenantService.getName(nodeRef) to get a fully qualified NodeRef as Solr returns this.
    // They look like:
    // workspace://@org.alfresco.rest.api.tests.queriespeopleapitest@SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
    NodeRef nodeRef = siteService.getSite(createdSiteId).getNodeRef();
    nodeRef = tenantService.getName(nodeRef);
    return nodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef)

Example 32 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class QueriesSitesApiTest method checkApiCall.

// Note expectedIds defaults to ids
private void checkApiCall(String term, String orderBy, Paging paging, int expectedStatus, String[] expectedIds, String... ids) throws Exception {
    Map<String, String> params = new HashMap<>(1);
    params.put(Queries.PARAM_TERM, "\"" + term + "\"");
    if (orderBy != null) {
        params.put(Queries.PARAM_ORDERBY, orderBy);
    }
    dummySearchServiceQueryNodeRefs.clear();
    for (String id : ids) {
        NodeRef nodeRef = getNodeRef(id);
        dummySearchServiceQueryNodeRefs.add(nodeRef);
    }
    expectedIds = expectedIds != null ? expectedIds : ids;
    HttpResponse response = getAll(URL_QUERIES_LSS, paging, params, 200);
    if (expectedStatus == 200) {
        String termWithEscapedAsterisks = term.replaceAll("\\*", "\\\\*");
        String expectedQuery = "TYPE:\"{http://www.alfresco.org/model/site/1.0}site\" AND (\"*" + termWithEscapedAsterisks + "*\")";
        ArgumentCaptor<SearchParameters> searchParametersCaptor = ArgumentCaptor.forClass(SearchParameters.class);
        verify(mockSearchService, times(++callCountToMockSearchService)).query(searchParametersCaptor.capture());
        SearchParameters parameters = searchParametersCaptor.getValue();
        assertEquals("Query", expectedQuery, parameters.getQuery());
        List<Site> sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
        assertEquals(expectedIds.length, sites.size());
        if (orderBy != null) {
            for (int i = 0; i < expectedIds.length; i++) {
                String id = expectedIds[i];
                String actualId = sites.get(i).getId();
                assertEquals("Order " + i + ":", id, actualId);
            }
        }
    }
}
Also used : Site(org.alfresco.rest.api.model.Site) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) HashMap(java.util.HashMap) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 33 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class RepoService method getActivitySummary.

@SuppressWarnings("unchecked")
public Map<String, Object> getActivitySummary(ActivityFeedEntity entity) throws JSONException {
    Map<String, Object> activitySummary = activities.getActivitySummary(entity);
    JSONObject json = new JSONObject();
    for (String key : activitySummary.keySet()) {
        Object value = activitySummary.get(key);
        if (value instanceof NodeRef) {
            value = ((NodeRef) value).getId();
        }
        json.put(key, value);
    }
    return json;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) JSONObject(org.json.simple.JSONObject) JSONObject(org.json.simple.JSONObject)

Example 34 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class RepoService method createFolder.

public NodeRef createFolder(final NodeRef parentNodeRef, final String name, final String title, final String description) {
    NodeRef nodeRef = fileFolderService.create(parentNodeRef, name, ContentModel.TYPE_FOLDER).getNodeRef();
    nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, title);
    nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, description);
    return nodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef)

Example 35 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class RepoService method createCmObject.

public NodeRef createCmObject(final NodeRef parentNodeRef, final String name) {
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));
    NodeRef nodeRef = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CMOBJECT).getChildRef();
    return nodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName)

Aggregations

NodeRef (org.alfresco.service.cmr.repository.NodeRef)1239 HashMap (java.util.HashMap)244 QName (org.alfresco.service.namespace.QName)242 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)209 Test (org.junit.Test)195 ArrayList (java.util.ArrayList)159 Serializable (java.io.Serializable)136 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)104 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)101 FileInfo (org.alfresco.service.cmr.model.FileInfo)82 Map (java.util.Map)81 Node (org.alfresco.web.bean.repository.Node)81 JSONObject (org.json.JSONObject)80 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)74 FacesContext (javax.faces.context.FacesContext)61 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)59 List (java.util.List)58 IOException (java.io.IOException)55 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)52 Date (java.util.Date)51