org.alfresco.query.PagingResults Java Examples

The following examples show how to use org.alfresco.query.PagingResults. 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: 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 #2
Source File: VirtualStoreImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public PagingResults<Reference> list(Reference ref, boolean actual, boolean virtual, Set<QName> searchTypeQNames,
            Set<QName> ignoreTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps,
            PagingRequest pagingRequest) throws VirtualizationException
{
    // TODO: find null string value for pattern
    return list(ref,
                actual,
                virtual,
                true,
                true,
                null,
                searchTypeQNames,
                Collections.<QName> emptySet(),
                ignoreAspectQNames,
                sortProps,
                pagingRequest);
}
 
Example #3
Source File: VirtualStoreImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public PagingResults<Reference> list(Reference ref, boolean actual, boolean virtual, boolean files,
            boolean folders, String pattern, Set<QName> ignoreTypeQNames, Set<QName> ignoreAspectQNames,
            List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest) throws VirtualizationException
{
    return list(ref,
                actual,
                virtual,
                files,
                folders,
                pattern,
                Collections.<QName> emptySet(),
                ignoreTypeQNames,
                ignoreAspectQNames,
                sortProps,
                pagingRequest);
}
 
Example #4
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<PersonNetwork> getNetworkMemberships()
{
	String personId = getId();
	String runAsNetworkId = Person.getNetworkId(personId);
	return TenantUtil.runAsUserTenant(new TenantRunAsWork<List<PersonNetwork>>()
	{
		@Override
		public List<PersonNetwork> doWork() throws Exception
		{
			List<PersonNetwork> members = new ArrayList<PersonNetwork>();
			PagingResults<Network> networks = networksService.getNetworks(new PagingRequest(0, Integer.MAX_VALUE));
			for(Network network : networks.getPage())
			{
	            NetworkImpl restNetwork = new NetworkImpl(network);
	            PersonNetwork personNetwork = new PersonNetwork(network.getIsHomeNetwork(), restNetwork);
				members.add(personNetwork);
			}
			return members;
		}
	}, personId, runAsNetworkId);
}
 
Example #5
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public PagingResults<SiteMembership> listMembersPaged(String shortName, boolean collapseGroups, List<Pair<SiteService.SortFields, Boolean>> sortProps, PagingRequest pagingRequest)
  {
      CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());

      // sort details
      CannedQuerySortDetails sortDetails = null;
      if(sortProps != null)
      {
          List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(sortProps.size());
          for (Pair<SiteService.SortFields, Boolean> sortProp : sortProps)
          {
              sortPairs.add(new Pair<SiteService.SortFields, SortOrder>(sortProp.getFirst(), (sortProp.getSecond() ? SortOrder.ASCENDING : SortOrder.DESCENDING)));
          }
          
          sortDetails = new CannedQuerySortDetails(sortPairs);
      }

      SiteMembersCannedQueryParams parameterBean = new SiteMembersCannedQueryParams(shortName, collapseGroups);
      CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());

CannedQuery<SiteMembership> query = new SiteMembersCannedQuery(this, personService, nodeService, params);

      CannedQueryResults<SiteMembership> results = query.execute();

      return getPagingResults(pagingRequest, results);
  }
 
Example #6
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public PagingResults<FileInfo> listContainers(String shortName, PagingRequest pagingRequest)
{
    SiteContainersCannedQueryFactory sitesContainersCannedQueryFactory = (SiteContainersCannedQueryFactory)cannedQueryRegistry.getNamedObject("siteContainersCannedQueryFactory");

    CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
    CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING));
    SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName));
    CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());

    CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params);
    
    CannedQueryResults<FileInfo> results = query.execute();

    return getPagingResults(pagingRequest, results);        
}
 
Example #7
Source File: AbstractArchivedNodeWebScript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * * This method gets all nodes from the archive which were originally
 * contained within the specified StoreRef.
 * 
 * @param storeRef mandatory store ref
 * @param paging mandatory paging
 * @param filter optional filter
 */
protected PagingResults<NodeRef> getArchivedNodesFrom(StoreRef storeRef, ScriptPagingDetails paging, String filter)
{
    NodeService nodeService = serviceRegistry.getNodeService();
    NodeRef archiveStoreRootNodeRef = nodeService.getStoreArchiveNode(storeRef);

    // Create canned query
    ArchivedNodesCannedQueryBuilder queryBuilder = new ArchivedNodesCannedQueryBuilder.Builder(
                archiveStoreRootNodeRef, paging).filter(filter)
                .sortOrderAscending(false).build();

    // Query the DB
    PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);

    return result;
}
 
