use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.
the class FilesEntityResource method declareAsRecord.
@Operation("declare")
@WebApiDescription(title = "Declare as record", description = "Declare a file as record.")
public Record declareAsRecord(String fileId, Void body, Parameters parameters, WithResponse withResponse) {
// Get fileplan
NodeRef filePlan = authenticationUtil.runAsSystem(new RunAsWork<NodeRef>() {
@Override
public NodeRef doWork() {
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
}
});
// default false (if not provided)
boolean hideRecord = Boolean.valueOf(parameters.getParameter(Record.PARAM_HIDE_RECORD));
// Create the record
NodeRef file = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, fileId);
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>() {
public Void execute() {
recordService.createRecord(filePlan, file, !hideRecord);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Return record state
FileInfo info = fileFolderService.getFileInfo(file);
return nodesModelFactory.createRecord(info, parameters, null, false);
}
use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.
the class RecordFolderEntityResource method delete.
@Override
@WebApiDescription(title = "Delete record folder", description = "Deletes a record folder with id 'recordFolderId'")
public void delete(String recordFolderId, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("parameters", parameters);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
fileFolderService.delete(nodeRef);
}
use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.
the class RecordFolderEntityResource method update.
@Override
@WebApiDescription(title = "Update record folder", description = "Updates a record folder with id 'recordFolderId'")
public RecordFolder update(String recordFolderId, RecordFolder recordFolderInfo, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("recordFolderInfo", recordFolderInfo);
mandatory("parameters", parameters);
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>() {
public Void execute() {
apiUtils.updateNode(nodeRef, recordFolderInfo, parameters);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>() {
public FileInfo execute() {
return fileFolderService.getFileInfo(nodeRef);
}
};
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
return nodesModelFactory.createRecordFolder(info, parameters, null, false);
}
use of org.alfresco.rest.framework.WebApiDescription in project records-management by Alfresco.
the class RecordsEntityResource method fileRecord.
@Operation("file")
@WebApiDescription(title = "File record", description = "File a record into fileplan.")
public Record fileRecord(String recordId, TargetContainer target, Parameters parameters, WithResponse withResponse) {
checkNotBlank("recordId", recordId);
mandatory("target", target);
mandatory("targetParentId", target.getTargetParentId());
mandatory("parameters", parameters);
// Get record and target folder
NodeRef record = apiUtils.validateRecord(recordId);
NodeRef targetRecordFolder = apiUtils.lookupAndValidateNodeType(target.getTargetParentId(), RecordsManagementModel.TYPE_RECORD_FOLDER);
// Get the current parent type to decide if we link or move the record
NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef();
if (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(primaryParent))) {
recordService.link(record, targetRecordFolder);
} else {
try {
fileFolderService.moveFrom(record, primaryParent, targetRecordFolder, null);
} catch (FileExistsException e) {
throw new IntegrityException(e.getMessage(), null);
} catch (FileNotFoundException e) {
throw new ConcurrencyFailureException("The record was deleted while filing it", e);
}
}
// return record state
FileInfo info = fileFolderService.getFileInfo(record);
return nodesModelFactory.createRecord(info, parameters, null, false);
}
use of org.alfresco.rest.framework.WebApiDescription 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;
}
Aggregations