Collection syntax change because of Sonar
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / AuthzCassServiceImpl.java
index 5c8526a..668d482 100644 (file)
@@ -214,7 +214,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 201,
                        errorCodes = { 403,404,406,409 }, 
                        text = {        "Add an Identity :id to the list of Admins for the Namespace :ns", 
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)" }
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)" }
                        )
        @Override
        public Result<Void> addAdminNS(AuthzTrans trans, String ns, String id) {
@@ -230,7 +230,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 200,
                        errorCodes = { 403,404 }, 
                        text = {        "Remove an Identity :id from the list of Admins for the Namespace :ns",
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)" }
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)" }
                        )
        @Override
        public Result<Void> delAdminNS(AuthzTrans trans, String ns, String id) {
@@ -246,7 +246,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 201,
                        errorCodes = { 403,404,406,409 }, 
                        text = {        "Add an Identity :id to the list of Responsibles for the Namespace :ns",
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)" }
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)" }
                        )
        @Override
        public Result<Void> addResponsibleNS(AuthzTrans trans, String ns, String id) {
@@ -262,7 +262,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 200,
                        errorCodes = { 403,404 }, 
                        text = {        "Remove an Identity :id to the list of Responsibles for the Namespace :ns",
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)",
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)",
                                                "Note: A namespace must have at least 1 responsible party"
                                        }
                        )
@@ -512,7 +512,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 200,
                        errorCodes = { 403,404 }, 
                        text = {        "Lists all Namespaces where Identity :id is an Admin", 
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)" 
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)" 
                                        }
                        )
        @Override
@@ -532,7 +532,6 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                NSS nss = mapper.newInstance(API.NSS);
                // Note: "loadNamespace" already validates view of Namespace
                return mapper.nss(trans, rn.value, nss);
-
        }
 
        @ApiDoc(
@@ -542,7 +541,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 200,
                        errorCodes = { 403,404 }, 
                        text = {        "Lists all Namespaces where Identity :id is either an Admin or an Owner", 
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)" 
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)" 
                                        }
                        )
        @Override
@@ -569,8 +568,8 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                if(urd.notOKorIsEmpty()) {
                        return Result.err(urd);
                }
