Search in sources :

Example 1 with BinaryProperties

use of org.alfresco.rest.framework.BinaryProperties in project records-management by Alfresco.

the class RecordsEntityResource method readProperty.

/**
 * Download content
 *
 * @param recordId the id of the record to get the content from
 * @param parameters {@link Parameters}
 * @return binary content resource
 * @throws EntityNotFoundException
 */
@Override
@WebApiDescription(title = "Download content", description = "Download content for a record with id 'recordId'")
@BinaryProperties({ "content" })
public BinaryResource readProperty(String recordId, Parameters parameters) throws EntityNotFoundException {
    checkNotBlank("recordId", recordId);
    mandatory("parameters", parameters);
    NodeRef record = apiUtils.validateRecord(recordId);
    if (nodeService.getType(record).equals(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT)) {
        throw new IllegalArgumentException("Cannot read content from Non-electronic record " + recordId + ".");
    }
    BinaryResource content = apiUtils.getContent(record, parameters, true);
    NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef();
    FileInfo info = fileFolderService.getFileInfo(record);
    apiUtils.postActivity(info, primaryParent, ActivityPoster.DOWNLOADED);
    return content;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) BinaryResource(org.alfresco.rest.framework.resource.content.BinaryResource) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) BinaryProperties(org.alfresco.rest.framework.BinaryProperties)

Aggregations

BinaryProperties (org.alfresco.rest.framework.BinaryProperties)1 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)1 BinaryResource (org.alfresco.rest.framework.resource.content.BinaryResource)1 FileInfo (org.alfresco.service.cmr.model.FileInfo)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1