org.alfresco.query.PagingRequest Java Examples

The following examples show how to use org.alfresco.query.PagingRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageCollatorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public PagingResults<R> retrieve(PagingRequest pr) throws PageCollationException
{
    final int skip = pr.getSkipCount();
    final int pageSize = pr.getMaxItems();
    if (skip < 0 || pageSize < 0)
    {
        throw new PageCollationException("Invalid page!");
    }

    if (boundsError && (skip >= array.length))
    {
        throw new InvalidPageBounds("Out of bounds " + skip + ">=" + array.length);
    }

    return new ListBackedPagingResults<R>(Arrays.asList(array),
                                          pr);
}
 
Example #2
Source File: DiscussionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public PostInfo getMostRecentPost(TopicInfo topic)
{
   // Do a listing at the Node level, ordered by created date
   //  to get the most recent nodes
   PagingRequest paging = new PagingRequest(0, 1);
   CannedQueryResults<NodeBackedEntity> results = 
       listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, null, null, false, paging);
      
   // Bail if the topic lacks posts
   if (results.getPage().size() == 0)
   {
      // No posts in the topic
      return null;
   }
   
   // Grab the newest node
   NodeBackedEntity node = results.getPage().get(0);
   
   // Wrap and return
   return buildPost(tenantService.getBaseName(node.getNodeRef()), topic, node.getName(), null);
}
 
Example #3
Source File: CustomModelServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public CustomModelsInfo getCustomModelsInfo()
{
    List<CustomModelDefinition> page = getCustomModels(new PagingRequest(0, Integer.MAX_VALUE)).getPage();

    int activeModels = 0;
    int activeTypes = 0;
    int activeAspects = 0;
    for (CustomModelDefinition cm : page)
    {
        if (cm.isActive())
        {
            activeModels++;
            activeTypes += cm.getTypeDefinitions().size();
            activeAspects += cm.getAspectDefinitions().size();
        }
    }

    CustomModelsInfo info = new CustomModelsInfo();
    info.setNumberOfActiveModels(activeModels);
    info.setNumberOfActiveTypes(activeTypes);
    info.setNumberOfActiveAspects(activeAspects);
    return info;
}
 
