Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. public static void main(String[] args) throws IOException {
  2. for (CatalogResource machine : machines) {
  3. example.viewDetails(machine);
  4. List<CatalogPrincipal> owners = machine.getOwners();
  5.  
  6. for( CatalogPrincipal owner : owners ){
  7. String ownerEmail = example.getUserEmail(owner.getRef());
  8. System.out.println("OWNER: " + owner.getValue()
  9. + " (" + owner.getType()
  10. + ") : Username" + owner.getRef()
  11. + "OWNER: email is " + ownerEmail);
  12. }
  13. }
  14.  
  15. ...
  16. }
  17. //Pass the machine owners getRef() value in the userName param
  18.  
  19. private String getUserEmail(String userName) {
  20. if (!isAuthenticated()) {
  21. throw new IllegalStateException("You must call login() first to authenticate");
  22. }
  23.  
  24. String userEmail = "";
  25. RestClient rcService = consumerService
  26. .getDefaultRestClientForService("identity");
  27. IdentityStoreClientServiceImpl iscs = new IdentityStoreClientServiceImpl(rcService);
  28.  
  29. OdataQuery orderByName = OdataQuery.query().addAscOrderBy("name");
  30. Pageable page = PageOdataRequest.page(1, 100, orderByName);
  31.  
  32. Set<IdentityStore> identityStores = iscs.getIdentityStores(tenant, page);
  33.  
  34. for (IdentityStore item : identityStores) {
  35. if( userEmail.equals("")){
  36. RestClient principalService = consumerService.getDefaultRestClientForService("identity");
  37. PrincipalService psvc = new PrincipalService(principalService);
  38. User wkgUser = psvc.getPrincipal(tenant,userName);
  39. userEmail=wkgUser.getEmailAddress();
  40. }
  41.  
  42. }
  43. return userEmail;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement