Search in sources :

Example 1 with Renditions

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

the class TestPeople method createAvatarDirect.

private NodeRef createAvatarDirect(NodeRef personRef, File avatarFile) {
    // create new avatar node
    nodeService.addAspect(personRef, ContentModel.ASPECT_PREFERENCES, null);
    ChildAssociationRef assoc = nodeService.createNode(personRef, ContentModel.ASSOC_PREFERENCE_IMAGE, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "origAvatar"), ContentModel.TYPE_CONTENT);
    final NodeRef avatarRef = assoc.getChildRef();
    // JSF client compatibility?
    nodeService.createAssociation(personRef, avatarRef, ContentModel.ASSOC_AVATAR);
    // upload the avatar content
    ContentService contentService = applicationContext.getBean("ContentService", ContentService.class);
    ContentWriter writer = contentService.getWriter(avatarRef, ContentModel.PROP_CONTENT, true);
    writer.guessMimetype(avatarFile.getName());
    writer.putContent(avatarFile);
    Rendition avatarR = new Rendition();
    avatarR.setId("avatar");
    Renditions renditions = applicationContext.getBean("Renditions", Renditions.class);
    renditions.createRendition(avatarRef, avatarR, false, null);
    return avatarRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) Rendition(org.alfresco.rest.api.model.Rendition) Renditions(org.alfresco.rest.api.Renditions) ContentService(org.alfresco.service.cmr.repository.ContentService) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Aggregations

Renditions (org.alfresco.rest.api.Renditions)1 Rendition (org.alfresco.rest.api.model.Rendition)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 ContentService (org.alfresco.service.cmr.repository.ContentService)1 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1