Sonar Fixes, Formatting
[aaf/authz.git] / auth / auth-cass / src / main / java / org / onap / aaf / auth / dao / cass / RoleDAO.java
index e5c9755..ae8d525 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,7 +50,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
 
     public static final String TABLE = "role";
     public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
-    
+
     private final HistoryDAO historyDAO;
     private final CacheInfoDAO infoDAO;
 
@@ -96,34 +96,34 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
             }
             return perms;
         }
-        
+
         public static Data create(NsDAO.Data ns, String name) {
-            NsSplit nss = new NsSplit(ns,name);        
+            NsSplit nss = new NsSplit(ns,name);
             RoleDAO.Data rv = new Data();
             rv.ns = nss.ns;
             rv.name=nss.name;
             return rv;
         }
-        
+
         public String fullName() {
             StringBuilder sb = new StringBuilder();
             if(ns==null) {
                 sb.append('.');
             } else {
                 sb.append(ns);
-                sb.append(ns.indexOf('@')<0?'.':':'); 
+                sb.append(ns.indexOf('@')<0?'.':':');
             }
             sb.append(name);
             return sb.toString();
         }
-        
+
         public String encode() {
             return ns + '|' + name;
         }
-        
+
         /**
          * Decode Perm String, including breaking into appropriate Namespace
-         * 
+         *
          * @param trans
          * @param q
          * @param r
@@ -171,7 +171,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
 
         /**
          * Decode Perm String, including breaking into appropriate Namespace
-         * 
+         *
          * @param trans
          * @param q
          * @param p
@@ -189,7 +189,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
             }
             return Result.ok(ss);
         }
-        
+
         @Override
         public int[] invalidate(Cached<?,?> cache) {
             return new int[] {
@@ -205,7 +205,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
             RoleLoader.deflt.marshal(this,new DataOutputStream(baos));
             return ByteBuffer.wrap(baos.toByteArray());
         }
-        
+
         @Override
         public void reconstitute(ByteBuffer bb) throws IOException {
             RoleLoader.deflt.unmarshal(this, toDIS(bb));
@@ -223,11 +223,11 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         public static final int BUFF_SIZE=96;
 
         public static final RoleLoader deflt = new RoleLoader(KEYLIMIT);
-        
+
         public RoleLoader(int keylimit) {
             super(keylimit);
         }
-        
+
         @Override
         public Data load(Data data, Row row) {
             // Int more efficient
@@ -275,15 +275,15 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
 
     private void init(AuthzTrans trans) {
         String[] helpers = setCRUD(trans, TABLE, Data.class, RoleLoader.deflt);
-        
+
         psNS = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
                 " WHERE ns = ?", new RoleLoader(1),readConsistency);
 
         psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
                 " WHERE name = ?", new RoleLoader(1),readConsistency);
 
-        psChildren = new PSInfo(trans, SELECT_SP +  helpers[FIELD_COMMAS] +  " FROM " + TABLE + 
-                " WHERE ns=? AND name > ? AND name < ?", 
+        psChildren = new PSInfo(trans, SELECT_SP +  helpers[FIELD_COMMAS] +  " FROM " + TABLE +
+                " WHERE ns=? AND name > ? AND name < ?",
                 new RoleLoader(3) {
             @Override
             protected void key(Data data, int _idx, Object[] obj) {
@@ -293,7 +293,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
                 obj[++idx]=data.name + DOT_PLUS_ONE;
             }
         },readConsistency);
-        
+
     }
 
     public Result<List<Data>> readNS(AuthzTrans trans, String ns) {
@@ -306,7 +306,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
 
     public Result<List<Data>> readChildren(AuthzTrans trans, String ns, String role) {
         if (role.length()==0 || "*".equals(role)) {
-            return psChildren.read(trans, R_TEXT, new Object[]{ns, FIRST_CHAR, LAST_CHAR}); 
+            return psChildren.read(trans, R_TEXT, new Object[]{ns, FIRST_CHAR, LAST_CHAR});
         } else {
             return psChildren.read(trans, R_TEXT, new Object[]{ns, role+DOT, role+DOT_PLUS_ONE});
         }
@@ -314,7 +314,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
 
     /**
      * Add a single Permission to the Role's Permission Collection
-     * 
+     *
      * @param trans
      * @param role
      * @param perm
@@ -326,7 +326,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         // Note: Prepared Statements for Collection updates aren't supported
         String pencode = perm.encode();
         try {
-            getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" + 
+            getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" +
                 pencode + "'} WHERE " +
                 "ns = '" + role.ns + "' AND name = '" + role.name + "';");
         } catch (DriverException | APIException | IOException e) {
@@ -351,10 +351,10 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         // Note: Prepared Statements for Collection updates aren't supported
 
         String pencode = perm.encode();
-        
+
         //ResultSet rv =
         try {
-            getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms - {'" + 
+            getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms - {'" +
                 pencode    + "'} WHERE " +
                 "ns = '" + role.ns + "' AND name = '" + role.name + "';");
         } catch (DriverException | APIException | IOException e) {
@@ -366,10 +366,10 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         wasModified(trans, CRUD.update, role, "Removed permission " + pencode + " from role " + role.fullName() );
         return Result.ok();
     }
-    
+
     /**
      * Add description to role
-     * 
+     *
      * @param trans
      * @param ns
      * @param name
@@ -378,7 +378,7 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
      */
     public Result<Void> addDescription(AuthzTrans trans, String ns, String name, String description) {
         try {
-            getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '" 
+            getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '"
                 + description + "' WHERE ns = '" + ns + "' AND name = '" + name + "';");
         } catch (DriverException | APIException | IOException e) {
             reportPerhapsReset(trans,e);
@@ -391,8 +391,8 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         wasModified(trans, CRUD.update, data, "Added description " + description + " to role " + data.fullName(), null );
         return Result.ok();
     }
-    
-    
+
+
     /**
      * Log Modification statements to History
      * @param modified           which CRUD action was done
@@ -426,5 +426,5 @@ public class RoleDAO extends CassDAOImpl<AuthzTrans,RoleDAO.Data> {
         }
     }
 
-    
+
 }
\ No newline at end of file