-               Map<String, Namespace> lm = new HashMap<String,Namespace>();
-               Map<String, Namespace> other = full || endsWith==null?null:new TreeMap<String,Namespace>();
+               Map<String, Namespace> lm = new HashMap<>();
+               Map<String, Namespace> other = full || endsWith==null?null:new TreeMap<>();
                for(UserRoleDAO.Data urdd : urd.value) {
                        if(full) {
                                if(endsWith==null || urdd.role.endsWith(endsWith)) {
@@ -605,8 +604,8 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                                                        }
                                                        if(namespace==null) {
                                                                namespace = new Namespace(nsd.value);
-                                                               namespace.admin=new ArrayList<String>();
-                                                               namespace.owner=new ArrayList<String>();
+                                                               namespace.admin=new ArrayList<>();
+                                                               namespace.owner=new ArrayList<>();
                                                        }
                                                        if(endsWith==null || urdd.role.endsWith(endsWith)) {
                                                                lm.put(namespace.name,namespace);
@@ -633,7 +632,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        expectedCode = 200,
                        errorCodes = { 403,404 }, 
                        text = {        "Lists all Namespaces where Identity :id is a Responsible Party", 
-                                               "Note: :id must be fully qualified (i.e. ab1234@csp.att.com)"
+                                               "Note: :id must be fully qualified (i.e. ab1234@people.osaaf.org)"
                                        }
                        )
        @Override
@@ -680,7 +679,7 @@ public class AuthzCassServiceImpl   <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        return Result.err(rnd); 
                }
 
-               Set<Namespace> lm = new HashSet<Namespace>();
+               Set<Namespace> lm = new HashSet<>();
                Result<List<NsDAO.Data>> rlnd = ques.nsDAO.dao().getChildren(trans, parent);
                if(rlnd.isOK()) {
                        if(rlnd.isEmpty()) {
@@ -1302,7 +1301,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                }
                
                // Create a set of Update Roles, which are in Internal Format
-               Set<String> updtRoles = new HashSet<String>();
+               Set<String> updtRoles = new HashSet<>();
                Result<NsSplit> nss;
                for(String role : updt.value.roles(false)) {
                        nss = ques.deriveNsSplit(trans, role);
@@ -1574,7 +1573,8 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                }
                
                // Look up data
-               Result<List<RoleDAO.Data>> rlrd = ques.getRolesByName(trans, role);
+               int query = role.indexOf('?');
+               Result<List<RoleDAO.Data>> rlrd = ques.getRolesByName(trans, query<0?role:role.substring(0, query));
                if(rlrd.isOK()) {
                        // Note: Mapper will restrict what can be viewed
                        ROLES roles = mapper.newInstance(API.ROLES);
@@ -1739,7 +1739,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
        @Override
        public Result<ROLES> getRolesByPerm(AuthzTrans trans, String type, String instance, String action) {
                final Validator v = new ServiceValidator();
-               if(v.permType(type,null)
+               if(v.permType(type)
                        .permInstance(instance)
                        .permAction(action)
                        .err()) {
@@ -2258,7 +2258,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
 
        }
 
-       private final long DAY_IN_MILLIS = 24*3600*1000;
+       private final long DAY_IN_MILLIS = 24*3600*1000L;
        
        @ApiDoc( 
                        method = POST,  
@@ -3114,7 +3114,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
        //                      filter = false;
                        
                        // Get list of roles per user, then add to Roles as we go
-                       HashSet<UserRoleDAO.Data> userSet = new HashSet<UserRoleDAO.Data>();
+                       HashSet<UserRoleDAO.Data> userSet = new HashSet<>();
                        Result<List<UserRoleDAO.Data>> rlurd = ques.userRoleDAO.readByRole(trans, role);
                        if(rlurd.isOK()) {
                                for(UserRoleDAO.Data data : rlurd.value) {
@@ -3186,7 +3186,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        
                        List<UserRoleDAO.Data> content;
                        if(mustFilter) {
-                               content = new ArrayList<UserRoleDAO.Data>(rlurd.value.size()); // avoid multi-memory redos
+                               content = new ArrayList<>(rlurd.value.size()); // avoid multi-memory redos
                                
                                for(UserRoleDAO.Data data : rlurd.value) {
                                        ndd.name=data.ns;
@@ -3231,7 +3231,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        return Result.err(Status.ERR_BadData,v.errs());
                }
 
-               Set<String> currRoles = new HashSet<String>();
+               Set<String> currRoles = new HashSet<>();
                Result<List<UserRoleDAO.Data>> rlurd = ques.userRoleDAO.readByUser(trans, rurdd.value.user);
                if(rlurd.isOK()) {
                        for(UserRoleDAO.Data data : rlurd.value) {
@@ -3325,7 +3325,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        return Result.err(nsr); 
                }
 
-               Set<String> currUsers = new HashSet<String>();
+               Set<String> currUsers = new HashSet<>();
                Result<List<UserRoleDAO.Data>> rlurd = ques.userRoleDAO.readByRole(trans, rurdd.value.role);
                if(rlurd.isOK()) { 
                        for(UserRoleDAO.Data data : rlurd.value) {
@@ -3541,7 +3541,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        return Result.err(rnd); 
                }
                
-               HashSet<UserRoleDAO.Data> userSet = new HashSet<UserRoleDAO.Data>();
+               HashSet<UserRoleDAO.Data> userSet = new HashSet<>();
                Result<List<UserRoleDAO.Data>> rlurd = ques.userRoleDAO.readUserInRole(trans, user, role);
                if(rlurd.isOK()) {
                        for(UserRoleDAO.Data data : rlurd.value) {
@@ -3593,7 +3593,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        }
                }
                
-               HashSet<UserRoleDAO.Data> userSet = new HashSet<UserRoleDAO.Data>();
+               HashSet<UserRoleDAO.Data> userSet = new HashSet<>();
                Result<List<UserRoleDAO.Data>> rlurd = ques.userRoleDAO.readByRole(trans, role);
                if(rlurd.isOK()) { 
                        for(UserRoleDAO.Data data : rlurd.value) {
@@ -3657,8 +3657,8 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                // Get list of roles per Permission, 
                // Then loop through Roles to get Users
                // Note: Use Sets to avoid processing or responding with Duplicates
-               Set<String> roleUsed = new HashSet<String>();
-               Set<UserRoleDAO.Data> userSet = new HashSet<UserRoleDAO.Data>();
+               Set<String> roleUsed = new HashSet<>();
+               Set<UserRoleDAO.Data> userSet = new HashSet<>();
                
                if(!nss.isEmpty()) {
                        Result<List<PermDAO.Data>> rlp = ques.permDAO.readByType(trans, nss.value.ns, nss.value.name);
@@ -4025,8 +4025,8 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        }
 
                        if(curr.isOKhasData()) {
-                       Map<String, Result<List<DelegateDAO.Data>>> delegateCache = new HashMap<String, Result<List<DelegateDAO.Data>>>();
-                       Map<UUID, FutureDAO.Data> futureCache = new HashMap<UUID, FutureDAO.Data>();
+                       Map<String, Result<List<DelegateDAO.Data>>> delegateCache = new HashMap<>();
+                       Map<UUID, FutureDAO.Data> futureCache = new HashMap<>();
                        FutureDAO.Data hasDeleted = new FutureDAO.Data();
                        
                            for(ApprovalDAO.Data cd : curr.value) {
@@ -4177,7 +4177,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
                        return Result.err(Status.ERR_BadData,v.errs());
                }
                
-               List<ApprovalDAO.Data> listRapds = new ArrayList<ApprovalDAO.Data>();
+               List<ApprovalDAO.Data> listRapds = new ArrayList<>();
                
                Result<List<ApprovalDAO.Data>> myRapd = ques.approvalDAO.readByApprover(trans, approver);
                if(myRapd.notOK()) {