Search in sources :

Example 1 with RecordFolderAPI

use of org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI in project records-management by Alfresco.

the class RMBaseEventProcessor method uploadElectronicRecordInRecordFolder.

/**
 * Helper method for uploading one record on specified record folder.
 *
 * @param folder - record folder that will contain uploaded record
 * @param userModel - UserModel instance with wich rest api will be called
 * @param nameIdentifier - a string identifier that the uploaded record will start with
 * @param loadFilePlanComponentDelay - delay between upload record operations
 * @throws Exception
 */
public void uploadElectronicRecordInRecordFolder(FolderData folder, UserModel userModel, String nameIdentifier, long loadFilePlanComponentDelay) throws Exception {
    String unique;
    String folderPath = folder.getPath();
    File file = testFileService.getFile();
    if (file == null) {
        throw new RuntimeException("No test files exist for upload: " + testFileService);
    }
    unique = UUID.randomUUID().toString();
    String newfilePlanComponentName = nameIdentifier + unique + "-" + file.getName();
    String newfilePlanComponentTitle = "title: " + newfilePlanComponentName;
    // Build record properties
    Record recordModel = Record.builder().name(newfilePlanComponentName).nodeType(CONTENT_TYPE).properties(RecordProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(userModel);
    recordFolderAPI.createRecord(recordModel, folder.getId(), file);
    TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
    fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
}
Also used : Record(org.alfresco.rest.rm.community.model.record.Record) File(java.io.File) RecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI) UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI)

Example 2 with RecordFolderAPI

use of org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI in project records-management by Alfresco.

the class RMBaseEventProcessor method createNonElectonicRecordInRecordFolder.

/**
 * Helper method for creating a non-electronic document in specified record folder.
 *
 * @param folder - record folder that will contain created non-electronic document
 * @param userModel - UserModel instance with wich rest api will be called
 * @param nameIdentifier - a string identifier that the created non-electronic document will start with
 * @param loadFilePlanComponentDelay - delay between creation of non-electronic documents
 * @throws Exception
 */
public void createNonElectonicRecordInRecordFolder(FolderData folder, UserModel userModel, String nameIdentifier, long loadFilePlanComponentDelay) throws Exception {
    String unique;
    String folderPath = folder.getPath();
    unique = UUID.randomUUID().toString();
    String newfilePlanComponentName = nameIdentifier + unique;
    String newfilePlanComponentTitle = "title: " + newfilePlanComponentName;
    // Build non electronic record properties
    Record recordModel = Record.builder().name(newfilePlanComponentName).nodeType(NON_ELECTRONIC_RECORD_TYPE).properties(RecordProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(userModel);
    String parentId = folder.getId();
    recordFolderAPI.createRecord(recordModel, parentId);
    TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
    // Increment counts
    fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
}
Also used : Record(org.alfresco.rest.rm.community.model.record.Record) RecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI) UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI)

Aggregations

Record (org.alfresco.rest.rm.community.model.record.Record)2 RecordFolderAPI (org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI)2 UnfiledRecordFolderAPI (org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI)2 File (java.io.File)1