Example #4
Source File: CustomModelsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public CollectionWithPagingInfo<CustomModel> getCustomModels(Parameters parameters)
{
    Paging paging = parameters.getPaging();
    PagingRequest pagingRequest = Util.getPagingRequest(paging);
    PagingResults<CustomModelDefinition> results = customModelService.getCustomModels(pagingRequest);

    Integer totalItems = results.getTotalResultCount().getFirst();
    List<CustomModelDefinition> page = results.getPage();

    List<CustomModel> models = new ArrayList<>(page.size());
    for (CustomModelDefinition modelDefinition : page)
    {
        models.add(new CustomModel(modelDefinition));
    }

    return CollectionWithPagingInfo.asPaged(paging, models, results.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
}
 
Example #5
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreQNames", "sortProps", "pagingRequest"})
@Override
@Extend(traitAPI = FileFolderServiceTrait.class, extensionAPI = FileFolderServiceExtension.class)
public PagingResults<FileInfo> list(NodeRef contextNodeRef,
                                  boolean files,
                                  boolean folders,
                                  Set<QName> ignoreQNames,
                                  List<Pair<QName, Boolean>> sortProps,
                                  PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    Pair<Set<QName>,Set<QName>> pair = buildSearchTypesAndIgnoreAspects(files, folders, ignoreQNames);
    Set<QName> searchTypeQNames = pair.getFirst();
    Set<QName> ignoreAspectQNames = pair.getSecond();
    
    // execute query
    final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, null, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
    return getPagingResults(pagingRequest, results);
}
 
Example #6
Source File: PersonTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkPeopleContain(String userName)
{
    PagingRequest pagingRequest = new PagingRequest(0, 20000, null);
    PagingResults<PersonInfo> ppr = personService.getPeople(null, null, null, pagingRequest);
    
    boolean found = false;
    for (PersonInfo person : ppr.getPage())
    {
        if (person.getUserName().equals(userName))
        {
            found = true;
            break;
        }
    }
    assertTrue(found);
}
 
Example #7
Source File: AuthorityServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testNoUser()
{
    pubAuthorityService.createAuthority(AuthorityType.GROUP, "DEFAULT");

    authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    PagingResults<String> results = pubAuthorityService.getAuthorities(
            AuthorityType.GROUP, null, null, true, true, new PagingRequest(10));
    AuthenticationUtil.clearCurrentSecurityContext();
    try
    {
        pubAuthorityService.getAuthorities(
                AuthorityType.GROUP, null, null, true, true, new PagingRequest(10));
        fail("Public AuthorityService should reject unauthorized use.");
    }
    catch (AuthenticationCredentialsNotFoundException e)
    {
        // Expected
    }
    PagingResults<String> resultsCheck = authorityService.getAuthorities(
            AuthorityType.GROUP, null, null, true, true, new PagingRequest(10));
    assertEquals(
            "Unauthorized use of private service should work just like 'admin'",
            results.getPage().size(), resultsCheck.getPage().size());
}
 
Example #8
Source File: CopyServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<NodeRef> getCopies(NodeRef nodeRef)
{
    PagingRequest pagingRequest = new PagingRequest(1000);
    PagingResults<CopyInfo> page = getCopies(nodeRef, pagingRequest);
    if (page.hasMoreItems())
    {
        logger.warn("Trimmed page size for deprecated getCopies() call.");
    }
    List<CopyInfo> pageResults = page.getPage();
    List<NodeRef> results = new ArrayList<NodeRef>(pageResults.size());
    for (CopyInfo copyInfo : pageResults)
    {
        results.add(copyInfo.getNodeRef());
    }
    return results;
}
 
Example #9
Source File: RemoteCredentialsServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<? extends BaseCredentialsInfo> listSharedCredentials(String remoteSystem,
        QName credentialsType, PagingRequest paging)
{
    // Get the container for that system
    NodeRef container = getSharedContainer(remoteSystem, false);
    if (container == null)
    {
        return new EmptyPagingResults<BaseCredentialsInfo>();
    }
    return listCredentials(new NodeRef[] {container}, remoteSystem, credentialsType, paging);
}
 
Example #10
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Extend(traitAPI=FileFolderServiceTrait.class,extensionAPI=FileFolderServiceExtension.class)
public PagingResults<FileInfo> list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    Pair<Set<QName>,Set<QName>> pair = buildSearchTypesAndIgnoreAspects(files, folders, ignoreQNames);
    Set<QName> searchTypeQNames = pair.getFirst();
    Set<QName> ignoreAspectQNames = pair.getSecond();
    
    // execute query
    final CannedQueryResults<NodeRef> results = listImpl(contextNodeRef, pattern, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
    return getPagingResults(pagingRequest, results);
}
 
Example #11
Source File: BlogPostsNewGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected PagingResults<BlogPostInfo> getBlogResultsImpl(
      SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq)
{
   if(site != null)
   {
      return blogService.getPublished(site.getShortName(), fromDate, toDate, null, pagingReq);
   }
   else
   {
      return blogService.getPublished(node, fromDate, toDate, null, pagingReq);
   }
}
 
Example #12
Source File: DiscussionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<TopicInfo> listTopics(NodeRef nodeRef,
      Date from, Date to, boolean sortAscending, PagingRequest paging) 
{
   // Do the listing, with the sort order as requested
   CannedQueryResults<NodeBackedEntity> nodes = 
      listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, from, to, sortAscending, paging);
   
   // Wrap and return
   return wrap(nodes, nodeRef);
}
 
