X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cass%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fdao%2Fcass%2FLocateDAO.java;h=3fad6a7ae5a18024bfa35df4538518af62f79919;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=085f4199f5cde81ba64ad9c0cd31cacb96ce8a40;hpb=12414fe43077e12d7ef711951b1633ad31d73573;p=aaf%2Fauthz.git diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java index 085f4199..3fad6a7a 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java @@ -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. @@ -44,14 +44,14 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Row; /** - * LocateDAO manages credentials. + * LocateDAO manages credentials. * @author Jonathan * Date: 10/11/17 */ public class LocateDAO extends CassDAOImpl { public static final String TABLE = "locate"; private AbsCassDAO.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)); init(trans); @@ -61,10 +61,10 @@ public class LocateDAO extends CassDAOImpl { super(trans, LocateDAO.class.getSimpleName(), adao, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE)); init(trans); } - + public static final int KEYLIMIT = 3; public static class Data implements Bytification { - + public String name; public String hostname; public int port; @@ -87,21 +87,21 @@ public class LocateDAO extends CassDAOImpl { } 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 void reconstitute(ByteBuffer bb) throws IOException { LocateLoader.deflt.unmarshal(this, toDIS(bb)); } - public Data copy() { - Data out = new Data(); + public Data copy() { + Data out = new Data(); out.name = name; out.hostname = hostname; out.port = port; @@ -115,15 +115,15 @@ public class LocateDAO extends CassDAOImpl { out.subprotocol = new HashSet<>(); out.subprotocol.addAll(subprotocol); out.port_key = port_key; - return out; - } + return out; + } } private static class LocateLoader extends Loader implements Streamer{ public static final int MAGIC=85102934; public static final int VERSION=1; - public static final int BUFF_SIZE=48; // Note: - + public static final int BUFF_SIZE=48; // Note: + public static final LocateLoader deflt = new LocateLoader(KEYLIMIT); public LocateLoader(int keylimit) { super(keylimit); @@ -188,7 +188,7 @@ public class LocateDAO extends CassDAOImpl { writeString(os,s); } } - + writeString(os,data.port_key==null?"":data.port_key.toString()); } @@ -207,7 +207,7 @@ public class LocateDAO extends CassDAOImpl { 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 { } } } - + public Result> readByName(AuthzTrans trans, String service) { return psName.read(trans, "Read By Name", new Object[] {service}); } @@ -235,7 +235,7 @@ public class LocateDAO extends CassDAOImpl { psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE + " WHERE name = ?", new LocateLoader(1),readConsistency); } - + /** * Log Modification statements to History *