• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PersonInfo类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.alfresco.service.cmr.security.PersonService.PersonInfo的典型用法代码示例。如果您正苦于以下问题:Java PersonInfo类的具体用法?Java PersonInfo怎么用?Java PersonInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PersonInfo类属于org.alfresco.service.cmr.security.PersonService包,在下文中一共展示了PersonInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkPeopleContain

点赞 3

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
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);
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:17,
代码来源:PersonTest.java

示例2: getPeoplePaging

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public Scriptable getPeoplePaging(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
{
    List<PersonInfo> persons = getPeopleImpl(filter, pagingRequest, sortBy, sortAsc);
    
    Object[] peopleRefs = new Object[persons.size()];
    for (int i = 0; i < peopleRefs.length; i++)
    {
        peopleRefs[i] = persons.get(i).getNodeRef();
    }
    
    return Context.getCurrentContext().newArray(getScope(), peopleRefs);
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:13,
代码来源:People.java

示例3: buildMailTextModel

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
@Override
protected Map<String, Serializable> buildMailTextModel(Map<String, String> properties)
{
    NodeRef invitee = personService.getPerson(properties.get(WorkflowModelModeratedInvitation.wfVarInviteeUserName));
    Map<String, Serializable> model = new HashMap<String, Serializable>();
    model.put(TemplateService.KEY_COMPANY_HOME, repository.getCompanyHome());
    model.put(TemplateService.KEY_USER_HOME, repository.getUserHome(repository.getPerson()));
    model.put(TemplateService.KEY_PRODUCT_NAME, ModelUtil.getProductName(repoAdminService));

    PersonInfo inviteePerson = personService.getPerson(invitee);
    model.put("inviteeName", StringUtils.join(new String[] { inviteePerson.getFirstName(), inviteePerson.getLastName() }, " "));
    model.put("siteName", getSiteName(properties));
    model.put("sharePendingInvitesLink", StringUtils.stripStart(getPendingInvitesLink(properties), "/"));
    return model;
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:16,
代码来源:InviteModeratedSender.java

示例4: mockPersonService

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
/**
 * Mocks up a PersonService that returns the correct NodeRef when given a* user name.
 * 
 * @return PersonService
 */
private PersonService mockPersonService()
{
    PersonService personService = mock(PersonService.class);
    
    when(personService.getPerson(requesterUserName)).thenReturn(requesterNodeRef);
    when(personService.getPerson(requesterNodeRef)).thenReturn(new PersonInfo(requesterNodeRef, requesterUserName, requesterFirstName, requesterLastName));
    return personService;
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:14,
代码来源:InviteModeratedSenderTest.java

示例5: checkUserExistsAndState

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
protected void checkUserExistsAndState(final String userName, final String firstName, final String lastName,
        final boolean avatarMustExist)
{
    final WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
    final PersonService personService = context.getBean("PersonService", PersonService.class);

    Assert.assertTrue("User should have been synchronised/created", personService.personExists(userName));
    final NodeRef personNodeRef = personService.getPerson(userName, false);
    final PersonInfo personInfo = personService.getPerson(personNodeRef);

    Assert.assertEquals("First name of user does not match expectation", firstName, personInfo.getFirstName());
    Assert.assertEquals("Last name of user does not match expectation", lastName, personInfo.getLastName());

    final NodeService nodeService = context.getBean("NodeService", NodeService.class);
    final ContentService contentService = context.getBean("ContentService", ContentService.class);

    final List<ChildAssociationRef> avatarAssocs = nodeService.getChildAssocs(personNodeRef, ContentModel.ASSOC_PREFERENCE_IMAGE,
            RegexQNamePattern.MATCH_ALL);
    Assert.assertEquals("No user thumbnail has been synchronised", avatarMustExist ? 1 : 0, avatarAssocs.size());
    if (avatarMustExist)
    {
        final NodeRef avatar = avatarAssocs.get(0).getChildRef();
        final ContentReader reader = contentService.getReader(avatar, ContentModel.PROP_CONTENT);

        Assert.assertNotNull("Avatar should have content", reader);
        Assert.assertTrue("Avatar should exist", reader.exists());
        Assert.assertNotEquals("Avatar should not be zero-byte", 0, reader.getSize());
        Assert.assertEquals("Avatar mimetype should have been image/jpeg", MimetypeMap.MIMETYPE_IMAGE_JPEG, reader.getMimetype());
    }
}
 

开发者ID:Acosix,
项目名称:alfresco-mt-support,
代码行数:31,
代码来源:AuthenticationAndSynchronisationTests.java

示例6: buildMailTextModel

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
@Override
protected Map<String, Serializable> buildMailTextModel(Map<String, String> properties)
{
    NodeRef invitee = personService.getPerson(properties.get(WorkflowModelModeratedInvitation.wfVarInviteeUserName));
    Map<String, Serializable> model = new HashMap<String, Serializable>();
    model.put(TemplateService.KEY_COMPANY_HOME, repository.getCompanyHome());
    model.put(TemplateService.KEY_USER_HOME, repository.getUserHome(repository.getPerson()));
    model.put(TemplateService.KEY_PRODUCT_NAME, ModelUtil.getProductName(repoAdminService));

    PersonInfo inviteePerson = personService.getPerson(invitee);
    model.put("inviteeName", StringUtils.join(new String[] { inviteePerson.getFirstName(), inviteePerson.getLastName() }, " "));
    model.put("siteName", getSiteName(properties));
    model.put("sharePendingInvitesLink", MessageFormat.format(SHARE_PENDING_INVITES_LINK, properties.get(WorkflowModelModeratedInvitation.wfVarResourceName)));
    return model;
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:16,
代码来源:InviteModeratedSender.java

示例7: searchUsers

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
/**
 * Search for users
 * Includes paging parameters to limit size of results returned.
 * 
 * @param nameFilter partial match of the name (username, first name, last name). If empty then matches everyone.
 * @param paging Paging object with max number to return, and items to skip
 * @param sortBy What to sort on (firstName, lastName or userName)
 * @return the users matching the query
 * 
 * @deprecated see People.getPeople(String filter, ScriptPagingDetails pagingRequest, String sortBy)
 */
public ScriptUser[] searchUsers(String nameFilter, ScriptPagingDetails paging, String sortBy)
{
   // Build the filter
   List<Pair<QName,String>> filter = new ArrayList<Pair<QName,String>>();
   filter.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, nameFilter));
   filter.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, nameFilter));
   filter.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, nameFilter));
   
   // In order to support queries for "Alan Smithee", we'll parse these tokens
   // and add them in to the query.
   final Pair<String, String> tokenisedName = tokeniseName(nameFilter);
   if (tokenisedName != null)
   {
       filter.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, tokenisedName.getFirst()));
       filter.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, tokenisedName.getSecond()));
   }
   
   // Build the sorting. The user controls the primary sort, we supply
   // additional ones automatically
   List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName,Boolean>>();
   if ("lastName".equals(sortBy))
   {
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, true));
   }
   else if ("firstName".equals(sortBy))
   {
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, true));
   }
   else
   {
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, true));
      sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, true));
   }
   
   // Do the search
   List<PersonInfo> people = personService.getPeople(filter, true, sort, paging).getPage();
   
   // Record the size of the results
   paging.setTotalItems(people.size());
   
   // Now wrap up the users
   ScriptUser[] users = new ScriptUser[people.size()];
   for (int i=0; i<users.length; i++)
   {
      PersonInfo person = people.get(i);
      users[i] = new ScriptUser(person.getUserName(), person.getNodeRef(), serviceRegistry, this.getScope());
   }
   
   return users;
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:67,
代码来源:ScriptAuthorityService.java

