Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException {
- for (CatalogResource machine : machines) {
- example.viewDetails(machine);
- List<CatalogPrincipal> owners = machine.getOwners();
- for( CatalogPrincipal owner : owners ){
- String ownerEmail = example.getUserEmail(owner.getRef());
- System.out.println("OWNER: " + owner.getValue()
- + " (" + owner.getType()
- + ") : Username" + owner.getRef()
- + "OWNER: email is " + ownerEmail);
- }
- }
- ...
- }
- //Pass the machine owners getRef() value in the userName param
- private String getUserEmail(String userName) {
- if (!isAuthenticated()) {
- throw new IllegalStateException("You must call login() first to authenticate");
- }
- String userEmail = "";
- RestClient rcService = consumerService
- .getDefaultRestClientForService("identity");
- IdentityStoreClientServiceImpl iscs = new IdentityStoreClientServiceImpl(rcService);
- OdataQuery orderByName = OdataQuery.query().addAscOrderBy("name");
- Pageable page = PageOdataRequest.page(1, 100, orderByName);
- Set<IdentityStore> identityStores = iscs.getIdentityStores(tenant, page);
- for (IdentityStore item : identityStores) {
- if( userEmail.equals("")){
- RestClient principalService = consumerService.getDefaultRestClientForService("identity");
- PrincipalService psvc = new PrincipalService(principalService);
- User wkgUser = psvc.getPrincipal(tenant,userName);
- userEmail=wkgUser.getEmailAddress();
- }
- }
- return userEmail;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement