Search in sources :

Example 1 with UnfiledRecordFolderAPI

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

the class RMBaseEventProcessor method uploadElectronicRecordInUnfiledContext.

/**
 * Helper method for uploading one record on specified unfiled container or unfiled record folder.
 *
 * @param folder - unfiled container or unfiled record folder that will contain uploaded records
 * @param userModel - UserModel instance with wich rest api will be called
 * @param nameIdentifier - a string identifier that the uploaded records will start with
 * @param loadFilePlanComponentDelay - delay between upload record operations
 * @throws Exception
 */
public void uploadElectronicRecordInUnfiledContext(FolderData folder, UserModel userModel, String nameIdentifier, // to-check: type of exception
long loadFilePlanComponentDelay) throws // to-check: type of exception
Exception {
    String unique;
    boolean isUnfiledContainer = fileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH).equals(folder);
    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
    UnfiledContainerChild unfiledContainerChildModel = UnfiledContainerChild.builder().name(newfilePlanComponentName).nodeType(CONTENT_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    String newRecordId;
    String newRecordName;
    if (isUnfiledContainer) {
        UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(userModel);
        UnfiledContainerChild uploadedRecord = unfiledContainersAPI.uploadRecord(unfiledContainerChildModel, folder.getId(), file);
        newRecordId = uploadedRecord.getId();
        newRecordName = uploadedRecord.getName();
    } else {
        UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(userModel);
        UnfiledContainerChild uploadedRecord = unfiledRecordFoldersAPI.uploadRecord(unfiledContainerChildModel, folder.getId(), file);
        newRecordId = uploadedRecord.getId();
        newRecordName = uploadedRecord.getName();
    }
    RecordData record = new RecordData(newRecordId, RecordContext.RECORD, newRecordName, folderPath, null, ExecutionState.UNFILED_RECORD_DECLARED);
    recordService.createRecord(record);
    fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
}
Also used : UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI) RecordData(org.alfresco.bm.dataload.rm.services.RecordData) UnfiledContainerChild(org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild) File(java.io.File) UnfiledContainerAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI)

Example 2 with UnfiledRecordFolderAPI

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

the class RMBaseEventProcessor method createUnfiledRecordFolderWithFixedName.

/**
 * Helper method for creating a child unfiled record folder with a specified name.
 *
 * @param folder - container that will contain created child unfiled record folder
 * @param name - the name that created child unfiled record folder will have
 * @return created child unfiled record folder with a specified name
 * @throws Exception
 */
public FolderData createUnfiledRecordFolderWithFixedName(FolderData folder, String name) throws Exception {
    FolderData createdFolder = null;
    String folderPath = folder.getPath();
    String newfilePlanComponentTitle = "title: " + name;
    // Build unfiled record folder properties
    UnfiledContainerChild unfiledRecordFolderChildModel = UnfiledContainerChild.builder().name(name).nodeType(UNFILED_RECORD_FOLDER_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
    UnfiledContainerChild unfiledRecordFolderChild = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(unfiledRecordFolderChildModel, folder.getId());
    String newUnfiledRecordFolderChildId = unfiledRecordFolderChild.getId();
    fileFolderService.createNewFolder(newUnfiledRecordFolderChildId, UNFILED_CONTEXT, folderPath + "/" + name);
    // Increment counts
    fileFolderService.incrementFolderCount(folder.getContext(), folderPath, 1);
    createdFolder = fileFolderService.getFolder(newUnfiledRecordFolderChildId);
    return createdFolder;
}
Also used : UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI) UnfiledContainerChild(org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild) FolderData(org.alfresco.bm.cm.FolderData)

Example 3 with UnfiledRecordFolderAPI

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

the class RMBaseEventProcessor method createUnfiledRecordFolder.

