use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class DynamicAuthoritiesGetUnitTest method processedWithParentNodeRef.
@SuppressWarnings("unchecked")
@Test
public void processedWithParentNodeRef() throws Exception {
List<Long> ids = Stream.of(1l, 2l, 3l).collect(Collectors.toList());
NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
List<FileInfo> children = new ArrayList<FileInfo>();
ids.stream().forEach((i) -> {
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService);
when(mockedNodeService.hasAspect(nodeRef, ASPECT_RECORD)).thenReturn(true);
when(mockedNodeService.hasAspect(nodeRef, ASPECT)).thenReturn(true);
when(mockedNodeService.getProperty(nodeRef, PROP_READERS)).thenReturn((Serializable) Collections.emptyMap());
when(mockedNodeService.getProperty(nodeRef, PROP_WRITERS)).thenReturn((Serializable) Collections.emptyMap());
String name = "name" + i;
when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_NAME)).thenReturn((Serializable) name);
FileInfo mockedFileInfo = mock(FileInfo.class);
when(mockedFileInfo.getNodeRef()).thenReturn(nodeRef);
children.add(mockedFileInfo);
});
when(mockedFileFolderService.search(eq(parentNodeRef), eq("*"), eq(true), eq(true), eq(true))).thenReturn(children);
Map<String, String> parameters = ImmutableMap.of("batchsize", "3", "maxProcessedRecords", "4", "export", "false", "parentNodeRef", parentNodeRef.toString());
JSONObject json = executeJSONWebScript(parameters);
assertNotNull(json);
String actualJSONString = json.toString();
ObjectMapper mapper = new ObjectMapper();
String expectedJSONString = "{\"responsestatus\":\"success\",\"message\":\"Processed 3 records.\"}";
assertEquals(mapper.readTree(expectedJSONString), mapper.readTree(actualJSONString));
verify(contentStreamer, never()).streamContent(any(WebScriptRequest.class), any(WebScriptResponse.class), any(File.class), any(Long.class), any(Boolean.class), any(String.class), any(Map.class));
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class FilePlanEntityResource method update.
@Override
@WebApiDescription(title = "Update file plan", description = "Updates a filePlan with id 'filePlanId'")
public FilePlan update(String filePlanId, FilePlan filePlanInfo, Parameters parameters) {
checkNotBlank("filePlanId", filePlanId);
mandatory("filePlanInfo", filePlanInfo);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
RetryingTransactionCallback<Void> updateCallback = new RetryingTransactionCallback<Void>() {
public Void execute() {
apiUtils.updateNode(nodeRef, filePlanInfo, parameters);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(updateCallback, 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.createFilePlan(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class FilePlanEntityResource method readById.
@WebApiDescription(title = "Get file plan information", description = "Get information for a file plan with id 'filePlanId'")
@WebApiParam(name = "filePlanId", title = "The file plan id")
public FilePlan readById(String filePlanId, Parameters parameters) {
checkNotBlank("filePlanId", filePlanId);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
FileInfo info = fileFolderService.getFileInfo(nodeRef);
return nodesModelFactory.createFilePlan(info, parameters, null, false);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RM4619Test method testConvertFolderToRecordFolder.
/**
* Given an existing category
* When we create a regular folder in the category
* Then the folder is immediately converted to a record folder
*/
public void testConvertFolderToRecordFolder() throws Exception {
/*
* Create a folder in a record category and check it is converted
*/
final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() throws Exception {
FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER);
return info.getNodeRef();
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() throws Exception {
assertEquals(TYPE_RECORD_FOLDER, nodeService.getType(recordFolder));
assertNotNull(nodeService.getProperty(recordFolder, PROP_IDENTIFIER));
return null;
}
}, ADMIN_USER);
/*
* Check that when the transaction ends the identifier is no longer editable
* And the record folder has the ASPECT_RM_SEARCH aspect
*/
doTestInTransaction(new Test<Void>() {
@Override
public Void run() throws Exception {
assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
return null;
}
}, ADMIN_USER);
}
use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.
the class RM4619Test method testConvertFolderToCategory.
/**
* Given the RM site is created
* When we create a regular folder in the fileplan
* Then the folder is immediately converted to a record category
*/
public void testConvertFolderToCategory() throws Exception {
/*
* Create a folder in the unfiled record container and check it is immediately converted
*/
final NodeRef recordCategory = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() throws Exception {
FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER);
return info.getNodeRef();
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() throws Exception {
assertEquals(TYPE_RECORD_CATEGORY, nodeService.getType(recordCategory));
assertNotNull(nodeService.getProperty(recordCategory, PROP_IDENTIFIER));
return null;
}
}, ADMIN_USER);
}
Aggregations