示例8: getUserAuthoritiesImpl

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
private PagingResults<String> getUserAuthoritiesImpl(String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest)
{
    List<Pair<QName,String>> filter = null;
    if (displayNameFilter != null)
    {
        filter = new ArrayList<Pair<QName,String>>();
        filter.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, displayNameFilter));
    }
    
    List<Pair<QName,Boolean>> sort = null;
    if (sortByDisplayName)
    {
        sort = new ArrayList<Pair<QName,Boolean>>();
        sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, sortAscending));
    }
    
    final PagingResults<PersonInfo> ppr = personService.getPeople(filter, true, sort, pagingRequest);
    
    List<PersonInfo> result = ppr.getPage();
    final List<String> auths = new ArrayList<String>(result.size());
    
    for (PersonInfo person : result)
    {
        auths.add(getPooledName(person.getUserName()));
    }
    
    return new PagingResults<String>()
    {
        @Override
        public String getQueryExecutionId()
        {
            return ppr.getQueryExecutionId();
        }
        @Override
        public List<String> getPage()
        {
            return auths;
        }
        @Override
        public boolean hasMoreItems()
        {
            return ppr.hasMoreItems();
        }
        @Override
        public Pair<Integer, Integer> getTotalResultCount()
        {
            return ppr.getTotalResultCount();
        }
    };
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:51,
代码来源:AuthorityDAOImpl.java

