Search in sources :

Example 1 with ChildAssociationRef

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

the class RenditionsImpl method getRenditions.

@Override
public CollectionWithPagingInfo<Rendition> getRenditions(NodeRef nodeRef, Parameters parameters) {
    final NodeRef validatedNodeRef = validateNode(nodeRef.getStoreRef(), nodeRef.getId());
    String contentMimeType = getMimeType(validatedNodeRef);
    Query query = parameters.getQuery();
    boolean includeCreated = true;
    boolean includeNotCreated = true;
    String status = getStatus(parameters);
    if (status != null) {
        includeCreated = RenditionStatus.CREATED.equals(RenditionStatus.valueOf(status));
        includeNotCreated = !includeCreated;
    }
    Map<String, Rendition> apiRenditions = new TreeMap<>();
    if (includeNotCreated) {
        // List all available thumbnail definitions
        List<ThumbnailDefinition> thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(contentMimeType, -1);
        for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions) {
            apiRenditions.put(thumbnailDefinition.getName(), toApiRendition(thumbnailDefinition));
        }
    }
    List<ChildAssociationRef> nodeRefRenditions = renditionService.getRenditions(validatedNodeRef);
    if (!nodeRefRenditions.isEmpty()) {
        for (ChildAssociationRef childAssociationRef : nodeRefRenditions) {
            NodeRef renditionNodeRef = childAssociationRef.getChildRef();
            Rendition apiRendition = toApiRendition(renditionNodeRef);
            if (includeCreated) {
                // Replace/append any thumbnail definitions with created rendition info
                apiRenditions.put(apiRendition.getId(), apiRendition);
            } else {
                // Remove any thumbnail definitions that has been created from the list,
                // as the filter requires only the Not_Created renditions
                apiRenditions.remove(apiRendition.getId());
            }
        }
    }
    // Wrap paging info, as the core service doesn't support paging
    Paging paging = parameters.getPaging();
    PagingResults<Rendition> results = Util.wrapPagingResults(paging, apiRenditions.values());
    return CollectionWithPagingInfo.asPaged(paging, results.getPage(), results.hasMoreItems(), results.getTotalResultCount().getFirst());
}
Also used : Query(org.alfresco.rest.framework.resource.parameters.where.Query) Rendition(org.alfresco.rest.api.model.Rendition) Paging(org.alfresco.rest.framework.resource.parameters.Paging) TreeMap(java.util.TreeMap) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ThumbnailDefinition(org.alfresco.repo.thumbnail.ThumbnailDefinition)

Example 2 with ChildAssociationRef

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

the class RenditionsImpl method getRenditionByName.

protected NodeRef getRenditionByName(NodeRef nodeRef, String renditionId, Parameters parameters) {
    if (nodeRef == null) {
        return null;
    }
    if (StringUtils.isEmpty(renditionId)) {
        throw new InvalidArgumentException("renditionId can't be null or empty.");
    }
    // Thumbnails have a cm: prefix.
    QName renditionQName = QName.resolveToQName(namespaceService, renditionId);
    ChildAssociationRef nodeRefRendition = renditionService.getRenditionByName(nodeRef, renditionQName);
    if (nodeRefRendition == null) {
        return null;
    }
    return tenantService.getName(nodeRef, nodeRefRendition.getChildRef());
}
Also used : InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 3 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.

the class BrowseBean method deleteSpace.

/**
 * Handles the deleteSpace action by deciding which delete dialog to display
 */
public void deleteSpace(ActionEvent event) {
    setupDeleteAction(event);
    boolean hasMultipleParents = false;
    boolean showDeleteAssocDialog = false;
    // determine if the node being delete has multiple parents
    Node node = this.getActionSpace();
    List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(node.getNodeRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
    if (parents != null && parents.size() > 1) {
        hasMultipleParents = true;
    }
    // determine which delete dialog to display
    if (this.navigator.getSearchContext() == null && hasMultipleParents) {
        // if we are not in a search and the node has multiple parents
        // see if the current node has the primary parent association
        NodeRef parentSpace = this.navigator.getCurrentNode().getNodeRef();
        ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
        // show delete assoc dialog if the current space is not the primary parent for the node
        showDeleteAssocDialog = !parentSpace.equals(assoc.getParentRef());
    }
    // show the appropriate dialog
    FacesContext fc = FacesContext.getCurrentInstance();
    if (showDeleteAssocDialog) {
        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpaceAssoc");
    } else {
        final Map<String, String> dialogParams = new HashMap<String, String>(1);
        dialogParams.put("hasMultipleParents", Boolean.toString(hasMultipleParents));
        Application.getDialogManager().setupParameters(dialogParams);
        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpace");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FacesContext(javax.faces.context.FacesContext) HashMap(java.util.HashMap) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 4 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.

the class AdminNodeBrowseBean method selectResultNode.

/**
 * Action to select search result node
 *
 * @return next action
 */
public String selectResultNode() {
    ChildAssociationRef assocRef = (ChildAssociationRef) searchResults.getRows().getRowData();
    NodeRef childRef = assocRef.getChildRef();
    setNodeRef(childRef);
    return "success";
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 5 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.

the class AdminNodeBrowseBean method getChildren.

/**
 * Gets the current node children
 *
 * @return node children
 */
public DataModel getChildren() {
    if (children == null) {
        List<ChildAssociationRef> assocRefs = getNodeService().getChildAssocs(getNodeRef());
        children = new ListDataModel(assocRefs);
    }
    return children;
}
Also used : ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ListDataModel(javax.faces.model.ListDataModel)

Aggregations

ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)260 NodeRef (org.alfresco.service.cmr.repository.NodeRef)204 QName (org.alfresco.service.namespace.QName)110 Test (org.junit.Test)57 HashMap (java.util.HashMap)54 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)53 ArrayList (java.util.ArrayList)52 Serializable (java.io.Serializable)42 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)25 FacesContext (javax.faces.context.FacesContext)22 Map (java.util.Map)19 UserTransaction (javax.transaction.UserTransaction)18 Node (org.alfresco.web.bean.repository.Node)17 Date (java.util.Date)15 StoreRef (org.alfresco.service.cmr.repository.StoreRef)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)12 List (java.util.List)11 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)11 IOException (java.io.IOException)10