summaryrefslogtreecommitdiffstats
path: root/auth/auth-locate
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-06-26 09:11:08 -0500
committerInstrumental <jonathan.gathman@att.com>2018-06-26 09:47:57 -0500
commit5f1a6a0ab09ea3fa4199a8d413af75d4378e2a8e (patch)
tree709b3c564f602f715fcf20f281aa21a7e0ee57e3 /auth/auth-locate
parent732344f175150fed87e0140ad75152d325364c8b (diff)
Initial Interface for remote Configuration
Issue-ID: AAF-378 Change-Id: I320b0c23ece63199a49a5d8b1706868d2c4e5355 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-locate')
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java15
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java24
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java9
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java12
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java34
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java (renamed from auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java)7
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java4
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java (renamed from auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java)5
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java5
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java43
-rw-r--r--auth/auth-locate/src/main/xsd/locate_1_1.xsd46
-rw-r--r--auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java4
-rw-r--r--auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java16
13 files changed, 190 insertions, 34 deletions
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
index efda67f7..9986c60a 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
@@ -30,6 +30,7 @@ import javax.servlet.Filter;
import org.onap.aaf.auth.cache.Cache;
import org.onap.aaf.auth.cache.Cache.Dated;
import org.onap.aaf.auth.dao.CassAccess;
+import org.onap.aaf.auth.dao.cass.ConfigDAO;
import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.direct.DirectLocatorCreator;
import org.onap.aaf.auth.direct.DirectRegistrar;
@@ -41,7 +42,7 @@ import org.onap.aaf.auth.locate.api.API_Api;
import org.onap.aaf.auth.locate.api.API_Find;
import org.onap.aaf.auth.locate.api.API_Proxy;
import org.onap.aaf.auth.locate.facade.LocateFacadeFactory;
-import org.onap.aaf.auth.locate.facade.LocateFacade_1_0;
+import org.onap.aaf.auth.locate.facade.LocateFacade_1_1;
import org.onap.aaf.auth.locate.mapper.Mapper.API;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
@@ -68,8 +69,8 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
private static final String DOT_LOCATOR = ".locator";
private static final String USER_PERMS = "userPerms";
- private LocateFacade_1_0 facade; // this is the default Facade
- private LocateFacade_1_0 facade_1_0_XML;
+ private LocateFacade_1_1 facade; // this is the default Facade
+ private LocateFacade_1_1 facade_1_1_XML;
public Map<String, Dated> cacheUser;
public final AAFAuthn<?> aafAuthn;
public final AAFLurPerm aafLurPerm;
@@ -77,6 +78,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
public final long expireIn;
private final Cluster cluster;
public final LocateDAO locateDAO;
+ public final ConfigDAO configDAO;
private Locator<URI> dal;
private final String aaf_service_name;
private final String aaf_gui_name;
@@ -103,6 +105,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
cluster = org.onap.aaf.auth.dao.CassAccess.cluster(env,null);
locateDAO = new LocateDAO(trans,cluster,CassAccess.KEYSPACE);
+ configDAO = new ConfigDAO(trans,locateDAO); // same stuff
// Have AAFLocator object Create DirectLocators for Location needs
AbsAAFLocator.setCreator(new DirectLocatorCreator(env, locateDAO));
@@ -112,8 +115,8 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
aafAuthn = aafCon().newAuthn(aafLurPerm);
- facade = LocateFacadeFactory.v1_0(env,locateDAO,trans,Data.TYPE.JSON); // Default Facade
- facade_1_0_XML = LocateFacadeFactory.v1_0(env,locateDAO,trans,Data.TYPE.XML);
+ facade = LocateFacadeFactory.v1_1(env,this,trans,Data.TYPE.JSON); // Default Facade
+ facade_1_1_XML = LocateFacadeFactory.v1_1(env,this,trans,Data.TYPE.XML);
synchronized(env) {
if(cacheUser == null) {
@@ -166,7 +169,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
- route(env,meth,path,code.clone(facade_1_0_XML,false),application,"text/xml;version="+version);
+ route(env,meth,path,code.clone(facade_1_1_XML,false),application,"text/xml;version="+version);
// Add other Supported APIs here as created
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
index 9de92d14..af7611a3 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
@@ -21,6 +21,8 @@
package org.onap.aaf.auth.locate.api;
+import static org.onap.aaf.auth.layer.Result.OK;
+
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
@@ -222,6 +224,28 @@ public class API_AAFAccess {
}
}
});
+
+ /**
+ * Configuration
+ */
+ gwAPI.route(HttpMethods.GET,"/configure/:id/:type",API.CONFIG,new LocateCode(facade,"Deliver Configuration Properties to AAF", true) {
+ @Override
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ try {
+ Result<Void> r = facade.getConfig(trans, req, resp, pathParam(req, ":id"),pathParam(req,":type"));
+ switch(r.status) {
+ case OK:
+ resp.setStatus(HttpStatus.OK_200);
+ break;
+ default:
+ context.error(trans,resp,r);
+ }
+
+ } catch (Exception e) {
+ context.error(trans, resp, Result.ERR_General, e.getMessage());
+ }
+ }
+ });
}
private static void redirect(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, LocateFacade context, Locator<URI> loc, String path) throws IOException {
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
index 817fcc58..8fb719fe 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
@@ -103,4 +103,13 @@ public interface LocateFacade {
*/
public abstract Result<Void> removeMgmtEndpoints(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
+ /**
+ *
+ * @param trans
+ * @param req
+ * @param resp
+ * @return
+ */
+ public Result<Void> getConfig(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String id, String type);
+
} \ No newline at end of file
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
index ea20df5a..cff70f03 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
@@ -1,5 +1,5 @@
/**
- * ============LICENSE_START====================================================
+\\ * ============LICENSE_START====================================================
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
@@ -21,10 +21,10 @@
package org.onap.aaf.auth.locate.facade;
-import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.env.AuthzEnv;
import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.locate.mapper.Mapper_1_0;
+import org.onap.aaf.auth.locate.AAF_Locate;
+import org.onap.aaf.auth.locate.mapper.Mapper_1_1;
import org.onap.aaf.auth.locate.service.LocateServiceImpl;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
@@ -35,13 +35,13 @@ import locate_local.v1_0.Out;
public class LocateFacadeFactory {
- public static LocateFacade_1_0 v1_0(AuthzEnv env, LocateDAO locateDAO, AuthzTrans trans, Data.TYPE type) throws APIException {
- return new LocateFacade_1_0(
+ public static LocateFacade_1_1 v1_1(AuthzEnv env, AAF_Locate locate, AuthzTrans trans, Data.TYPE type) throws APIException {
+ return new LocateFacade_1_1(
env,
new LocateServiceImpl<
InRequest,
Out,
- Error>(trans,locateDAO,new Mapper_1_0()),
+ Error>(trans,locate,new Mapper_1_1()),
type);
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
index fdb02c70..af6ad1c1 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
@@ -54,9 +54,9 @@ import org.onap.aaf.auth.rserv.doc.ApiDoc;
import org.onap.aaf.cadi.aaf.client.Examples;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
+import org.onap.aaf.misc.env.Data.TYPE;
import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
-import org.onap.aaf.misc.env.Data.TYPE;
import org.onap.aaf.misc.rosetta.env.RosettaDF;
import org.onap.aaf.misc.rosetta.env.RosettaData;
@@ -82,28 +82,30 @@ import locate_local.v1_0.Api;
* @author Jonathan
*
*/
-public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> extends FacadeImpl implements LocateFacade
+public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> extends FacadeImpl implements LocateFacade
{
- private LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> service;
+ private LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> service;
private final RosettaDF<ERROR> errDF;
private final RosettaDF<Api> apiDF;
private final RosettaDF<ENDPOINTS> epDF;
private final RosettaDF<MGMT_ENDPOINTS> mepDF;
+ private final RosettaDF<CONFIGURATION> confDF;
private static long cacheClear = 0L, emptyCheck=0L;
private final static Map<String,String> epsCache = new HashMap<String, String>(); // protected manually, in getEndpoints
- public LocateFacadeImpl(AuthzEnv env, LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> service, Data.TYPE dataType) throws APIException {
+ public LocateFacadeImpl(AuthzEnv env, LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> service, Data.TYPE dataType) throws APIException {
this.service = service;
(errDF = env.newDataFactory(mapper().getClass(API.ERROR))).in(dataType).out(dataType);
(apiDF = env.newDataFactory(Api.class)).in(dataType).out(dataType);
(epDF = env.newDataFactory(mapper().getClass(API.ENDPOINTS))).in(dataType).out(dataType);
(mepDF = env.newDataFactory(mapper().getClass(API.MGMT_ENDPOINTS))).in(dataType).out(dataType);
+ (confDF = env.newDataFactory(mapper().getClass(API.CONFIG))).in(dataType).out(dataType);
}
- public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> mapper() {
+ public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> mapper() {
return service.mapper();
}
@@ -391,4 +393,26 @@ public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> ex
}
}
+ private static final String GET_CONFIG = "Get Configuration";
+ @Override
+ public Result<Void> getConfig(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, final String id, final String type) {
+ TimeTaken tt = trans.start(GET_CONFIG, Env.SUB|Env.ALWAYS);
+ try {
+ Result<CONFIGURATION> rp = service.getConfig(trans, id, type);
+ switch(rp.status) {
+ case OK:
+ setContentType(resp,mepDF.getOutType());
+ confDF.newData(trans).load(rp.value).to(resp.getOutputStream());
+ return Result.ok();
+ default:
+ return Result.err(rp);
+ }
+ } catch (Exception e) {
+ trans.error().log(e,IN,GET_CONFIG);
+ return Result.err(e);
+ } finally {
+ tt.done();
+ }
+ }
+
} \ No newline at end of file
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java
index e2d2c9f6..d044b731 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java
@@ -28,13 +28,14 @@ import org.onap.aaf.misc.env.Data;
import locate.v1_0.Endpoints;
import locate.v1_0.MgmtEndpoints;
+import locate_local.v1_0.Error;
import locate_local.v1_0.InRequest;
import locate_local.v1_0.Out;
-import locate_local.v1_0.Error;
+import locate_local.v1_1.Configuration;
-public class LocateFacade_1_0 extends LocateFacadeImpl<InRequest,Out,Endpoints,MgmtEndpoints,Error>
+public class LocateFacade_1_1 extends LocateFacadeImpl<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error>
{
- public LocateFacade_1_0(AuthzEnv env, LocateService<InRequest,Out,Endpoints,MgmtEndpoints,Error> service, Data.TYPE type) throws APIException {
+ public LocateFacade_1_1(AuthzEnv env, LocateService<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error> service, Data.TYPE type) throws APIException {
super(env, service, type);
}
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
index 685d096f..7e012f2d 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
@@ -28,9 +28,9 @@ import org.onap.aaf.auth.layer.Result;
import locate.v1_0.MgmtEndpoint;
-public interface Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR>
+public interface Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR>
{
- public enum API{IN_REQ,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR,VOID};
+ public enum API{IN_REQ,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR,VOID};
public Class<?> getClass(API api);
public<A> A newInstance(API api);
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java
index 50839b73..61178951 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java
@@ -35,8 +35,9 @@ import locate.v1_0.MgmtEndpoints;
import locate_local.v1_0.Error;
import locate_local.v1_0.InRequest;
import locate_local.v1_0.Out;
+import locate_local.v1_1.Configuration;
-public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,Error> {
+public class Mapper_1_1 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error> {
@Override
public Class<?> getClass(API api) {
@@ -47,6 +48,7 @@ public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,
case VOID: return Void.class;
case ENDPOINTS: return Endpoints.class;
case MGMT_ENDPOINTS: return MgmtEndpoints.class;
+ case CONFIG: return Configuration.class;
}
return null;
}
@@ -60,6 +62,7 @@ public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,
case ERROR: return (A)new Error();
case ENDPOINTS: return (A) new Endpoints();
case MGMT_ENDPOINTS: return (A) new MgmtEndpoints();
+ case CONFIG: return (A) new Configuration();
case VOID: return null;
}
return null;
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
index d2a37348..ac2e3c46 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
@@ -25,9 +25,10 @@ import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
import org.onap.aaf.auth.locate.mapper.Mapper;
-public interface LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> {
- public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> mapper();
+public interface LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR> {
+ public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR> mapper();
public Result<ENDPOINTS> getEndPoints(AuthzTrans trans, String service, String version, String other);
public Result<Void> putMgmtEndPoints(AuthzTrans trans, MGMT_ENDPOINTS meps);
public Result<Void> removeMgmtEndPoints(AuthzTrans trans, MGMT_ENDPOINTS meps);
+ public Result<CONFIG> getConfig(AuthzTrans trans, String id, String type);
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
index d1a03cdc..9789ad0e 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
@@ -21,11 +21,15 @@
package org.onap.aaf.auth.locate.service;
+import java.util.List;
import java.util.UUID;
+import org.onap.aaf.auth.dao.cass.ConfigDAO;
+import org.onap.aaf.auth.dao.cass.ConfigDAO.Data;
import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.auth.locate.AAF_Locate;
import org.onap.aaf.auth.locate.mapper.Mapper;
import org.onap.aaf.auth.locate.validation.LocateValidator;
import org.onap.aaf.cadi.aaf.AAFPermission;
@@ -34,20 +38,24 @@ import org.onap.aaf.misc.env.APIException;
import locate.v1_0.Endpoints;
import locate.v1_0.MgmtEndpoint;
import locate.v1_0.MgmtEndpoints;
+import locate_local.v1_1.Configuration;
+import locate_local.v1_1.Configuration.Props;
public class LocateServiceImpl<IN,OUT,ERROR>
- implements LocateService<IN,OUT,Endpoints,MgmtEndpoints,ERROR> {
- private Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper;
- private LocateDAO locateDAO;
+ implements LocateService<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> {
+ private Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper;
+ protected LocateDAO locateDAO;
+ private ConfigDAO configDAO;
private boolean permToRegister;
- public LocateServiceImpl(AuthzTrans trans, LocateDAO locateDAO, Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper) throws APIException {
+ public LocateServiceImpl(AuthzTrans trans, AAF_Locate locate, Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper) throws APIException {
this.mapper = mapper;
- this.locateDAO = locateDAO;
+ this.locateDAO = locate.locateDAO;
+ this.configDAO = locate.configDAO;
permToRegister = false; //TODO Setup a Configuration for this
}
- public Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper() {return mapper;}
+ public Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper() {return mapper;}
@Override
public Result<Endpoints> getEndPoints(AuthzTrans trans, String service, String version, String other) {
@@ -117,6 +125,29 @@ public class LocateServiceImpl<IN,OUT,ERROR>
}
}
+ ///// ADDED v1_1
+ /* (non-Javadoc)
+ * @see org.onap.aaf.auth.locate.service.LocateService#getConfig(org.onap.aaf.auth.env.AuthzTrans, java.lang.String, java.lang.String)
+ */
+ @Override
+ public Result<Configuration> getConfig(AuthzTrans trans, String id, String type) {
+ Result<List<Data>> dr = configDAO.readName(trans, type);
+ Configuration c = new Configuration();
+ c.setName(type);
+ Props p;
+
+ if(dr.isOKhasData()) {
+ for(ConfigDAO.Data data : dr.value) {
+ p = new Props();
+ p.setTag(data.tag);
+ p.setValue(data.value);
+ c.getProps().add(p);
+ }
+ }
+ return Result.ok(c);
+ //return Result.err(Result.ERR_NotImplemented,"not done yet");
+ }
+
//////////////// APIs ///////////////////
};
diff --git a/auth/auth-locate/src/main/xsd/locate_1_1.xsd b/auth/auth-locate/src/main/xsd/locate_1_1.xsd
new file mode 100644
index 00000000..59409d45
--- /dev/null
+++ b/auth/auth-locate/src/main/xsd/locate_1_1.xsd
@@ -0,0 +1,46 @@
+<!--
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+-->
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:locate_local="urn:locate_local:v1_1"
+ targetNamespace="urn:locate_local:v1_1"
+ elementFormDefault="qualified">
+
+
+<!--
+ Configurations
+ -->
+ <xs:element name="Configuration">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="props" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="tag" type="xs:string"/>
+ <xs:element name="value" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema> \ No newline at end of file
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
index 93b39b2d..26bea940 100644
--- a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
+++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
@@ -42,7 +42,7 @@ public class JU_Mapper_1_0Test {
@Test
public void testGetClasses() {
- Mapper_1_0 mapper = new Mapper_1_0();
+ Mapper_1_1 mapper = new Mapper_1_1();
assertEquals(InRequest.class, mapper.getClass(API.IN_REQ));
assertEquals(Out.class, mapper.getClass(API.OUT));
assertEquals(Error.class, mapper.getClass(API.ERROR));
@@ -53,7 +53,7 @@ public class JU_Mapper_1_0Test {
@Test
public void testNewInstance() {
- Mapper_1_0 mapper = new Mapper_1_0();
+ Mapper_1_1 mapper = new Mapper_1_1();
assertTrue(mapper.newInstance(API.IN_REQ) instanceof InRequest);
assertTrue(mapper.newInstance(API.OUT) instanceof Out);
assertTrue(mapper.newInstance(API.ERROR) instanceof Error);
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
index d9200d76..c79e9cbd 100644
--- a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
+++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
@@ -35,6 +35,7 @@ import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.dao.cass.LocateDAO.Data;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.auth.locate.AAF_Locate;
import org.onap.aaf.auth.locate.mapper.Mapper;
import org.onap.aaf.misc.env.APIException;
@@ -43,9 +44,21 @@ import locate.v1_0.MgmtEndpoints;
public class JU_LocateServiceImplTest {
+ // Extend, because I don't want a "setter" in the original. Compromised with a protected...
+ private final class LocateServiceImplExtension extends LocateServiceImpl {
+ private LocateServiceImplExtension(AuthzTrans trans, AAF_Locate locate, Mapper mapper) throws APIException {
+ super(trans, locate, mapper);
+ }
+ public void set(LocateDAO ld) {
+ locateDAO=ld;
+ }
+ }
+
@Mock
private AuthzTrans trans;
@Mock
+ private AAF_Locate aaf_locate;
+ @Mock
private LocateDAO locateDAO;
@Mock
private Mapper mapper;
@@ -65,7 +78,8 @@ public class JU_LocateServiceImplTest {
@Test
public void test() throws APIException {
- LocateServiceImpl locateServiceImpl = new LocateServiceImpl(trans, locateDAO, mapper);
+ LocateServiceImplExtension locateServiceImpl = new LocateServiceImplExtension(trans, aaf_locate, mapper);
+ locateServiceImpl.set(locateDAO);
assertEquals(mapper, locateServiceImpl.mapper());