Example #13
Source File: ADMRemoteStore.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected PagingResults<FileInfo> getFileNodes(FileInfo fileInfo, String pattern, boolean recurse)
{
    return fileFolderService.list(
            fileInfo.getNodeRef(), true, false,
            pattern, null, null,
            new PagingRequest(CannedQueryPageDetails.DEFAULT_PAGE_SIZE));
}
 
Example #14
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private CannedQueryResults<NodeRef> listImpl(NodeRef contextNodeRef, String pattern, Set<QName> assocTypeQNames, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames,
                                             List<Pair<QName, Boolean>> sortProps, List<FilterProp> filterProps, PagingRequest pagingRequest)
{
    Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
    
    // get canned query
    GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_FILEFOLDER_LIST);

    GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, pattern, assocTypeQNames, searchTypeQNames, ignoreAspectQNames, filterProps, sortProps, pagingRequest);

    // execute canned query
    CannedQueryResults<NodeRef> results = cq.execute();
    
    if (start != null)
    {
        int cnt = results.getPagedResultCount();
        int skipCount = pagingRequest.getSkipCount();
        int maxItems = pagingRequest.getMaxItems();
        boolean hasMoreItems = results.hasMoreItems();
        Pair<Integer, Integer> totalCount = (pagingRequest.getRequestTotalCountMax() > 0 ? results.getTotalResultCount() : null);
        int pageNum = (skipCount / maxItems) + 1;
        
        logger.debug("List: "+cnt+" items in "+(System.currentTimeMillis()-start)+" msecs [pageNum="+pageNum+",skip="+skipCount+",max="+maxItems+",hasMorePages="+hasMoreItems+",totalCount="+totalCount+",parentNodeRef="+contextNodeRef+"]");
    }
    
    return results;
}
 
Example #15
Source File: VirtualFileFolderServiceExtensionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testListWithIgnores() throws Exception
{
    NodeRef vf = createVirtualizedFolder(testRootFolder.getNodeRef(),
                                         "TestVirtualFileFolderService_testVirtualFolderVirtualChild",
                                         TEST_TEMPLATE_3_JSON_SYS_PATH);
    NodeRef node2 = nodeService.getChildByName(vf,
                                               ContentModel.ASSOC_CHILDREN,
                                               "Node2");

    final String contentName = "ContentVirtualChild";
    NodeRef contentNodeRef = createContent(node2,
                                           contentName).getChildRef();

    CheckOutCheckInService checkOutCheckInService = ctx.getBean("checkOutCheckInService",
                                                                CheckOutCheckInService.class);

    checkOutCheckInService.checkout(contentNodeRef);

    Set<QName> searchTypeQNames = Collections.emptySet();
    Set<QName> ignoreAspectQNames = Collections.singleton(ContentModel.ASPECT_CHECKED_OUT);
    List<Pair<QName, Boolean>> sortProps = Collections.<Pair<QName, Boolean>> emptyList();
    PagingRequest pagingRequest = new PagingRequest(100);
    PagingResults<FileInfo> node2List = fileAndFolderService.list(node2,
                                                                  searchTypeQNames,
                                                                  ignoreAspectQNames,
                                                                  sortProps,
                                                                  pagingRequest);

    assertEquals(1,
                 node2List.getPage().size());

}
 
Example #16
Source File: DiscussionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<TopicInfo> findTopics(String siteShortName,
      String username, String tag, boolean sortAscending, PagingRequest paging) 
{
   NodeRef container = getSiteDiscussionsContainer(siteShortName, false);
   if (container == null)
   {
      // No topics
      return new EmptyPagingResults<TopicInfo>();
   }
   
   // We can now search by parent nodeRef
   return findTopics(container, username, tag, sortAscending, paging);
}
 