/**
 * Helper method for creating one unfiled record folder that have the name starting with provided nameIdentifier and a random generated string.
 *
 * @param folder - container that will contain created unfiled record folder
 * @param userModel - UserModel instance with wich rest api will be called
 * @param nameIdentifier - a string identifier that the created unfiled record folder will start with
 * @param context - the context for created unfiled record folder
 * @param loadFilePlanComponentDelay - delay between creation of unfiled record folders
 * @throws Exception
 */
public void createUnfiledRecordFolder(FolderData folder, UserModel userModel, String nameIdentifier, String context, long loadFilePlanComponentDelay) throws Exception {
    String unique;
    String folderPath = folder.getPath();
    unique = UUID.randomUUID().toString();
    String newfilePlanComponentName = nameIdentifier + unique;
    String newfilePlanComponentTitle = "title: " + newfilePlanComponentName;
    // Build unfiled record folder properties
    UnfiledContainerChild unfiledRecordFolderChildModel = UnfiledContainerChild.builder().name(newfilePlanComponentName).nodeType(UNFILED_RECORD_FOLDER_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(userModel);
    UnfiledContainerChild unfiledRecordFolderChild = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(unfiledRecordFolderChildModel, folder.getId());
    String newUnfiledRecordFolderChildId = unfiledRecordFolderChild.getId();
    fileFolderService.createNewFolder(newUnfiledRecordFolderChildId, context, folderPath + "/" + newfilePlanComponentName);
    TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
    // Increment counts
    fileFolderService.incrementFolderCount(folder.getContext(), folderPath, 1);
}
Also used : UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI) UnfiledContainerChild(org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild)

Example 4 with UnfiledRecordFolderAPI

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

the class RMBaseEventProcessor method createNonElectonicRecordInUnfiledContext.

/**
 * Helper method for creating specified number of non-electronic documents in specified unfiled container or unfiled record folder.
 *
 * @param folder - unfiled container or unfiled 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 documents will start with
 * @param loadFilePlanComponentDelay - delay between creation of non-electronic documents
 * @throws Exception
 */
public void createNonElectonicRecordInUnfiledContext(FolderData folder, UserModel userModel, String nameIdentifier, long loadFilePlanComponentDelay) throws Exception {
    String unique;
    boolean isUnfiledContainer = fileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH).equals(folder);
    String folderPath = folder.getPath();
    unique = UUID.randomUUID().toString();
    String newfilePlanComponentName = nameIdentifier + unique;
    String newfilePlanComponentTitle = "title: " + newfilePlanComponentName;
    // Build non electronic record properties
    UnfiledContainerChild unfiledContainerChildModel = UnfiledContainerChild.builder().name(newfilePlanComponentName).nodeType(NON_ELECTRONIC_RECORD_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    String newRecordId;
    String newRecordName;
    if (isUnfiledContainer) {
        UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(userModel);
        UnfiledContainerChild createdRecord = unfiledContainersAPI.createUnfiledContainerChild(unfiledContainerChildModel, folder.getId());
        newRecordId = createdRecord.getId();
        newRecordName = createdRecord.getName();
    } else {
        UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(userModel);
        UnfiledContainerChild createdRecord = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(unfiledContainerChildModel, folder.getId());
        newRecordId = createdRecord.getId();
        newRecordName = createdRecord.getName();
    }
    RecordData record = new RecordData(newRecordId, RecordContext.RECORD, newRecordName, folderPath, null, ExecutionState.UNFILED_RECORD_DECLARED);
    recordService.createRecord(record);
    TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
    // Increment counts
    fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
}
Also used : UnfiledRecordFolderAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI) RecordData(org.alfresco.bm.dataload.rm.services.RecordData) UnfiledContainerChild(org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild) UnfiledContainerAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI)

Aggregations

UnfiledContainerChild (org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild)4 UnfiledRecordFolderAPI (org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI)4 RecordData (org.alfresco.bm.dataload.rm.services.RecordData)2 UnfiledContainerAPI (org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI)2 File (java.io.File)1 FolderData (org.alfresco.bm.cm.FolderData)1