Search in sources :

Example 91 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordCategoriesEntityResource method update.

@Override
@WebApiDescription(title = "Update record category", description = "Updates a record category with id 'recordCategoryId'")
public RecordCategory update(String recordCategoryId, RecordCategory recordCategoryInfo, Parameters parameters) {
    checkNotBlank("recordCategoryId", recordCategoryId);
    mandatory("recordCategoryInfo", recordCategoryInfo);
    mandatory("parameters", parameters);
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
    RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>() {

        public Void execute() {
            apiUtils.updateNode(nodeRef, recordCategoryInfo, 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.createRecordCategory(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 92 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordFolderEntityResource method readById.

@WebApiDescription(title = "Get record folder information", description = "Gets information for a record folder with id 'recordFolderId'")
@WebApiParam(name = "recordFolderId", title = "The record folder id")
public RecordFolder readById(String recordFolderId, Parameters parameters) {
    checkNotBlank("recordFolderId", recordFolderId);
    mandatory("parameters", parameters);
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
    FileInfo info = fileFolderService.getFileInfo(nodeRef);
    return nodesModelFactory.createRecordFolder(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 93 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordsEntityResource method update.

@Override
@WebApiDescription(title = "Update record", description = "Updates a record with id 'recordId'")
public Record update(String recordId, Record recordInfo, Parameters parameters) {
    checkNotBlank("recordId", recordId);
    mandatory("recordInfo", recordInfo);
    mandatory("parameters", parameters);
    // Get record
    NodeRef record = apiUtils.validateRecord(recordId);
    // update info
    RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>() {

        public Void execute() {
            apiUtils.updateNode(record, recordInfo, parameters);
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
    // return record state
    RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>() {

        public FileInfo execute() {
            return fileFolderService.getFileInfo(record);
        }
    };
    FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
    apiUtils.postActivity(info, recordInfo.getParentId(), ActivityType.FILE_UPDATED);
    return nodesModelFactory.createRecord(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 94 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordsEntityResource method readById.

@WebApiDescription(title = "Get record information", description = "Gets information for a record with id 'recordId'")
@WebApiParam(name = "recordId", title = "The record id")
public Record readById(String recordId, Parameters parameters) {
    checkNotBlank("recordId", recordId);
    mandatory("parameters", parameters);
    NodeRef record = apiUtils.validateRecord(recordId);
    FileInfo info = fileFolderService.getFileInfo(record);
    return nodesModelFactory.createRecord(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 95 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class TransferEntityResource method readById.

@Override
@WebApiDescription(title = "Get transfer information", description = "Gets information for a transfer with id 'transferId'")
@WebApiParam(name = "transferId", title = "The transfer id")
public Transfer readById(String transferId, Parameters parameters) throws EntityNotFoundException {
    checkNotBlank("transferId", transferId);
    mandatory("parameters", parameters);
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferId, RecordsManagementModel.TYPE_TRANSFER);
    FileInfo info = fileFolderService.getFileInfo(nodeRef);
    return nodesModelFactory.createTransfer(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Aggregations

FileInfo (org.alfresco.service.cmr.model.FileInfo)101 NodeRef (org.alfresco.service.cmr.repository.NodeRef)82 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)34 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)26 HashMap (java.util.HashMap)20 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)20 QName (org.alfresco.service.namespace.QName)20 AbstractList (java.util.AbstractList)13 UserInfo (org.alfresco.rest.api.model.UserInfo)13 WebApiParam (org.alfresco.rest.framework.WebApiParam)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)10 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)9 IOException (java.io.IOException)8 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)8 Serializable (java.io.Serializable)7 List (java.util.List)7 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)7 FacesContext (javax.faces.context.FacesContext)6