Example #17
Source File: TaggingServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
@Category({RedundantTests.class,LuceneTests.class})
public void testPagedTags() throws UnsupportedEncodingException
{
    authenticationComponent.setSystemUserAsCurrentUser();
    Pair<List<String>, Integer> tags = taggingService.getPagedTags(storeRef, 1, 10);
    assertNotNull(tags);
    PagingResults<Pair<NodeRef, String>> res = taggingService.getTags(storeRef, new PagingRequest(10));
    assertNotNull(res);


    String guid = GUID.generate();
    // Create a node
    Map<QName, Serializable> docProps = new HashMap<QName, Serializable>(1);
    String docName = "testDocument" + guid + ".txt";
    docProps.put(ContentModel.PROP_NAME, docName);
    NodeRef myDoc = nodeService.createNode(
            folder,
            ContentModel.ASSOC_CONTAINS,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, docName),
            ContentModel.TYPE_CONTENT,
            docProps).getChildRef();
    taggingService.addTag(myDoc,"dog");

    res = taggingService.getTags(myDoc, new PagingRequest(10));
    assertNotNull(res);
    assertTrue(res.getTotalResultCount().getFirst() == 1);
}
 
Example #18
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Extend(traitAPI=FileFolderServiceTrait.class,extensionAPI=FileFolderServiceExtension.class)
public PagingResults<FileInfo> list(NodeRef rootNodeRef, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
    CannedQueryResults<NodeRef> results = listImpl(rootNodeRef, null,  searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
    return getPagingResults(pagingRequest, results);
}
 
Example #19
Source File: ArchivedNodesCannedQueryBuilder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ArchivedNodesCannedQueryBuilder(Builder builder)
{
    ParameterCheck.mandatory("storeRef", (this.archiveRootNodeRef = builder.archiveRootNodeRef));
    ParameterCheck.mandatory("pagingRequest", builder.pagingRequest);        
  
    // Defensive copy
    PagingRequest pr = new PagingRequest(builder.pagingRequest.getSkipCount(),
                builder.pagingRequest.getMaxItems(),
                builder.pagingRequest.getQueryExecutionId());
    pr.setRequestTotalCountMax(builder.pagingRequest.getRequestTotalCountMax());
    this.pagingRequest = pr;
    this.filter = builder.filter;        
    this.sortOrderAscending = builder.sortOrderAscending;
}
 
Example #20
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<FileInfo> list(final NodeRef contextNodeRef, final boolean files, final boolean folders,
            final String pattern, final Set<QName> ignoreQNames, final List<Pair<QName, Boolean>> sortProps,
            final PagingRequest pagingRequest)
{
    return thisService.list(contextNodeRef,
                            files,
                            folders,
                            pattern,
                            ignoreQNames,
                            sortProps,
                            pagingRequest);
}
 
Example #21
Source File: GetChildrenCannedQueryFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Retrieve an optionally filtered/sorted instance of a {@link CannedQuery} based on parameters including request for a total count (up to a given max)
 * 
 * Note: if both filtering and sorting is required then the combined total of unique QName properties should be the 0 to 3.
 *
 * @param parentRef             parent node ref
 * @param pattern			    the pattern to use to filter children (wildcard character is '*')
 * @param assocTypeQNames	    qnames of assocs to include (may be null)
 * @param childTypeQNames       type qnames of children nodes (pre-filter)
 * @param inclusiveAspects      If not null, only child nodes with any aspect in this collection will be included in the results.
 * @param exclusiveAspects      If not null, any child nodes with any aspect in this collection will be excluded in the results.
 * @param filterProps           filter properties
 * @param sortProps             sort property pairs (QName and Boolean - true if ascending)
 * @param pagingRequest         skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax
 * 
 * @return                      an implementation that will execute the query
 */
public CannedQuery<NodeRef> getCannedQuery(NodeRef parentRef, String pattern, Set<QName> assocTypeQNames, Set<QName> childTypeQNames, Set<QName> inclusiveAspects, Set<QName> exclusiveAspects, List<FilterProp> filterProps, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("parentRef", parentRef);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    int requestTotalCountMax = pagingRequest.getRequestTotalCountMax();
    
    // specific query params - context (parent) and inclusive filters (child types, property values)
    GetChildrenCannedQueryParams paramBean = new GetChildrenCannedQueryParams(tenantService.getName(parentRef), assocTypeQNames, childTypeQNames, inclusiveAspects, exclusiveAspects, filterProps, pattern);

    // page details
    CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT);
    
    // sort details
    CannedQuerySortDetails cqsd = null;
    if (sortProps != null)
    {
        List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size());
        for (Pair<QName, Boolean> sortProp : sortProps)
        {
            sortPairs.add(new Pair<QName, SortOrder>(sortProp.getFirst(), (sortProp.getSecond() ? SortOrder.ASCENDING : SortOrder.DESCENDING)));
        }
        
        cqsd = new CannedQuerySortDetails(sortPairs);
    }
    
    // create query params holder
    CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId());
    
    // return canned query instance
    return getCannedQuery(params);
}
 
