From 7e966914050e66219689001ff4ab601a49eef0ac Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 7 Sep 2018 13:43:23 -0500 Subject: Mass whitespace changes (Style Warnings) Issue-ID: AAF-473 Change-Id: Ia1b3825a527bd56299949b5962bb9354dffbeef8 Signed-off-by: Instrumental --- .../java/org/onap/aaf/auth/dao/AbsCassDAO.java | 60 +++++----- .../main/java/org/onap/aaf/auth/dao/Cached.java | 32 +++--- .../main/java/org/onap/aaf/auth/dao/CachedDAO.java | 34 +++--- .../java/org/onap/aaf/auth/dao/CassAccess.java | 54 ++++----- .../java/org/onap/aaf/auth/dao/CassDAOImpl.java | 72 ++++++------ .../main/java/org/onap/aaf/auth/dao/Loader.java | 32 +++--- .../onap/aaf/auth/dao/cached/CachedCredDAO.java | 2 +- .../onap/aaf/auth/dao/cached/CachedPermDAO.java | 12 +- .../onap/aaf/auth/dao/cached/CachedRoleDAO.java | 8 +- .../aaf/auth/dao/cached/CachedUserRoleDAO.java | 18 +-- .../org/onap/aaf/auth/dao/cass/ApprovalDAO.java | 16 +-- .../java/org/onap/aaf/auth/dao/cass/ArtiDAO.java | 16 +-- .../org/onap/aaf/auth/dao/cass/CacheInfoDAO.java | 70 ++++++------ .../java/org/onap/aaf/auth/dao/cass/CertDAO.java | 16 +-- .../java/org/onap/aaf/auth/dao/cass/CredDAO.java | 16 +-- .../java/org/onap/aaf/auth/dao/cass/FutureDAO.java | 6 +- .../org/onap/aaf/auth/dao/cass/HistoryDAO.java | 14 +-- .../java/org/onap/aaf/auth/dao/cass/LocateDAO.java | 8 +- .../java/org/onap/aaf/auth/dao/cass/Namespace.java | 10 +- .../java/org/onap/aaf/auth/dao/cass/NsDAO.java | 54 ++++----- .../java/org/onap/aaf/auth/dao/cass/NsSplit.java | 6 +- .../java/org/onap/aaf/auth/dao/cass/NsType.java | 10 +- .../java/org/onap/aaf/auth/dao/cass/PermDAO.java | 20 ++-- .../java/org/onap/aaf/auth/dao/cass/RoleDAO.java | 16 +-- .../org/onap/aaf/auth/dao/cass/UserRoleDAO.java | 8 +- .../org/onap/aaf/auth/dao/hl/CassExecutor.java | 4 +- .../java/org/onap/aaf/auth/dao/hl/Function.java | 120 ++++++++++---------- .../java/org/onap/aaf/auth/dao/hl/PermLookup.java | 28 ++--- .../java/org/onap/aaf/auth/dao/hl/Question.java | 122 ++++++++++----------- .../org/onap/aaf/auth/direct/DirectAAFLocator.java | 20 ++-- .../org/onap/aaf/auth/direct/DirectAAFLur.java | 32 +++--- .../onap/aaf/auth/direct/DirectAAFUserPass.java | 6 +- .../onap/aaf/auth/direct/DirectCertIdentity.java | 6 +- .../onap/aaf/auth/direct/DirectLocatorCreator.java | 2 +- .../org/onap/aaf/auth/direct/DirectRegistrar.java | 18 +-- 35 files changed, 484 insertions(+), 484 deletions(-) (limited to 'auth/auth-cass/src/main/java') diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java index f24c7c9f..d0e4eaab 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java @@ -128,18 +128,18 @@ public abstract class AbsCassDAO { psinfos.add(this); cql = theCQL.trim().toUpperCase(); - if(cql.startsWith("INSERT")) { + if (cql.startsWith("INSERT")) { crud = CRUD.create; - } else if(cql.startsWith("UPDATE")) { + } else if (cql.startsWith("UPDATE")) { crud = CRUD.update; - } else if(cql.startsWith("DELETE")) { + } else if (cql.startsWith("DELETE")) { crud = CRUD.delete; } else { crud = CRUD.read; } int idx = 0, count=0; - while((idx=cql.indexOf('?',idx))>=0) { + while ((idx=cql.indexOf('?',idx))>=0) { ++idx; ++count; } @@ -155,7 +155,7 @@ public abstract class AbsCassDAO { You should prepare only once, and cache the PreparedStatement in your application (it is thread-safe). If you call prepare multiple times with the same query string, the driver will log a warning. */ - if(ps==null) { + if (ps==null) { TimeTaken tt = trans.start("Preparing PSInfo " + crud.toString().toUpperCase() + " on " + name,Env.SUB); try { ps = getSession(trans).prepare(cql); @@ -287,7 +287,7 @@ public abstract class AbsCassDAO { rs = getSession(trans).execute(key==null?ps(trans):ps(trans).bind(key)); /// TEST CODE for Exception // boolean force = true; -// if(force) { +// if (force) { // Map misa = new HashMap<>(); // //misa.put(new InetSocketAddress(444),new Exception("no host was tried")); // misa.put(new InetSocketAddress(444),new Exception("Connection has been closed")); @@ -334,19 +334,19 @@ public abstract class AbsCassDAO { @SuppressWarnings("unchecked") protected final Result> extract(Loader loader, ResultSet rs, List indata, Accept accept) { List rows = rs.all(); - if(rows.isEmpty()) { + if (rows.isEmpty()) { return Result.ok((List)EMPTY); // Result sets now .emptyList(true); } else { DATA d; List data = indata==null?new ArrayList<>(rows.size()):indata; - for(Row row : rows) { + for (Row row : rows) { try { d = loader.load(dataClass.newInstance(),row); - if(accept.ok(d)) { + if (accept.ok(d)) { data.add(d); } - } catch(Exception e) { + } catch (Exception e) { return Result.err(e); } } @@ -372,8 +372,8 @@ public abstract class AbsCassDAO { public static final void primePSIs(TransStore trans) throws APIException, IOException { - for(AbsCassDAO.PSInfo psi : psinfos) { - if(psi.ps==null) { + for (AbsCassDAO.PSInfo psi : psinfos) { + if (psi.ps==null) { psi.ps(trans); } } @@ -382,28 +382,28 @@ public abstract class AbsCassDAO { public final Session getSession(TransStore trans) throws APIException, IOException { // SessionFilter unused since 2015 // Try to use Trans' session, if exists -// if(sessionSlot!=null) { // try to get from Trans +// if (sessionSlot!=null) { // try to get from Trans // Session sess = trans.get(sessionSlot, null); -// if(sess!=null) { +// if (sess!=null) { // return sess; // } // } // If there's an owning DAO, use it's session - if(owningDAO!=null) { + if (owningDAO!=null) { return owningDAO.getSession(trans); } // OK, nothing else works... get our own. - if(session==null || resetTrigger) { + if (session==null || resetTrigger) { Cluster tempCluster = null; Session tempSession = null; try { synchronized(LOCK) { boolean reset = false; - for(ResetRequest r : resetDeque) { - if(r.session == session) { - if(r.timestamp>nextAvailableReset) { + for (ResetRequest r : resetDeque) { + if (r.session == session) { + if (r.timestamp>nextAvailableReset) { reset=true; nextAvailableReset = System.currentTimeMillis() + 60000; tempCluster = cluster; @@ -415,22 +415,22 @@ public abstract class AbsCassDAO { } } - if(reset || session == null) { + if (reset || session == null) { TimeTaken tt = trans.start(NEW_CASSANDRA_SESSION, Env.SUB); try { // Note: Maitrayee recommended not closing the cluster, just // overwrite it. Jonathan 9/30/2016 assuming same for Session // This was a bad idea. Ran out of File Handles as I suspected, Jonathan - if(reset) { - for(AbsCassDAO.PSInfo psi : psinfos) { + if (reset) { + for (AbsCassDAO.PSInfo psi : psinfos) { psi.reset(); } } - if(reset || cluster==null) { + if (reset || cluster==null) { cluster = CassAccess.cluster(trans, keyspace); trans.warn().log(NEW_CASSANDRA_CLUSTER_OBJECT_CREATED); } - if(reset || session==null) { + if (reset || session==null) { session = cluster.connect(keyspace); trans.warn().log(NEW_CASSANDRA_SESSION_CREATED); } @@ -445,10 +445,10 @@ public abstract class AbsCassDAO { try { resetDeque.clear(); // Not clearing Session/Cluster appears to kill off FileHandles - if(tempSession!=null && !tempSession.isClosed()) { + if (tempSession!=null && !tempSession.isClosed()) { tempSession.close(); } - if(tempCluster!=null && !tempCluster.isClosed()) { + if (tempCluster!=null && !tempCluster.isClosed()) { tempCluster.close(); } } finally { @@ -460,11 +460,11 @@ public abstract class AbsCassDAO { } public final boolean reportPerhapsReset(TransStore trans, Exception e) { - if(owningDAO!=null) { + if (owningDAO!=null) { return owningDAO.reportPerhapsReset(trans, e); } else { boolean rv = false; - if(CassAccess.isResetException(e)) { + if (CassAccess.isResetException(e)) { trans.warn().printf("Session Reset called for %s by %s ",session==null?"":session,e==null?"Mgmt Command":e.getClass().getName()); resetDeque.addFirst(new ResetRequest(session)); rv = resetTrigger = true; @@ -475,8 +475,8 @@ public abstract class AbsCassDAO { } public void close(TransStore trans) { - if(owningDAO==null) { - if(session!=null) { + if (owningDAO==null) { + if (session!=null) { TimeTaken tt = trans.start("Cassandra Session Close", Env.SUB); try { session.close(); diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java index 3f4bbb20..1bda405c 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/Cached.java @@ -56,7 +56,7 @@ public class Cached extends Cache extends Cache extends Cache map = ((Map)cache[cacheIdx]); -// if(map.remove(key)!=null) // Not seeming to remove all the time - if(map!=null)map.clear(); +// if (map.remove(key)!=null) // Not seeming to remove all the time + if (map!=null)map.clear(); // System.err.println("Remove " + name + " " + key); return cacheIdx; } public Result invalidate(int segment) { - if(segment<0 || segment>=cache.length) return Result.err(Status.ERR_BadData,"Cache Segment %s is out of range",Integer.toString(segment)); + if (segment<0 || segment>=cache.length) return Result.err(Status.ERR_BadData,"Cache Segment %s is out of range",Integer.toString(segment)); @SuppressWarnings("unchecked") Map map = ((Map)cache[segment]); - if(map!=null) { + if (map!=null) { map.clear(); } return Result.ok(); @@ -118,14 +118,14 @@ public class Cached extends Cache)cached.data; rld = Result.ok(ld); } else { rld = getter.get(); - if(rld.isOK()) { // only store valid lists + if (rld.isOK()) { // only store valid lists map.put(key, new Dated(rld.value,expireIn)); // successful item found gets put in cache -// } else if(rld.status == Result.ERR_Backend){ +// } else if (rld.status == Result.ERR_Backend){ // map.remove(key); } } @@ -138,8 +138,8 @@ public class Cached extends Cache ... dao) { - for(CachedDAO d : dao) { - for(int i=0;i d : dao) { + for (int i=0;i extends Cache void startRefresh(AuthzEnv env, CIDAO cidao) { - if(infoTimer==null) { + if (infoTimer==null) { infoTimer = new Timer("CachedDAO Info Refresh Timer"); int minRefresh = 10*1000*60; // 10 mins Integer.parseInt(env.getProperty(CACHE_MIN_REFRESH_INTERVAL,"2000")); // 2 second minimum refresh infoTimer.schedule(new Refresh(env,cidao, minRefresh), 1000, minRefresh); // note: Refresh from DB immediately @@ -156,7 +156,7 @@ public class Cached extends Cache extends Cache rv = cidao.check(trans); - if(rv.status!=Result.OK) { + if (rv.status!=Result.OK) { env.error().log("Error in CacheInfo Refresh",rv.details); } - if(env.debug().isLoggable()) { + if (env.debug().isLoggable()) { StringBuilder sb = new StringBuilder("Cache Info Refresh: "); trans.auditTrail(0, sb, Env.REMOTE); env.debug().log(sb); diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java index 9375502c..cf410d0b 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CachedDAO.java @@ -52,7 +52,7 @@ public class CachedDAO,DATA extend this.dao = dao; //read_str = "Cached READ for " + dao.table(); // dirty_str = "Cache DIRTY on " + dao.table(); - if(dao instanceof CassDAOImpl) { + if (dao instanceof CassDAOImpl) { ((CassDAOImpl)dao).cache = this; } } @@ -80,14 +80,14 @@ public class CachedDAO,DATA extend public static String keyFromObjs(Object ... objs) { String key; - if(objs.length==1 && objs[0] instanceof String) { + if (objs.length==1 && objs[0] instanceof String) { key = (String)objs[0]; } else { StringBuilder sb = new StringBuilder(); boolean first = true; - for(Object o : objs) { - if(o!=null) { - if(first) { + for (Object o : objs) { + if (o!=null) { + if (first) { first =false; } else { sb.append('|'); @@ -102,7 +102,7 @@ public class CachedDAO,DATA extend public Result create(TRANS trans, DATA data) { Result d = dao.create(trans,data); - if(d.status==Status.OK) { + if (d.status==Status.OK) { add(d.value); } else { trans.error().log(d.errorString()); @@ -134,7 +134,7 @@ public class CachedDAO,DATA extend @Override public final Result> get() { return call(); -// if(result.isOKhasData()) { // Note, given above logic, could exist, but stale +// if (result.isOKhasData()) { // Note, given above logic, could exist, but stale // return result.value; // } else { // return null; @@ -146,11 +146,11 @@ public class CachedDAO,DATA extend public Result> read(final TRANS trans, final Object ... objs) { DAOGetter getter = new DAOGetter(trans,dao,objs); return get(trans, keyFromObjs(objs),getter); -// if(ld!=null) { +// if (ld!=null) { // return Result.ok(ld);//.emptyList(ld.isEmpty()); // } // // Result Result if exists -// if(getter.result==null) { +// if (getter.result==null) { // return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table()); // } // return getter.result; @@ -160,11 +160,11 @@ public class CachedDAO,DATA extend public Result> read(final String key, final TRANS trans, final Object[] objs) { DAOGetter getter = new DAOGetter(trans,dao,objs); return get(trans, key, getter); -// if(ld!=null) { +// if (ld!=null) { // return Result.ok(ld);//.emptyList(ld.isEmpty()); // } // // Result Result if exists -// if(getter.result==null) { +// if (getter.result==null) { // return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table()); // } // return getter.result; @@ -176,7 +176,7 @@ public class CachedDAO,DATA extend } public Result update(TRANS trans, DATA data) { Result d = dao.update(trans, data); - if(d.status==Status.OK) { + if (d.status==Status.OK) { add(data); } else { trans.error().log(d.errorString()); @@ -185,14 +185,14 @@ public class CachedDAO,DATA extend } public Result delete(TRANS trans, DATA data, boolean reread) { - if(reread) { // If reread, get from Cache, if possible, not DB exclusively + if (reread) { // If reread, get from Cache, if possible, not DB exclusively Result> rd = read(trans,data); - if(rd.notOK()) { + if (rd.notOK()) { return Result.err(rd); // } else { // trans.error().log(rd.errorString()); } - if(rd.isEmpty()) { + if (rd.isEmpty()) { data.invalidate(this); return Result.err(Status.ERR_NotFound,"Not Found"); } @@ -205,7 +205,7 @@ public class CachedDAO,DATA extend @Override public void close(TRANS trans) { - if(dao!=null) { + if (dao!=null) { dao.close(trans); } } @@ -221,7 +221,7 @@ public class CachedDAO,DATA extend } public void invalidate(TRANS trans, DATA data) { - if(info.touch(trans, dao.table(),data.invalidate(this)).notOK()) { + if (info.touch(trans, dao.table(),data.invalidate(this)).notOK()) { trans.error().log("Cannot touch CacheInfo for Role"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java index 9b168a83..b8062fcd 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java @@ -64,9 +64,9 @@ public class CassAccess { // @SuppressWarnings("deprecation") public static synchronized Cluster cluster(Env env, String prefix) throws APIException, IOException { - if(cb == null) { + if (cb == null) { String pre; - if(prefix==null) { + if (prefix==null) { pre=""; } else { env.info().log("Cassandra Connection for ",prefix); @@ -74,19 +74,19 @@ public class CassAccess { } cb = Cluster.builder(); String str = env.getProperty(pre+CASSANDRA_CLUSTERS_PORT,env.getProperty(CASSANDRA_CLUSTERS_PORT,"9042")); - if(str!=null) { + if (str!=null) { env.init().log("Cass Port = ",str ); cb.withPort(Integer.parseInt(str)); } str = env.getProperty(pre+CASSANDRA_CLUSTERS_USER_NAME,env.getProperty(CASSANDRA_CLUSTERS_USER_NAME,null)); - if(str!=null) { + if (str!=null) { env.init().log("Cass User = ",str ); String epass = env.getProperty(pre + CASSANDRA_CLUSTERS_PASSWORD,env.getProperty(CASSANDRA_CLUSTERS_PASSWORD,null)); - if(epass==null) { + if (epass==null) { throw new APIException("No Password configured for " + str); } //TODO Figure out way to ensure Decryptor setting in AuthzEnv - if(env instanceof AuthzEnv) { + if (env instanceof AuthzEnv) { cb.withCredentials(str,((AuthzEnv)env).decrypt(epass,true)); } else { cb.withCredentials(str, env.decryptor().decrypt(epass)); @@ -94,9 +94,9 @@ public class CassAccess { } str = env.getProperty(pre+CASSANDRA_RESET_EXCEPTIONS,env.getProperty(CASSANDRA_RESET_EXCEPTIONS,null)); - if(str!=null) { + if (str!=null) { env.init().log("Cass ResetExceptions = ",str ); - for(String ex : Split.split(',', str)) { + for (String ex : Split.split(',', str)) { resetExceptions.add(new Resettable(env,ex)); } } @@ -105,7 +105,7 @@ public class CassAccess { Double lat = str!=null?Double.parseDouble(str):null; str = env.getProperty(Config.CADI_LONGITUDE); Double lon = str!=null?Double.parseDouble(str):null; - if(lat == null || lon == null) { + if (lat == null || lon == null) { throw new APIException(Config.CADI_LATITUDE + " and/or " + Config.CADI_LONGITUDE + " are not set"); } @@ -118,23 +118,23 @@ public class CassAccess { String bestDC = null; int numInBestDC = 1; double mlat, mlon,temp,distance = Double.MAX_VALUE; - for(int i=0;i0) { + if (minfo.length>0) { cpoints[i]=minfo[0]; } - if(minfo.length>3) { - if(minfo[1].equals(bestDC)) { + if (minfo.length>3) { + if (minfo[1].equals(bestDC)) { ++numInBestDC; } else { // Calc closest DC with Great Circle mlat = Double.parseDouble(minfo[2]); mlon = Double.parseDouble(minfo[3]); // Note: GreatCircle Distance is always >= 0.0 (not negative) - if((temp=GreatCircle.calc(lat, lon, mlat, mlon)) < distance) { + if ((temp=GreatCircle.calc(lat, lon, mlat, mlon)) < distance) { distance = temp; - if(bestDC==null || !bestDC.equals(minfo[1])) { + if (bestDC==null || !bestDC.equals(minfo[1])) { bestDC = minfo[1]; numInBestDC = 1; } @@ -145,7 +145,7 @@ public class CassAccess { cb.addContactPoints(cpoints); - if(bestDC!=null) { + if (bestDC!=null) { // 8/26/2016 Management has determined that Accuracy is preferred over speed in bad situations // Local DC Aware Load Balancing appears to have the highest normal performance, with the best // Degraded Accuracy @@ -171,18 +171,18 @@ public class CassAccess { @SuppressWarnings("unchecked") public Resettable(Env env, String propData) throws APIException { - if(propData!=null && propData.length()>1) { + if (propData!=null && propData.length()>1) { String[] split = Split.split(':', propData); - if(split.length>0) { + if (split.length>0) { try { cls = (Class)Class.forName(split[0]); } catch (ClassNotFoundException e) { throw new APIException("Declared Cassandra Reset Exception, " + propData + ", cannot be ClassLoaded"); } } - if(split.length>1) { + if (split.length>1) { messages=new ArrayList<>(); - for(int i=1;i extends AbsCassDAO0) { - for(int i=0;i0) { + if (keylimit>0) { + for (int i=0;i0) { sbfc.append(','); sbq.append(','); - if(i=keylimit) { - if(i>keylimit) { + if (i>=keylimit) { + if (i>keylimit) { sbup.append(','); } sbup.append(fields[i].getName()); sbup.append("=?"); } - if(i extends AbsCassDAO extends AbsCassDAO create(TRANS trans, DATA data) { - if(createPS==null) { + if (createPS==null) { return Result.err(Result.ERR_NotImplemented,"Create is disabled for %s",getClass().getSimpleName()); } - if(async) /*ResultSetFuture */ { + if (async) /*ResultSetFuture */ { Result rs = createPS.execAsync(trans, C_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } else { Result rs = createPS.exec(trans, C_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } @@ -206,26 +206,26 @@ public class CassDAOImpl extends AbsCassDAO> read(TRANS trans, DATA data) { - if(readPS==null) { + if (readPS==null) { return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } return readPS.read(trans, R_TEXT, data); } public Result> read(TRANS trans, Object ... key) { - if(readPS==null) { + if (readPS==null) { return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } return readPS.read(trans, R_TEXT, key); } public Result readPrimKey(TRANS trans, Object ... key) { - if(readPS==null) { + if (readPS==null) { return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } Result> rld = readPS.read(trans, R_TEXT, key); - if(rld.isOK()) { - if(rld.isEmpty()) { + if (rld.isOK()) { + if (rld.isEmpty()) { return Result.err(Result.ERR_NotFound,rld.details); } else { return Result.ok(rld.value.get(0)); @@ -240,17 +240,17 @@ public class CassDAOImpl extends AbsCassDAO update(TRANS trans, DATA data, boolean async) { - if(updatePS==null) { + if (updatePS==null) { return Result.err(Result.ERR_NotImplemented,"Update is disabled for %s",getClass().getSimpleName()); } - if(async)/* ResultSet rs =*/ { + if (async)/* ResultSet rs =*/ { Result rs = updatePS.execAsync(trans, U_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } else { Result rs = updatePS.exec(trans, U_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } @@ -261,41 +261,41 @@ public class CassDAOImpl extends AbsCassDAO delete(TRANS trans, DATA data, boolean reread) { - if(deletePS==null) { + if (deletePS==null) { return Result.err(Result.ERR_NotImplemented,"Delete is disabled for %s",getClass().getSimpleName()); } // Since Deleting will be stored off, for possible re-constitution, need the whole thing - if(reread) { + if (reread) { Result> rd = read(trans,data); - if(rd.notOK()) { + if (rd.notOK()) { return Result.err(rd); } - if(rd.isEmpty()) { + if (rd.isEmpty()) { return Result.err(Status.ERR_NotFound,"Not Found"); } - for(DATA d : rd.value) { - if(async) { + for (DATA d : rd.value) { + if (async) { Result rs = deletePS.execAsync(trans, D_TEXT, d); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } else { Result rs = deletePS.exec(trans, D_TEXT, d); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } wasModified(trans, CRUD.delete, d); } } else { - if(async)/* ResultSet rs =*/ { + if (async)/* ResultSet rs =*/ { Result rs = deletePS.execAsync(trans, D_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } else { Result rs = deletePS.exec(trans, D_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } } @@ -317,9 +317,9 @@ public class CassDAOImpl extends AbsCassDAO extends AbsCassDAO { rv = new Object[size]; body(data,0,rv); int body = size-keylimit(); - if(body>0) { + if (body>0) { key(data,body,rv); } break; default: rv = new Object[size]; key(data,0,rv); - if(size>keylimit()) { + if (size>keylimit()) { body(data,keylimit(),rv); } break; @@ -76,7 +76,7 @@ public abstract class Loader { } public static void writeString(DataOutputStream os, String s) throws IOException { - if(s==null) { + if (s==null) { os.writeInt(-1); } else { switch(s.length()) { @@ -108,7 +108,7 @@ public abstract class Loader { case 0: return ""; default: // Cover case where there is a large string, without always allocating a large buffer. - if(l>buff.length) { + if (l>buff.length) { buff = new byte[l]; } is.read(buff,0,l); @@ -127,11 +127,11 @@ public abstract class Loader { * @throws IOException */ public static void writeStringSet(DataOutputStream os, Collection set) throws IOException { - if(set==null) { + if (set==null) { os.writeInt(-1); } else { os.writeInt(set.size()); - for(String s : set) { + for (String s : set) { writeString(os, s); } } @@ -140,11 +140,11 @@ public abstract class Loader { public static Set readStringSet(DataInputStream is, byte[] buff) throws IOException { int l = is.readInt(); - if(l<0) { + if (l<0) { return null; } Set set = new HashSet<>(l); - for(int i=0;i { public static List readStringList(DataInputStream is, byte[] buff) throws IOException { int l = is.readInt(); - if(l<0) { + if (l<0) { return null; } List list = new ArrayList<>(l); - for(int i=0;i { * @throws IOException */ public static void writeStringMap(DataOutputStream os, Map map) throws IOException { - if(map==null) { + if (map==null) { os.writeInt(-1); } else { Set> es = map.entrySet(); os.writeInt(es.size()); - for(Entry e : es) { + for (Entry e : es) { writeString(os, e.getKey()); writeString(os, e.getValue()); } @@ -184,11 +184,11 @@ public abstract class Loader { public static Map readStringMap(DataInputStream is, byte[] buff) throws IOException { int l = is.readInt(); - if(l<0) { + if (l<0) { return null; } Map map = new HashMap<>(l); - for(int i=0;i { } public static int readHeader(DataInputStream is, final int magic, final int version) throws IOException { - if(is.readInt()!=magic) { + if (is.readInt()!=magic) { throw new IOException("Corrupted Data Stream"); } int v = is.readInt(); - if(version<0 || v>version) { + if (version<0 || v>version) { throw new IOException("Unsupported Data Version: " + v); } return v; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java index eb5885f0..106999d3 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedCredDAO.java @@ -57,7 +57,7 @@ public class CachedCredDAO extends CachedDAO }; Result> lurd = get(trans, id, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_UserNotFound,"No User Cred found"); } return lurd; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java index a18e6a67..13180ab1 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedPermDAO.java @@ -46,13 +46,13 @@ public class CachedPermDAO extends CachedDAO { }; Result> lurd = get(trans, ns, getter); - if(lurd.isOKhasData()) { + if (lurd.isOKhasData()) { return lurd; } else { } -// if(getter.result==null) { -// if(lurd==null) { +// if (getter.result==null) { +// if (lurd==null) { return Result.err(Status.ERR_PermissionNotFound,"No Permission found - " + lurd.details); // } else { // return Result.ok(lurd); @@ -81,7 +81,7 @@ public class CachedPermDAO extends CachedDAO { // Note: Can reuse index1 here, because there is no name collision versus response Result> lurd = get(trans, ns+'|'+type, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_PermissionNotFound,"No Permission found"); } return lurd; @@ -106,7 +106,7 @@ public class CachedPermDAO extends CachedDAO { public Result addRole(AuthzTrans trans, PermDAO.Data perm, RoleDAO.Data role) { Result rv = dao().addRole(trans,perm,role.encode()); - if(trans.debug().isLoggable()) + if (trans.debug().isLoggable()) trans.debug().log("Adding",role.encode(),"to", perm, "with CachedPermDAO.addRole"); invalidate(trans,perm); return rv; @@ -114,7 +114,7 @@ public class CachedPermDAO extends CachedDAO { public Result delRole(AuthzTrans trans, Data perm, RoleDAO.Data role) { Result rv = dao().delRole(trans,perm,role.encode()); - if(trans.debug().isLoggable()) + if (trans.debug().isLoggable()) trans.debug().log("Removing",role.encode(),"from", perm, "with CachedPermDAO.delRole"); invalidate(trans,perm); return rv; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java index 1d8e6709..99fac2da 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedRoleDAO.java @@ -45,7 +45,7 @@ public class CachedRoleDAO extends CachedDAO { }; Result> lurd = get(trans, ns, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_RoleNotFound,"No Role found"); } return lurd; @@ -59,7 +59,7 @@ public class CachedRoleDAO extends CachedDAO { }; Result> lurd = get(trans, name, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_RoleNotFound,"No Role found"); } return lurd; @@ -74,7 +74,7 @@ public class CachedRoleDAO extends CachedDAO { public Result addPerm(AuthzTrans trans, RoleDAO.Data rd, PermDAO.Data perm) { Result rv = dao().addPerm(trans,rd,perm); - if(trans.debug().isLoggable()) + if (trans.debug().isLoggable()) trans.debug().log("Adding",perm,"to", rd, "with CachedRoleDAO.addPerm"); invalidate(trans, rd); return rv; @@ -82,7 +82,7 @@ public class CachedRoleDAO extends CachedDAO { public Result delPerm(AuthzTrans trans, RoleDAO.Data rd, PermDAO.Data perm) { Result rv = dao().delPerm(trans,rd,perm); - if(trans.debug().isLoggable()) + if (trans.debug().isLoggable()) trans.debug().log("Removing",perm,"from", rd, "with CachedRoleDAO.addPerm"); invalidate(trans, rd); return rv; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java index 2121b136..c1aa9017 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/CachedUserRoleDAO.java @@ -53,9 +53,9 @@ public class CachedUserRoleDAO extends CachedDAO> call() { // If the call is for THIS user, and it exists, get from TRANS, add to TRANS if not. - if(user!=null && user.equals(trans.user())) { + if (user!=null && user.equals(trans.user())) { Result> transLD = trans.get(transURSlot,null); - if(transLD==null ) { + if (transLD==null ) { transLD = dao.readByUser(trans, user); } return transLD; @@ -65,7 +65,7 @@ public class CachedUserRoleDAO extends CachedDAO> lurd = get(trans, user, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_UserRoleNotFound,"UserRole not found for [%s]",user); } return lurd; @@ -79,7 +79,7 @@ public class CachedUserRoleDAO extends CachedDAO> lurd = get(trans, role, getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_UserRoleNotFound,"UserRole not found for [%s]",role); } return lurd; @@ -88,12 +88,12 @@ public class CachedUserRoleDAO extends CachedDAO> readUserInRole(final AuthzTrans trans, final String user, final String role) { DAOGetter getter = new DAOGetter(trans,dao()) { public Result> call() { - if(user.equals(trans.user())) { + if (user.equals(trans.user())) { Result> rrbu = readByUser(trans, user); - if(rrbu.isOK()) { + if (rrbu.isOK()) { List ld = new ArrayList<>(1); - for(Data d : rrbu.value) { - if(d.role.equals(role)) { + for (Data d : rrbu.value) { + if (d.role.equals(role)) { ld.add(d); break; } @@ -107,7 +107,7 @@ public class CachedUserRoleDAO extends CachedDAO> lurd = get(trans, keyFromObjs(user,role), getter); - if(lurd.isOK() && lurd.isEmpty()) { + if (lurd.isOK() && lurd.isEmpty()) { return Result.err(Status.ERR_UserRoleNotFound,"UserRole not found for role [%s] and user [%s]",role,user); } return lurd; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java index 1948ac65..cc4135ee 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ApprovalDAO.java @@ -99,7 +99,7 @@ public class ApprovalDAO extends CassDAOImpl { data.operation = row.getString(7); data.last_notified = row.getTimestamp(8); // This is used to get "WRITETIME(STATUS)" from Approval, which gives us an "updated" - if(row.getColumnDefinitions().size()>9) { + if (row.getColumnDefinitions().size()>9) { // Rows reported in MicroSeconds data.updated = new Date(row.getLong(9)/1000); } @@ -168,11 +168,11 @@ public class ApprovalDAO extends CassDAOImpl { @Override public Result create(AuthzTrans trans, Data data) { // If ID is not set (typical), create one. - if(data.id==null) { + if (data.id==null) { data.id = Chrono.dateToUUID(System.currentTimeMillis()); } Result rs = createPS.exec(trans, C_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } return Result.ok(data); @@ -200,14 +200,14 @@ public class ApprovalDAO extends CassDAOImpl { */ @Override public Result delete(AuthzTrans trans, Data data, boolean reread) { - if(reread || data.status == null) { // if Memo is empty, likely not full record + if (reread || data.status == null) { // if Memo is empty, likely not full record Result rd = readPS.exec(trans, R_TEXT, data); - if(rd.notOK()) { + if (rd.notOK()) { return Result.err(rd); } ApprovalLoader.deflt.load(data, rd.value.one()); } - if("approved".equals(data.status) || "denied".equals(data.status)) { + if ("approved".equals(data.status) || "denied".equals(data.status)) { StringBuilder sb = new StringBuilder("BEGIN BATCH\n"); sb.append("INSERT INTO "); sb.append(TABLELOG); @@ -228,7 +228,7 @@ public class ApprovalDAO extends CassDAOImpl { sb.append("APPLY BATCH;\n"); TimeTaken tt = trans.start("DELETE APPROVAL",Env.REMOTE); try { - if(async) { + if (async) { getSession(trans).executeAsync(sb.toString()); return Result.ok(); } else { @@ -270,7 +270,7 @@ public class ApprovalDAO extends CassDAOImpl { : (modified.name() + "d approval for " + data.user); // Detail? // Reconstruct? - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java index 6702476a..e0c0c0d4 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ArtiDAO.java @@ -170,7 +170,7 @@ public class ArtiDAO extends CassDAOImpl { writeString(os, data.mechid); writeString(os, data.machine); os.writeInt(data.type.size()); - for(String s : data.type) { + for (String s : data.type) { writeString(os, s); } writeString(os, data.sponsor); @@ -181,9 +181,9 @@ public class ArtiDAO extends CassDAOImpl { writeString(os, data.notify); os.writeLong(data.expires==null?-1:data.expires.getTime()); os.writeInt(data.renewDays); - if(data.sans!=null) { + if (data.sans!=null) { os.writeInt(data.sans.size()); - for(String s : data.sans) { + for (String s : data.sans) { writeString(os, s); } } else { @@ -200,7 +200,7 @@ public class ArtiDAO extends CassDAOImpl { data.machine = readString(is,buff); int size = is.readInt(); data.type = new HashSet<>(size); - for(int i=0;i { data.renewDays = is.readInt(); size = is.readInt(); data.sans = new HashSet<>(size); - for(int i=0;i { private void init(AuthzTrans trans) { // Set up sub-DAOs - if(historyDAO==null) { + if (historyDAO==null) { historyDAO = new HistoryDAO(trans,this); } @@ -288,7 +288,7 @@ public class ArtiDAO extends CassDAOImpl { ? String.format("%s by %s", override[0], hd.user) : String.format("%sd %s for %s",modified.name(),data.mechid,data.machine); // Detail? - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -296,7 +296,7 @@ public class ArtiDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java index e3f994c0..4aa94866 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java @@ -138,7 +138,7 @@ public class CacheInfoDAO extends CassDAOImpl impl } public static void startUpdate(AuthzEnv env, HMangr hman, SecuritySetter ss, String ip, int port) { - if(cacheUpdate==null) { + if (cacheUpdate==null) { Thread t= new Thread(cacheUpdate = new CacheUpdate(env,hman,ss, ip,port),"CacheInfo Update Thread"); t.setDaemon(true); t.start(); @@ -146,7 +146,7 @@ public class CacheInfoDAO extends CassDAOImpl impl } public static void stopUpdate() { - if(cacheUpdate!=null) { + if (cacheUpdate!=null) { cacheUpdate.go=false; } } @@ -195,9 +195,9 @@ public class CacheInfoDAO extends CassDAOImpl impl @Override public Integer code(Rcli client) throws APIException, CadiException { URI to = client.getURI(); - if(!to.getAuthority().equals(authority)) { + if (!to.getAuthority().equals(authority)) { Future f = client.delete("/mgmt/cache/"+type+'/'+segs,VOID_CT); - if(f.get(hman.readTimeout())) { + if (f.get(hman.readTimeout())) { ++total; } else { trans.error().log("Error During AAF Peer Notify",f.code(),f.body()); @@ -216,14 +216,14 @@ public class CacheInfoDAO extends CassDAOImpl impl set = null; } public void add(int[] ints) { - if(set==null) { + if (set==null) { set = new HashSet<>(); - for(int i=0;i impl public String toString() { StringBuilder sb = new StringBuilder(); boolean first = true; - if(set==null) { - for(int i : raw) { - if(first) { + if (set==null) { + for (int i : raw) { + if (first) { first=false; } else { sb.append(','); @@ -242,8 +242,8 @@ public class CacheInfoDAO extends CassDAOImpl impl sb.append(i); } } else { - for(Integer i : set) { - if(first) { + for (Integer i : set) { + if (first) { first=false; } else { sb.append(','); @@ -260,7 +260,7 @@ public class CacheInfoDAO extends CassDAOImpl impl do { try { Transfer data = notifyDQ.poll(4,TimeUnit.SECONDS); - if(data==null) { + if (data==null) { continue; } @@ -271,37 +271,37 @@ public class CacheInfoDAO extends CassDAOImpl impl long start=0; // Do a block poll first do { - if(gather==null) { + if (gather==null) { start = System.nanoTime(); trans = env.newTransNoAvg(); cc = new CacheClear(trans); gather = new HashMap<>(); } IntHolder prev = gather.get(data.table); - if(prev==null) { + if (prev==null) { gather.put(data.table,new IntHolder(data.segs)); } else { prev.add(data.segs); } // continue while there is data - } while((data = notifyDQ.poll())!=null); - if(gather!=null) { - for(Entry es : gather.entrySet()) { + } while ((data = notifyDQ.poll())!=null); + if (gather!=null) { + for (Entry es : gather.entrySet()) { cc.set(es); try { - if(hman.all(ss, cc, false)!=null) { + if (hman.all(ss, cc, false)!=null) { ++count; } } catch (Exception e) { trans.error().log(e, "Error on Cache Update"); } } - if(env.debug().isLoggable()) { + if (env.debug().isLoggable()) { float millis = (System.nanoTime()-start)/1000000f; StringBuilder sb = new StringBuilder("Direct Cache Refresh: "); sb.append("Updated "); sb.append(count); - if(count==1) { + if (count==1) { sb.append(" entry for "); } else { sb.append(" entries for "); @@ -309,7 +309,7 @@ public class CacheInfoDAO extends CassDAOImpl impl int peers = count<=0?0:cc.total/count; sb.append(peers); sb.append(" client"); - if(peers!=1) { + if (peers!=1) { sb.append('s'); } sb.append(" in "); @@ -323,7 +323,7 @@ public class CacheInfoDAO extends CassDAOImpl impl go = false; Thread.currentThread().interrupt(); } - } while(go); + } while (go); } } @@ -347,9 +347,9 @@ public class CacheInfoDAO extends CassDAOImpl impl ///////////// // ConcurrentQueues are open-ended. We don't want any Memory leaks // Note: we keep a separate counter, because "size()" on a Linked Queue is expensive - if(cacheUpdate!=null) { + if (cacheUpdate!=null) { try { - if(!CacheUpdate.notifyDQ.offer(new CacheUpdate.Transfer(name, seg),2,TimeUnit.SECONDS)) { + if (!CacheUpdate.notifyDQ.offer(new CacheUpdate.Transfer(name, seg),2,TimeUnit.SECONDS)) { trans.error().log("Cache Notify Queue is not accepting messages, bouncing may be appropriate" ); } } catch (InterruptedException e) { @@ -367,7 +367,7 @@ public class CacheInfoDAO extends CassDAOImpl impl start.append(": "); StringBuilder sb = new StringBuilder("BEGIN BATCH\n"); boolean first = true; - for(int s : seg) { + for (int s : seg) { sb.append(UPDATE_SP); sb.append(TABLE); sb.append(" SET touched=dateof(now()) WHERE name = '"); @@ -375,7 +375,7 @@ public class CacheInfoDAO extends CassDAOImpl impl sb.append("' AND seg = "); sb.append(s); sb.append(";\n"); - if(first) { + if (first) { first =false; } else { start.append(','); @@ -413,24 +413,24 @@ public class CacheInfoDAO extends CassDAOImpl impl String lastName = null; Date[] dates = null; - for(Row row : rs.all()) { + for (Row row : rs.all()) { String name = row.getString(0); int seg = row.getInt(1); - if(!name.equals(lastName)) { + if (!name.equals(lastName)) { dates = info.get(name); lastName=name; } - if(dates==null) { + if (dates==null) { dates=new Date[seg+1]; info.put(name,dates); - } else if(dates.length<=seg) { + } else if (dates.length<=seg) { Date[] temp = new Date[seg+1]; System.arraycopy(dates, 0, temp, 0, dates.length); dates = temp; info.put(name, dates); } Date temp = row.getTimestamp(2); - if(dates[seg]==null || dates[seg].before(temp)) { + if (dates[seg]==null || dates[seg].before(temp)) { dates[seg]=temp; } } @@ -443,16 +443,16 @@ public class CacheInfoDAO extends CassDAOImpl impl @Override public Date get(AuthzTrans trans, String table, int seg) { Date[] dates = info.get(table); - if(dates==null) { + if (dates==null) { dates = new Date[seg+1]; touch(trans,table, seg); - } else if(dates.length<=seg) { + } else if (dates.length<=seg) { Date[] temp = new Date[seg+1]; System.arraycopy(dates, 0, temp, 0, dates.length); dates = temp; } Date rv = dates[seg]; - if(rv==null) { + if (rv==null) { rv=dates[seg]=startTime; } return rv; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java index 00c9ae90..6c23938f 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java @@ -143,7 +143,7 @@ public class CertDAO extends CassDAOImpl { writeString(os, data.x500); writeString(os, data.x509); writeString(os, data.ca); - if(data.serial==null) { + if (data.serial==null) { os.writeInt(-1); } else { byte[] dsba = data.serial.toByteArray(); @@ -164,9 +164,9 @@ public class CertDAO extends CassDAOImpl { data.ca = readString(is,buff); int i = is.readInt(); data.serial=null; - if(i>=0) { + if (i>=0) { byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads - if(is.read(bytes)>0) { + if (is.read(bytes)>0) { data.serial = new BigInteger(bytes); } } @@ -180,10 +180,10 @@ public class CertDAO extends CassDAOImpl { private void init(AuthzTrans trans) throws APIException, IOException { // Set up sub-DAOs - if(historyDAO==null) { + if (historyDAO==null) { historyDAO = new HistoryDAO(trans,this); } - if(infoDAO==null) { + if (infoDAO==null) { infoDAO = new CacheInfoDAO(trans,this); } @@ -226,7 +226,7 @@ public class CertDAO extends CassDAOImpl { ? String.format("%s by %s", override[0], hd.user) : (modified.name() + "d certificate info for " + data.id); // Detail? - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -234,10 +234,10 @@ public class CertDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).status!=Status.OK) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).status!=Status.OK) { trans.error().log("Cannot touch Cert"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java index 5bcba9d9..7674c7e8 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java @@ -158,7 +158,7 @@ public class CredDAO extends CassDAOImpl { os.writeInt(data.other==null?0:data.other); writeString(os, data.ns); writeString(os, data.notes); - if(data.cred==null) { + if (data.cred==null) { os.writeInt(-1); } else { int l = data.cred.limit()-data.cred.position(); @@ -183,10 +183,10 @@ public class CredDAO extends CassDAOImpl { int i = is.readInt(); data.cred=null; - if(i>=0) { + if (i>=0) { byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads int read = is.read(bytes); - if(read>0) { + if (read>0) { data.cred = ByteBuffer.wrap(bytes); } } @@ -195,10 +195,10 @@ public class CredDAO extends CassDAOImpl { private void init(AuthzTrans trans) throws APIException, IOException { // Set up sub-DAOs - if(historyDAO==null) { + if (historyDAO==null) { historyDAO = new HistoryDAO(trans,this); } - if(infoDAO==null) { + if (infoDAO==null) { infoDAO = new CacheInfoDAO(trans,this); } @@ -241,7 +241,7 @@ public class CredDAO extends CassDAOImpl { ? String.format("%s by %s", override[0], hd.user) : (modified.name() + "d credential for " + data.id); // Detail? - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -249,10 +249,10 @@ public class CredDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).status!=Status.OK) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).status!=Status.OK) { trans.error().log("Cannot touch Cred"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java index 6b0ea2df..a98f101f 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/FutureDAO.java @@ -143,14 +143,14 @@ public class FutureDAO extends CassDAOImpl { */ public Result create(AuthzTrans trans, FutureDAO.Data data, String id) { // If ID is not set (typical), create one. - if(data.id==null) { + if (data.id==null) { StringBuilder sb = new StringBuilder(trans.user()); sb.append(data.target); sb.append(System.currentTimeMillis()); data.id = UUID.nameUUIDFromBytes(sb.toString().getBytes()); } Result rs = createPS.exec(trans, C_TEXT, data); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } wasModified(trans, CRUD.create, data, null, id); @@ -175,7 +175,7 @@ public class FutureDAO extends CassDAOImpl { hd.subject = subject?override[1]:""; hd.memo = memo?String.format("%s by %s", override[0], hd.user):data.memo; - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java index ce7e5477..a40b28fb 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java @@ -174,7 +174,7 @@ public class HistoryDAO extends CassDAOImpl { public Result> readByYYYYMM(AuthzTrans trans, int yyyymm) { Result rs = readByYRMN.exec(trans, "yr_mon", yyyymm); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } return extract(defLoader,rs.value,null,dflt); @@ -186,22 +186,22 @@ public class HistoryDAO extends CassDAOImpl { * month - the month in a year ...values 1 - 12 **/ public Result> readByUser(AuthzTrans trans, String user, int ... yyyymm) { - if(yyyymm.length==0) { + if (yyyymm.length==0) { return Result.err(Status.ERR_BadData, "No or invalid yyyymm specified"); } Result rs = readByUser.exec(trans, "user", user); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } return extract(defLoader,rs.value,null,yyyymm.length>0?new YYYYMM(yyyymm):dflt); } public Result> readBySubject(AuthzTrans trans, String subject, String target, int ... yyyymm) { - if(yyyymm.length==0) { + if (yyyymm.length==0) { return Result.err(Status.ERR_BadData, "No or invalid yyyymm specified"); } Result rs = readBySubject.exec(trans, "subject", subject, target); - if(rs.notOK()) { + if (rs.notOK()) { return Result.err(rs); } return extract(defLoader,rs.value,null,yyyymm.length>0?new YYYYMM(yyyymm):dflt); @@ -215,8 +215,8 @@ public class HistoryDAO extends CassDAOImpl { @Override public boolean ok(Data data) { int dym = data.yr_mon; - for(int ym:yyyymm) { - if(dym==ym) { + for (int ym:yyyymm) { + if (dym==ym) { return true; } } 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 5d7aebed..757efa5f 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 @@ -162,11 +162,11 @@ public class LocateDAO extends CassDAOImpl { os.writeFloat(data.latitude); os.writeFloat(data.longitude); writeString(os, data.protocol); - if(data.subprotocol==null) { + if (data.subprotocol==null) { os.writeInt(0); } else { os.writeInt(data.subprotocol.size()); - for(String s: data.subprotocol) { + for (String s: data.subprotocol) { writeString(os,s); } } @@ -192,11 +192,11 @@ public class LocateDAO extends CassDAOImpl { int size = is.readInt(); data.subprotocol = new HashSet<>(size); - for(int i=0;i0) { + if (port_key.length()>0) { data.port_key=UUID.fromString(port_key); } else { data.port_key = null; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java index 29ac379b..192887b9 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/Namespace.java @@ -55,9 +55,9 @@ public class Namespace implements Bytification { description = ndd.description; type = ndd.type; parent = ndd.parent; - if(ndd.attrib!=null && !ndd.attrib.isEmpty()) { + if (ndd.attrib!=null && !ndd.attrib.isEmpty()) { attrib = new ArrayList<>(); - for( Entry entry : ndd.attrib.entrySet()) { + for ( Entry entry : ndd.attrib.entrySet()) { attrib.add(new Pair(entry.getKey(),entry.getValue())); } } @@ -70,9 +70,9 @@ public class Namespace implements Bytification { description = ndd.description; type = ndd.type; parent = ndd.parent; - if(ndd.attrib!=null && !ndd.attrib.isEmpty()) { + if (ndd.attrib!=null && !ndd.attrib.isEmpty()) { attrib = new ArrayList<>(); - for( Entry entry : ndd.attrib.entrySet()) { + for ( Entry entry : ndd.attrib.entrySet()) { attrib.add(new Pair(entry.getKey(),entry.getValue())); } } @@ -141,7 +141,7 @@ public class Namespace implements Bytification { */ @Override public boolean equals(Object arg0) { - if(arg0==null || !(arg0 instanceof Namespace)) { + if (arg0==null || !(arg0 instanceof Namespace)) { return false; } return name.equals(((Namespace)arg0).name); diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java index 30f0d6b5..f769e38c 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsDAO.java @@ -149,10 +149,10 @@ public class NsDAO extends CassDAOImpl { private void init(AuthzTrans trans) throws APIException, IOException { // Set up sub-DAOs - if(historyDAO==null) { + if (historyDAO==null) { historyDAO = new HistoryDAO(trans, this); } - if(infoDAO==null) { + if (infoDAO==null) { infoDAO = new CacheInfoDAO(trans,this); } @@ -205,11 +205,11 @@ public class NsDAO extends CassDAOImpl { os.writeInt(data.type); writeString(os,data.description); writeString(os,data.parent); - if(data.attrib==null) { + if (data.attrib==null) { os.writeInt(-1); } else { os.writeInt(data.attrib.size()); - for(Entry es : data.attrib(false).entrySet()) { + for (Entry es : data.attrib(false).entrySet()) { writeString(os,es.getKey()); writeString(os,es.getValue()); } @@ -227,9 +227,9 @@ public class NsDAO extends CassDAOImpl { data.description = readString(is,buff); data.parent = readString(is,buff); int count = is.readInt(); - if(count>0) { + if (count>0) { Map da = data.attrib(true); - for(int i=0;i { public Result create(AuthzTrans trans, Data data) { String ns = data.name; // Ensure Parent is set - if(data.parent==null) { + if (data.parent==null) { return Result.err(Result.ERR_BadData, "Need parent for %s", ns); } @@ -254,7 +254,7 @@ public class NsDAO extends CassDAOImpl { getSession(trans).execute(stmt.toString()); //// TEST CODE for Exception // boolean force = true; -// if(force) { +// if (force) { // throw new com.datastax.driver.core.exceptions.NoHostAvailableException(new HashMap<>()); //// throw new com.datastax.driver.core.exceptions.AuthenticationException(new InetSocketAddress(9999),"Sample Message"); // } @@ -272,7 +272,7 @@ public class NsDAO extends CassDAOImpl { public Result update(AuthzTrans trans, Data data) { String ns = data.name; // Ensure Parent is set - if(data.parent==null) { + if (data.parent==null) { return Result.err(Result.ERR_BadData, "Need parent for %s", ns); } @@ -281,26 +281,26 @@ public class NsDAO extends CassDAOImpl { try { Map localAttr = data.attrib; Result> rremoteAttr = readAttribByNS(trans,ns); - if(rremoteAttr.notOK()) { + if (rremoteAttr.notOK()) { return Result.err(rremoteAttr); } // update Attributes String str; - for(Entry es : localAttr.entrySet()) { + for (Entry es : localAttr.entrySet()) { str = rremoteAttr.value.get(es.getKey()); - if(str==null || !str.equals(es.getValue())) { + if (str==null || !str.equals(es.getValue())) { attribUpdateStmt(stmt, ns, es.getKey(),es.getValue()); } } // No point in deleting... insert overwrites... -// for(Entry es : remoteAttr.entrySet()) { +// for (Entry es : remoteAttr.entrySet()) { // str = localAttr.get(es.getKey()); -// if(str==null || !str.equals(es.getValue())) { +// if (str==null || !str.equals(es.getValue())) { // attribDeleteStmt(stmt, ns, es.getKey()); // } // } - if(stmt.length()>BEGIN_BATCH.length()) { + if (stmt.length()>BEGIN_BATCH.length()) { stmt.append(APPLY_BATCH); getSession(trans).execute(stmt.toString()); } @@ -320,11 +320,11 @@ public class NsDAO extends CassDAOImpl { public Result> read(AuthzTrans trans, Data data) { Result> rld = super.read(trans, data); - if(rld.isOKhasData()) { - for(Data d : rld.value) { + if (rld.isOKhasData()) { + for (Data d : rld.value) { // Note: Map is null at this point, save time/mem by assignment Result> rabn = readAttribByNS(trans,d.name); - if(rabn.isOK()) { + if (rabn.isOK()) { d.attrib = rabn.value; } else { return Result.err(rabn); @@ -341,11 +341,11 @@ public class NsDAO extends CassDAOImpl { public Result> read(AuthzTrans trans, Object... key) { Result> rld = super.read(trans, key); - if(rld.isOKhasData()) { - for(Data d : rld.value) { + if (rld.isOKhasData()) { + for (Data d : rld.value) { // Note: Map is null at this point, save time/mem by assignment Result> rabn = readAttribByNS(trans,d.name); - if(rabn.isOK()) { + if (rabn.isOK()) { d.attrib = rabn.value; } else { return Result.err(rabn); @@ -385,7 +385,7 @@ public class NsDAO extends CassDAOImpl { + ns + "';"); - for(Iterator iter = rs.iterator();iter.hasNext(); ) { + for (Iterator iter = rs.iterator();iter.hasNext(); ) { Row r = iter.next(); map.put(r.getString(0), r.getString(1)); } @@ -408,7 +408,7 @@ public class NsDAO extends CassDAOImpl { + key + "';"); - for(Iterator iter = rs.iterator();iter.hasNext(); ) { + for (Iterator iter = rs.iterator();iter.hasNext(); ) { Row r = iter.next(); set.add(r.getString(0)); } @@ -489,7 +489,7 @@ public class NsDAO extends CassDAOImpl { private void attribInsertStmts(StringBuilder stmt, Data data) { // INSERT new Attrib - for(Entry es : data.attrib(false).entrySet() ) { + for (Entry es : data.attrib(false).entrySet() ) { stmt.append(" "); attribInsertStmt(stmt,data.name,es.getKey(),es.getValue()); } @@ -541,7 +541,7 @@ public class NsDAO extends CassDAOImpl { hd.target = TABLE; hd.subject = subject ? override[1] : data.name; hd.memo = memo ? override[0] : (data.name + " was " + modified.name() + 'd' ); - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -549,10 +549,10 @@ public class NsDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { trans.error().log("Cannot touch CacheInfo"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java index a64c0a94..2beeaf38 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsSplit.java @@ -28,10 +28,10 @@ public class NsSplit { public NsSplit(NsDAO.Data nsd, String child) { this.nsd = nsd; - if(child.startsWith(nsd.name)) { + if (child.startsWith(nsd.name)) { ns = nsd.name; int dot = ns.length(); - if(dot=0) { + if (dot>=0) { nsd.parent = ns.substring(0, dot); } else { nsd.parent = "."; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java index 59e18ae9..e656a555 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/NsType.java @@ -46,8 +46,8 @@ public enum NsType { * @return */ public static NsType fromType(int t) { - for(NsType nst : values()) { - if(t==nst.type) { + for (NsType nst : values()) { + if (t==nst.type) { return nst; } } @@ -60,9 +60,9 @@ public enum NsType { * @return */ public static NsType fromString(String s) { - if(s!=null) { - for(NsType nst : values()) { - if(nst.name().equals(s)) { + if (s!=null) { + for (NsType nst : values()) { + if (nst.name().equals(s)) { return nst; } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java index c02387b1..6e1057b8 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/PermDAO.java @@ -114,13 +114,13 @@ public class PermDAO extends CassDAOImpl { */ public static Result decode(AuthzTrans trans, Question q, String p) { String[] ss = Split.splitTrim('|', p,4); - if(ss[2]==null) { + if (ss[2]==null) { return Result.err(Status.ERR_BadData,"Perm Encodings must be separated by '|'"); } Data data = new Data(); - if(ss[3]==null) { // older 3 part encoding must be evaluated for NS + if (ss[3]==null) { // older 3 part encoding must be evaluated for NS Result nss = q.deriveNsSplit(trans, ss[0]); - if(nss.notOK()) { + if (nss.notOK()) { return Result.err(nss); } data.ns=nss.value.ns; @@ -146,15 +146,15 @@ public class PermDAO extends CassDAOImpl { */ public static Result decodeToArray(AuthzTrans trans, Question q, String p) { String[] ss = Split.splitTrim('|', p,4); - if(ss[2]==null) { + if (ss[2]==null) { return Result.err(Status.ERR_BadData,"Perm Encodings must be separated by '|'"); } - if(ss[3]==null) { // older 3 part encoding must be evaluated for NS + if (ss[3]==null) { // older 3 part encoding must be evaluated for NS ss[3] = ss[2]; ss[2] = ss[1]; Result nss = q.deriveNsSplit(trans, ss[0]); - if(nss.notOK()) { + if (nss.notOK()) { return Result.err(nss); } ss[1] = nss.value.name; @@ -191,7 +191,7 @@ public class PermDAO extends CassDAOImpl { String[] s = name.split("\\|"); Result rdns = q.deriveNsSplit(trans, s[0]); Data rv = new PermDAO.Data(); - if(rdns.isOKhasData()) { + if (rdns.isOKhasData()) { switch(s.length) { case 3: rv.type=s[1]; @@ -482,7 +482,7 @@ public class PermDAO extends CassDAOImpl { hd.memo = String.format("%sd %s|%s|%s", modified.name(),data.fullType(),data.instance,data.action); } - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -490,10 +490,10 @@ public class PermDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { trans.error().log("Cannot touch CacheInfo"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java index 4489d268..127dd4e2 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/RoleDAO.java @@ -124,9 +124,9 @@ public class RoleDAO extends CassDAOImpl { public static Result decode(AuthzTrans trans, Question q, String r) { String[] ss = Split.splitTrim('|', r,2); Data data = new Data(); - if(ss[1]==null) { // older 1 part encoding must be evaluated for NS + if (ss[1]==null) { // older 1 part encoding must be evaluated for NS Result nss = q.deriveNsSplit(trans, ss[0]); - if(nss.notOK()) { + if (nss.notOK()) { return Result.err(nss); } data.ns=nss.value.ns; @@ -161,9 +161,9 @@ public class RoleDAO extends CassDAOImpl { */ public static Result decodeToArray(AuthzTrans trans, Question q, String p) { String[] ss = Split.splitTrim('|', p,2); - if(ss[1]==null) { // older 1 part encoding must be evaluated for NS + if (ss[1]==null) { // older 1 part encoding must be evaluated for NS Result nss = q.deriveNsSplit(trans, ss[0]); - if(nss.notOK()) { + if (nss.notOK()) { return Result.err(nss); } ss[0] = nss.value.ns; @@ -287,7 +287,7 @@ public class RoleDAO extends CassDAOImpl { } public Result> readChildren(AuthzTrans trans, String ns, String role) { - if(role.length()==0 || "*".equals(role)) { + if (role.length()==0 || "*".equals(role)) { 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}); @@ -392,7 +392,7 @@ public class RoleDAO extends CassDAOImpl { hd.target = TABLE; hd.subject = subject ? override[1] : data.fullName(); hd.memo = memo ? override[0] : (data.fullName() + " was " + modified.name() + 'd' ); - if(modified==CRUD.delete) { + if (modified==CRUD.delete) { try { hd.reconstruct = data.bytify(); } catch (IOException e) { @@ -400,10 +400,10 @@ public class RoleDAO extends CassDAOImpl { } } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { trans.error().log("Cannot touch CacheInfo for Role"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java index 7b9f7b91..26f9a995 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/UserRoleDAO.java @@ -127,7 +127,7 @@ public class UserRoleDAO extends CassDAOImpl { public boolean role(AuthzTrans trans, Question ques, String role) { this.role = role; Result rnss = ques.deriveNsSplit(trans, role); - if(rnss.isOKhasData()) { + if (rnss.isOKhasData()) { ns = rnss.value.ns; rname = rnss.value.name; return true; @@ -304,15 +304,15 @@ public class UserRoleDAO extends CassDAOImpl { : "n/a"; } - if(historyDAO.create(trans, hd).status!=Status.OK) { + if (historyDAO.create(trans, hd).status!=Status.OK) { trans.error().log("Cannot log to History"); } - if(historyDAO.create(trans, hdRole).status!=Status.OK) { + if (historyDAO.create(trans, hdRole).status!=Status.OK) { trans.error().log("Cannot log to History"); } // uses User as Segment - if(infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { + if (infoDAO.touch(trans, TABLE,data.invalidate(cache)).notOK()) { trans.error().log("Cannot touch CacheInfo"); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java index f0a59582..0bc23c92 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/CassExecutor.java @@ -47,7 +47,7 @@ public class CassExecutor implements Executor { @Override public boolean inRole(String name) { Result nss = q.deriveNsSplit(trans, name); - if(nss.notOK())return false; + if (nss.notOK())return false; return q.roleDAO.read(trans, nss.value.ns,nss.value.name).isOKhasData(); } @@ -58,7 +58,7 @@ public class CassExecutor implements Executor { @Override public String namespace() throws Exception { Result res = q.validNSOfDomain(trans,trans.user()); - if(res.isOK()) { + if (res.isOK()) { String user[] = trans.user().split("\\."); return user[user.length-1] + '.' + user[user.length-2]; } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java index f3aae2ec..f440a8cd 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java @@ -81,9 +81,9 @@ public class Function { * @return */ public static FUTURE_OP toFO(String value) { - if(value!=null) { - for(FUTURE_OP fo : values()) { - if(fo.name().equals(value)){ + if (value!=null) { + for (FUTURE_OP fo : values()) { + if (fo.name().equals(value)){ return fo; } } @@ -194,16 +194,16 @@ public class Function { String reason; if (orgUser == null) { return Result.err(Status.ERR_Policy,"%s is not a valid user at %s",u,org.getName()); - } else if((reason=orgUser.mayOwn())!=null) { + } else if ((reason=orgUser.mayOwn())!=null) { if (org.isTestEnv()) { String reason2; - if((reason2=org.validate(trans, Policy.AS_RESPONSIBLE,new CassExecutor(trans, this), u))!=null) { // can masquerade as responsible + if ((reason2=org.validate(trans, Policy.AS_RESPONSIBLE,new CassExecutor(trans, this), u))!=null) { // can masquerade as responsible trans.debug().log(reason2); return Result.err(Status.ERR_Policy,CANNOT_BE_THE_OWNER_OF_A_NAMESPACE,orgUser.fullName(),orgUser.id(),namespace.name,reason); } // a null means ok } else { - if(orgUser.isFound()) { + if (orgUser.isFound()) { return Result.err(Status.ERR_Policy,CANNOT_BE_THE_OWNER_OF_A_NAMESPACE,orgUser.fullName(),orgUser.id(),namespace.name, reason); } else { return Result.err(Status.ERR_Policy,u + " is an invalid Identity"); @@ -267,7 +267,7 @@ public class Function { // or helpful for Operations folks.. // Admins can be empty, because they can be changed by lower level // NSs - // if(ns.admin(false).isEmpty()) { + // if (ns.admin(false).isEmpty()) { // ns.admin(true).add(user); // } if (namespace.admin != null) { @@ -334,9 +334,9 @@ public class Function { for (RoleDAO.Data rdd : rrdc.value) { // Remove old Role from Perms, save them off List lpdd = new ArrayList<>(); - for(String p : rdd.perms(false)) { + for (String p : rdd.perms(false)) { Result rpdd = PermDAO.Data.decode(trans,q,p); - if(rpdd.isOKhasData()) { + if (rpdd.isOKhasData()) { PermDAO.Data pdd = rpdd.value; lpdd.add(pdd); q.permDAO.delRole(trans, pdd, rdd); @@ -358,13 +358,13 @@ public class Function { // "create" per se if ((rq = q.roleDAO.create(trans, rdd)).isOK()) { // Put Role back into Perm, with correct info - for(PermDAO.Data pdd : lpdd) { + for (PermDAO.Data pdd : lpdd) { q.permDAO.addRole(trans, pdd, rdd); } // Change data for User Roles Result> rurd = q.userRoleDAO.readByRole(trans, rdd.fullName()); - if(rurd.isOKhasData()) { - for(UserRoleDAO.Data urd : rurd.value) { + if (rurd.isOKhasData()) { + for (UserRoleDAO.Data urd : rurd.value) { urd.ns = rdd.ns; urd.rname = rdd.name; q.userRoleDAO.update(trans, urd); @@ -389,9 +389,9 @@ public class Function { // Remove old Perm from Roles, save them off List lrdd = new ArrayList<>(); - for(String rl : pdd.roles(false)) { + for (String rl : pdd.roles(false)) { Result rrdd = RoleDAO.Data.decode(trans,q,rl); - if(rrdd.isOKhasData()) { + if (rrdd.isOKhasData()) { RoleDAO.Data rdd = rrdd.value; lrdd.add(rdd); q.roleDAO.delPerm(trans, rdd, pdd); @@ -408,7 +408,7 @@ public class Function { .substring(targetNameDot) : ""; if ((rq = q.permDAO.create(trans, pdd)).isOK()) { // Put Role back into Perm, with correct info - for(RoleDAO.Data rdd : lrdd) { + for (RoleDAO.Data rdd : lrdd) { q.roleDAO.addPerm(trans, rdd, pdd); } @@ -698,7 +698,7 @@ public class Function { } else { if (org.isTestEnv()) { String reason2; - if((reason2 = org.validate(trans, Policy.AS_RESPONSIBLE, new CassExecutor(trans, this), id))==null) { + if ((reason2 = org.validate(trans, Policy.AS_RESPONSIBLE, new CassExecutor(trans, this), id))==null) { return Result.ok(); } else { trans.debug().log(reason2); @@ -726,7 +726,7 @@ public class Function { rq = q.mayUser(trans, trans.user(), rq.value, Access.write); if (rq.notOK()) { Result> ruinr = q.userRoleDAO.readUserInRole(trans, trans.user(),ns+".owner"); - if(!(ruinr.isOKhasData() && ruinr.value.get(0).expires.after(new Date()))) { + if (!(ruinr.isOKhasData() && ruinr.value.get(0).expires.after(new Date()))) { return Result.err(rq); } } @@ -748,7 +748,7 @@ public class Function { "%s is not a valid %s Credential", user, org.getName()); } //TODO find out how to make sure good ALTERNATE OAUTH DOMAIN USER -// } else if(user.endsWith(ALTERNATE OAUTH DOMAIN)) { +// } else if (user.endsWith(ALTERNATE OAUTH DOMAIN)) { // return Result.ok(); } else { Result> cdr = q.credDAO.readID(trans, user); @@ -794,7 +794,7 @@ public class Function { if (rq.notOK()) { // Even though not a "writer", Owners still determine who gets to be an Admin Result> ruinr = q.userRoleDAO.readUserInRole(trans, trans.user(),ns+".owner"); - if(!(ruinr.isOKhasData() && ruinr.value.get(0).expires.after(new Date()))) { + if (!(ruinr.isOKhasData() && ruinr.value.get(0).expires.after(new Date()))) { return Result.err(rq); } } @@ -827,9 +827,9 @@ public class Function { // Remove old Perm from Roles, save them off List lrdd = new ArrayList<>(); - for(String rl : pdd.roles(false)) { + for (String rl : pdd.roles(false)) { Result rrdd = RoleDAO.Data.decode(trans,q,rl); - if(rrdd.isOKhasData()) { + if (rrdd.isOKhasData()) { RoleDAO.Data rdd = rrdd.value; lrdd.add(rdd); q.roleDAO.delPerm(trans, rdd, pdd); @@ -846,7 +846,7 @@ public class Function { // Use direct Create/Delete, because switching namespaces if ((pd = q.permDAO.create(trans, pdd)).isOK()) { // Put Role back into Perm, with correct info - for(RoleDAO.Data rdd : lrdd) { + for (RoleDAO.Data rdd : lrdd) { q.roleDAO.addPerm(trans, rdd, pdd); } @@ -892,9 +892,9 @@ public class Function { } // Remove old Role from Perms, save them off List lpdd = new ArrayList<>(); - for(String p : rdd.perms(false)) { + for (String p : rdd.perms(false)) { Result rpdd = PermDAO.Data.decode(trans,q,p); - if(rpdd.isOKhasData()) { + if (rpdd.isOKhasData()) { PermDAO.Data pdd = rpdd.value; lpdd.add(pdd); q.permDAO.delRole(trans, pdd, rdd); @@ -912,7 +912,7 @@ public class Function { // Use direct Create/Delete, because switching namespaces if ((rd = q.roleDAO.create(trans, rdd)).isOK()) { // Put Role back into Perm, with correct info - for(PermDAO.Data pdd : lpdd) { + for (PermDAO.Data pdd : lpdd) { q.permDAO.addRole(trans, pdd, rdd); } @@ -973,7 +973,7 @@ public class Function { // For each Role for (String role : roles = perm.roles(true)) { Result rdd = RoleDAO.Data.decode(trans,q,role); - if(rdd.isOKhasData()) { + if (rdd.isOKhasData()) { RoleDAO.Data rd = rdd.value; if (!fromApproval) { // May User write to the Role in question. @@ -1038,7 +1038,7 @@ public class Function { for (String role : fullperm.roles) { Result rv = null; Result rrdd = RoleDAO.Data.decode(trans, q, role); - if(rrdd.isOKhasData()) { + if (rrdd.isOKhasData()) { trans.debug().log("Removing", role, "from", fullperm, "on Perm Delete"); if ((rv = q.roleDAO.delPerm(trans, rrdd.value, fullperm)).notOK()) { if (rv.notOK()) { @@ -1131,19 +1131,19 @@ public class Function { if (!fromApproval) { Result rRoleCo = q.deriveFirstNsForType(trans, role.ns, NsType.COMPANY); - if(rRoleCo.notOK()) { + if (rRoleCo.notOK()) { return Result.err(rRoleCo); } Result rPermCo = q.deriveFirstNsForType(trans, pd.ns, NsType.COMPANY); - if(rPermCo.notOK()) { + if (rPermCo.notOK()) { return Result.err(rPermCo); } // Not from same company - if(!rRoleCo.value.name.equals(rPermCo.value.name)) { + if (!rRoleCo.value.name.equals(rPermCo.value.name)) { Result r; // Only grant if User ALSO has Write ability in Other Company - if((r = q.mayUser(trans, user, role, Access.write)).notOK()) { + if ((r = q.mayUser(trans, user, role, Access.write)).notOK()) { return Result.err(r); } } @@ -1279,7 +1279,7 @@ public class Function { break; } } - if(!notFound) { + if (!notFound) { break; } } @@ -1343,14 +1343,14 @@ public class Function { */ public Result addUserRole(AuthzTrans trans,UserRoleDAO.Data urData) { Result rv; - if(Question.ADMIN.equals(urData.rname)) { + if (Question.ADMIN.equals(urData.rname)) { rv = mayAddAdmin(trans, urData.ns, urData.user); - } else if(Question.OWNER.equals(urData.rname)) { + } else if (Question.OWNER.equals(urData.rname)) { rv = mayAddOwner(trans, urData.ns, urData.user); } else { rv = checkValidID(trans, new Date(), urData.user); } - if(rv.notOK()) { + if (rv.notOK()) { return rv; } @@ -1378,7 +1378,7 @@ public class Function { public Result addUserRole(AuthzTrans trans, String user, String ns, String rname) { try { - if(trans.org().getIdentity(trans, user)==null) { + if (trans.org().getIdentity(trans, user)==null) { return Result.err(Result.ERR_BadData,user+" is an Invalid Identity for " + trans.org().getName()); } } catch (OrganizationException e) { @@ -1476,9 +1476,9 @@ public class Function { Result> rrbr = q.userRoleDAO .readByRole(trans, nsd.name + Question.DOT_OWNER); if (rrbr.isOKhasData()) { - for(UserRoleDAO.Data urd : rrbr.value) { + for (UserRoleDAO.Data urd : rrbr.value) { Identity owner = org.getIdentity(trans, urd.user); - if(owner==null) { + if (owner==null) { return Result.err(Result.ERR_NotFound,urd.user + " is not a Valid Owner of " + nsd.name); } else { owners.add(owner); @@ -1487,7 +1487,7 @@ public class Function { } } - if(owners.isEmpty()) { + if (owners.isEmpty()) { return Result.err(Result.ERR_NotFound,"No Owners found for " + nsd.name); } @@ -1501,17 +1501,17 @@ public class Function { final UUID ticket = fr.value.id; sb.append(", Approvals: "); Boolean first[] = new Boolean[]{true}; - if(op!=FUTURE_OP.A) { + if (op!=FUTURE_OP.A) { for (Identity u : approvers) { Result r = addIdentity(trans,sb,first,user,data.memo,op,u,ticket,org.getApproverType()); - if(r.notOK()) { + if (r.notOK()) { return Result.err(r); } } } for (Identity u : owners) { Result r = addIdentity(trans,sb,first,user,data.memo,op,u,ticket,"owner"); - if(r.notOK()) { + if (r.notOK()) { return Result.err(r); } } @@ -1534,7 +1534,7 @@ public class Function { @Override public UserRoleDAO.Data get(AuthzTrans trans, Object ... keys) { Result> r = q.userRoleDAO.read(trans, keys); - if(r.isOKhasData()) { + if (r.isOKhasData()) { return r.value.get(0); } else { return null; @@ -1556,18 +1556,18 @@ public class Function { public Result performFutureOp(final AuthzTrans trans, FUTURE_OP fop, FutureDAO.Data curr, Lookup> la, Lookup lur) { // Pre-Evaluate if ReApproval is already done. UserRoleDAO.Data urdd = null; - if(fop.equals(FUTURE_OP.A) && curr.target.equals(FOP_USER_ROLE) && curr.construct!=null) { + if (fop.equals(FUTURE_OP.A) && curr.target.equals(FOP_USER_ROLE) && curr.construct!=null) { try { // Get Expected UserRole from Future urdd = new UserRoleDAO.Data(); urdd.reconstitute(curr.construct); // Get Current UserRole from lookup UserRoleDAO.Data lurdd = lur.get(trans, urdd.user,urdd.role); - if(lurdd==null) { + if (lurdd==null) { q.futureDAO.delete(trans, curr, false); return OP_STATUS.RL; } else { - if(curr.expires.compareTo(lurdd.expires)<0) { + if (curr.expires.compareTo(lurdd.expires)<0) { q.futureDAO.delete(trans, curr, false); return OP_STATUS.RL; } @@ -1579,21 +1579,21 @@ public class Function { boolean aDenial = false; int cntSuper=0, appSuper=0,cntOwner=0, appOwner=0; - for(ApprovalDAO.Data add : la.get(trans)) { + for (ApprovalDAO.Data add : la.get(trans)) { switch(add.status) { case "approved": - if("owner".equals(add.type)) { + if ("owner".equals(add.type)) { ++cntOwner; ++appOwner; - } else if("supervisor".equals(add.type)) { + } else if ("supervisor".equals(add.type)) { ++cntSuper; ++appSuper; } break; case "pending": - if("owner".equals(add.type)) { + if ("owner".equals(add.type)) { ++cntOwner; - } else if("supervisor".equals(add.type)) { + } else if ("supervisor".equals(add.type)) { ++cntSuper; } break; @@ -1604,18 +1604,18 @@ public class Function { } Result ros=null; - if(aDenial) { + if (aDenial) { // Note: Denial will be Audit-logged. // for (ApprovalDAO.Data ad : allApprovalsForTicket.value) { // q.approvalDAO.delete(trans, ad, false); // } ros = OP_STATUS.RD; - if(q.futureDAO.delete(trans, curr, false).notOK()) { + if (q.futureDAO.delete(trans, curr, false).notOK()) { trans.info().printf("Future %s could not be deleted", curr.id.toString()); } else { if (FOP_USER_ROLE.equalsIgnoreCase(curr.target)) { // A Denial means we must remove UserRole - if(fop.equals(FUTURE_OP.U) || fop.equals(FUTURE_OP.A)) { + if (fop.equals(FUTURE_OP.U) || fop.equals(FUTURE_OP.A)) { UserRoleDAO.Data data = new UserRoleDAO.Data(); try { data.reconstitute(curr.construct); @@ -1631,7 +1631,7 @@ public class Function { // Decision: If not Denied, and at least owner, if exists, and at least one Super, if exists boolean goDecision = (cntOwner>0?appOwner>0:true) && (cntSuper>0?appSuper>0:true); - if(goDecision) { + if (goDecision) { // should check if any other pendings before performing // actions try { @@ -1684,7 +1684,7 @@ public class Function { default: } } else if (FOP_USER_ROLE.equalsIgnoreCase(curr.target)) { - if(urdd==null) { + if (urdd==null) { urdd = new UserRoleDAO.Data(); urdd.reconstitute(curr.construct); } @@ -1737,7 +1737,7 @@ public class Function { } q.futureDAO.delete(trans, curr, false); } // end for goDecision - if(ros==null) { + if (ros==null) { //return Result.err(Status.ACC_Future, "Full Approvals not obtained: No action taken"); ros = OP_STATUS.RP; } @@ -1747,7 +1747,7 @@ public class Function { // Convenience method for setting OPSTatus Results private Result set(Result rs, Result orig) { - if(orig.isOK()) { + if (orig.isOK()) { return rs; } else { return Result.err(orig); @@ -1767,8 +1767,8 @@ public class Function { ad.operation = op.name(); // Note ad.updated is created in System Result r = q.approvalDAO.create(trans,ad); - if(r.isOK()) { - if(first[0]) { + if (r.isOK()) { + if (first[0]) { first[0] = false; } else { sb.append(", "); diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java index 6bb440ad..98621457 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/PermLookup.java @@ -75,17 +75,17 @@ class PermLookup { } public Result> getUserRoles() { - if(userRoles==null) { + if (userRoles==null) { userRoles = q.userRoleDAO.readByUser(trans,user); - if(userRoles.isOKhasData()) { + if (userRoles.isOKhasData()) { List lurdd = new ArrayList<>(); Date now = new Date(); - for(UserRoleDAO.Data urdd : userRoles.value) { - if(urdd.expires.after(now)) { // Remove Expired + for (UserRoleDAO.Data urdd : userRoles.value) { + if (urdd.expires.after(now)) { // Remove Expired lurdd.add(urdd); } } - if(lurdd.size()==0) { + if (lurdd.size()==0) { return userRoles = Result.err(Status.ERR_UserNotFound, "%s not found or not associated with any Roles: ", user); @@ -101,18 +101,18 @@ class PermLookup { } public Result> getRoles() { - if(roles==null) { + if (roles==null) { Result> rur = getUserRoles(); - if(rur.isOK()) { + if (rur.isOK()) { List lrdd = new ArrayList<>(); for (UserRoleDAO.Data urdata : rur.value) { // Gather all permissions from all Roles - if(urdata.ns==null || urdata.rname==null) { + if (urdata.ns==null || urdata.rname==null) { return Result.err(Status.ERR_BadData,"DB Content Error: nulls in User Role %s %s", urdata.user,urdata.role); } else { Result> rlrd = q.roleDAO.read( trans, urdata.ns, urdata.rname); - if(rlrd.isOK()) { + if (rlrd.isOK()) { lrdd.addAll(rlrd.value); } } @@ -127,7 +127,7 @@ class PermLookup { } public Result> getPermNames() { - if(permNames==null) { + if (permNames==null) { Result> rlrd = getRoles(); if (rlrd.isOK()) { Set pns = new TreeSet<>(); @@ -144,16 +144,16 @@ class PermLookup { } public Result> getPerms(boolean lookup) { - if(perms==null) { + if (perms==null) { // Note: It should be ok for a Valid user to have no permissions - // Jonathan 8/12/2013 Result> rss = getPermNames(); - if(rss.isOK()) { + if (rss.isOK()) { List lpdd = new ArrayList<>(); for (String perm : rss.value) { - if(lookup) { + if (lookup) { Result ap = PermDAO.Data.decodeToArray(trans, q, perm); - if(ap.isOK()) { + if (ap.isOK()) { Result> rlpd = q.permDAO.read(perm,trans,ap.value); if (rlpd.isOKhasData()) { diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java index 152412a2..e63bc52a 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java @@ -166,17 +166,17 @@ public class Question { // Only want to aggressively cleanse User related Caches... The others, // just normal refresh - if(startClean) { + if (startClean) { CachedDAO.startCleansing(trans.env(), credDAO, userRoleDAO); CachedDAO.startRefresh(trans.env(), cacheInfoDAO); } // Set a Timer to Check Caches to send messages for Caching changes - if(specialLogSlot==null) { + if (specialLogSlot==null) { specialLogSlot = trans.slot(AuthzTransFilter.SPECIAL_LOG_SLOT); } - if(transIDSlot==null) { + if (transIDSlot==null) { transIDSlot = trans.slot(AuthzTransFilter.TRANS_ID_SLOT); } @@ -226,25 +226,25 @@ public class Question { public Result> getPermsByUserFromRolesFilter(AuthzTrans trans, String user, String forUser) { PermLookup plUser = PermLookup.get(trans, this, user); Result> plPermNames = plUser.getPermNames(); - if(plPermNames.notOK()) { + if (plPermNames.notOK()) { return Result.err(plPermNames); } Set nss; - if(forUser.equals(user)) { + if (forUser.equals(user)) { nss = null; } else { // Setup a TreeSet to check on Namespaces to nss = new TreeSet<>(); PermLookup fUser = PermLookup.get(trans, this, forUser); Result> forUpn = fUser.getPermNames(); - if(forUpn.notOK()) { + if (forUpn.notOK()) { return Result.err(forUpn); } - for(String pn : forUpn.value) { + for (String pn : forUpn.value) { Result decoded = PermDAO.Data.decodeToArray(trans, this, pn); - if(decoded.isOKhasData()) { + if (decoded.isOKhasData()) { nss.add(decoded.value[0]); } else { trans.error().log(pn,", derived from a Role, is invalid:",decoded.errorString()); @@ -255,11 +255,11 @@ public class Question { List rlpUser = new ArrayList<>(); Result rpdd; PermDAO.Data pdd; - for(String pn : plPermNames.value) { + for (String pn : plPermNames.value) { rpdd = PermDAO.Data.decode(trans, this, pn); - if(rpdd.isOKhasData()) { + if (rpdd.isOKhasData()) { pdd=rpdd.value; - if(nss==null || nss.contains(pdd.ns)) { + if (nss==null || nss.contains(pdd.ns)) { rlpUser.add(pdd); } } else { @@ -314,7 +314,7 @@ public class Question { return Result.err(pr); } - if(lookup) { + if (lookup) { Result> rlpd = permDAO.read(trans, pr.value); if (rlpd.isOKhasData()) { for (PermDAO.Data pData : rlpd.value) { @@ -368,7 +368,7 @@ public class Question { return Result.ok(r.value.get(0)); } else { int dot; - if(child==null) { + if (child==null) { return Result.err(Status.ERR_NsNotFound, "No Namespace"); } else { dot = child.lastIndexOf('.'); @@ -384,12 +384,12 @@ public class Question { public Result deriveFirstNsForType(AuthzTrans trans, String str, NsType type) { NsDAO.Data nsd; - for(String lookup = str;!".".equals(lookup) && lookup!=null;) { + for (String lookup = str;!".".equals(lookup) && lookup!=null;) { Result> rld = nsDAO.read(trans, lookup); - if(rld.isOKhasData()) { + if (rld.isOKhasData()) { nsd=rld.value.get(0); lookup = nsd.parent; - if(type.type == nsd.type) { + if (type.type == nsd.type) { return Result.ok(nsd); } } else { @@ -455,13 +455,13 @@ public class Question { public Result validNSOfDomain(AuthzTrans trans, String id) { // Take domain, reverse order, and check on NS String ns; - if(id.indexOf('@')<0) { // it's already an ns, not an ID + if (id.indexOf('@')<0) { // it's already an ns, not an ID ns = id; } else { ns = domain2ns(id); } if (ns.length() > 0) { - if(!trans.org().getDomain().equals(ns)) { + if (!trans.org().getDomain().equals(ns)) { Result> rlnsd = nsDAO.read(trans, ns); if (rlnsd.isOKhasData()) { return Result.ok(rlnsd.value.get(0)); @@ -490,7 +490,7 @@ public class Question { Result rv = mayUserVirtueOfNS(trans, user, ndd, ":" + ndd.name + ":ns", access.name()); if (rv.isOK()) { return rv; - } else if(rv.status==Result.ERR_Backend) { + } else if (rv.status==Result.ERR_Backend) { return Result.err(rv); } else { return Result.err(Status.ERR_Denied, "[%s] may not %s in NS [%s]", @@ -532,7 +532,7 @@ public class Question { + rdd.ns + roleInst, access.name()); if (rnsd.isOK()) { return rnsd; - } else if(rnsd.status==Result.ERR_Backend) { + } else if (rnsd.status==Result.ERR_Backend) { return Result.err(rnsd); } @@ -543,7 +543,7 @@ public class Question { ":" + rdd.ns + ":ns", access.name()); if (rv.isOK()) { return rv; - } else if(rnsd.status==Result.ERR_Backend) { + } else if (rnsd.status==Result.ERR_Backend) { return Result.err(rnsd); } else { return Result.err(Status.ERR_Denied, "[%s] may not %s Role [%s]", @@ -582,7 +582,7 @@ public class Question { Result rnsd = mayUserVirtueOfNS(trans, user, ndd, ":" + pdd.ns + permInst, access.name()); if (rnsd.isOK()) { return rnsd; - } else if(rnsd.status==Result.ERR_Backend) { + } else if (rnsd.status==Result.ERR_Backend) { return Result.err(rnsd); } @@ -603,7 +603,7 @@ public class Question { public Result mayUser(AuthzTrans trans, DelegateDAO.Data dd, Access access) { try { Result rnsd = deriveNs(trans, domain2ns(trans.user())); - if(rnsd.isOKhasData() && mayUserVirtueOfNS(trans,trans.user(),rnsd.value, ":" + rnsd.value.name + ":ns", access.name()).isOK()) { + if (rnsd.isOKhasData() && mayUserVirtueOfNS(trans,trans.user(),rnsd.value, ":" + rnsd.value.name + ":ns", access.name()).isOK()) { return Result.ok(); } boolean isUser = trans.user().equals(dd.user); @@ -663,7 +663,7 @@ public class Question { Result> rurd; if ((rurd = userRoleDAO.readUserInRole(trans, user, ns+DOT_ADMIN)).isOKhasData()) { return Result.ok(nsd); - } else if(rurd.status==Result.ERR_Backend) { + } else if (rurd.status==Result.ERR_Backend) { return Result.err(rurd); } @@ -679,12 +679,12 @@ public class Question { Result rnsd = deriveNs(trans, ns.substring(0, dot)); if (rnsd.isOK()) { rnsd = mayUserVirtueOfNS(trans, user, rnsd.value, ns_and_type,access); - } else if(rnsd.status==Result.ERR_Backend) { + } else if (rnsd.status==Result.ERR_Backend) { return Result.err(rnsd); } if (rnsd.isOK()) { return Result.ok(nsd); - } else if(rnsd.status==Result.ERR_Backend) { + } else if (rnsd.status==Result.ERR_Backend) { return Result.err(rnsd); } } @@ -712,7 +712,7 @@ public class Question { if (ns.equals(pd.ns)) { if (type.equals(pd.type)) { if (PermEval.evalInstance(pd.instance, instance)) { - if(PermEval.evalAction(pd.action, action)) { // don't return action here, might miss other action + if (PermEval.evalAction(pd.action, action)) { // don't return action here, might miss other action return true; } } @@ -733,7 +733,7 @@ public class Question { } Result rv = null; - if(result.isOK()) { + if (result.isOK()) { if (result.isEmpty()) { rv = Result.err(Status.ERR_UserNotFound, user); if (willSpecialLog(trans,user)) { @@ -743,14 +743,14 @@ public class Question { Date now = new Date();//long now = System.currentTimeMillis(); // Bug noticed 6/22. Sorting on the result can cause Concurrency Issues. List cddl; - if(result.value.size() > 1) { + if (result.value.size() > 1) { cddl = new ArrayList<>(result.value.size()); - for(CredDAO.Data old : result.value) { - if(old.type==CredDAO.BASIC_AUTH || old.type==CredDAO.BASIC_AUTH_SHA256) { + for (CredDAO.Data old : result.value) { + if (old.type==CredDAO.BASIC_AUTH || old.type==CredDAO.BASIC_AUTH_SHA256) { cddl.add(old); } } - if(cddl.size()>1) { + if (cddl.size()>1) { Collections.sort(cddl,new Comparator() { @Override public int compare(org.onap.aaf.auth.dao.cass.CredDAO.Data a, @@ -766,7 +766,7 @@ public class Question { Date expired = null; StringBuilder debug = willSpecialLog(trans,user)?new StringBuilder():null; for (CredDAO.Data cdd : cddl) { - if(!cdd.id.equals(user)) { + if (!cdd.id.equals(user)) { trans.error().log("doesUserCredMatch DB call does not match for user: " + user); } if (cdd.expires.after(now)) { @@ -776,7 +776,7 @@ public class Question { switch(cdd.type) { case CredDAO.BASIC_AUTH: byte[] md5=Hash.hashMD5(cred); - if(Hash.compareTo(md5,dbcred)==0) { + if (Hash.compareTo(md5,dbcred)==0) { checkLessThanDays(trans,7,now,cdd); return Result.ok(cdd.expires); } else if (debug!=null) { @@ -789,7 +789,7 @@ public class Question { bb.put(cred); byte[] hash = Hash.hashSHA256(bb.array()); - if(Hash.compareTo(hash,dbcred)==0) { + if (Hash.compareTo(hash,dbcred)==0) { checkLessThanDays(trans,7,now,cdd); return Result.ok(cdd.expires); } else if (debug!=null) { @@ -803,17 +803,17 @@ public class Question { trans.error().log(e); } } else { - if(expired==null || expired.before(cdd.expires)) { + if (expired==null || expired.before(cdd.expires)) { expired = cdd.expires; } } } // end for each - if(debug==null) { + if (debug==null) { trans.audit().printf("No cred matches ip=%s, user=%s\n",trans.ip(),user); } else { trans.audit().printf("No cred matches ip=%s, user=%s %s\n",trans.ip(),user,debug.toString()); } - if(expired!=null) { + if (expired!=null) { // Note: this is only returned if there are no good Credentials rv = Result.err(Status.ERR_Security, "Credentials %s from %s expired %s",trans.user(), trans.ip(), Chrono.dateTime(expired)); @@ -840,7 +840,7 @@ public class Question { private void checkLessThanDays(AuthzTrans trans, int days, Date now, Data cdd) { long close = now.getTime() + (days * 86400000); long cexp=cdd.expires.getTime(); - if(cexp userCredSetup(AuthzTrans trans, CredDAO.Data cred) { - if(cred.type==CredDAO.RAW) { + if (cred.type==CredDAO.RAW) { TimeTaken tt = trans.start("Hash Cred", Env.SUB); try { cred.type = CredDAO.BASIC_AUTH_SHA256; @@ -935,32 +935,32 @@ public class Question { if (all || NsDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, NsDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, NsDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, NsDAO.TABLE, seg); } if (all || PermDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, PermDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, PermDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, PermDAO.TABLE,seg); } if (all || RoleDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, RoleDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, RoleDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, RoleDAO.TABLE,seg); } if (all || UserRoleDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, UserRoleDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, UserRoleDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, UserRoleDAO.TABLE,seg); } if (all || CredDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, CredDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, CredDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, CredDAO.TABLE,seg); } if (all || CertDAO.TABLE.equals(cname)) { int seg[] = series(NsDAO.CACHE_SEG); - for(int i: seg) {cacheClear(trans, CertDAO.TABLE,i);} + for (int i: seg) {cacheClear(trans, CertDAO.TABLE,i);} rv = cacheInfoDAO.touch(trans, CertDAO.TABLE,seg); } @@ -999,11 +999,11 @@ public class Question { public boolean isDelegated(AuthzTrans trans, String user, String approver, Map>> rldd ) { Result> userDelegatedFor = rldd.get(user); - if(userDelegatedFor==null) { + if (userDelegatedFor==null) { userDelegatedFor=delegateDAO.readByDelegate(trans, user); rldd.put(user, userDelegatedFor); } - if(userDelegatedFor.isOKhasData()) { + if (userDelegatedFor.isOKhasData()) { for (DelegateDAO.Data curr : userDelegatedFor.value) { if (curr.user.equals(approver) && curr.delegate.equals(user) && curr.expires.after(new Date())) { @@ -1016,8 +1016,8 @@ public class Question { public static boolean willSpecialLog(AuthzTrans trans, String user) { Boolean b = trans.get(specialLogSlot, null); - if(b==null) { // we haven't evaluated in this trans for Special Log yet - if(specialLog==null) { + if (b==null) { // we haven't evaluated in this trans for Special Log yet + if (specialLog==null) { return false; } else { b = specialLog.contains(user); @@ -1042,21 +1042,21 @@ public class Question { specialLog = new HashSet<>(); } boolean rc = specialLog.add(id); - if(rc) { + if (rc) { trans.trace().printf("Trace on for %s requested by %s",id,trans.user()); } return rc; } public static synchronized boolean specialLogOff(AuthzTrans trans, String id) { - if(specialLog==null) { + if (specialLog==null) { return false; } boolean rv = specialLog.remove(id); if (specialLog.isEmpty()) { specialLog = null; } - if(rv) { + if (rv) { trans.trace().printf("Trace off for %s requested by %s",id,trans.user()); } return rv; @@ -1086,8 +1086,8 @@ public class Question { public boolean isAdmin(AuthzTrans trans, String user, String ns) { Date now = new Date(); Result> rur = userRoleDAO.read(trans, user,ns+DOT_ADMIN); - if(rur.isOKhasData()) {for(UserRoleDAO.Data urdd : rur.value){ - if(urdd.expires.after(now)) { + if (rur.isOKhasData()) {for (UserRoleDAO.Data urdd : rur.value){ + if (urdd.expires.after(now)) { return true; } }}; @@ -1097,8 +1097,8 @@ public class Question { public boolean isOwner(AuthzTrans trans, String user, String ns) { Result> rur = userRoleDAO.read(trans, user,ns+DOT_OWNER); Date now = new Date(); - if(rur.isOKhasData()) {for(UserRoleDAO.Data urdd : rur.value){ - if(urdd.expires.after(now)) { + if (rur.isOKhasData()) {for (UserRoleDAO.Data urdd : rur.value){ + if (urdd.expires.after(now)) { return true; } }}; @@ -1109,8 +1109,8 @@ public class Question { Result> rur = userRoleDAO.readByRole(trans,ns+DOT_OWNER); Date now = new Date(); int count = 0; - if(rur.isOKhasData()) {for(UserRoleDAO.Data urdd : rur.value){ - if(urdd.expires.after(now)) { + if (rur.isOKhasData()) {for (UserRoleDAO.Data urdd : rur.value){ + if (urdd.expires.after(now)) { ++count; } }}; @@ -1129,7 +1129,7 @@ public class Question { byte[] from = name.getBytes(); StringBuilder sb = new StringBuilder(); byte f; - for(int i=0;i>4)+0x61)); sb.append((char)((f&0x0F)+0x61)); @@ -1141,7 +1141,7 @@ public class Question { byte[] from = name.getBytes(); StringBuilder sb = new StringBuilder(); char c; - for(int i=0;i { super(env.access(), name, 1000L /* Don't hit DB more than once a second */); this.env = env; this.ldao = ldao; - if(version!=null) { + if (version!=null) { try { String[] v = Split.split('.',version); - if(v.length>0) {major = Integer.parseInt(v[0]);} - if(v.length>1) {minor = Integer.parseInt(v[1]);} - if(v.length>2) {patch = Integer.parseInt(v[2]);} - if(v.length>3) {pkg = Integer.parseInt(v[3]);} + if (v.length>0) {major = Integer.parseInt(v[0]);} + if (v.length>1) {minor = Integer.parseInt(v[1]);} + if (v.length>2) {patch = Integer.parseInt(v[2]);} + if (v.length>3) {pkg = Integer.parseInt(v[3]);} } catch (NumberFormatException e) { throw new LocatorException("Invalid Version String: " + version); } @@ -83,13 +83,13 @@ public class DirectAAFLocator extends AbsAAFLocator { public boolean refresh() { AuthzTrans trans = env.newTransNoAvg(); Result> rl = ldao.readByName(trans, name); - if(rl.isOK()) { + if (rl.isOK()) { LinkedList epl = new LinkedList<>(); - for(Data d : rl.value) { -// if(myhostname!=null && d.port==myport && d.hostname.equals(myhostname)) { + for (Data d : rl.value) { +// if (myhostname!=null && d.port==myport && d.hostname.equals(myhostname)) { // continue; // } - if((major<0 || major==d.major) && + if ((major<0 || major==d.major) && (minor<0 || minor<=d.minor) && (patch<0 || patch==d.patch) && (pkg<0 || pkg ==d.pkg)) { @@ -104,7 +104,7 @@ public class DirectAAFLocator extends AbsAAFLocator { endpoint.setLatitude(d.latitude); endpoint.setLongitude(d.longitude); endpoint.setProtocol(d.protocol); - for(String s : d.subprotocol(false)) { + for (String s : d.subprotocol(false)) { endpoint.getSubprotocol().add(s); } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java index 75f6c7a5..59613961 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLur.java @@ -61,10 +61,10 @@ public class DirectAAFLur implements Lur { Result> pdr = question.getPermsByUser(trans, bait.getName(),false); switch(pdr.status) { case OK: - for(PermDAO.Data d : pdr.value) { - if(!rv) { + for (PermDAO.Data d : pdr.value) { + if (!rv) { for (Permission p : pond) { - if(new PermPermission(d).match(p)) { + if (new PermPermission(d).match(p)) { rv=true; break; } @@ -86,7 +86,7 @@ public class DirectAAFLur implements Lur { Result> pdr = question.getPermsByUser(env.newTrans(), bait.getName(),false); switch(pdr.status) { case OK: - for(PermDAO.Data d : pdr.value) { + for (PermDAO.Data d : pdr.value) { permissions.add(new PermPermission(d)); } break; @@ -135,23 +135,23 @@ public class DirectAAFLur implements Lur { @Override public boolean match(Permission p) { - if(p==null) { + if (p==null) { return false; } PermDAO.Data pd; - if(p instanceof DirectAAFLur.PermPermission) { + if (p instanceof DirectAAFLur.PermPermission) { pd = ((DirectAAFLur.PermPermission)p).data; - if(data.ns.equals(pd.ns)) - if(data.type.equals(pd.type)) - if(data.instance!=null && (data.instance.equals(pd.instance) || "*".equals(data.instance))) - if(data.action!=null && (data.action.equals(pd.action) || "*".equals(data.action))) + if (data.ns.equals(pd.ns)) + if (data.type.equals(pd.type)) + if (data.instance!=null && (data.instance.equals(pd.instance) || "*".equals(data.instance))) + if (data.action!=null && (data.action.equals(pd.action) || "*".equals(data.action))) return true; } else{ String[] lp = p.getKey().split("\\|"); - if(lp.length<3)return false; - if(data.fullType().equals(lp[0])) - if(data.instance!=null && (data.instance.equals(lp[1]) || "*".equals(data.instance))) - if(data.action!=null && (data.action.equals(lp[2]) || "*".equals(data.action))) + if (lp.length<3)return false; + if (data.fullType().equals(lp[0])) + if (data.instance!=null && (data.instance.equals(lp[1]) || "*".equals(data.instance))) + if (data.action!=null && (data.action.equals(lp[2]) || "*".equals(data.action))) return true; } return false; @@ -180,9 +180,9 @@ public class DirectAAFLur implements Lur { @Override public Permission createPerm(String p) { String[] params = Split.split('|', p); - if(params.length==3) { + if (params.length==3) { Result nss = question.deriveNsSplit(NullTrans.singleton(), params[0]); - if(nss.isOK()) { + if (nss.isOK()) { return new PermPermission(nss.value.ns,nss.value.name,params[1],params[2]); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java index 9d4cd05f..3ef532b4 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFUserPass.java @@ -54,12 +54,12 @@ public class DirectAAFUserPass implements CredVal { public boolean validate(String user, Type type, byte[] pass, Object state) { try { AuthzTrans trans; - if(state !=null) { - if(state instanceof AuthzTrans) { + if (state !=null) { + if (state instanceof AuthzTrans) { trans = (AuthzTrans)state; } else { trans = env.newTransNoAvg(); - if(state instanceof HttpServletRequest) { + if (state instanceof HttpServletRequest) { trans.set((HttpServletRequest)state); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java index 6dd5e006..f3351dae 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectCertIdentity.java @@ -53,10 +53,10 @@ public class DirectCertIdentity implements CertIdentity { @Override public TaggedPrincipal identity(HttpServletRequest req, X509Certificate cert, byte[] _certBytes) throws CertificateException { byte[] certBytes = _certBytes; - if(cert==null && certBytes==null) { + if (cert==null && certBytes==null) { return null; } - if(certBytes==null) { + if (certBytes==null) { certBytes = cert.getEncoded(); } byte[] fingerprint = X509Taf.getFingerPrint(certBytes); @@ -64,7 +64,7 @@ public class DirectCertIdentity implements CertIdentity { AuthzTrans trans = (AuthzTrans) req.getAttribute(TransFilter.TRANS_TAG); Result> cresp = certDAO.read(trans, ByteBuffer.wrap(fingerprint)); - if(cresp.isOKhasData()) { + if (cresp.isOKhasData()) { Data cdata = cresp.value.get(0); return new X509Principal(cdata.id,cert,certBytes,null); } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java index caededa2..aa6bf8c5 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectLocatorCreator.java @@ -40,7 +40,7 @@ public class DirectLocatorCreator implements AbsAAFLocator.LocatorCreator { @Override public AbsAAFLocator create(String key, String version) throws LocatorException { DirectAAFLocator dal = new DirectAAFLocator(env,locateDAO,key,version); - if(myhostname!=null) { + if (myhostname!=null) { dal.setSelf(myhostname, myport); } return dal; diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java index da7044cf..9eea77e3 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java @@ -45,14 +45,14 @@ public class DirectRegistrar implements Registrant { try { String latitude = access.getProperty(Config.CADI_LATITUDE, null); - if(latitude==null) { + if (latitude==null) { latitude = access.getProperty("AFT_LATITUDE", null); } String longitude = access.getProperty(Config.CADI_LONGITUDE, null); - if(longitude==null) { + if (longitude==null) { longitude = access.getProperty("AFT_LONGITUDE", null); } - if(latitude==null || longitude==null) { + if (latitude==null || longitude==null) { throw new CadiException(Config.CADI_LATITUDE + " and " + Config.CADI_LONGITUDE + " is required"); } else { locate.latitude = Float.parseFloat(latitude); @@ -64,18 +64,18 @@ public class DirectRegistrar implements Registrant { locate.minor = split.length>1?Integer.parseInt(split[1]):0; locate.major = split.length>0?Integer.parseInt(split[0]):0; locate.hostname = access.getProperty(Config.AAF_REGISTER_AS, null); - if(locate.hostname==null) { + if (locate.hostname==null) { locate.hostname = access.getProperty(Config.HOSTNAME, null); } - if(locate.hostname==null) { + if (locate.hostname==null) { locate.hostname = Inet4Address.getLocalHost().getHostName(); } String subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null); - if(subprotocols==null) { + if (subprotocols==null) { locate.protocol="http"; } else { locate.protocol="https"; - for(String s : Split.split(',', subprotocols)) { + for (String s : Split.split(',', subprotocols)) { locate.subprotocol(true).add(s); } } @@ -87,7 +87,7 @@ public class DirectRegistrar implements Registrant { @Override public Result update(AuthzEnv env) { org.onap.aaf.auth.layer.Result dr = ldao.update(env.newTransNoAvg(), locate); - if(dr.isOK()) { + if (dr.isOK()) { return Result.ok(200, null); } else { return Result.err(503, dr.errorString()); @@ -100,7 +100,7 @@ public class DirectRegistrar implements Registrant { @Override public Result cancel(AuthzEnv env) { org.onap.aaf.auth.layer.Result dr = ldao.delete(env.newTransNoAvg(), locate, false); - if(dr.isOK()) { + if (dr.isOK()) { return Result.ok(200, null); } else { return Result.err(503, dr.errorString()); -- cgit 1.2.3-korg