use of org.alfresco.service.cmr.model.FileInfo 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;
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RecordsEntityResource method completeRecord.
@Operation("complete")
@WebApiDescription(title = "Complete record", description = "Complete a record.")
public Record completeRecord(String recordId, Void body, Parameters parameters, WithResponse withResponse) {
checkNotBlank("recordId", recordId);
mandatory("parameters", parameters);
// Get record
NodeRef record = apiUtils.validateRecord(recordId);
// Complete the record
try {
recordService.complete(record);
} catch (RecordMissingMetadataException e) {
throw new IntegrityException("The record has missing mandatory properties.", null);
}
// return record state
FileInfo info = fileFolderService.getFileInfo(record);
return nodesModelFactory.createRecord(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class TransferContainerChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of transfers for the transfer container identified by 'transferContainerId'")
public CollectionWithPagingInfo<Transfer> readAll(String transferContainerId, Parameters parameters) {
checkNotBlank("transferContainerId", transferContainerId);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
// list transfers
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForTransferContainersEndpoint();
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<Transfer> nodes = new AbstractList<Transfer>() {
@Override
public Transfer get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createTransfer(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
TransferContainer sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createTransferContainer(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class UnfiledContainerChildrenRelation method create.
@Override
@WebApiDescription(title = "Upload file content and meta-data into a unfiled record container identified by 'unfiledContainerId'.")
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
public UnfiledContainerChild create(String unfiledContainerId, FormData formData, Parameters parameters, WithResponse withResponse) {
checkNotBlank("unfiledContainerId", unfiledContainerId);
mandatory("formData", formData);
mandatory("parameters", parameters);
UploadInfo uploadInfo = new UploadInfo(formData);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>() {
public NodeRef execute() {
return apiUtils.uploadRecord(parentNodeRef, uploadInfo, parameters);
}
};
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get file info for response
FileInfo info = fileFolderService.getFileInfo(newNode);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
return nodesModelFactory.createUnfiledContainerChild(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class UnfiledContainerChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
public CollectionWithPagingInfo<UnfiledContainerChild> readAll(String unfiledContainerId, Parameters parameters) {
// validate parameters
checkNotBlank("unfiledContainerId", unfiledContainerId);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
// list unfiled record folders and records
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), filterProps, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<UnfiledContainerChild> nodes = new AbstractList<UnfiledContainerChild>() {
@Override
public UnfiledContainerChild get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createUnfiledContainerChild(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
UnfiledContainer sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createUnfiledContainer(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
Aggregations