use of org.alfresco.rest.api.model.UserInfo in project records-management by Alfresco.
the class UnfiledRecordFolderChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
public CollectionWithPagingInfo<UnfiledRecordFolderChild> readAll(String unfileRecordFolderId, Parameters parameters) {
checkNotBlank("unfileRecordFolderId", unfileRecordFolderId);
mandatory("parameters", parameters);
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfileRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
// list unfiled record folders and records
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_RECORD_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<UnfiledRecordFolderChild> nodes = new AbstractList<UnfiledRecordFolderChild>() {
@Override
public UnfiledRecordFolderChild get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
UnfiledRecordFolder sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createUnfiledRecordFolder(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.rest.api.model.UserInfo in project records-management by Alfresco.
the class RecordFolderChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of records for the record folder identified by 'recordFolderId'")
public CollectionWithPagingInfo<Record> readAll(String recordFolderId, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
// list record folders
// FIXME searchParam
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, null);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<Record> nodes = new AbstractList<Record>() {
@Override
public Record get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createRecord(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
RecordFolder sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createRecordFolder(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.rest.api.model.UserInfo in project records-management by Alfresco.
the class RecordFolderChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) records as children of a record folder identified by 'recordFolderId'")
public List<Record> create(String recordFolderId, List<Record> nodeInfos, Parameters parameters) {
checkNotBlank("recordFolderId", recordFolderId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (Record nodeInfo : nodeInfos) {
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<Record> result = new LinkedList<>();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
result.add(nodesModelFactory.createRecord(info, parameters, mapUserInfo, false));
}
return result;
}
use of org.alfresco.rest.api.model.UserInfo in project records-management by Alfresco.
the class ApiNodesModelFactory method mapBasicInfo.
/**
* Helper method that sets the basic information for most of the node types.
*
* @param rmNode
* @param info
* @param propertyFilter
* @param isMinimalInfo
*/
private void mapBasicInfo(RMNode rmNode, FileInfo info, BeanPropertiesFilter propertyFilter, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
if (propertyFilter.isAllowed(RMNode.PARAM_ID)) {
rmNode.setNodeRef(info.getNodeRef());
}
if (propertyFilter.isAllowed(RMNode.PARAM_PARENT_ID)) {
rmNode.setParentId(nodeService.getPrimaryParent(info.getNodeRef()).getParentRef());
}
if (propertyFilter.isAllowed(RMNode.PARAM_NAME)) {
rmNode.setName(info.getName());
}
if (propertyFilter.isAllowed(RMNode.PARAM_NODE_TYPE)) {
rmNode.setNodeType(info.getType().toPrefixString(namespaceService));
}
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_AT)) {
rmNode.setModifiedAt(info.getModifiedDate());
}
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_BY_USER)) {
if (mapUserInfo == null) {
mapUserInfo = new HashMap<>(2);
}
UserInfo modifer = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_MODIFIER), mapUserInfo, personService);
rmNode.setModifiedByUser(modifer);
}
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_AT)) {
rmNode.setCreatedAt(info.getCreatedDate());
}
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_BY_USER)) {
if (mapUserInfo == null) {
mapUserInfo = new HashMap<>(2);
}
UserInfo creator = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_CREATOR), mapUserInfo, personService);
rmNode.setCreatedByUser(creator);
}
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_ASPECT_NAMES)) {
rmNode.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
}
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_PROPERTIES)) {
rmNode.setProperties(mapFromNodeProperties(info.getProperties()));
}
}
use of org.alfresco.rest.api.model.UserInfo in project records-management by Alfresco.
the class FilePlanChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) record categories as children of container identified by 'filePlanId'")
public List<RecordCategory> create(String filePlanId, List<RecordCategory> nodeInfos, Parameters parameters) {
checkNotBlank("filePlanId", filePlanId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (RecordCategory nodeInfo : nodeInfos) {
// Create the node
nodeInfo.setNodeType(RECORD_CATEGORY_TYPE);
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<RecordCategory> result = new ArrayList<>(nodeInfos.size());
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false));
}
return result;
}
Aggregations