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());
}
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());
}
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");
}
}
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";
}
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;
}
Aggregations