Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / auth / auth-cass / src / main / java / org / onap / aaf / auth / dao / cass / LocateDAO.java
index 4778331..5d7aebe 100644 (file)
@@ -50,7 +50,7 @@ import com.datastax.driver.core.Row;
  */
 public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
     public static final String TABLE = "locate";
-       private AbsCassDAO<AuthzTrans, Data>.PSInfo psName;
+    private AbsCassDAO<AuthzTrans, Data>.PSInfo psName;
     
     public LocateDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
         super(trans, LocateDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
@@ -63,68 +63,68 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
     }
     
     public static final int KEYLIMIT = 3;
-       public static class Data implements Bytification {
-       
-        public String                                  name;
-               public String                                   hostname;
-               public int                                              port;
-               public int                                              major;
-               public int                                              minor;
-               public int                                              patch;
-               public int                                              pkg;
-               public float                                            latitude;
-               public float                                            longitude;
-               public String                                   protocol;
-               private Set<String>                             subprotocol;
-               public UUID                                             port_key; // Note: Keep Port_key LAST at all times, because we shorten the UPDATE to leave Port_key Alone during reregistration.
+    public static class Data implements Bytification {
+        
+        public String                    name;
+        public String                    hostname;
+        public int                        port;
+        public int                        major;
+        public int                        minor;
+        public int                        patch;
+        public int                        pkg;
+        public float                        latitude;
+        public float                        longitude;
+        public String                    protocol;
+        private Set<String>                subprotocol;
+        public UUID                        port_key; // Note: Keep Port_key LAST at all times, because we shorten the UPDATE to leave Port_key Alone during reregistration.
 
-         // Getters
-               public Set<String> subprotocol(boolean mutable) {
-                       if (subprotocol == null) {
-                               subprotocol = new HashSet<>();
-                       } else if (mutable && !(subprotocol instanceof HashSet)) {
-                               subprotocol = new HashSet<>(subprotocol);
-                       }
-                       return subprotocol;
-               }
-               
+      // Getters
+        public Set<String> subprotocol(boolean mutable) {
+            if (subprotocol == null) {
+                subprotocol = new HashSet<>();
+            } else if (mutable && !(subprotocol instanceof HashSet)) {
+                subprotocol = new HashSet<>(subprotocol);
+            }
+            return subprotocol;
+        }
+        
+        @Override
+        public ByteBuffer bytify() throws IOException {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            LocateLoader.deflt.marshal(this,new DataOutputStream(baos));
+            return ByteBuffer.wrap(baos.toByteArray());
+        }
+        
         @Override
-               public ByteBuffer bytify() throws IOException {
-                       ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                       LocateLoader.deflt.marshal(this,new DataOutputStream(baos));
-                       return ByteBuffer.wrap(baos.toByteArray());
-               }
-               
-               @Override
-               public void reconstitute(ByteBuffer bb) throws IOException {
-                       LocateLoader.deflt.unmarshal(this, toDIS(bb));
-               }
+        public void reconstitute(ByteBuffer bb) throws IOException {
+            LocateLoader.deflt.unmarshal(this, toDIS(bb));
+        }
     }
 
     private static class LocateLoader extends Loader<Data> implements Streamer<Data>{
-               public static final int MAGIC=85102934;
-               public static final int VERSION=1;
-               public static final int BUFF_SIZE=48; // Note: 
-       
-               public static final LocateLoader deflt = new LocateLoader(KEYLIMIT);
-               public LocateLoader(int keylimit) {
-               super(keylimit);
+        public static final int MAGIC=85102934;
+            public static final int VERSION=1;
+            public static final int BUFF_SIZE=48; // Note: 
+    
+            public static final LocateLoader deflt = new LocateLoader(KEYLIMIT);
+            public LocateLoader(int keylimit) {
+            super(keylimit);
         }
 
-       @Override
+        @Override
         public Data load(Data data, Row row) {
-                       data.name = row.getString(0);
-                       data.hostname = row.getString(1);
-                       data.port = row.getInt(2);
-                       data.major = row.getInt(3);
-                       data.minor = row.getInt(4);
-                       data.patch = row.getInt(5);
-                       data.pkg = row.getInt(6);
-                       data.latitude = row.getFloat(7);
-                       data.longitude = row.getFloat(8);
-                       data.protocol = row.getString(9);
-                       data.subprotocol = row.getSet(10,String.class);
-                       data.port_key = row.getUUID(11);
+                data.name = row.getString(0);
+                data.hostname = row.getString(1);
+                data.port = row.getInt(2);
+                data.major = row.getInt(3);
+                data.minor = row.getInt(4);
+                data.patch = row.getInt(5);
+                data.pkg = row.getInt(6);
+                data.latitude = row.getFloat(7);
+                data.longitude = row.getFloat(8);
+                data.protocol = row.getString(9);
+                data.subprotocol = row.getSet(10,String.class);
+                data.port_key = row.getUUID(11);
             return data;
         }
 
@@ -137,7 +137,7 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
 
         @Override
         protected void body(final Data data, final int _idx, final Object[] obj) {
-                       int idx = _idx;
+                int idx = _idx;
             obj[idx] = data.major;
             obj[++idx] = data.minor;
             obj[++idx] = data.patch;
@@ -149,73 +149,73 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
             obj[++idx] = data.port_key;
         }
 
-               @Override
-               public void marshal(Data data, DataOutputStream os) throws IOException {
-                       writeHeader(os,MAGIC,VERSION);
-                       writeString(os, data.name);
-                       writeString(os, data.hostname);
-                       os.writeInt(data.port);
-                       os.writeInt(data.major);
-                       os.writeInt(data.minor);
-                       os.writeInt(data.patch);
-                       os.writeInt(data.pkg);
-                       os.writeFloat(data.latitude);
-                       os.writeFloat(data.longitude);
-                       writeString(os, data.protocol);
-                       if(data.subprotocol==null) {
-                               os.writeInt(0);
-                       } else {
-                               os.writeInt(data.subprotocol.size());
-                               for(String s: data.subprotocol) {
-                                       writeString(os,s);
-                               }
-                       }
-                       
-                       writeString(os,data.port_key==null?"":data.port_key.toString());
-               }
+        @Override
+        public void marshal(Data data, DataOutputStream os) throws IOException {
+            writeHeader(os,MAGIC,VERSION);
+            writeString(os, data.name);
+            writeString(os, data.hostname);
+            os.writeInt(data.port);
+            os.writeInt(data.major);
+            os.writeInt(data.minor);
+            os.writeInt(data.patch);
+            os.writeInt(data.pkg);
+            os.writeFloat(data.latitude);
+            os.writeFloat(data.longitude);
+            writeString(os, data.protocol);
+            if(data.subprotocol==null) {
+                os.writeInt(0);
+            } else {
+                os.writeInt(data.subprotocol.size());
+                for(String s: data.subprotocol) {
+                    writeString(os,s);
+                }
+            }
+            
+            writeString(os,data.port_key==null?"":data.port_key.toString());
+        }
 
-               @Override
-               public void unmarshal(Data data, DataInputStream is) throws IOException {
-                       /*int version = */readHeader(is,MAGIC,VERSION);
-                       // If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
-                       byte[] buff = new byte[BUFF_SIZE];
-                       data.name = readString(is,buff);
-                       data.hostname = readString(is,buff);
-                       data.port = is.readInt();
-                       data.major = is.readInt();
-                       data.minor = is.readInt();
-                       data.patch = is.readInt();
-                       data.pkg = is.readInt();
-                       data.latitude = is.readFloat();
-                       data.longitude = is.readFloat();
-                       data.protocol = readString(is,buff);
-                       
-                       int size = is.readInt();
-                       data.subprotocol = new HashSet<>(size);
-                       for(int i=0;i<size;++i) {
-                               data.subprotocol.add(readString(is,buff));
-                       }
-                       String port_key = readString(is,buff);
-                       if(port_key.length()>0) {
-                               data.port_key=UUID.fromString(port_key);
-                       } else {
-                               data.port_key = null;
-                       }
-               }
+        @Override
+        public void unmarshal(Data data, DataInputStream is) throws IOException {
+            /*int version = */readHeader(is,MAGIC,VERSION);
+            // If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
+            byte[] buff = new byte[BUFF_SIZE];
+            data.name = readString(is,buff);
+            data.hostname = readString(is,buff);
+            data.port = is.readInt();
+            data.major = is.readInt();
+            data.minor = is.readInt();
+            data.patch = is.readInt();
+            data.pkg = is.readInt();
+            data.latitude = is.readFloat();
+            data.longitude = is.readFloat();
+            data.protocol = readString(is,buff);
+            
+            int size = is.readInt();
+            data.subprotocol = new HashSet<>(size);
+            for(int i=0;i<size;++i) {
+                data.subprotocol.add(readString(is,buff));
+            }
+            String port_key = readString(is,buff);
+            if(port_key.length()>0) {
+                data.port_key=UUID.fromString(port_key);
+            } else {
+                data.port_key = null;
+            }
+        }
     }
     
     public Result<List<LocateDAO.Data>> readByName(AuthzTrans trans, String service) {
-               return psName.read(trans, "Read By Name", new Object[] {service});
+            return psName.read(trans, "Read By Name", new Object[] {service});
     }
 
     private void init(AuthzTrans trans) throws APIException, IOException {
         // Set up sub-DAOs
-               String[] helpers = setCRUD(trans, TABLE, Data.class, LocateLoader.deflt);
-//             int lastComma = helpers[ASSIGNMENT_COMMAS].lastIndexOf(',');
-//             replace(CRUD.update,new PSInfo(trans,"UPDATE LOCATE SET " + helpers[ASSIGNMENT_COMMAS].substring(0, lastComma) +
-//                             " WHERE name=? AND hostname=? AND port=?;", new LocateLoader(3),writeConsistency));
-               psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
-                               " WHERE name = ?", new LocateLoader(1),readConsistency);
+        String[] helpers = setCRUD(trans, TABLE, Data.class, LocateLoader.deflt);
+//        int lastComma = helpers[ASSIGNMENT_COMMAS].lastIndexOf(',');
+//        replace(CRUD.update,new PSInfo(trans,"UPDATE LOCATE SET " + helpers[ASSIGNMENT_COMMAS].substring(0, lastComma) +
+//                " WHERE name=? AND hostname=? AND port=?;", new LocateLoader(3),writeConsistency));
+        psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+                " WHERE name = ?", new LocateLoader(1),readConsistency);
     }
     
     /**