Search in sources :

Example 6 with UnfiledContainerAPI

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

the class RMBaseEventProcessor method createRootUnfiledRecordFolderWithFixedName.

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

Example 7 with UnfiledContainerAPI

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

the class RMBaseEventProcessor method createRootUnfiledRecordFolder.

/**
 * Helper method for creating one root unfiled record folder with the name starting with provided nameIdentifier and a random generated string.
 *
 * @param folder - container that will contain created root unfiled record folder
 * @param userModel - UserModel instance with wich rest api will be called
 * @param nameIdentifier - a string identifier that the created root unfiled record folder will start with
 * @param context - the context for created root unfiled record folder
 * @param loadFilePlanComponentDelay - delay between creation of root unfiled record folders
 * @throws Exception
 */
public void createRootUnfiledRecordFolder(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 root unfiled records folder properties
    UnfiledContainerChild unfiledContainerChildModel = UnfiledContainerChild.builder().name(newfilePlanComponentName).nodeType(UNFILED_RECORD_FOLDER_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
    UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(userModel);
    UnfiledContainerChild unfiledContainerChild = unfiledContainersAPI.createUnfiledContainerChild(unfiledContainerChildModel, folder.getId());
    String newUnfiledContainerChildId = unfiledContainerChild.getId();
    fileFolderService.createNewFolder(newUnfiledContainerChildId, context, folderPath + "/" + newfilePlanComponentName);
    TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
    // Increment counts
    fileFolderService.incrementFolderCount(folder.getContext(), folderPath, 1);
}
Also used : UnfiledContainerChild(org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild) UnfiledContainerAPI(org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI)

Example 8 with UnfiledContainerAPI

use of org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI 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

UnfiledContainerAPI (org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI)8 DBObject (com.mongodb.DBObject)4 FolderData (org.alfresco.bm.cm.FolderData)4 RecordData (org.alfresco.bm.dataload.rm.services.RecordData)4 Event (org.alfresco.bm.event.Event)4 EventResult (org.alfresco.bm.event.EventResult)4 UnfiledContainer (org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer)4 UnfiledContainerChild (org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild)4 UserModel (org.alfresco.utility.model.UserModel)4 Test (org.junit.Test)4 RMRestWrapper (org.alfresco.rest.core.RMRestWrapper)3 SiteData (org.alfresco.bm.site.SiteData)2 SiteMemberData (org.alfresco.bm.site.SiteMemberData)2 FilePlan (org.alfresco.rest.rm.community.model.fileplan.FilePlan)2 Record (org.alfresco.rest.rm.community.model.record.Record)2 RMSite (org.alfresco.rest.rm.community.model.site.RMSite)2 TransferContainer (org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer)2 FilePlanAPI (org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI)2 FilesAPI (org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI)2 RMSiteAPI (org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI)2