All pastes #448090 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-19 13:25 UTC
rendered paste body
	/**
	* createRole
	*
	* Create a role.  Assign it to a user.
	* 
	* @throws Exception
	*/
	public void createRole()
	throws Exception
	{
		PartyManager partyManager = Connector.getPartyManager();
		String coderUuid;
        
        // Create a role within the Acme organization (see setUp())
		coderUuid = partyManager.createRole(m_rootAuth,
                                            "Developer",
                                            "Description of role here. JUnit created.",
                                            m_kpRoot,
                                            null);
	    
        // Now we'll create a user and give him the Developer role.
	    UserInfo userInfo = new UserInfo();
	    userInfo.setLogin("dbowie");
	    userInfo.setName("David Bowie");
	    userInfo.setFirstName("David");
	    userInfo.setLastName("Bowie");
	    userInfo.setTitle("Engineer");
	    userInfo.setEmailAddress("david.bowie@acme.com");

	    String userUuid = 
	    	partyManager.createUser(m_rootAuth, userInfo, m_kpRoot);
	    
	    partyManager.assignToParty(m_rootAuth, userUuid, coderUuid);
	    
	    Collection roles = 
	    	partyManager.findRolesByName(m_rootAuth, "Developer", m_kpRoot);
	    
	    System.out.println("== createRole: Prining role info");
	    Iterator iterator = roles.iterator();
	    while(iterator.hasNext())
	    	System.out.println((GroupInfo)iterator.next());
	    
	    System.out.println("== createRole: Print user roles for" + userInfo.getName());
	    List userRoles = partyManager.getChildRoles(m_rootAuth, userUuid, 0, 0);
	    for(int i = 0; i < userRoles.size(); ++i)
	    	System.out.println((PartyInfo)userRoles.get(i));
	}