Example #8
Source File: AbstractGetBlogWebScript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Fetches all posts of the given blog
 */
private PagingResults<BlogPostInfo> getBlogPostList(SiteInfo site, NodeRef nonSiteContainer, 
      Date fromDate, Date toDate, String tag, PagingRequest pagingReq)
{
    // Currently we only support CannedQuery-based gets without tags:
    if (tag == null || tag.trim().isEmpty())
    {
        return getBlogResultsImpl(site, nonSiteContainer, fromDate, toDate, pagingReq);
    }
    else
    {
        RangedDateProperty dateRange = new RangedDateProperty(fromDate, toDate, ContentModel.PROP_CREATED);  
        if(site != null)
        {
           return blogService.findBlogPosts(site.getShortName(), dateRange, tag, pagingReq);
        }
        else
        {
           return blogService.findBlogPosts(nonSiteContainer, dateRange, tag, pagingReq);
        }
    }
}
 
Example #9
Source File: DeletedNodesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public CollectionWithPagingInfo<Node> listDeleted(Parameters parameters)
{
    PagingRequest pagingRequest = Util.getPagingRequest(parameters.getPaging());
    NodeRef archiveStoreRootNodeRef = nodeService.getStoreArchiveNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Create canned query
    ArchivedNodesCannedQueryBuilder queryBuilder = new ArchivedNodesCannedQueryBuilder.Builder(
            archiveStoreRootNodeRef, pagingRequest).sortOrderAscending(false).build();

    // Query the DB
    PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);

    Integer totalItems = result.getTotalResultCount().getFirst();

    List<Node> nodesFound = new ArrayList<Node>(result.getPage().size());
    Map mapUserInfo = new HashMap<>();
    for (NodeRef nRef:result.getPage())
    {
        Node foundNode = nodes.getFolderOrDocument(nRef, null, null, parameters.getInclude(), mapUserInfo);
        mapArchiveInfo(foundNode,mapUserInfo);
        nodesFound.add(foundNode);
    }

    return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodesFound, result.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
}
 
Example #10
Source File: AuthorityServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testGetAuthoritiesForZone() 
{
    String role = pubAuthorityService.createAuthority(AuthorityType.ROLE, "one");
    String group = pubAuthorityService.createAuthority(AuthorityType.GROUP, "group1");
    String user = "user@" + System.currentTimeMillis();
    createUserAuthority(user);

    PagingResults<String> authorities = authorityService.getAuthorities(null, AuthorityService.ZONE_APP_DEFAULT, "*", false, false, new PagingRequest(100));
    assertTrue(authorities.getPage().contains(user));
    assertTrue(authorities.getPage().contains(role));
    assertTrue(authorities.getPage().contains(group));
    
    PagingResults<String> groups = authorityService.getAuthorities(AuthorityType.GROUP, AuthorityService.ZONE_APP_DEFAULT, "*", false, false, new PagingRequest(100));
    assertTrue(groups.getPage().contains(group));
    assertFalse(groups.getPage().contains(user));
    assertFalse(groups.getPage().contains(role));
}
 
Example #11
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 #12
Source File: CalendarServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<CalendarEntry> listCalendarEntries(
      String[] siteShortNames, PagingRequest paging) 
{
   // If we only have the one site, use the list above 
   if (siteShortNames != null && siteShortNames.length == 1)
   {
      return listCalendarEntries(siteShortNames[0], paging);
   }

   // Use the date one with no dates
   return listCalendarEntries(siteShortNames, null, null, paging);
}
 
Example #13
Source File: CalendarServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<CalendarEntry> listCalendarEntries(
      String siteShortName, PagingRequest paging) 
{
   NodeRef container = getSiteCalendarContainer(siteShortName, false);
   if (container == null)
   {
      // No events
      return new EmptyPagingResults<CalendarEntry>();
   }
   
   // Build our sorting, by date
   // Sort by start date, then end date, then created at for two events with matching times 
   List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName, Boolean>>();
   sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_FROM_DATE, true)); 
   sort.add(new Pair<QName, Boolean>(CalendarModel.PROP_TO_DATE, true));
   sort.add(new Pair<QName, Boolean>(ContentModel.PROP_CREATED, true)); 
   
   // We only want calendar entries
   Set<QName> types = new HashSet<QName>();
   types.add(CalendarModel.TYPE_EVENT);
   
   // Run the canned query
   GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
   GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
         container, null, null, types, null, sort, paging);
   
   // Execute the canned query
   CannedQueryResults<NodeRef> results = cq.execute();
   return wrap(results, container);
}
 
