Search in sources :

Example 1 with RecordBodyFile

use of org.alfresco.rest.rm.community.model.record.RecordBodyFile in project records-management by Alfresco.

the class LoadSingleComponent method fileRecordOperation.

/**
 * Helper method to file the unfiled record with specified id in specified record folder.
 *
 * @param folder - the record folded to file unfiled record in
 * @param recordId - the id of the unfiled record to be filed
 * @param userModel - the user model with which the unfiled record will be filed
 * @return String - the filing message
 * @throws Exception
 */
private String fileRecordOperation(FolderData folder, String recordId, UserModel userModel) throws Exception {
    // FileRecords records
    String folderPath = folder.getPath();
    String parentId = folder.getId();
    RecordBodyFile recordBodyFileModel = RecordBodyFile.builder().targetParentId(parentId).build();
    RecordData randomRecord = recordService.getRecord(recordId);
    super.resumeTimer();
    RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(userModel);
    recordsAPI.fileRecord(recordBodyFileModel, randomRecord.getId());
    super.suspendTimer();
    // Increment counts
    fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
    // Decrement counts for unfiled record folder or unfiled container
    String unfiledParentPath = randomRecord.getParentPath();
    fileFolderService.incrementFileCount(UNFILED_CONTEXT, unfiledParentPath, -1);
    // change parent path to the new parent
    randomRecord.setParentPath(folderPath);
    randomRecord.setExecutionState(ExecutionState.RECORD_FILED);
    recordService.updateRecord(randomRecord);
    TimeUnit.MILLISECONDS.sleep(getDelay());
    return "Filed record with id " + recordId + ".";
}
Also used : RecordData(org.alfresco.bm.dataload.rm.services.RecordData) RecordsAPI(org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI) RecordBodyFile(org.alfresco.rest.rm.community.model.record.RecordBodyFile)

Aggregations

RecordData (org.alfresco.bm.dataload.rm.services.RecordData)1 RecordBodyFile (org.alfresco.rest.rm.community.model.record.RecordBodyFile)1 RecordsAPI (org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI)1