Example #22
Source File: VirtualQueryImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private SearchParameters createSearchParameters(boolean files, boolean folders, PagingRequest pagingRequest)
            throws VirtualizationException
{
    SearchParameters searchParameters = new SearchParameters();

    if (store != null)
    {
        searchParameters.addStore(new StoreRef(store));
    }
    else
    {
        searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    }
    searchParameters.setLanguage(language);
    searchParameters.setQuery(filter(language,
                                     query,
                                     files,
                                     folders));
    searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);

    if (pagingRequest != null)
    {
        searchParameters.setSkipCount(pagingRequest.getSkipCount());
        searchParameters.setMaxItems(pagingRequest.getMaxItems());
    }

    return searchParameters;
}
 
Example #23
Source File: DiscussionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Finds nodes in the specified parent container, with the given
 *  type, optionally filtered by creator
 */
private CannedQueryResults<NodeBackedEntity> listEntries(NodeRef parent, 
      QName nodeType, String creatorUsername, Date from, Date to, 
      boolean oldestFirst, PagingRequest paging) 
{
   // The Canned Query system doesn't allow for zero sized pages
   // If they asked for that (bits of share sometimes do), bail out now
   if (paging != null && paging.getMaxItems() == 0)
   {
      return new EmptyCannedQueryResults<NodeBackedEntity>(null);
   }
   
   // Grab the factory
   GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
   
   // Do the sorting, newest first or last by created date (as requested)
   CannedQuerySortDetails sorting = null;
   if (oldestFirst)
   {
      sorting = getChildrenCannedQueryFactory.createDateAscendingCQSortDetails();
   }
   else
   {
      sorting = getChildrenCannedQueryFactory.createDateDescendingCQSortDetails();
   }
   
   // Run the canned query
   GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
         parent, nodeType, creatorUsername, from, to, null,
         null, null, sorting, paging);
   
   // Execute the canned query
   CannedQueryResults<NodeBackedEntity> results = cq.execute();
   
   // Return for wrapping
   return results;
}
 
Example #24
Source File: FileFolderServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testListNotIgnoreSpaces()
{
    String [] foldersToTest = new String[] { 
        "A B", 
        "AA", 
        "AC" 
    };
    
    NodeRef testFolder = fileFolderService.create(workingRootNodeRef, "" + System.currentTimeMillis(), ContentModel.TYPE_FOLDER).getNodeRef();
    
    // create provided nodes
    for (String folder : foldersToTest)
    {
        fileFolderService.create(testFolder, folder, ContentModel.TYPE_FOLDER).getNodeRef();
    }
    
    PagingRequest pagingRequest = new PagingRequest(100, null);
    // ensure sort by property name
    List<Pair<QName, Boolean>> sortProps = new ArrayList<Pair<QName, Boolean>>(1);
    sortProps.add(new Pair<QName, Boolean>(ContentModel.PROP_NAME, true));
    // list nodes
    PagingResults<FileInfo> pagingResults = fileFolderService.list(testFolder, true, true, null, null, sortProps, pagingRequest);
    List<FileInfo> files = pagingResults.getPage();
     
    assertEquals(files.size(), foldersToTest.length);
    
    for (int index = 0; index < files.size(); index++)
    {
        // ensure node order is expected
        String folderName = files.get(index).getName();
        String excpectedFolderName = foldersToTest[index];
        assertEquals(folderName, excpectedFolderName);
    }
    
    System.out.println(files);
}
 