示例9: getPeopleImpl

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
protected List<PersonInfo> getPeopleImpl(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
{
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    boolean useCQ = false;
    if (filter != null)
    {
        if (filter.endsWith(HINT_CQ_SUFFIX))
        {
            useCQ = honorHintUseCQ;
            filter = filter.substring(0, filter.length()-HINT_CQ_SUFFIX.length());
        }
    }
    else
    {
        filter = "*";
    }
    
    List<PersonInfo> persons = null;
    
    int maxResults = pagingRequest.getMaxItems();
    if ((maxResults <= 0) || (maxResults > defaultListMaxResults))
    {
        // remove open-ended query (eg cutoff at default/configurable max, eg. 5000 people)
        maxResults = defaultListMaxResults;
        pagingRequest.setMaxItems(maxResults);
    }
    
    // In order to use a SOLR/Lucene search, we must have a non-empty filter string - see ALF-18876
    if ((filter == null || filter.trim().isEmpty()) || useCQ)
    {
        persons = getPeopleImplDB(filter, pagingRequest, sortBy, sortAsc);
    }
    else
    {
        filter = filter.trim();
        
        String term = filter.replace("\"", "");
        String[] tokens = term.split("(?<!\\\\) ");
        int propIndex = term.lastIndexOf(':');
        int wildPosition = term.indexOf('*');
        
        // simple filter - can use CQ if search fails
        useCQ = ((tokens.length == 1) && (propIndex == -1) && ((wildPosition == -1) || (wildPosition == (term.length() - 1))));
        
        try
        {
            // FTS
            List<NodeRef> personRefs = getPeopleImplSearch(term, tokens, pagingRequest, sortBy, sortAsc);
            
            if (personRefs != null)
            {
                persons = new ArrayList<PersonInfo>(personRefs.size());
                for (NodeRef personRef : personRefs)
                {
                    persons.add(personService.getPerson(personRef));
                }
            }
        }
        catch (Throwable err)
        {
            if (useCQ)
            {
                // search unavailable and/or parser exception - try CQ instead
                // simple non-FTS filter: firstname or lastname or username starting with term (ignoring case)
                persons = getPeopleImplDB(filter, pagingRequest, sortBy, sortAsc);
            }
        }
    }
    
    return (persons != null ? persons : new ArrayList<PersonInfo>(0));
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:73,
代码来源:People.java

示例10: getPeopleImplDB

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
protected List<PersonInfo> getPeopleImplDB(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc)
{
    List<QName> filterProps = null;
    
    if ((filter != null) && (filter.length() > 0))
    {
        filter = filter.trim();
        if (! filter.equals("*"))
        {
            filter = filter.replace("\\", "").replace("\"", "");
            
            // simple non-FTS filter: firstname or lastname or username starting with term (ignoring case)
            
            filterProps = new ArrayList<QName>(3);
            filterProps.add(ContentModel.PROP_FIRSTNAME);
            filterProps.add(ContentModel.PROP_LASTNAME);
            filterProps.add(ContentModel.PROP_USERNAME);
        }
    }
    
    // Build the sorting. The user controls the primary sort, we supply
    // additional ones automatically
    List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName,Boolean>>();
    if ("lastName".equals(sortBy))
    {
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, sortAsc));
    }
    else if ("firstName".equals(sortBy))
    {
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, sortAsc));
    }
    else
    {
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, sortAsc));
       sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, sortAsc));
    }
    
    return personService.getPeople(filter, filterProps, sort, pagingRequest).getPage();
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:45,
代码来源:People.java

