use of org.alfresco.service.cmr.repository.ChildAssociationRef in project alfresco-remote-api by Alfresco.
the class DownloadRestApiTest 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 PeopleImpl method getAvatarOriginal.
private NodeRef getAvatarOriginal(NodeRef personNode) {
NodeRef avatarOrigNodeRef = null;
List<ChildAssociationRef> avatarChildAssocs = nodeService.getChildAssocs(personNode, Collections.singleton(ContentModel.ASSOC_PREFERENCE_IMAGE));
if (avatarChildAssocs.size() > 0) {
ChildAssociationRef ref = avatarChildAssocs.get(0);
avatarOrigNodeRef = ref.getChildRef();
} else {
// TODO do we still need this ? - backward compatible with JSF web-client avatar
List<AssociationRef> avatorAssocs = nodeService.getTargetAssocs(personNode, ContentModel.ASSOC_AVATAR);
if (avatorAssocs.size() > 0) {
AssociationRef ref = avatorAssocs.get(0);
avatarOrigNodeRef = ref.getTargetRef();
}
}
return avatarOrigNodeRef;
}
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 alfresco-remote-api by Alfresco.
the class AbstractNodeRelation method listNodeChildAssocs.
protected CollectionWithPagingInfo<Node> listNodeChildAssocs(List<ChildAssociationRef> childAssocRefs, Parameters parameters, Boolean isPrimary, boolean returnChild) {
Map<QName, String> qnameMap = new HashMap<>(3);
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
List<String> includeParam = parameters.getInclude();
List<Node> collection = new ArrayList<Node>(childAssocRefs.size());
for (ChildAssociationRef childAssocRef : childAssocRefs) {
if (isPrimary == null || (isPrimary == childAssocRef.isPrimary())) {
// minimal info by default (unless "include"d otherwise)
NodeRef nodeRef = (returnChild ? childAssocRef.getChildRef() : childAssocRef.getParentRef());
Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo);
QName assocTypeQName = childAssocRef.getTypeQName();
if (!EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI())) {
String assocType = qnameMap.get(assocTypeQName);
if (assocType == null) {
assocType = assocTypeQName.toPrefixString(namespaceService);
qnameMap.put(assocTypeQName, assocType);
}
node.setAssociation(new AssocChild(assocType, childAssocRef.isPrimary()));
collection.add(node);
}
}
}
return listPage(collection, parameters.getPaging());
}
Aggregations