Example #14
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,
      boolean sortAscending, PagingRequest paging) 
{
   // Do the listing, oldest first
   CannedQueryResults<NodeBackedEntity> nodes = 
      listEntries(nodeRef, ForumModel.TYPE_TOPIC, null, null, null, sortAscending, paging);
   
   // Wrap and return
   return wrap(nodes, nodeRef);
}
 
Example #15
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 #16
Source File: AuthorityDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private <T> PagingResults<T> getAuthoritiesImpl(AuthorityType type, NodeRef containerRef, String displayNameFilter, String sortBy, boolean sortAscending, PagingRequest pagingRequest, AbstractPagingResults<T> finalResults)
{
    Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
    
    if (type != null)
    {
        switch (type)
        {
        case GROUP:
        case ROLE:
        case USER:
            // drop through
            break;
        default:
            throw new UnsupportedOperationException("Unexpected authority type: "+type);
        }
    }
    
    // get canned query
    GetAuthoritiesCannedQueryFactory getAuthoritiesCannedQueryFactory = (GetAuthoritiesCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_AUTHS_LIST);
    CannedQuery<AuthorityInfo> cq = getAuthoritiesCannedQueryFactory.getCannedQuery(type, containerRef, displayNameFilter, sortBy, sortAscending, pagingRequest);
    
    // execute canned query
    final CannedQueryResults<AuthorityInfo> results = cq.execute();

    finalResults.setResults(results);
    
    if (start != null)
    {
        int cnt = finalResults.getPage().size();
        int skipCount = pagingRequest.getSkipCount();
        int maxItems = pagingRequest.getMaxItems();
        boolean hasMoreItems = finalResults.hasMoreItems();
        int pageNum = (skipCount / maxItems) + 1;
        
        logger.debug("getAuthoritiesByType: "+cnt+" items in "+(System.currentTimeMillis()-start)+" msecs [type="+type+",pageNum="+pageNum+",skip="+skipCount+",max="+maxItems+",hasMorePages="+hasMoreItems+",filter="+displayNameFilter+"]");
    }
    
    return finalResults;
}
 
Example #17
Source File: AuthorityDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PagingResults<String> getAuthorities(AuthorityType type, String zoneName, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest)
{
    checkGetAuthorityParams(type, zoneName, pagingRequest);
    
    if ((zoneName == null) && (type.equals(AuthorityType.USER)))
    {
        return getUserAuthoritiesImpl(displayNameFilter, sortByDisplayName, sortAscending, pagingRequest);
    }
    
    return getAuthoritiesImpl(type, getContainerRef(zoneName), displayNameFilter, (sortByDisplayName ? GetAuthoritiesCannedQuery.DISPLAY_NAME : null), sortAscending, pagingRequest, new PagingResultsString());
}
 
Example #18
Source File: SitesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CollectionWithPagingInfo<SiteMember> getSiteMembers(String siteId, Parameters parameters)
{
    SiteInfo siteInfo = validateSite(siteId);
    if(siteInfo == null)
    {
        // site does not exist
        throw new EntityNotFoundException(siteId);
    }
    // set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
    siteId = siteInfo.getShortName();

    Paging paging = parameters.getPaging();

    PagingRequest pagingRequest = Util.getPagingRequest(paging);

    final List<Pair<SiteService.SortFields, Boolean>> sort = new ArrayList<Pair<SiteService.SortFields, Boolean>>();
    sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.LastName, Boolean.TRUE));
    sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.FirstName, Boolean.TRUE));
    sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.Role, Boolean.TRUE));
    sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.Username, Boolean.TRUE));
    PagingResults<SiteMembership> pagedResults = siteService.listMembersPaged(siteId, true, sort, pagingRequest);

    List<SiteMembership> siteMembers = pagedResults.getPage();
    List<SiteMember> ret = new ArrayList<SiteMember>(siteMembers.size());
    for(SiteMembership siteMembership : siteMembers)
    {
        SiteMember siteMember = new SiteMember(siteMembership.getPersonId(), siteMembership.getRole());
        ret.add(siteMember);
    }

    return CollectionWithPagingInfo.asPaged(paging, ret, pagedResults.hasMoreItems(), null);
}
 