示例11: testPeopleFiltering

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testPeopleFiltering()
{
    personService.setCreateMissingPeople(false);
    
    assertEquals(2, getPeopleCount());
    
    checkPeopleContain(AuthenticationUtil.getAdminUserName());
    checkPeopleContain(AuthenticationUtil.getGuestUserName());
    
    personService.createPerson(createDefaultProperties("aa", "Aa", "Aa", "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("bc", "c", "C", "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("yy", "B", "D", "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("Yz", "yz", "B", "[email protected]", "alfresco", rootNodeRef));
    
    assertEquals(6, getPeopleCount());
    
    PagingRequest pr = new PagingRequest(100, null);
    
    PagingResults<PersonInfo> people = personService.getPeople(null, null, null, null, false, null, pr);
    assertEquals("Administrators not filtered", 5, people.getPage().size());

    List<QName> filters = new ArrayList<QName>(4);
    
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    assertEquals(2, personService.getPeople("y", filters, null, pr).getPage().size());
    
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    filters.add(ContentModel.PROP_FIRSTNAME);
    filters.add(ContentModel.PROP_LASTNAME);
    assertEquals(3, personService.getPeople("b", filters, null, pr).getPage().size());
    
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    assertEquals(2, personService.getPeople("A", filters, null, pr).getPage().size()); // includes "admin"
    
    personService.deletePerson("aa");
    
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    assertEquals(1, personService.getPeople("a", filters, null, pr).getPage().size()); // includes "admin"
    
    // a* is the same as a
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    assertEquals(1, personService.getPeople("a*", filters, null, pr).getPage().size()); // includes "admin"
    
    // * means everyone
    filters.clear();
    filters.add(ContentModel.PROP_USERNAME);
    assertEquals(5, getPeopleCount());
    assertEquals(5, personService.getPeople("*", filters, null, pr).getPage().size());
}
 

开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:55,
代码来源:PersonTest.java

示例12: getUserLoginFromEmail

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
/**
 * @see org.alfresco.module.vti.handler.UserGroupServiceHandler#getUserLoginFromEmail(java.lang.String, java.util.List)
 */
public List<UserBean> getUserLoginFromEmail(String dwsUrl, List<String> emailList)
{
    if (logger.isDebugEnabled())
        logger.debug("Method with name 'getUserLoginFromEmail' is started.");

    List<UserBean> result = new LinkedList<UserBean>();

    for (String loginOrEmail : emailList)
    {
        if (logger.isDebugEnabled())
            logger.debug("Checking existence of login or email '" + loginOrEmail + "'.");

        if (personService.personExists(loginOrEmail))
        {
            if (logger.isDebugEnabled())
                logger.debug("Login '" + loginOrEmail + "' is exist, adding to result.");

            result.add(getUserBean(personService.getPerson(loginOrEmail)));
        }
        else
        {
            // Search for the person by email
            List<Pair<QName,String>> filter = new ArrayList<Pair<QName,String>>();
            filter.add(new Pair<QName,String>(
                    ContentModel.PROP_EMAIL, loginOrEmail
            ));
            PagingRequest paging = new PagingRequest(10);
            
            // Do the search, case insensitively without sorting
            PagingResults<PersonInfo> people = personService.getPeople(filter, true, null, paging);
            
            // Did we find them?
            if (people.getPage().size() == 0)
            {
                if (logger.isDebugEnabled())
                    logger.debug("No person details found for " + loginOrEmail);
                
                // Fake their details
                UserBean userBean = new UserBean();
                userBean.setEmail(loginOrEmail);
                result.add(userBean);
            }
            else
            {
                if (people.getPage().size() > 1)
                {
                    logger.info("Found " + people.getPage().size() + " person details for " +
                                "email " + loginOrEmail + ", using only the first");
                }
                
                // Build up the details for them
                PersonInfo person = people.getPage().get(0);
                result.add(getUserBean(person.getNodeRef()));
                
                if (logger.isDebugEnabled())
                    logger.debug("Found user details for " + loginOrEmail + " as " + person.getFirstName() + 
                                 " " + person.getLastName() + " at " + person.getNodeRef());
            }
        }
    }
    if (logger.isDebugEnabled())
        logger.debug("Method with name 'getUserLoginFromEmail' is finished.");

    return result;
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:69,
代码来源:AlfrescoUserGroupServiceHandler.java

示例13: getPeopleCount

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
private int getPeopleCount()
{
    // Can either get a large page with all results (up to a given max) ...
    
    PagingRequest pagingRequest = new PagingRequest(20000, null); // note: people (up to max of 20000)
    int count = personService.getPeople(null, null, null, pagingRequest).getPage().size();
    
    // ... or request 1 item + total count (up to a given max)
    
    pagingRequest = new PagingRequest(0, 1, null);
    pagingRequest.setRequestTotalCountMax(20000); // note: request total people count (up to max of 20000)
    
    PagingResults<PersonInfo> ppr = personService.getPeople(null, null, null, pagingRequest);
    
    Pair<Integer, Integer> totalResultCount = ppr.getTotalResultCount();
    assertNotNull(totalResultCount);
    assertTrue(totalResultCount.getFirst() == totalResultCount.getSecond());
    
    assertEquals(count, totalResultCount.getFirst().intValue());
    
    return count;
    
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:24,
代码来源:PersonTest.java

示例14: testPeopleSortingPaging

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testPeopleSortingPaging()
{
    personService.setCreateMissingPeople(false);
    
    assertEquals(2, getPeopleCount());
    
    NodeRef p1 = personService.getPerson(AuthenticationUtil.getAdminUserName()); // admin - by default
    NodeRef p2 = personService.getPerson(AuthenticationUtil.getGuestUserName()); // guest - by default
    
    NodeRef p3 = personService.createPerson(createDefaultProperties("aa", "Aa", "Aa", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p4 = personService.createPerson(createDefaultProperties("cc", "Cc", "Cc", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p5 = personService.createPerson(createDefaultProperties("hh", "Hh", "Hh", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p6 = personService.createPerson(createDefaultProperties("bb", "Bb", "Bb", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p7 = personService.createPerson(createDefaultProperties("dd", "Dd", "Dd", "[email protected]", "alfresco", rootNodeRef));
    
    int expectedTotalCount = 7;
    assertEquals(expectedTotalCount, getPeopleCount());
    
    Pair<Integer,Integer> expectedResultCount = new Pair<Integer,Integer>(expectedTotalCount,expectedTotalCount);
    
    List<Pair<QName, Boolean>> sort = new ArrayList<Pair<QName, Boolean>>(1);
    sort.add(new Pair<QName,Boolean>(ContentModel.PROP_USERNAME, true));
    
    // page 1
    PagingRequest pr = new PagingRequest(0, 2, null);
    PagingResults<PersonInfo> ppr = personService.getPeople(null, true, sort, pr);
    List<PersonInfo> results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p3, results.get(0).getNodeRef());
    assertEquals(p1, results.get(1).getNodeRef());
    
    // page 2 (with total count)
    pr = new PagingRequest(2, 2, null);
    pr.setRequestTotalCountMax(Integer.MAX_VALUE);
    
    ppr = personService.getPeople(null, true, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p6, results.get(0).getNodeRef());
    assertEquals(p4, results.get(1).getNodeRef());
    assertEquals(expectedResultCount, ppr.getTotalResultCount());
    
    // page 3
    pr = new PagingRequest(4, 2, null);
    ppr = personService.getPeople(null, true, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p7, results.get(0).getNodeRef());
    assertEquals(p2, results.get(1).getNodeRef());
    
    // page 4 (with total count)
    pr = new PagingRequest(6, 2, null);
    pr.setRequestTotalCountMax(Integer.MAX_VALUE);
    
    ppr = personService.getPeople(null, true, sort, pr);
    results = ppr.getPage();
    assertEquals(1, results.size());
    assertEquals(p5, results.get(0).getNodeRef());
    assertEquals(expectedResultCount, ppr.getTotalResultCount());
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:61,
代码来源:PersonTest.java

示例15: testPeopleSortingPaging_NoAdmin

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testPeopleSortingPaging_NoAdmin()
{
    personService.setCreateMissingPeople(false);
    
    assertEquals(2, getPeopleCount());
    
    NodeRef p1 = personService.getPerson(AuthenticationUtil.getAdminUserName()); // admin - by default
    NodeRef p2 = personService.getPerson(AuthenticationUtil.getGuestUserName()); // guest - by default
    
    NodeRef p3 = personService.createPerson(createDefaultProperties("aa", "Aa", "Aa", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p4 = personService.createPerson(createDefaultProperties("cc", "Cc", "Cc", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p5 = personService.createPerson(createDefaultProperties("hh", "Hh", "Hh", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p6 = personService.createPerson(createDefaultProperties("bb", "Bb", "Bb", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p7 = personService.createPerson(createDefaultProperties("dd", "Dd", "Dd", "[email protected]", "alfresco", rootNodeRef));
    
    int expectedTotalCount = 7;
    assertEquals(expectedTotalCount, getPeopleCount());
    
    int expectedTotalCountWithAdmin = expectedTotalCount - 1;
    Pair<Integer,Integer> expectedResultCount = new Pair<Integer,Integer>(expectedTotalCountWithAdmin,expectedTotalCountWithAdmin);
    
    List<Pair<QName, Boolean>> sort = new ArrayList<Pair<QName, Boolean>>(1);
    sort.add(new Pair<QName,Boolean>(ContentModel.PROP_USERNAME, true));
    
    // page 1
    PagingRequest pr = new PagingRequest(0, 2, null);
    PagingResults<PersonInfo> ppr = personService.getPeople(null, null, null, null, false, sort, pr);
    List<PersonInfo> results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p3, results.get(0).getNodeRef());
    assertEquals(p6, results.get(1).getNodeRef());
    
    // page 2 (with total count)
    pr = new PagingRequest(2, 2, null);
    pr.setRequestTotalCountMax(Integer.MAX_VALUE);
    
    ppr = personService.getPeople(null, null, null, null, false, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p4, results.get(0).getNodeRef());
    assertEquals(p7, results.get(1).getNodeRef());
    assertEquals(expectedResultCount, ppr.getTotalResultCount());
    
    // page 3
    pr = new PagingRequest(4, 2, null);
    ppr = personService.getPeople(null, null, null, null, false, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p2, results.get(0).getNodeRef());
    assertEquals(p5, results.get(1).getNodeRef());
    
    // page 4 (with total count)
    pr = new PagingRequest(6, 2, null);
    pr.setRequestTotalCountMax(Integer.MAX_VALUE);
    
    ppr = personService.getPeople(null, null, null, null, false, sort, pr);
    results = ppr.getPage();
    assertEquals(0, results.size());
    assertEquals(expectedResultCount, ppr.getTotalResultCount());
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:61,
代码来源:PersonTest.java

示例16: testPeopleSortingPaging_deprecatedCQ_via_getChildren

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testPeopleSortingPaging_deprecatedCQ_via_getChildren()
{
    personService.setCreateMissingPeople(false);
    
    assertEquals(2, getPeopleCount());
    
    NodeRef p1 = personService.getPerson(AuthenticationUtil.getAdminUserName()); // admin - by default
    NodeRef p2 = personService.getPerson(AuthenticationUtil.getGuestUserName()); // guest - by default
    
    NodeRef p3 = personService.createPerson(createDefaultProperties("aa", "Aa", "Aa", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p4 = personService.createPerson(createDefaultProperties("cc", "Cc", "Cc", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p5 = personService.createPerson(createDefaultProperties("hh", "Hh", "Hh", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p6 = personService.createPerson(createDefaultProperties("bb", "Bb", "Bb", "[email protected]", "alfresco", rootNodeRef));
    NodeRef p7 = personService.createPerson(createDefaultProperties("dd", "Dd", "Dd", "[email protected]", "alfresco", rootNodeRef));
    
    
    
    assertEquals(7, getPeopleCount());
    
    List<Pair<QName, Boolean>> sort = new ArrayList<Pair<QName, Boolean>>(1);
    sort.add(new Pair<QName,Boolean>(ContentModel.PROP_USERNAME, true));
    
    // page 1
    PagingRequest pr = new PagingRequest(0, 2, null);
    PagingResults<PersonInfo> ppr = personService.getPeople(null, null, sort, pr);
    List<PersonInfo> results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p3, results.get(0).getNodeRef());
    assertEquals(p1, results.get(1).getNodeRef());
    
    // page 2
    pr = new PagingRequest(2, 2, null);
    ppr = personService.getPeople(null, null, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p6, results.get(0).getNodeRef());
    assertEquals(p4, results.get(1).getNodeRef());
    
    // page 3
    pr = new PagingRequest(4, 2, null);
    ppr = personService.getPeople(null, null, sort, pr);
    results = ppr.getPage();
    assertEquals(2, results.size());
    assertEquals(p7, results.get(0).getNodeRef());
    assertEquals(p2, results.get(1).getNodeRef());
    
    // page 4
    pr = new PagingRequest(6, 2, null);
    ppr = personService.getPeople(null, null, sort, pr);
    results = ppr.getPage();
    assertEquals(1, results.size());
    assertEquals(p5, results.get(0).getNodeRef());
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:54,
代码来源:PersonTest.java

示例17: testPeopleFiltering_deprecatedFTS

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testPeopleFiltering_deprecatedFTS()
{
    personService.setCreateMissingPeople(false);
    assertEquals(2, getPeopleCount());

    checkPeopleContain(AuthenticationUtil.getAdminUserName());
    checkPeopleContain(AuthenticationUtil.getGuestUserName());
    
    String suffix = Long.toString(System.currentTimeMillis());
    String jjFirstname = "john junior"+suffix;
    String jjLastname = "lewis second"+suffix;
    
    personService.createPerson(createDefaultProperties("janedoe", "jane", "doe"+suffix, "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("janemoe", "jane", "moe"+suffix, "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("jjlewis", jjFirstname, jjLastname, "[email protected]", "alfresco", rootNodeRef));
    personService.createPerson(createDefaultProperties("jlewis", "john", jjLastname, "[email protected]", "alfresco", rootNodeRef));

    assertEquals(6, getPeopleCount());

    PagingRequest pr = new PagingRequest(100, null);
    List<Pair<QName, String>> filters = new ArrayList<Pair<QName, String>>(3);

    filters.clear();
    // Set username, firstname and lastname same as
    // "org.alfresco.web.ui.common.Utils.generatePersonFilter(String term)" method
    String searchTerm = "jane doe"+suffix;
    filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, searchTerm));
    List<PersonInfo> result = personService.getPeople(filters, true, null, pr).getPage();
    assertEquals(1, result.size());
    assertEquals("jane", result.get(0).getFirstName());
    assertEquals("doe"+suffix, result.get(0).getLastName());

    // test two parts firstname
    filters.clear();
    searchTerm = jjFirstname;
    filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, searchTerm));
    result = personService.getPeople(filters, true, null, pr).getPage();
    assertEquals(1, result.size());
    assertEquals(jjFirstname, result.get(0).getFirstName());
    assertEquals(jjLastname, result.get(0).getLastName());

    // test two parts lastname
    filters.clear();
    searchTerm = "john " + jjLastname;
    filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, searchTerm));
    result = personService.getPeople(filters, true, null, pr).getPage();
    assertEquals(2, result.size());

    // test two parts firstname and lastname
    filters.clear();
    searchTerm = jjFirstname + " " + jjLastname;
    filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, searchTerm));
    result = personService.getPeople(filters, true, null, pr).getPage();
    assertEquals(1, result.size());
    assertEquals(jjFirstname, result.get(0).getFirstName());
    assertEquals(jjLastname, result.get(0).getLastName());

    // test different firstname and lastname
    filters.clear();
    searchTerm = jjFirstname + " " + jjLastname;
    filters.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, searchTerm));
    filters.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, jjFirstname));
    filters.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, jjLastname));
    result = personService.getPeople(filters, true, null, pr).getPage();
    assertEquals(1, result.size());
    assertEquals(jjFirstname, result.get(0).getFirstName());
    assertEquals(jjLastname, result.get(0).getLastName());
}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:77,
代码来源:PersonTest.java

示例18: testGetPeople

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
public void testGetPeople()
{
    ScriptPagingDetails paging = new ScriptPagingDetails(0, 0);
    // Get people with multi-part firstNames
    // USER_1 and USER_3 both have 'john junior' as their firstName
    // The query shouldn't select USER_4
    List<PersonInfo> persons = people.getPeopleImpl("john junior", paging, null, null);
    assertEquals("There are two users who have \"john junior\" as their first name.", 2,
                persons.size());
    assertEquals(USER_1.getFirstName(), persons.get(0).getFirstName());
    assertEquals(USER_3.getFirstName(), persons.get(1).getFirstName());

    // Get user with multi-part firstNames and lastNames
    persons = people.getPeopleImpl("john junior lewis sec*", paging, null, null);
    assertEquals("There is one user with the name: \"john junior lewis second\".", 1,
                persons.size());
    assertEquals(USER_1.getFirstName(), persons.get(0).getFirstName());
    assertEquals(USER_1.getLastName(), persons.get(0).getLastName());

    // Only USER_2's first name is "john senior"
    persons = people.getPeopleImpl("john senior", paging, null, null);
    assertEquals("There is one user who has \"john senior\" as his first name.", 1,
                persons.size());
    assertEquals(USER_2.getFirstName(), persons.get(0).getFirstName());
    assertEquals(USER_2.getLastName(), persons.get(0).getLastName());

    persons = people.getPeopleImpl("john*", paging, null, null);
    assertEquals("There are four users with \"john\" as their first name.", 4, persons.size());

    // Get people with multi-part lastNames
    // USER_3 and USER_4 both have 'lewis third' as their lastName
    persons = people.getPeopleImpl("lewis third", paging, null, null);
    assertEquals("There are two users who have \"lewis third\" as their last name.", 2,
                persons.size());
    assertEquals(USER_3.getLastName(), persons.get(0).getLastName());
    assertEquals(USER_4.getLastName(), persons.get(1).getLastName());

    // Only USER_5 and USER_6 have last name "doe first"
    // The query shouldn't select USER_7
    persons = people.getPeopleImpl("doe fi*", paging, null, null);
    assertEquals("There are two users who have \"doe first\" as their last name.", 2,
                persons.size());
    assertEquals(USER_5.getLastName(), persons.get(0).getLastName());
    assertEquals(USER_6.getLastName(), persons.get(1).getLastName());

    persons = people.getPeopleImpl("lewi*", paging, null, null);
    assertEquals("There are four users with \"lewis\" as their last name.", 4, persons.size());

    persons = people.getPeopleImpl("thir*", paging, null, null);
    assertEquals("There are two users with \"lewis third\" as their last name.", 2, persons.size());

    // Get people with single firstName and multi-part lastNames
    persons = people.getPeopleImpl("sam doe first", paging, null, null);
    assertEquals("There is one user with the name: \"sam doe first\".", 1, persons.size());
    assertEquals(USER_6.getFirstName(), persons.get(0).getFirstName());
    assertEquals(USER_6.getLastName(), persons.get(0).getLastName());

    // Get people with multi-part firstNames and single lastName
    persons = people.getPeopleImpl("sara jones doe", paging, null, null);
    assertEquals("There is one user with the name: \"sara jones doe\".", 1, persons.size());
    assertEquals(USER_7.getFirstName(), persons.get(0).getFirstName());
    assertEquals(USER_7.getLastName(), persons.get(0).getLastName());

    // Get people with single firstName and single lastName
    persons = people.getPeopleImpl("sara doe", paging, null, null);
    assertEquals("There are two users with the name: \"sara doe\".", 2, persons.size());
    assertEquals(USER_7.getLastName(), persons.get(0).getLastName());
    assertEquals(USER_8.getLastName(), persons.get(0).getLastName());

}
 

开发者ID:Alfresco,
项目名称:community-edition-old,
代码行数:71,
代码来源:PeopleTest.java

示例19: postActivity

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
private void postActivity(NodeRef nodeRef)
    throws JSONException
{
    log.debug("Create Activity Stream Entry");
    if (personService.personExists(AuthenticationUtil.getRunAsUser()))
    {
        try
        {
            String activityType = FILE_UPDATED;
            if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
            {
                activityType = FILE_ADDED;
            }

            SiteInfo site = siteService.getSite(nodeRef);
            if (site == null)
            {
                log.debug("Activity stream entry not created -- outside of site.");
                return;
            }

            String siteId = site.getShortName();

            JSONObject jsonActivityData = new JSONObject();

            // Using local getPerson ... not cloud
            // personservice.getPerson(nodeRef) which returns personInfo object
            PersonInfo personInfo = getPerson(personService.getPerson(AuthenticationUtil.getRunAsUser(), false));

            jsonActivityData.put("firstName", personInfo.getFirstName());
            jsonActivityData.put("lastName", personInfo.getLastName());
            jsonActivityData.put("title", fileFolderService.getFileInfo(nodeRef).getName());
            jsonActivityData.put("page", "document-details?nodeRef=" + nodeRef.toString());
            jsonActivityData.put("nodeRef", nodeRef.toString());

            if (AuthenticationUtil.isMtEnabled())
            {
                // MT share - add tenantDomain
                jsonActivityData.put("tenantDomain", tenantService.getCurrentUserDomain());
            }

            activityService.postActivity(activityType, siteId, GoogleDocsService.class.getSimpleName(), jsonActivityData.toString());
            log.debug("Post Activity Stream Entry -- type:" + activityType + "; site: " + siteId + "; Data: "
                      + jsonActivityData);
        }
        catch (JSONException jsonException)
        {
            throw jsonException;
        }
    } else {
        log.debug("Activity stream entry not created -- user does not exist.");
    }
}
 

开发者ID:Pluies,
项目名称:Alfresco-Google-docs-plugin,
代码行数:54,
代码来源:GoogleDocsServiceImpl.java

示例20: getPerson

点赞 2

import org.alfresco.service.cmr.security.PersonService.PersonInfo; //导入依赖的package包/类
private PersonInfo getPerson(NodeRef nodeRef)
{
    return new PersonInfo(nodeRef, AuthenticationUtil.getRunAsUser(), nodeService.getProperty(nodeRef, ContentModel.PROP_FIRSTNAME).toString(), nodeService.getProperty(nodeRef, ContentModel.PROP_LASTNAME).toString());
}
 

开发者ID:Pluies,
项目名称:Alfresco-Google-docs-plugin,
代码行数:5,
代码来源:GoogleDocsServiceImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)