X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fregister%2FRemoteRegistrant.java;h=883410c074abc3ef06f83839d4d00367896d09e5;hp=49d40ab458167f2ed697564d6a7c5f9d9c6b0810;hb=12414fe43077e12d7ef711951b1633ad31d73573;hpb=a5bcce655e339151445fbce2c129687e3bc8610a diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java index 49d40ab4..883410c0 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java @@ -22,10 +22,8 @@ package org.onap.aaf.cadi.register; import java.net.HttpURLConnection; -import java.net.Inet4Address; import java.net.URI; import java.net.URISyntaxException; -import java.net.UnknownHostException; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; @@ -39,16 +37,13 @@ import org.onap.aaf.cadi.client.Result; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.locator.PropertyLocator; import org.onap.aaf.cadi.locator.SingleEndpointLocator; -import org.onap.aaf.cadi.util.Split; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.impl.BasicEnv; import org.onap.aaf.misc.rosetta.env.RosettaDF; -import locate.v1_0.MgmtEndpoint; import locate.v1_0.MgmtEndpoints; public class RemoteRegistrant implements Registrant { - private final MgmtEndpoint mep; private final MgmtEndpoints meps; private final AAFCon aafcon; private final RosettaDF mgmtEndpointsDF; @@ -56,8 +51,7 @@ public class RemoteRegistrant implements Registrant { private final Access access; private final int timeout; - @SafeVarargs - public RemoteRegistrant(AAFCon aafcon, String name, String version, int port, RemoteRegistrant ... others) throws CadiException, LocatorException { + public RemoteRegistrant(AAFCon aafcon, int port) throws CadiException, LocatorException { this.aafcon = aafcon; access = aafcon.access; try { @@ -82,60 +76,13 @@ public class RemoteRegistrant implements Registrant { } } - mep = new MgmtEndpoint(); - mep.setName(name); - mep.setPort(port); - - try { - String hostnameToRegister = access.getProperty(Config.AAF_REGISTER_AS, null); - if (hostnameToRegister==null) { - hostnameToRegister = access.getProperty(Config.HOSTNAME, null); - } - if (hostnameToRegister==null) { - hostnameToRegister = Inet4Address.getLocalHost().getHostName(); - } - mep.setHostname(hostnameToRegister); - - String latitude = access.getProperty(Config.CADI_LATITUDE, null); - if (latitude==null) { - latitude = access.getProperty("AFT_LATITUDE", null); - } - String longitude = access.getProperty(Config.CADI_LONGITUDE, null); - if (longitude==null) { - longitude = access.getProperty("AFT_LONGITUDE", null); - } - if (latitude==null || longitude==null) { - throw new CadiException(Config.CADI_LATITUDE + " and " + Config.CADI_LONGITUDE + " is required"); - } else { - mep.setLatitude(Float.parseFloat(latitude)); - mep.setLongitude(Float.parseFloat(longitude)); - } - String split[] = Split.split('.', version); - mep.setPkg(split.length>3?Integer.parseInt(split[3]):0); - mep.setPatch(split.length>2?Integer.parseInt(split[2]):0); - mep.setMinor(split.length>1?Integer.parseInt(split[1]):0); - mep.setMajor(split.length>0?Integer.parseInt(split[0]):0); - - String subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null); - if (subprotocols==null) { - mep.setProtocol("http"); - } else { - mep.setProtocol("https"); - for (String s : Split.split(',', subprotocols)) { - mep.getSubprotocol().add(s); - } - } - } catch (NumberFormatException | UnknownHostException e) { - throw new CadiException("Error extracting Data from Properties for Registrar",e); - } - meps = new MgmtEndpoints(); - meps.getMgmtEndpoint().add(mep); - for (RemoteRegistrant rr : others) { - meps.getMgmtEndpoint().add(rr.mep); - } + RegistrationCreator rcreator = new RegistrationCreator(access); + meps = rcreator.create(port); } - @Override + + + @Override public Result update(ENV env) { try { Rcli client = aafcon.client(locator);