Example #25
Source File: DiscussionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<TopicInfo> listTopics(String siteShortName,
      boolean sortAscending, PagingRequest paging) 
{
   NodeRef container = getSiteDiscussionsContainer(siteShortName, false);
   if (container == null)
   {
      // No topics
      return new EmptyPagingResults<TopicInfo>();
   }
   
   // We can now fetch by parent nodeRef
   return listTopics(container, sortAscending, paging);
}
 
Example #26
Source File: CommentsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging, List<String> include)
  {
final NodeRef nodeRef = nodes.validateNode(nodeId);
      
      /* MNT-10536 : fix */
      final Set<QName> contentAndFolders = 
              new HashSet<>(Arrays.asList(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT));
      if (!nodes.nodeMatches(nodeRef, contentAndFolders, null))
      {
          throw new InvalidArgumentException("NodeId of folder or content is expected");
      }

  	PagingRequest pagingRequest = Util.getPagingRequest(paging);
      final PagingResults<NodeRef> pagingResults = commentService.listComments(nodeRef, pagingRequest);
      
final List<NodeRef> page = pagingResults.getPage();
List<Comment> comments = new AbstractList<>()
{
	@Override
	public Comment get(int index)
	{
		return toComment(nodeRef, page.get(index), include);
	}

	@Override
	public int size()
	{
		return page.size();
	}
};

      return CollectionWithPagingInfo.asPaged(paging, comments, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst());
  }
 
Example #27
Source File: SubscriptionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingFollowingResults getFollowing(String userId, PagingRequest pagingRequest)
{
    checkEnabled();
    checkRead(userId, true);
    return subscriptionsDAO.selectFollowing(userId, pagingRequest);
}
 
Example #28
Source File: BlogServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<BlogPostInfo> getPublished(String siteShortName,
     Date fromDate, Date toDate, String byUser, PagingRequest pagingReq) 
{
   NodeRef container = getSiteBlogContainer(siteShortName, false);
   if (container == null)
   {
      // No blog posts yet
      return new EmptyPagingResults<BlogPostInfo>();
   }
   
   // We can now fetch by parent nodeRef
   return getPublished(container, fromDate, toDate, byUser, pagingReq);
}
 
Example #29
Source File: FileFolderService.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Lists page of immediate child files and/or folders of the given context node
 * with optional filtering (exclusion of certain child file/folder subtypes) and sorting
 * 
 * <br/><br/>author janv
 * @since 4.0
 */
@Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreTypeQNames", "sortProps", "pagingRequest"})
public PagingResults<FileInfo> list(NodeRef contextNodeRef,
                                  boolean files,
                                  boolean folders,
                                  Set<QName> ignoreTypeQNames,
                                  List<Pair<QName, Boolean>> sortProps,
                                  PagingRequest pagingRequest);
 
Example #30
Source File: BlogServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<BlogPostInfo> findBlogPosts(String siteShortName,
     RangedDateProperty dateRange, String tag, PagingRequest pagingReq) 
{
    NodeRef container = getSiteBlogContainer(siteShortName, false);
    if (container == null)
    {
       // No blog posts yet
       return new EmptyPagingResults<BlogPostInfo>();
    }
    
    // We can now fetch by parent nodeRef
    return findBlogPosts(container, dateRange, tag, pagingReq);
}