Search in sources :

Example 86 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class FilePlanChildrenRelation method readAll.

@Override
@WebApiDescription(title = "Return a paged list of file plan children (record categories) for the container identified by 'filePlanId'")
public CollectionWithPagingInfo<RecordCategory> readAll(String filePlanId, Parameters parameters) {
    // validate parameters
    checkNotBlank("filePlanId", filePlanId);
    mandatory("parameters", parameters);
    QName filePlanType = apiUtils.getFilePlanType();
    if (// rm site not created
    filePlanType == null) {
        throw new EntityNotFoundException(filePlanId);
    }
    NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
    // list record categories
    Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForFilePlanEndpoint();
    // FIXME this param null
    List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, null);
    final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), filterProps, Util.getPagingRequest(parameters.getPaging()));
    final List<FileInfo> page = pagingResults.getPage();
    Map<String, UserInfo> mapUserInfo = new HashMap<>();
    List<RecordCategory> nodes = new AbstractList<RecordCategory>() {

        @Override
        public RecordCategory get(int index) {
            FileInfo info = page.get(index);
            return nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, true);
        }

        @Override
        public int size() {
            return page.size();
        }
    };
    FilePlan sourceEntity = null;
    if (parameters.includeSource()) {
        FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
        sourceEntity = nodesModelFactory.createFilePlan(info, parameters, mapUserInfo, true);
    }
    return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
Also used : AbstractList(java.util.AbstractList) FilePlan(org.alfresco.rm.rest.api.model.FilePlan) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) UserInfo(org.alfresco.rest.api.model.UserInfo) RecordCategory(org.alfresco.rm.rest.api.model.RecordCategory) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 87 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordsManagementSearchServiceImpl method getSavedSearches.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearches(java.lang.String)
 */
@Override
public List<SavedSearchDetails> getSavedSearches(String siteId) {
    List<SavedSearchDetails> result = new ArrayList<SavedSearchDetails>(17);
    NodeRef container = siteService.getContainer(siteId, SEARCH_CONTAINER);
    if (container != null) {
        // add the details of all the public saved searches
        List<FileInfo> searches = fileFolderService.listFiles(container);
        for (FileInfo search : searches) {
            addSearchDetailsToList(result, search.getNodeRef());
        }
        // add the details of any "private" searches for the current user
        String userName = AuthenticationUtil.getFullyAuthenticatedUser();
        NodeRef userContainer = fileFolderService.searchSimple(container, userName);
        if (userContainer != null) {
            List<FileInfo> userSearches = fileFolderService.listFiles(userContainer);
            for (FileInfo userSearch : userSearches) {
                addSearchDetailsToList(result, userSearch.getNodeRef());
            }
        }
    }
    return result;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) ArrayList(java.util.ArrayList)

Example 88 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class UnfiledContainerChildrenRelation method create.

@Override
@WebApiDescription(title = "Create one (or more) nodes as children of a unfiled container identified by 'unfiledContainerId'")
public List<UnfiledContainerChild> create(String unfiledContainerId, final List<UnfiledContainerChild> nodeInfos, Parameters parameters) {
    checkNotBlank("unfiledContainerId", unfiledContainerId);
    mandatory("nodeInfos", nodeInfos);
    mandatory("parameters", parameters);
    final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
    // Create the nodes
    RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {

        public List<NodeRef> execute() {
            List<NodeRef> createdNodes = new LinkedList<>();
            for (UnfiledContainerChild 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<UnfiledContainerChild> 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.createUnfiledContainerChild(info, parameters, mapUserInfo, false));
    }
    return result;
}
Also used : UnfiledContainerChild(org.alfresco.rm.rest.api.model.UnfiledContainerChild) HashMap(java.util.HashMap) UserInfo(org.alfresco.rest.api.model.UserInfo) LinkedList(java.util.LinkedList) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) AbstractList(java.util.AbstractList) LinkedList(java.util.LinkedList) List(java.util.List) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 89 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class UnfiledRecordFolderEntityResource method readById.

@WebApiDescription(title = "Get unfiled record folder information", description = "Gets information for an unfiled record folder with id 'unfiledRecordFolderId'")
@WebApiParam(name = "unfiledRecordFolderId", title = "The unfiled record folder id")
public UnfiledRecordFolder readById(String unfiledRecordFolderId, Parameters parameters) {
    checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
    mandatory("parameters", parameters);
    String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
    FileInfo info = fileFolderService.getFileInfo(nodeRef);
    return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Example 90 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project records-management by Alfresco.

the class RecordCategoriesEntityResource method readById.

@WebApiDescription(title = "Get record category information", description = "Gets information for a record category with id 'recordCategoryId'")
@WebApiParam(name = "recordCategoryId", title = "The record category id")
public RecordCategory readById(String recordCategoryId, Parameters parameters) {
    checkNotBlank("recordCategoryId", recordCategoryId);
    mandatory("parameters", parameters);
    String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
    NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY, relativePath, true);
    FileInfo info = fileFolderService.getFileInfo(nodeRef);
    return nodesModelFactory.createRecordCategory(info, parameters, null, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription) WebApiParam(org.alfresco.rest.framework.WebApiParam)

Aggregations

FileInfo (org.alfresco.service.cmr.model.FileInfo)101 NodeRef (org.alfresco.service.cmr.repository.NodeRef)82 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)34 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)26 HashMap (java.util.HashMap)20 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)20 QName (org.alfresco.service.namespace.QName)20 AbstractList (java.util.AbstractList)13 UserInfo (org.alfresco.rest.api.model.UserInfo)13 WebApiParam (org.alfresco.rest.framework.WebApiParam)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)10 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)9 IOException (java.io.IOException)8 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)8 Serializable (java.io.Serializable)7 List (java.util.List)7 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)7 FacesContext (javax.faces.context.FacesContext)6