Example #19
Source File: AuthorityServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    ParameterCheck.mandatory("type", type);
    
    if (type != AuthorityType.USER && type != AuthorityType.GROUP && type != AuthorityType.ROLE)
    {
        throw new UnsupportedOperationException("Unexpected authority type: "+type);
    }
    return authorityDAO.getAuthoritiesInfo(type, zoneName, displayNameFilter, sortBy, sortAscending, pagingRequest);
}
 
Example #20
Source File: FavouritesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private CollectionWithPagingInfo<Favourite> wrap(Paging paging, PagingResults<PersonFavourite> personFavourites, Parameters parameters)
  {
  	final List<PersonFavourite> page = personFavourites.getPage();
  	final List<Favourite> list = new AbstractList<Favourite>()
{
	@Override
	public Favourite get(int index)
	{
		PersonFavourite personFavourite = page.get(index);
		Favourite fav = getFavourite(personFavourite, parameters);
		return fav;
	}

	@Override
	public int size()
	{
		return page.size();
	}
};
Pair<Integer, Integer> pair = personFavourites.getTotalResultCount();
Integer total = null;
if(pair.getFirst().equals(pair.getSecond()))
{
	total = pair.getFirst();
}
  	return CollectionWithPagingInfo.asPaged(paging, list, personFavourites.hasMoreItems(), total);
  }
 
Example #21
Source File: BlogPostsMyPublishedGet.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)
{
    String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
    if(site != null)
    {
       return blogService.getPublished(site.getShortName(), fromDate, toDate, fullyAuthenticatedUser, pagingReq);
    }
    else
    {
       return blogService.getPublished(node, fromDate, toDate, fullyAuthenticatedUser, pagingReq);
    }
}
 
Example #22
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 #23
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 #24
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 rootNodeRef, final Set<QName> searchTypeQNames,
            final Set<QName> ignoreAspectQNames, final List<Pair<QName, Boolean>> sortProps,
            final PagingRequest pagingRequest)
{
    return thisService.list(rootNodeRef,
                            searchTypeQNames,
                            ignoreAspectQNames,
                            sortProps,
                            pagingRequest);
}
 
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> 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 #26
Source File: SystemTemplateLocationsConstraintTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testConfiguredConstraints() throws Exception
{
    List<String> rawAllowedValues = constraints.getRawAllowedValues();
    NodeRefExpression sysTemplatesPath = virtualizationConfigTestBootstrap.getSystemTemplatesPath();

    NodeRef templatesLocation = sysTemplatesPath.resolve(true);

    PagingResults<FileInfo> templates = fileAndFolderService
                .list(templatesLocation,
                      Collections.singleton(VirtualContentModel.TYPE_VIRTUAL_FOLDER_TEMPLATE),
                      null,
                      null,
                      new PagingRequest(1000));

    List<FileInfo> templatesPage = templates.getPage();
    if (!templatesPage.isEmpty())
    {
        assertEquals(templatesPage.size(),
                     rawAllowedValues.size());

        List<String> expectedSysPaths = new LinkedList<>();
        for (FileInfo fi : templatesPage)
        {
            expectedSysPaths.add("N" + fi.getNodeRef().toString());
        }

        assertTrue(rawAllowedValues.containsAll(expectedSysPaths));
    }

}
 
Example #27
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 #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: 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 #30
Source File: PreferencesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CollectionWithPagingInfo<Preference> getPreferences(String personId, Paging paging)
{
	personId = people.validatePerson(personId);

	PagingResults<Pair<String, Serializable>> preferences = preferenceService.getPagedPreferences(personId, null, Util.getPagingRequest(paging));
	List<Preference> ret = new ArrayList<Preference>(preferences.getPage().size());
	for(Pair<String, Serializable> prefEntity : preferences.getPage())
	{
		Preference pref = new Preference(prefEntity.getFirst(), prefEntity.getSecond());
		ret.add(pref);
	}

       return CollectionWithPagingInfo.asPaged(paging, ret, preferences.hasMoreItems(), preferences.getTotalResultCount().getFirst());
}