aboutsummaryrefslogtreecommitdiffstats
path: root/aai-service/provider
diff options
context:
space:
mode:
Diffstat (limited to 'aai-service/provider')
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java118
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java731
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java6
-rwxr-xr-x[-rw-r--r--]aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIExecutorInterface.java6
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java46
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java1796
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java16
-rw-r--r--aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java41
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java13
-rwxr-xr-x[-rw-r--r--]aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java2
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipListRequest.java68
-rwxr-xr-x[-rw-r--r--]aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipRequest.java111
-rwxr-xr-x[-rw-r--r--]aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java5
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/query/Result.java28
-rwxr-xr-xaai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequestTest.java5
-rwxr-xr-xaai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequestTest.java38
-rwxr-xr-xaai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/RegressionTest.java30
-rwxr-xr-xaai-service/provider/src/test/resources/aaiclient.properties5
18 files changed, 1030 insertions, 2035 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
index cfeda4cc..712ea2a6 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java
@@ -39,147 +39,37 @@ import com.fasterxml.jackson.databind.JsonMappingException;
public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin {
- // VCE
- public boolean postNetworkVceData(String vnfId, Vce request) throws AAIServiceException;
- public Vce requestNetworkVceData(String vnfId) throws AAIServiceException;
- public boolean deleteNetworkVceData(String vnfId, String resourceVersion) throws AAIServiceException;
-
- // Service Inteface
- public ServiceInstance requestServiceInterfaceData(String customerId, String serviceType, String svc_instanceId) throws AAIServiceException;
- public boolean postServiceInterfaceData(String customerId, String serviceType, String svcInstanceId, ServiceInstance request) throws AAIServiceException;
- public SearchResults requestServiceInstanceURL(String svcInstanceId) throws AAIServiceException;
+ public SearchResults requestServiceInstanceURL(String svc_instanceId) throws AAIServiceException;
// VServers
public Vserver requestVServerData(String tenantId, String vserverId, String cloudOwner, String cloudRegionId) throws AAIServiceException;
- public boolean postVServerData(String tenantId, String vserverId, String cloudOwner, String cloudRegionId, Vserver request) throws AAIServiceException;
- public boolean deleteVServerData(String tenantId, String vserverId, String cloudOwner, String cloudRegionId, String resourceVersion) throws AAIServiceException;
- public URL requestVserverURLNodeQuery(String vserver_name) throws AAIServiceException;
+ public URL requestVserverURLNodeQuery(String vserverName) throws AAIServiceException;
public String getTenantIdFromVserverUrl(URL url);
public String getCloudOwnerFromVserverUrl(URL url);
public String getCloudRegionFromVserverUrl(URL url);
public String getVServerIdFromVserverUrl(URL url, String tennantId);
public Vserver requestVServerDataByURL(URL url) throws AAIServiceException;
- // VPLS-PE
- public VplsPe requestNetworkVplsPeData(String equipmentName) throws AAIServiceException;
- public boolean postNetworkVplsPeData(String vnfId, VplsPe request) throws AAIServiceException;
- public boolean deleteNetworkVplsPeData(String vnfId, String resourceVersion) throws AAIServiceException;
-
-
- // Complexes
- public Complex requestNetworkComplexData(String vnfId) throws AAIServiceException;
- public boolean postNetworkComplexData(String vnfId, Complex request) throws AAIServiceException;
- public boolean deleteNetworkComplexData(String vnfId, String resourceVersion) throws AAIServiceException;
-
- // CTag Pool
- public CtagPool requestCtagPoolData(String physicalLocationId, String targetPe, String availabilityZoneName) throws AAIServiceException;
-
- // --------------------------------- 1507 ---------------------------
- // Data Change
- public Vserver dataChangeRequestVServerData(URL url) throws AAIServiceException;
-
- public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException;
-
- public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException;
-
- public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException;
-
- public Pserver dataChangeRequestPServerData(URL url) throws AAIServiceException;
-
- //OAM-Network:
- public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException;
- //Availability-Zone:
- public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException;
- //Complex:
- public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException;
-
-
- /* DELETE */
- public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException;
-
- public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException;
- public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException;
-
- public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException;
-
- public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException;
- //OAM-Network:
- public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException;
- //Availability-Zone:
- public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException;
- //Complex:
- public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException;
// ----------------- Release 1510 ----------------------
// // GenericVNF
public GenericVnf requestGenericVnfData(String vnfId) throws AAIServiceException;
public boolean postGenericVnfData(String vnfId, GenericVnf request) throws AAIServiceException;
- public boolean deleteGenericVnfData(String vnfId, String resourceVersion) throws AAIServiceException;
-
- // DvsSwitch
- public DvsSwitch requestDvsSwitchData(String vnfId) throws AAIServiceException;
- public boolean postDvsSwitchData(String vnfId, DvsSwitch request) throws AAIServiceException;
- public boolean deleteDvsSwitchData(String vnfId, String resourceVersion) throws AAIServiceException;
-
- // PInterface
- public PInterface requestPInterfaceData(String hostname, String interfaceName) throws AAIServiceException;
- public boolean postPInterfaceData(String hostname, String interfaceName, PInterface request) throws AAIServiceException;
- public boolean deletePInterfaceData(String hostname, String interfaceName, String resourceVersion) throws AAIServiceException;
// Physical Link
public PhysicalLink requestPhysicalLinkData(String vnfId) throws AAIServiceException;
public boolean postPhysicalLinkData(String vnfId, PhysicalLink request) throws AAIServiceException;
public boolean deletePhysicalLinkData(String vnfId, String resourceVersion) throws AAIServiceException;
- // PServers
- public Pserver requestPServerData(String hostname) throws AAIServiceException;
- public boolean postPServerData(String hostname, Pserver server) throws AAIServiceException;
- public boolean deletePServerData(String hostname, String resourceVersion) throws AAIServiceException;
-
- // L3Networks
- public L3Network requestL3NetworkData(String networkId) throws AAIServiceException;
- public L3Network requestL3NetworkQueryByName(String networkId) throws AAIServiceException;
- public boolean postL3NetworkData(String networkId, L3Network request) throws AAIServiceException;
- public boolean deleteL3NetworkData(String networkId, String resourceVersion) throws AAIServiceException;
-
- // Vpn Bindings
- public VpnBinding requestVpnBindingData(String vpnId) throws AAIServiceException;
-// public boolean postVpnBindingData(String vpnId, VpnBinding request) throws AAIServiceException;
- public boolean deleteVpnBindingData(String vpnId, String resourceVersion) throws AAIServiceException;
-
- //VnfImage
- public VnfImage requestVnfImageData(String vpnId) throws AAIServiceException;
- public VnfImage requestVnfImageDataByVendorModel(String vendor, String model) throws AAIServiceException;
- public VnfImage requestVnfImageDataByVendorModelVersion(String vendor, String model, String version) throws AAIServiceException;
-
// UBB Notify
public boolean sendNotify(NotifyEvent event, String serviceInstanceId, String pathCode) throws AAIServiceException;
- // 1512
- // Site Pair Site
- public SitePairSet requestSitePairSetData(String sitePairSetId) throws AAIServiceException;
- public boolean postSitePairSetData(String sitePairSetId, SitePairSet request) throws AAIServiceException;
- public boolean deleteSitePairSetData(String sitePairSetId, String resourceVersion) throws AAIServiceException;
-
- // Services
- public Service requestServiceData(String serviceId) throws AAIServiceException;
- public boolean postServiceData(String serviceId, Service request) throws AAIServiceException;
- public boolean deleteServiceData(String serviceId, String resourceVersion) throws AAIServiceException;
-
// Node Query - 1602
public SearchResults requestNodeQuery(String type, String entityIdentifier, String entityName) throws AAIServiceException;
public String requestDataByURL(URL url) throws AAIServiceException;
-// public Object requestDataInstanceNodeQuery(String type, String vnf_name) throws AAIServiceException;
- public GenericVnf requestGenericVnfeNodeQuery(String vnf_name) throws AAIServiceException;
-
- // // tenant
- public Tenant requestTenantData(String tenant_id, String cloudOwner, String cloudRegionId) throws AAIServiceException;
- public Tenant requestTenantDataByName(String tenant_name, String cloudOwner, String cloudRegionId) throws AAIServiceException;
- public boolean postTenantData(String tenant_id, String cloudOwner, String cloudRegionId, Tenant request) throws AAIServiceException;
-// public boolean deleteGenericVnfData(String vnfId, String resourceVersion) throws AAIServiceException;
-
+ public GenericVnf requestGenericVnfeNodeQuery(String vnfName) throws AAIServiceException;
public QueryStatus backup(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
public QueryStatus restore(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
@@ -193,6 +83,6 @@ public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin {
String query(AAIRequest request) throws AAIServiceException;
String save(AAIRequest request) throws AAIServiceException;
boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException;
-
+ boolean update(AAIRequest request, String resourceVersion) throws AAIServiceException;
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
new file mode 100755
index 00000000..e27d44ad
--- /dev/null
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
@@ -0,0 +1,731 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 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=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.aai;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Properties;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.ws.rs.HttpMethod;
+
+import org.apache.commons.codec.binary.Base64;
+import org.onap.ccsdk.sli.adaptors.aai.AAIService.TransactionIdTracker;
+import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
+import org.onap.ccsdk.sli.adaptors.aai.data.ErrorResponse;
+import org.onap.ccsdk.sli.adaptors.aai.data.RequestError;
+import org.onap.ccsdk.sli.adaptors.aai.data.ResourceVersion;
+import org.onap.ccsdk.sli.adaptors.aai.data.ServiceException;
+import org.onap.ccsdk.sli.core.sli.MetricLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.client.urlconnection.HTTPSProperties;
+
+public class AAIClientRESTExecutor implements AAIExecutorInterface {
+
+ private final String truststorePath;
+ private final String truststorePassword;
+ private final String keystorePath;
+ private final String keystorePassword;
+ private final Boolean ignoreCertificateHostError;
+ // authentication credentials
+ private String userName;
+ private String userPassword;
+ private final String applicationId;
+
+ public AAIClientRESTExecutor(Properties props) {
+ super();
+
+ userName = props.getProperty(AAIService.CLIENT_NAME);
+ userPassword = props.getProperty(AAIService.CLIENT_PWWD);
+
+ if(userName == null || userName.isEmpty()){
+ LOG.debug("Basic user name is not set");
+ }
+ if(userPassword == null || userPassword.isEmpty()) {
+ LOG.debug("Basic password is not set");
+ }
+
+ truststorePath = props.getProperty(AAIService.TRUSTSTORE_PATH);
+ truststorePassword = props.getProperty(AAIService.TRUSTSTORE_PSSWD);
+ keystorePath = props.getProperty(AAIService.KEYSTORE_PATH);
+ keystorePassword = props.getProperty(AAIService.KEYSTORE_PSSWD);
+// this.read_timeout = read_timeout;
+
+ String tmpApplicationId =props.getProperty(AAIService.APPLICATION_ID);
+ if(tmpApplicationId == null || tmpApplicationId.isEmpty()) {
+ tmpApplicationId = "SDNC";
+ }
+ applicationId = tmpApplicationId;
+
+ String iche = props.getProperty(AAIService.CERTIFICATE_HOST_ERROR);
+ boolean host_error = false;
+ if(iche != null && !iche.isEmpty()) {
+ host_error = Boolean.valueOf(iche);
+ }
+
+ ignoreCertificateHostError = host_error;
+
+ HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
+ public boolean verify(String string,SSLSession ssls) {
+ return ignoreCertificateHostError;
+ }
+ });
+
+ if(truststorePath != null && truststorePassword != null && (new File(truststorePath)).exists()) {
+ System.setProperty("javax.net.ssl.trustStore", truststorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
+ }
+
+// MyX509ExtendedTrustManager trustManager = null;
+// try {
+// trustManager = new MyX509ExtendedTrustManager();
+// } catch (Exception e1) {
+// // TODO Auto-generated catch block
+// e1.printStackTrace();
+// }
+//
+// TrustManager[] trustManagers = {trustManager};
+
+ if(keystorePath != null && keystorePassword != null && (new File(keystorePath)).exists())
+ {
+ DefaultClientConfig config = new DefaultClientConfig();
+ //both jersey and HttpURLConnection can use this
+ SSLContext ctx = null;
+ try {
+ ctx = SSLContext.getInstance("TLS");
+
+ KeyManagerFactory kmf = null;
+ try {
+ String def = "SunX509";
+ String storeType = "PKCS12";
+ def = KeyStore.getDefaultType();
+ kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ FileInputStream fin = new FileInputStream(keystorePath);
+ // KeyStore ks = KeyStore.getInstance("PKCS12");
+
+ String extension = keystorePath.substring(keystorePath.lastIndexOf(".") + 1);
+
+ if(extension != null && !extension.isEmpty() && extension.equalsIgnoreCase("JKS")) {
+ storeType = "JKS";
+ }
+ KeyStore ks = KeyStore.getInstance(storeType);
+
+ char[] pwd = keystorePassword.toCharArray();
+ ks.load(fin, pwd);
+ kmf.init(ks, pwd);
+ } catch (Exception ex) {
+ LOG.error("AAIResource", ex);
+ }
+
+ ctx.init(kmf.getKeyManagers(), null, null);
+ config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties( new HostnameVerifier() {
+ @Override
+ public boolean verify( String s, SSLSession sslSession ) {
+ return ignoreCertificateHostError;
+ }
+ }, ctx));
+
+ CTX = ctx;
+ LOG.debug("SSLContext created");
+
+ } catch (KeyManagementException | NoSuchAlgorithmException exc) {
+ LOG.error("AAIResource", exc);
+ }
+ }
+
+ try {
+ Field methodsField = HttpURLConnection.class.getDeclaredField("methods");
+ methodsField.setAccessible(true);
+ // get the methods field modifiers
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ // bypass the "private" modifier
+ modifiersField.setAccessible(true);
+
+ // remove the "final" modifier
+ modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL);
+
+ /* valid HTTP methods */
+ String[] methods = {
+ "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE", "PATCH"
+ };
+ // set the new methods - including patch
+ methodsField.set(null, methods);
+
+ } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ LOG.info("AAIResource.ctor initialized.");
+
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(AAIService.class);
+ private final MetricLogger ml = new MetricLogger();
+
+ private SSLContext CTX;
+
+
+ private int connection_timeout = 300000;
+
+ private int read_timeout = 300000;
+
+ /**
+ * Returns an String that contains JSON data returned from the AAI Server.
+ * <p>
+ * This method always returns immediately, whether or not the
+ * data exists.
+ *
+ * @param request an instance of AAIRequiest representing
+ * the request made by DirectedGraph node.
+ * @return the JSON based representation of data instance requested.
+ * @see String
+ */
+ @Override
+ public String get(AAIRequest request) throws AAIServiceException {
+ String response = null;
+ InputStream inputStream = null;
+ HttpURLConnection con = null;
+ URL requestUrl = null;
+
+ StringBuilder errorStringBuilder = new StringBuilder();
+
+ try {
+
+ if(request.getRequestObject() != null) {
+ requestUrl = request.getRequestUrl(HttpMethod.POST, null);
+ requestUrl = appendDepth(requestUrl, request);
+ con = getConfiguredConnection(requestUrl, HttpMethod.POST);
+ String json_text = request.toJSONString();
+ LOGwriteDateTrace("data", json_text);
+ logMetricRequest("POST "+requestUrl.getPath(), json_text, requestUrl.getPath());
+ OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
+ osw.write(json_text);
+ osw.flush();
+ } else {
+ requestUrl = request.getRequestUrl(HttpMethod.GET, null);
+ requestUrl = appendDepth(requestUrl, request);
+ con = getConfiguredConnection(requestUrl, HttpMethod.GET);
+ logMetricRequest("GET "+requestUrl.getPath(), "", requestUrl.getPath());
+ }
+
+ // Check for errors
+ String responseMessage = con.getResponseMessage();
+ int responseCode = con.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_OK) {
+ inputStream = con.getInputStream();
+ } else {
+ inputStream = con.getErrorStream();
+ }
+
+ // Process the response
+ LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
+ logMetricResponse(responseCode, responseMessage);
+
+ if(inputStream == null) inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
+ BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
+
+ ObjectMapper mapper = AAIService.getObjectMapper();
+
+ if (responseCode == HttpURLConnection.HTTP_OK) {
+ StringBuilder stringBuilder = new StringBuilder();
+ String line = null;
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ response = stringBuilder.toString();
+ try {
+ Object object = mapper.readValue(response, Object.class);
+ LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, responseMessage, mapper.writeValueAsString(object));
+ } catch(Exception exc) {
+ LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, responseMessage, mapper.writeValueAsString(response));
+ }
+ } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
+ LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist.");
+ ErrorResponse errorresponse = null;
+ try {
+ errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ } catch(Exception exc) {
+ errorresponse = new ErrorResponse();
+ RequestError requestError = new RequestError();
+ ServiceException serviceException = new ServiceException();
+ serviceException.setText("Entry does not exist.");
+ requestError.setServiceException(serviceException);
+ errorresponse.setRequestError(requestError );
+ }
+ throw new AAIServiceException(responseCode, errorresponse);
+ } else if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ StringBuilder stringBuilder = new StringBuilder();
+ String line = null;
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ LOGwriteEndingTrace(responseCode, responseMessage, stringBuilder.toString());
+ ServiceException serviceException = new ServiceException();
+ serviceException.setMessageId("HTTP_UNAUTHORIZED");
+ serviceException.setText(stringBuilder.toString());
+ RequestError requestError = new RequestError();
+ requestError.setServiceException(serviceException);
+ ErrorResponse errorresponse = new ErrorResponse();
+ errorresponse.setRequestError(requestError);
+ throw new AAIServiceException(responseCode, errorresponse);
+ } else {
+// StringBuilder errorStringBuilder = new StringBuilder();
+ String line = null;
+ while( ( line = reader.readLine() ) != null ) {
+ errorStringBuilder.append("\n").append( line );
+ }
+
+ ErrorResponse errorresponse = mapper.readValue(errorStringBuilder.toString(), ErrorResponse.class);
+// ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
+ throw new AAIServiceException(responseCode, errorresponse);
+ }
+
+ } catch(AAIServiceException aaiexc) {
+ throw aaiexc;
+ } catch (Exception exc) {
+ LOG.warn(errorStringBuilder.toString(), exc);
+ throw new AAIServiceException(exc);
+ } finally {
+ if(inputStream != null){
+ try {
+ inputStream.close();
+ } catch(Exception exc) {
+
+ }
+ }
+ }
+ return response;
+ }
+
+ @Override
+ public String post(AAIRequest request) throws AAIServiceException {
+ InputStream inputStream = null;
+
+ try {
+ String resourceVersion = null;
+ AAIDatum instance = request.getRequestObject();
+
+ try {
+ Method getResourceVersionMethod = instance.getClass().getMethod("getResourceVersion");
+ if(getResourceVersionMethod != null){
+ try {
+ Object object = getResourceVersionMethod.invoke(instance);
+ if(object != null)
+ resourceVersion = object.toString();
+ } catch (InvocationTargetException x) {
+ Throwable cause = x.getCause();
+ }
+ }
+ } catch(Exception exc) {
+ LOG.error("", exc);
+ }
+
+ URL requestUrl = null;
+ HttpURLConnection con = getConfiguredConnection(requestUrl = request.getRequestUrl(HttpMethod.PUT, resourceVersion), HttpMethod.PUT);
+ ObjectMapper mapper = AAIService.getObjectMapper();
+ String json_text = request.toJSONString();
+
+ LOGwriteDateTrace("data", json_text);
+ logMetricRequest("PUT "+requestUrl.getPath(), json_text, requestUrl.getPath());
+
+ OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
+ osw.write(json_text);
+ osw.flush();
+
+ // Check for errors
+ String responseMessage = con.getResponseMessage();
+ int responseCode = con.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ inputStream = con.getInputStream();
+ } else {
+ inputStream = con.getErrorStream();
+ }
+
+ LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
+ logMetricResponse(responseCode, responseMessage);
+
+ // Process the response
+ BufferedReader reader;
+ String line = null;
+ reader = new BufferedReader( new InputStreamReader( inputStream ) );
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ LOGwriteEndingTrace(responseCode, responseMessage, (stringBuilder != null) ? stringBuilder.toString() : "{no-data}");
+ return stringBuilder.toString();
+ } else {
+ ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
+
+ throw new AAIServiceException(responseCode, errorresponse);
+ }
+ } catch(AAIServiceException aaiexc) {
+ throw aaiexc;
+ } catch (Exception exc) {
+ LOG.warn("AAIRequestExecutor.post", exc);
+ throw new AAIServiceException(exc);
+ } finally {
+ try {
+ if(inputStream != null)
+ inputStream.close();
+ } catch (Exception exc) {
+
+ }
+ }
+ }
+
+ @Override
+ public Boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException {
+ Boolean response = null;
+ InputStream inputStream = null;
+
+ if(resourceVersion == null) {
+ throw new AAIServiceException("resource-version is required for DELETE request");
+ }
+
+ try {
+ URL requestUrl = null;
+ HttpURLConnection conn = getConfiguredConnection(requestUrl = request.getRequestUrl(HttpMethod.DELETE, resourceVersion), HttpMethod.DELETE);
+ logMetricRequest("DELETE "+requestUrl.getPath(), "", requestUrl.getPath());
+ conn.setDoOutput(true);
+// if(request.isDeleteDataRequired()) {
+// String json_text = request.toJSONString();
+//
+// LOGwriteDateTrace("data", json_text);
+// OutputStream os = con.getOutputStream();
+// OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
+// osw.write(json_text);
+// osw.flush();
+// }
+
+ // Check for errors
+ String responseMessage = conn.getResponseMessage();
+ int responseCode = conn.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ inputStream = conn.getInputStream();
+ } else {
+ inputStream = conn.getErrorStream();
+ }
+
+ // Process the response
+ LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
+ logMetricResponse(responseCode, responseMessage);
+
+ if(inputStream == null) inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
+ BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
+ String line = null;
+
+ ObjectMapper mapper = AAIService.getObjectMapper();
+
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ LOGwriteEndingTrace(responseCode, responseMessage, stringBuilder.toString());
+ response = true;
+ } else if(responseCode == HttpURLConnection.HTTP_NOT_FOUND ) {
+ LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist.");
+ response = false;
+ } else {
+ ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
+ throw new AAIServiceException(responseCode, errorresponse);
+ }
+ } catch(AAIServiceException aaiexc) {
+ throw aaiexc;
+ } catch (Exception exc) {
+ LOG.warn("delete", exc);
+ throw new AAIServiceException(exc);
+ } finally {
+ if(inputStream != null){
+ try {
+ inputStream.close();
+ } catch(Exception exc) {
+
+ }
+ }
+ }
+ return response;
+ }
+
+ @Override
+ public Object query(AAIRequest request, Class clas) throws AAIServiceException {
+ Object response = null;
+ InputStream inputStream = null;
+ HttpURLConnection con = null;
+ URL requestUrl = null;
+
+ try {
+ con = getConfiguredConnection(requestUrl = request.getRequestQueryUrl(HttpMethod.GET), HttpMethod.GET);
+ logMetricRequest("GET "+requestUrl.getPath(), "", requestUrl.getPath());
+
+ // Check for errors
+ String responseMessage = con.getResponseMessage();
+ int responseCode = con.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_OK) {
+ inputStream = con.getInputStream();
+ } else {
+ inputStream = con.getErrorStream();
+ }
+
+ logMetricResponse(responseCode, responseMessage);
+ ObjectMapper mapper = AAIService.getObjectMapper();
+
+ if (responseCode == HttpURLConnection.HTTP_OK) {
+ // Process the response
+ BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
+ response = mapper.readValue(reader, clas);
+ LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, "SUCCESS", mapper.writeValueAsString(response));
+ } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
+ LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", "Entry does not exist.");
+ return response;
+ } else {
+ BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
+ ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
+ throw new AAIServiceException(responseCode, errorresponse);
+ }
+
+ } catch(AAIServiceException aaiexc) {
+ throw aaiexc;
+ } catch (Exception exc) {
+ LOG.warn("GET", exc);
+ throw new AAIServiceException(exc);
+ } finally {
+ if(inputStream != null){
+ try {
+ inputStream.close();
+ } catch(Exception exc) {
+
+ }
+ }
+ con = null;
+ }
+ return response;
+ }
+
+ @Override
+ public Boolean patch(AAIRequest request, String resourceVersion) throws AAIServiceException {
+ InputStream inputStream = null;
+
+ try {
+ AAIDatum instance = request.getRequestObject();
+ if(instance instanceof ResourceVersion) {
+ resourceVersion = ((ResourceVersion)instance).getResourceVersion();
+ }
+
+ URL requestUrl = null;
+ HttpURLConnection con = getConfiguredConnection(requestUrl = request.getRequestUrl("PATCH", resourceVersion), "PATCH");
+ ObjectMapper mapper = AAIService.getObjectMapper();
+ String json_text = request.toJSONString();
+
+ LOGwriteDateTrace("data", json_text);
+ logMetricRequest("PATCH "+requestUrl.getPath(), json_text, requestUrl.getPath());
+
+ OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
+ osw.write(json_text);
+ osw.flush();
+
+ // Check for errors
+ String responseMessage = con.getResponseMessage();
+ int responseCode = con.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ inputStream = con.getInputStream();
+ } else {
+ inputStream = con.getErrorStream();
+ }
+
+ LOG.info("HttpURLConnection result: " + responseCode + " : " + responseMessage);
+ logMetricResponse(responseCode, responseMessage);
+
+ // Process the response
+ BufferedReader reader;
+ String line = null;
+ reader = new BufferedReader( new InputStreamReader( inputStream ) );
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+
+ if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ LOGwriteEndingTrace(responseCode, responseMessage, (stringBuilder != null) ? stringBuilder.toString() : "{no-data}");
+ return true;
+ } else {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append("\n").append( line );
+ }
+ LOG.info(stringBuilder.toString());
+
+
+ ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
+ LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
+
+ throw new AAIServiceException(responseCode, errorresponse);
+ }
+ } catch(AAIServiceException aaiexc) {
+ throw aaiexc;
+ } catch (Exception exc) {
+ LOG.warn("AAIRequestExecutor.patch", exc);
+ throw new AAIServiceException(exc);
+ } finally {
+ try {
+ if(inputStream != null)
+ inputStream.close();
+ } catch (Exception exc) {
+
+ }
+ }
+ }
+
+ /**
+ *
+ * @param httpReqUrl
+ * @param method
+ * @return
+ * @throws Exception
+ */
+ protected HttpURLConnection getConfiguredConnection(URL httpReqUrl, String method) throws Exception {
+ HttpURLConnection con = (HttpURLConnection) httpReqUrl.openConnection();
+
+ // Set up the connection properties
+ con.setRequestProperty("Connection", "close");
+ con.setDoInput(true);
+ con.setDoOutput(true);
+ con.setUseCaches(false);
+ con.setConnectTimeout(connection_timeout);
+ con.setReadTimeout(read_timeout);
+ con.setRequestMethod(method);
+ con.setRequestProperty("Accept", "application/json");
+ // con.setRequestProperty( "Accept-Encoding", "gzip,compress" );
+ con.setRequestProperty("Transfer-Encoding","chunked");
+ con.setRequestProperty("Content-Type",
+ "PATCH".equalsIgnoreCase(method) ? "application/merge-patch+json" : "application/json");
+ con.setRequestProperty("X-FromAppId", applicationId);
+ con.setRequestProperty("X-TransactionId", TransactionIdTracker.getNextTransactionId());
+ String mlId = ml.getRequestID();
+ if (mlId != null && !mlId.isEmpty()) {
+ LOG.debug(String.format("MetricLogger requestId = %s", mlId));
+ con.setRequestProperty(MetricLogger.REQUEST_ID, mlId);
+ } else {
+ LOG.debug("MetricLogger requestId is null");
+ }
+
+ if (userName != null && !userName.isEmpty() && userPassword != null && !userPassword.isEmpty()) {
+ String basicAuth = "Basic " + new String(Base64.encodeBase64((userName + ":" + userPassword).getBytes()));
+ con.setRequestProperty("Authorization", basicAuth);
+ }
+
+ if (con instanceof HttpsURLConnection && CTX != null) {
+ SSLSocketFactory sockFact = CTX.getSocketFactory();
+ HttpsURLConnection.class.cast(con).setSSLSocketFactory(sockFact);
+ }
+ return con;
+ }
+
+ private URL appendDepth(URL requestUrl, AAIRequest request) throws MalformedURLException {
+
+ String depth = request.requestProperties.getProperty("depth", "1");
+ String path = requestUrl.toString();
+ if(path.contains("?depth=") || path.contains("&depth=")) {
+ return requestUrl;
+ } else {
+ if(path.contains("?")) {
+ path = String.format("%s&depth=%s", path, depth);
+ } else {
+ path = String.format("%s?depth=%s", path, depth);
+ }
+ return new URL(path);
+ }
+ }
+
+ public void logMetricRequest(String targetServiceName, String msg, String path){
+ String svcInstanceId = "";
+ String svcName = null;
+ String partnerName = null;
+ String targetEntity = "A&AI";
+ String targetVirtualEntity = null;
+
+ targetServiceName = "";
+
+ ml.logRequest(svcInstanceId, svcName, partnerName, targetEntity, targetServiceName, targetVirtualEntity, msg);
+ }
+
+ public void logMetricResponse(int responseCode, String responseDescription){
+ ml.logResponse(responseCode < 400 ? "SUCCESS" : "FAILURE", Integer.toString(responseCode), responseDescription);
+ }
+
+ protected void LOGwriteFirstTrace(String method, String url) {
+ String time = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(System.currentTimeMillis());
+ LOG.info("A&AI transaction :");
+ LOG.info("Request Time : " + time + ", Method : " + method);
+ LOG.info("Request URL : "+ url);
+ }
+
+ protected void LOGwriteDateTrace(String name, String data) {
+ LOG.info("Input - " + name + " : " + data);
+ }
+
+ protected void LOGwriteEndingTrace(int response_code, String comment, String data) {
+ LOG.info("Response code : " + response_code +", " + comment);
+ LOG.info(String.format("Response data : %s", data));
+ }
+
+}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
index c5a4c22e..e262df04 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
@@ -28,6 +28,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
@@ -68,7 +69,6 @@ import org.openecomp.aai.inventory.v11.ServiceInstance;
import org.openecomp.aai.inventory.v11.Vlan;
import org.openecomp.aai.inventory.v11.Vlans;
import org.openecomp.aai.inventory.v11.Vserver;
-import org.onap.ccsdk.sli.adaptors.aai.AAIService.AAIRequestExecutor;
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryResultList;
import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilter;
@@ -140,7 +140,7 @@ public abstract class AAIDeclarations implements AAIClient {
protected abstract Logger getLogger();
- public abstract AAIRequestExecutor getExecutor();
+ public abstract AAIExecutorInterface getExecutor();
@Override
@@ -482,7 +482,7 @@ public abstract class AAIDeclarations implements AAIClient {
request.processRequestPathValues(nameValues);
path = request.getRequestUrl("GET", null);
params.put("vserver-selflink", path.toString());
- } catch (UnsupportedEncodingException | MalformedURLException e) {
+ } catch (UnsupportedEncodingException | MalformedURLException | URISyntaxException e) {
// TODO : Fix this
params.put("vserver-selflink", "/vserver");
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIExecutorInterface.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIExecutorInterface.java
index 3cc7e5ba..9203daa1 100644..100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIExecutorInterface.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIExecutorInterface.java
@@ -3,7 +3,7 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
package org.onap.ccsdk.sli.adaptors.aai;
public interface AAIExecutorInterface {
- public Object get(AAIRequest request) throws AAIServiceException;
- public Object post(AAIRequest request) throws AAIServiceException;
+ public String get(AAIRequest request) throws AAIServiceException;
+ public String post(AAIRequest request) throws AAIServiceException;
public Boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException;
public Object query(AAIRequest request, Class clas) throws AAIServiceException;
public Boolean patch(AAIRequest request, String resourceVersion) throws AAIServiceException;
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
index 215f9ae8..f26b71de 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java
@@ -28,6 +28,7 @@ import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
@@ -80,14 +81,28 @@ public abstract class AAIRequest {
public static AAIRequest createRequest(String resoourceName, Map<String, String> nameValues){
String resoource = resoourceName;
+ String masterResource = null;
if(resoource == null)
return null;
if(resoource.contains(":")) {
String[] tokens = resoource.split(":");
- if(tokens != null && tokens.length > 0) {
- resoource = tokens[0];
+ if(tokens != null && tokens.length == 2) {
+ resoource = tokens[1];
+ masterResource = tokens[0];
+ //
+ Class<? extends AAIDatum> clazz = null;
+ try {
+ clazz = getClassFromResource(resoource) ;
+ } catch (ClassNotFoundException e) {
+ LOG.warn("AAIRequest does not support class: " + e.getMessage());
+ return null;
+ }
+
+ if(clazz == null) {
+ return null;
+ }
}
}
@@ -125,21 +140,14 @@ public abstract class AAIRequest {
case "l2-bridge-bgf":
{
resoource = "l-interface";
- AAIRequest request = getRequestFromResource("l-interface");
- if(request == null) {
- return null;
- }
- return request;
+ return getRequestFromResource("l-interface");
}
-
+ case "relationship-list":
+ return new RelationshipListRequest(AAIRequest.createRequest(masterResource, nameValues));
+ case "relationship":
+ return new RelationshipRequest(AAIRequest.createRequest(masterResource, nameValues));
default:
- {
- AAIRequest request = getRequestFromResource(resoource);
- if(request == null) {
- return null;
- }
- return request;
- }
+ return getRequestFromResource(resoource);
}
}
@@ -243,7 +251,7 @@ public abstract class AAIRequest {
aaiService.getLogger().warn("Could not deserialize object of type " + lInterfaceRequest.getClass().getSimpleName(), exc) ;
}
- public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
+ public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
String request_url = null;
@@ -287,6 +295,10 @@ public abstract class AAIRequest {
}
protected String getRequestPath(String resource) throws MalformedURLException {
+ if(requestProperties.containsKey("resource-path")) {
+ return requestProperties.getProperty("resource-path");
+ }
+
Set<String> uniqueResources = extractUniqueResourceSetFromKeys(requestProperties.stringPropertyNames());
if(resource != null) {
// for group search add itself, but remove singular version of itself
@@ -332,7 +344,7 @@ public abstract class AAIRequest {
return path;
}
- public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException;
+ public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException;
public abstract String toJSONString();
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java
index d2f90159..c4604a4a 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java
@@ -31,8 +31,6 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@@ -45,7 +43,6 @@ import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.HashMap;
@@ -71,39 +68,19 @@ import javax.xml.bind.annotation.XmlElement;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
+import org.onap.ccsdk.sli.adaptors.aai.data.ErrorResponse;
+import org.onap.ccsdk.sli.adaptors.aai.data.notify.NotifyEvent;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.openecomp.aai.inventory.v11.AvailabilityZone;
-import org.openecomp.aai.inventory.v11.Complex;
-import org.openecomp.aai.inventory.v11.CtagPool;
-import org.openecomp.aai.inventory.v11.DvsSwitch;
import org.openecomp.aai.inventory.v11.GenericVnf;
-import org.openecomp.aai.inventory.v11.L3Network;
-import org.openecomp.aai.inventory.v11.OamNetwork;
-import org.openecomp.aai.inventory.v11.PInterface;
import org.openecomp.aai.inventory.v11.PhysicalLink;
-import org.openecomp.aai.inventory.v11.Pserver;
import org.openecomp.aai.inventory.v11.ResultData;
import org.openecomp.aai.inventory.v11.SearchResults;
-import org.openecomp.aai.inventory.v11.Service;
-import org.openecomp.aai.inventory.v11.ServiceInstance;
-import org.openecomp.aai.inventory.v11.SitePairSet;
-import org.openecomp.aai.inventory.v11.Tenant;
-import org.openecomp.aai.inventory.v11.Vce;
-import org.openecomp.aai.inventory.v11.VnfImage;
-import org.openecomp.aai.inventory.v11.VnfImages;
-import org.openecomp.aai.inventory.v11.VplsPe;
-import org.openecomp.aai.inventory.v11.VpnBinding;
import org.openecomp.aai.inventory.v11.Vserver;
-import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
-import org.onap.ccsdk.sli.adaptors.aai.data.ErrorResponse;
-import org.onap.ccsdk.sli.adaptors.aai.data.RequestError;
-import org.onap.ccsdk.sli.adaptors.aai.data.ResourceVersion;
-import org.onap.ccsdk.sli.adaptors.aai.data.ServiceException;
-import org.onap.ccsdk.sli.adaptors.aai.data.notify.NotifyEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -132,7 +109,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
private final String keystorePassword;
private final Boolean ignoreCertificateHostError;
- private final String target_uri;
+ private final String targetUri;
private final String queryPath;
private final String networkVserverPath;
@@ -145,26 +122,26 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
private final String param_service_type; //= "service-type";
private final String ubb_notify_path;
- private final String selflink_avpn;
- private final String selflink_fqdn;
+ private final String selflinkAvpn;
+ private final String selflinkFqdn;
- private final String p_interface_path;
+ private final String pInterfacePath;
- private final String service_path;
- private final String site_pair_set_path;
+ private final String servicePath;
+ private final String sitePairSetPath;
- private final int connection_timeout;
- private final int read_timeout;
+ private final int connectionTimeout;
+ private final int readTimeout;
// 1602
- private final String query_nodes_path;
- private final String update_path;
+ private final String queryNodesPath;
+ private final String updatePath;
- private final String application_id;
+ private final String applicationId;
// authentication credentials
- private String user_name;
- private String user_password;
+ private String userName;
+ private String userPassword;
// runtime
private final boolean runtimeOSGI;
@@ -173,7 +150,11 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
private final MetricLogger ml = new MetricLogger();
- private final AAIRequestExecutor executor;
+ private AAIExecutorInterface executor;
+
+ public void setExecutor(AAIExecutorInterface executor) {
+ this.executor = executor;
+ }
public AAIService(URL propURL) {
LOG.info("Entered AAIService.ctor");
@@ -194,15 +175,15 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
LOG.error("AicAAIResource.static", exc);
}
- executor = new AAIRequestExecutor();
+ executor = new AAIClientRESTExecutor(props);
- user_name = props.getProperty(CLIENT_NAME);
- user_password = props.getProperty(CLIENT_PWWD);
+ userName = props.getProperty(CLIENT_NAME);
+ userPassword = props.getProperty(CLIENT_PWWD);
- if(user_name == null || user_name.isEmpty()){
+ if(userName == null || userName.isEmpty()){
LOG.debug("Basic user name is not set");
}
- if(user_password == null || user_password.isEmpty()) {
+ if(userPassword == null || userPassword.isEmpty()) {
LOG.debug("Basic password is not set");
}
@@ -211,15 +192,15 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
keystorePath = props.getProperty(KEYSTORE_PATH);
keystorePassword = props.getProperty(KEYSTORE_PSSWD);
- target_uri = props.getProperty(TARGET_URI);
+ targetUri = props.getProperty(TARGET_URI);
queryPath = props.getProperty(QUERY_PATH);
- update_path = props.getProperty(UPDATE_PATH);
+ updatePath = props.getProperty(UPDATE_PATH);
- String applicationId =props.getProperty(APPLICATION_ID);
- if(applicationId == null || applicationId.isEmpty()) {
- applicationId = "SDNC";
+ String tmpApplicationId = props.getProperty(APPLICATION_ID);
+ if(tmpApplicationId == null || tmpApplicationId.isEmpty()) {
+ tmpApplicationId = "SDNC";
}
- application_id = applicationId;
+ this.applicationId = tmpApplicationId;
// connection timeout
int tmpConnectionTimeout = 30000;
@@ -236,8 +217,8 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
tmpConnectionTimeout = 30000;
tmpReadTimeout = 30000;
}
- connection_timeout = tmpConnectionTimeout;
- read_timeout = tmpReadTimeout;
+ connectionTimeout = tmpConnectionTimeout;
+ readTimeout = tmpReadTimeout;
networkVserverPath =props.getProperty(NETWORK_VSERVER_PATH);
@@ -246,19 +227,19 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
param_service_type = props.getProperty(PARAM_SERVICE_TYPE, "service-type");
// P-Interfaces
- p_interface_path = props.getProperty(P_INTERFACE_PATH);
+ pInterfacePath = props.getProperty(P_INTERFACE_PATH);
vnf_image_query_path = props.getProperty(VNF_IMAGE_QUERY_PATH);
ubb_notify_path = props.getProperty(UBB_NOTIFY_PATH);
- selflink_avpn = props.getProperty(SELFLINK_AVPN);
- selflink_fqdn = props.getProperty(SELFLINK_FQDN);
+ selflinkAvpn = props.getProperty(SELFLINK_AVPN);
+ selflinkFqdn = props.getProperty(SELFLINK_FQDN);
- service_path = props.getProperty(SERVICE_PATH);
+ servicePath = props.getProperty(SERVICE_PATH);
- site_pair_set_path = props.getProperty(SITE_PAIR_SET_PATH);
+ sitePairSetPath = props.getProperty(SITE_PAIR_SET_PATH);
- query_nodes_path = props.getProperty(QUERY_NODES_PATH);
+ queryNodesPath = props.getProperty(QUERY_NODES_PATH);
String iche = props.getProperty(CERTIFICATE_HOST_ERROR);
boolean host_error = false;
@@ -367,12 +348,12 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
- con.setConnectTimeout( connection_timeout );
- con.setReadTimeout( read_timeout );
+ con.setConnectTimeout( connectionTimeout );
+ con.setReadTimeout( readTimeout );
con.setRequestMethod( method );
con.setRequestProperty( "Accept", "application/json" );
con.setRequestProperty( "Content-Type", "PATCH".equalsIgnoreCase(method) ? "application/merge-patch+json" : "application/json" );
- con.setRequestProperty("X-FromAppId", application_id);
+ con.setRequestProperty("X-FromAppId", applicationId);
con.setRequestProperty("X-TransactionId",TransactionIdTracker.getNextTransactionId());
String mlId = ml.getRequestID();
if(mlId != null && !mlId.isEmpty()) {
@@ -383,8 +364,8 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
con.setRequestProperty("Transfer-Encoding","chunked");
- if(user_name != null && !user_name.isEmpty() && user_password != null && !user_password.isEmpty()) {
- String basicAuth = "Basic " + new String(Base64.encodeBase64((user_name + ":" + user_password).getBytes()));
+ if(userName != null && !userName.isEmpty() && userPassword != null && !userPassword.isEmpty()) {
+ String basicAuth = "Basic " + new String(Base64.encodeBase64((userName + ":" + userPassword).getBytes()));
con.setRequestProperty ("Authorization", basicAuth);
}
@@ -436,88 +417,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
@Override
- public boolean deleteGenericVnfData(String vnf_id, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("generic-vnf");
- request.addRequestProperty("generic-vnf.vnf-id", vnf_id);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteGenericVnfData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- /* (non-Javadoc)
- * @see org.onap.ccsdk.sli.adaptors.resource.aic.AnAIClient#requestSdnZoneQuery(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public Vce requestNetworkVceData(String vnf_id) throws AAIServiceException {
- Vce response = null;
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vce");
- request.addRequestProperty("vce.vnf-id", vnf_id);
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, Vce.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
-
-
- /* (non-Javadoc)
- * @see org.onap.ccsdk.sli.adaptors.resource.aic.AnAIClient#requestSdnZoneQuery(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public boolean deleteNetworkVceData(String vnf_id, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vce");
- request.addRequestProperty("vce.vnf-id", vnf_id);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteNetworkVceData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- /* (non-Javadoc)
- * @see org.onap.ccsdk.sli.adaptors.resource.aic.AnAIClient#postNetworkVceData(java.lang.String, org.onap.ccsdk.sli.adaptors.resource.aic.aai.VCERequest)
- */
- @Override
- public boolean postNetworkVceData(String vnf_id, Vce data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vce");
- request.addRequestProperty("vce.vnf-id", vnf_id);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestGenericVnfData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
-
- @Override
public SearchResults requestServiceInstanceURL(String svc_instance_id) throws AAIServiceException {
SearchResults response = null;
InputStream inputStream = null;
@@ -526,7 +425,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
String path = svc_inst_qry_path;
path = path.replace("{svc-instance-id}", encodeQuery(svc_instance_id));
- String request_url = target_uri+path;
+ String request_url = targetUri+path;
URL http_req_url = new URL(request_url);
HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.GET);
@@ -577,48 +476,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
return response;
}
- @Override
- public ServiceInstance requestServiceInterfaceData(String customer_id, String service_type, String svc_instance_id) throws AAIServiceException {
- ServiceInstance response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("service-instance");
- request.addRequestProperty("customer.global-customer-id", customer_id);
- request.addRequestProperty("service-subscription.service-type", service_type);
- request.addRequestProperty("service-instance.service-instance-id", svc_instance_id);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, ServiceInstance.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestServiceInterfaceData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postServiceInterfaceData(String customer_id, String service_type, String svc_instance_id, ServiceInstance data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("service-instance");
- request.addRequestProperty("customer.global-customer-id", customer_id);
- request.addRequestProperty("service-subscription.service-type", service_type);
- request.addRequestProperty("service-instance.service-instance-id", svc_instance_id);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestGenericVnfData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
private static Properties initialize(URL url ) throws ConfigurationException {
@@ -719,118 +576,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
return encrypted_url;
}
- @Override
- public VplsPe requestNetworkVplsPeData(String equipment_name)throws AAIServiceException {
- VplsPe response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vpls-pe");
- request.addRequestProperty("vpls-pe.equipment-name", equipment_name);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, VplsPe.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(),
- exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postNetworkVplsPeData(String equipment_name, VplsPe data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vpls-pe");
- request.addRequestProperty("vpls-pe.equipment-name", equipment_name);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestGenericVnfData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deleteNetworkVplsPeData(String vnf_id, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vpls-pe");
- request.addRequestProperty("vpls-pe.equipment-name", vnf_id);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteNetworkVplsPeData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public Complex requestNetworkComplexData(String pLocId) throws AAIServiceException {
- Complex response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("complex");
- request.addRequestProperty("complex.physical-location-id", pLocId);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, Complex.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestNetworkComplexData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postNetworkComplexData(String vnf_id, Complex data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("complex");
- request.addRequestProperty("complex.physical-location-id", vnf_id);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postNetworkComplexData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deleteNetworkComplexData(String pLocId, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("complex");
- request.addRequestProperty("complex.physical-location-id", pLocId);
-
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteNetworkComplexData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
/*
* (non-Javadoc)
@@ -862,133 +608,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
- @Override
- public boolean postVServerData(String tenantId, String vserverId, String cloudOwner, String cloudRegionId, Vserver data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vserver");
- request.addRequestProperty("cloud-region.cloud-owner", cloudOwner);
- request.addRequestProperty("cloud-region.cloud-region-id", cloudRegionId);
- request.addRequestProperty("tenant.tenant-id", tenantId);
- request.addRequestProperty("vserver.vserver-id", vserverId);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postNetworkComplexData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deleteVServerData(String tenant_id, String vserver_id, String cloudOwner, String cloudRegionId, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vserver");
-
- request.addRequestProperty("vserver.vserver-id", vserver_id);
- request.addRequestProperty("tenant.tenant-id", tenant_id);
- request.addRequestProperty("cloud-region.cloud-owner", cloudOwner);
- request.addRequestProperty("cloud-region.cloud-region-id",cloudRegionId);
-
- response = executor.delete(request, resourceVersion);
-
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteVServerData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.onap.ccsdk.sli.adaptors.aai.AAIClient#requestCtagPoolData(String)
- */
- @Override
- public CtagPool requestCtagPoolData(String physical_location_id, String target_pe, String availability_zone_name) throws AAIServiceException {
- CtagPool response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("ctag-pool");
-
- request.addRequestProperty("ctag-pool.target-pe", target_pe);
- request.addRequestProperty("ctag-pool.availability-zone-name", availability_zone_name);
- request.addRequestProperty("complex.physical-location-id", physical_location_id);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, CtagPool.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestNetworkVceData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- //==================== DvsSwitch ======================
- @Override
- public DvsSwitch requestDvsSwitchData(String vnf_id) throws AAIServiceException {
- DvsSwitch response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("dvs-switch");
- request.addRequestProperty("dvs-switch.switch-name", vnf_id);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, DvsSwitch.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestDvsSwitchData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postDvsSwitchData(String switch_name, DvsSwitch data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("dvs-switch");
- request.addRequestProperty("dvs-switch.switch-name", switch_name);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deleteDvsSwitchData(String vnf_id, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("dvs-switch");
- request.addRequestProperty("dvs-switch.switch-name", vnf_id);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteDvsSwitchData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
//================== End of DvsSwitch =================
//==================== PhysicalLink ======================
@Override
@@ -1045,518 +664,8 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
return response;
}
- //================== End of PhysicalLink =================
- //==================== PInterface ======================
- @Override
- public PInterface requestPInterfaceData(String hostname, String interfaceName) throws AAIServiceException {
- PInterface response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("p-interface");
- request.addRequestProperty("p-interface.interface-name", interfaceName);
- request.addRequestProperty("pserver.hostname", hostname);
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, PInterface.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postPInterfaceData(String hostname, String interfaceName, PInterface request) throws AAIServiceException {
- InputStream inputStream = null;
-
- try {
-
- ObjectMapper mapper = getObjectMapper();
- String json_text = mapper.writeValueAsString(request);
-
- SSLSocketFactory sockFact = CTX.getSocketFactory();
-
- String request_url = target_uri+p_interface_path;
- String encoded_vnf = encodeQuery(hostname);
- request_url = request_url.replace("{hostname}", encoded_vnf) ;
- encoded_vnf = encodeQuery(interfaceName);
- request_url = request_url.replace("{interface-name}", encoded_vnf) ;
- URL http_req_url = new URL(request_url);
-
- HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.PUT);
-
- if (json_text != null) {
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- osw.close();
- }
-
- LOGwriteFirstTrace("PUT", request_url);
- LOGwriteDateTrace("hostname", hostname);
- LOGwriteDateTrace("interface-name", interfaceName);
- LOGwriteDateTrace("PInterface", json_text);
-
- // Check for errors
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- // Process the response
- BufferedReader reader;
- String line = null;
- reader = new BufferedReader( new InputStreamReader( inputStream ) );
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, "SUCCESS", (stringBuilder.length() > 0) ? stringBuilder.toString() : "{no-data}");
- return true;
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
-
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postPInterfaceData", exc);
- throw new AAIServiceException(exc);
- } finally {
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (Exception exc) {
-
- }
- }
- }
-
- @Override
- public boolean deletePInterfaceData(String hostname, String interfaceName, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("p-interface");
- request.addRequestProperty("p-interface.interface-name", interfaceName);
- request.addRequestProperty("pserver.hostname", hostname);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deletePInterfaceData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
- //================== End of PInterface =================
- //==================== SitePairSet ======================
- @Override
- public SitePairSet requestSitePairSetData(String sitePairSetId) throws AAIServiceException {
- SitePairSet response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("site-pair-set");
- request.addRequestProperty("site-pair-set.site-pair-set-id", sitePairSetId);
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, SitePairSet.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postSitePairSetData(String linkName, SitePairSet request) throws AAIServiceException {
- InputStream inputStream = null;
-
- try {
-
- ObjectMapper mapper = getObjectMapper();
- String json_text = mapper.writeValueAsString(request);
-
- SSLSocketFactory sockFact = CTX.getSocketFactory();
-
- String request_url = target_uri+site_pair_set_path;
- String encoded_vnf = encodeQuery(linkName);
- request_url = request_url.replace("{site-pair-set-id}", encoded_vnf) ;
- URL http_req_url = new URL(request_url);
-
- HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.PUT);
-
- if (json_text != null) {
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- osw.close();
- }
-
- LOGwriteFirstTrace("PUT", request_url);
- LOGwriteDateTrace("link-name", linkName);
- LOGwriteDateTrace("SitePairSet", json_text);
-
- // Check for errors
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- // Process the response
- BufferedReader reader;
- String line = null;
- reader = new BufferedReader( new InputStreamReader( inputStream ) );
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, "SUCCESS", (stringBuilder.length() > 0) ? stringBuilder.toString() : "{no-data}");
- return true;
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
-
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postSitePairSetData", exc);
- throw new AAIServiceException(exc);
- } finally {
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (Exception exc) {
-
- }
- }
- }
-
- @Override
- public boolean deleteSitePairSetData(String linkName, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("site-pair-set");
- request.addRequestProperty("site-pair-set.site-pair-set-id", linkName);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteSitePairSetData", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
- //================== End of SitePairSet =================
- //==================== Service ======================
- @Override
- public Service requestServiceData(String serviceId) throws AAIServiceException {
- Service response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("service");
- request.addRequestProperty("service.service-id", serviceId);
-
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, Service.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestServiceData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postServiceData(String linkName, Service request) throws AAIServiceException {
- InputStream inputStream = null;
-
- try {
-
- ObjectMapper mapper = getObjectMapper();
- String json_text = mapper.writeValueAsString(request);
-
- SSLSocketFactory sockFact = CTX.getSocketFactory();
-
- String request_url = target_uri+service_path;
- String encoded_vnf = encodeQuery(linkName);
- request_url = request_url.replace("{service-id}", encoded_vnf) ;
- URL http_req_url = new URL(request_url);
-
- HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.PUT);
-
- if (json_text != null) {
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- osw.close();
- }
-
- LOGwriteFirstTrace("PUT", request_url);
- LOGwriteDateTrace("service-id", linkName);
- LOGwriteDateTrace("Service", json_text);
-
- // Check for errors
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- // Process the response
- BufferedReader reader;
- String line = null;
- reader = new BufferedReader( new InputStreamReader( inputStream ) );
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, "SUCCESS", (stringBuilder.length() > 0) ? stringBuilder.toString() : "{no-data}");
- return true;
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
-
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postServiceData", exc);
- throw new AAIServiceException(exc);
- } finally {
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (Exception exc) {
-
- }
- }
- }
-
- @Override
- public boolean deleteServiceData(String service_id, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("service");
- request.addRequestProperty("service.service-id", service_id);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteServiceData", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
- //================== End of Service =================
-
-
- @Override
- public Vserver dataChangeRequestVServerData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), Vserver.class);
- }
-
- @Override
- public Pserver dataChangeRequestPServerData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), Pserver.class);
- }
-
- @Override
- public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), CtagPool.class);
- }
-
- @Override
- public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), VplsPe.class);
- }
-
- @Override
- public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), DvsSwitch.class);
- }
-
- @Override
- public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), OamNetwork.class);
- }
-
- @Override
- public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), AvailabilityZone.class);
- }
-
- @Override
- public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return this.getResource(url.toString(), Complex.class);
- }
-
- /* DELETE */
- @Override
- public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
-
- @Override
- public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
-
- @Override
- public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
-
- @Override
- public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
-
- @Override
- public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
- //OAM-Network:
- @Override
- public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
- //Availability-Zone:
- @Override
- public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
- //Complex:
- @Override
- public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
-
- if(url == null) {
- throw new NullPointerException();
- }
-
- return deleteAAIEntity(url, Object.class.getClass().getEnclosingMethod()
- .getName());
- }
- private boolean deleteAAIEntity(URL url, String caller) throws AAIServiceException {
+ public boolean deleteAAIEntity(URL url, String caller) throws AAIServiceException {
if(url == null) {
throw new NullPointerException();
@@ -1662,297 +771,15 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
return response != null ? type.cast(response) : response;
}
- @Override
- public Pserver requestPServerData(String hostname) throws AAIServiceException {
- Pserver response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("pserver");
- request.addRequestProperty("pserver.hostname", hostname);
-
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, Pserver.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestPServerData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postPServerData(String hostname, Pserver data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("pserver");
- request.addRequestProperty("pserver.hostname", hostname);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deletePServerData(String hostname, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("pserver");
- request.addRequestProperty("pserver.hostname", hostname);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deletePServerData", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
-
-
- @Override
- public L3Network requestL3NetworkData(String networkId) throws AAIServiceException {
- L3Network response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("l3-network");
- request.addRequestProperty("l3-network.network-id", networkId);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, L3Network.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestL3NetworkData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public L3Network requestL3NetworkQueryByName(String networkName) throws AAIServiceException {
- L3Network response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("l3-network");
- request.addRequestProperty("l3-network.network-name", networkName);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, L3Network.class);
- }
-
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestL3NetworkQueryByName", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean postL3NetworkData(String networkId, L3Network data) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("l3-network");
- request.addRequestProperty("l3-network.network-id", networkId);
- request.setRequestObject(data);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(Object.class.getClass().getEnclosingMethod().getName(), exc);
- throw new AAIServiceException(exc);
- }
- }
-
- @Override
- public boolean deleteL3NetworkData(String networkId, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("l3-network");
- request.addRequestProperty("l3-network.network-id", networkId);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteL3NetworkData", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
-
-
- @Override
- public VpnBinding requestVpnBindingData(String vpnId) throws AAIServiceException {
- VpnBinding response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vpn-binding");
- request.addRequestProperty("vpn-binding.vpn-id", vpnId);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, VpnBinding.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestVpnBindingData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public boolean deleteVpnBindingData(String vpnId, String resourceVersion) throws AAIServiceException {
- boolean response = false;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vpn-binding");
- request.addRequestProperty("vpn-binding.vpn-id", vpnId);
- response = executor.delete(request, resourceVersion);
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("deleteVpnBindingData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
-
- @Override
- public VnfImage requestVnfImageData(String vnf_image_uuid) throws AAIServiceException {
- VnfImage response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("vnf-image");
- request.addRequestProperty("vnf-image.vnf-image-uuid", vnf_image_uuid);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, VnfImage.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestVnfImageData", exc);
- throw new AAIServiceException(exc);
- }
- return response;
- }
-
- @Override
- public VnfImage requestVnfImageDataByVendorModel(String vendor, String model) throws AAIServiceException {
- return requestVnfImageDataByVendorModelVersion(vendor, model, null);
- }
-
- @Override
- public VnfImage requestVnfImageDataByVendorModelVersion(String vendor, String model, String version) throws AAIServiceException
- {
- List<VnfImage> responseList = new ArrayList<VnfImage>();
- VnfImage response = null;
- InputStream inputStream = null;
-
- try {
- String request_url = target_uri+vnf_image_query_path + (version==null? "": "&application-version={application_version}");
- request_url = request_url.replace("{application_vendor}", encodeQuery(vendor)) ;
- request_url = request_url.replace("{application_model}", encodeQuery(model)) ;
- if(version != null) {
- request_url = request_url.replace("{application_version}", encodeQuery(version)) ;
- }
- URL http_req_url = new URL(request_url);
-
- HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.GET);
-
- LOGwriteFirstTrace(HttpMethod.GET, http_req_url.toString());
- LOGwriteDateTrace("application_vendor", vendor);
- LOGwriteDateTrace("application_model", model);
- if(version != null) {
- LOGwriteDateTrace("application_version", version);
- }
-
- // Check for errors
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- // Process the response
- LOG.debug("HttpURLConnection result:" + responseCode);
- if(inputStream == null) inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
- BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
-
- ObjectMapper mapper = getObjectMapper();
-
- if (responseCode == HttpURLConnection.HTTP_OK) {
- response = mapper.readValue(reader, VnfImage.class);
- String original_buffer = mapper.writeValueAsString(response);
- LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, "SUCCESS", original_buffer);
- if(response.getApplicationVendor() == null /*&& response.getAdditionalProperties() != null && !response.getAdditionalProperties().isEmpty()*/){
- LOG.warn("A List of multiple VNF-IMAGE entries has been returned");
- VnfImages listOfObjects = mapper.readValue(original_buffer, VnfImages.class);
- if(!listOfObjects.getVnfImage().isEmpty()) {
- response = listOfObjects.getVnfImage().get(0);
- }
- }
- } else if(responseCode == HttpURLConnection.HTTP_NOT_FOUND ) {
- LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", "Entry does not exist.");
- return response;
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
- throw new AAIServiceException(responseCode, errorresponse);
- }
-
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestVnfImageData", exc);
- throw new AAIServiceException(exc);
- } finally {
- if(inputStream != null){
- try {
- inputStream.close();
- } catch(Exception exc) {
-
- }
- }
- }
- return response;
- }
-
public boolean sendNotify(NotifyEvent event, String serviceInstanceId, String pathCode) throws AAIServiceException {
InputStream inputStream = null;
try {
- String selfLink = selflink_fqdn;
+ String selfLink = selflinkFqdn;
if(SELFLINK_AVPN != null && SELFLINK_AVPN.equals(pathCode)) {
- selfLink = selflink_avpn;
+ selfLink = selflinkAvpn;
}
selfLink = selfLink.replace("{service-instance-id}", encodeQuery(serviceInstanceId));
event.setSelflink(selfLink);
@@ -1962,7 +789,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
SSLSocketFactory sockFact = CTX.getSocketFactory();
- String request_url = target_uri+ubb_notify_path;
+ String request_url = targetUri+ubb_notify_path;
URL http_req_url = new URL(request_url);
HttpURLConnection con = getConfiguredConnection(http_req_url, HttpMethod.PUT);
@@ -2026,7 +853,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
InputStream inputStream = null;
try {
- String request_url = target_uri+query_nodes_path;
+ String request_url = targetUri+queryNodesPath;
request_url = request_url.replace("{node-type}", encodeQuery(node_type)) ;
request_url = request_url.replace("{entity-identifier}", entityIdentifier) ;
request_url = request_url.replace("{entity-name}", encodeQuery(entityName)) ;
@@ -2225,511 +1052,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
return entity;
}
- class AAIRequestExecutor implements AAIExecutorInterface {
-
- @Override
- public String get(AAIRequest request) throws AAIServiceException {
- String response = null;
- InputStream inputStream = null;
- HttpURLConnection con = null;
- URL requestUrl = null;
-
- String requestId = UUID.randomUUID().toString();
- StringBuilder errorStringBuilder = new StringBuilder();
-
- try {
-
- if(request.getRequestObject() != null) {
- requestUrl = request.getRequestUrl(HttpMethod.POST, null);
- requestUrl = appendDepth(requestUrl, request);
- con = getConfiguredConnection(requestUrl, HttpMethod.POST);
- String json_text = request.toJSONString();
- LOGwriteDateTrace("data", json_text);
- logMetricRequest(requestId, "POST "+requestUrl.getPath(), json_text, requestUrl.getPath());
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- } else {
- requestUrl = request.getRequestUrl(HttpMethod.GET, null);
- requestUrl = appendDepth(requestUrl, request);
- con = getConfiguredConnection(requestUrl, HttpMethod.GET);
- logMetricRequest(requestId, "GET "+requestUrl.getPath(), "", requestUrl.getPath());
- }
-
- // Check for errors
- String responseMessage = con.getResponseMessage();
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- // Process the response
- LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
- logMetricResponse(requestId, responseCode, responseMessage);
-
- if(inputStream == null) inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
- BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
-
- ObjectMapper mapper = getObjectMapper();
-
- if (responseCode == HttpURLConnection.HTTP_OK) {
- StringBuilder stringBuilder = new StringBuilder();
- String line = null;
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- response = stringBuilder.toString();
- try {
- Object object = mapper.readValue(response, Object.class);
- LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, responseMessage, mapper.writeValueAsString(object));
- } catch(Exception exc) {
- LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, responseMessage, mapper.writeValueAsString(response));
- }
- } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
- LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist.");
- ErrorResponse errorresponse = null;
- try {
- errorresponse = mapper.readValue(reader, ErrorResponse.class);
- } catch(Exception exc) {
- errorresponse = new ErrorResponse();
- RequestError requestError = new RequestError();
- ServiceException serviceException = new ServiceException();
- serviceException.setText("Entry does not exist.");
- requestError.setServiceException(serviceException);
- errorresponse.setRequestError(requestError );
- }
- throw new AAIServiceException(responseCode, errorresponse);
- } else if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
- StringBuilder stringBuilder = new StringBuilder();
- String line = null;
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, responseMessage, stringBuilder.toString());
- ServiceException serviceException = new ServiceException();
- serviceException.setMessageId("HTTP_UNAUTHORIZED");
- serviceException.setText(stringBuilder.toString());
- RequestError requestError = new RequestError();
- requestError.setServiceException(serviceException);
- ErrorResponse errorresponse = new ErrorResponse();
- errorresponse.setRequestError(requestError);
- throw new AAIServiceException(responseCode, errorresponse);
- } else {
-// StringBuilder errorStringBuilder = new StringBuilder();
- String line = null;
- while( ( line = reader.readLine() ) != null ) {
- errorStringBuilder.append("\n").append( line );
- }
-
- ErrorResponse errorresponse = mapper.readValue(errorStringBuilder.toString(), ErrorResponse.class);
-// ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
- throw new AAIServiceException(responseCode, errorresponse);
- }
-
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn(errorStringBuilder.toString(), exc);
- throw new AAIServiceException(exc);
- } finally {
- if (con != null) {
- con.disconnect();
- }
- if(inputStream != null){
- try {
- inputStream.close();
- } catch(Exception exc) {
-
- }
- }
- }
- return response;
- }
-
- private URL appendDepth(URL requestUrl, AAIRequest request) throws MalformedURLException {
-
- String depth = request.requestProperties.getProperty("depth", "1");
- String path = requestUrl.toString();
- if(path.contains("?depth=") || path.contains("&depth=")) {
- return requestUrl;
- } else {
- if(path.contains("?")) {
- path = String.format("%s&depth=%s", path, depth);
- } else {
- path = String.format("%s?depth=%s", path, depth);
- }
- return new URL(path);
- }
- }
-
- @Override
- public String post(AAIRequest request) throws AAIServiceException {
- InputStream inputStream = null;
- String requestId = UUID.randomUUID().toString();
- HttpURLConnection con = null;
-
- try {
- String resourceVersion = null;
- AAIDatum instance = request.getRequestObject();
-
- Method getResourceVersionMethod = instance.getClass().getMethod("getResourceVersion");
- if(getResourceVersionMethod != null){
- try {
- getResourceVersionMethod.setAccessible(true);
- Object object = getResourceVersionMethod.invoke(instance);
- if(object != null)
- resourceVersion = object.toString();
- } catch (InvocationTargetException x) {
- Throwable cause = x.getCause();
- }
- }
-
- URL requestUrl = null;
- con = getConfiguredConnection(requestUrl = request.getRequestUrl(HttpMethod.PUT, resourceVersion), HttpMethod.PUT);
- ObjectMapper mapper = getObjectMapper();
- String json_text = request.toJSONString();
-
- LOGwriteDateTrace("data", json_text);
- logMetricRequest(requestId, "PUT "+requestUrl.getPath(), json_text, requestUrl.getPath());
-
- if (json_text != null) {
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- }
- // Check for errors
- String responseMessage = con.getResponseMessage();
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
- logMetricResponse(requestId,responseCode, responseMessage);
-
- // Process the response
- BufferedReader reader;
- String line = null;
- reader = new BufferedReader( new InputStreamReader( inputStream ) );
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, responseMessage, (stringBuilder != null) ? stringBuilder.toString() : "{no-data}");
- return stringBuilder.toString();
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
-
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("AAIRequestExecutor.post", exc);
- throw new AAIServiceException(exc);
- } finally {
- if (con != null) {
- con.disconnect();
- }
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (Exception exc) {
-
- }
- }
- }
-
- @Override
- public Boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException {
- Boolean response = null;
- InputStream inputStream = null;
- String requestId = UUID.randomUUID().toString();
-
- if(resourceVersion == null) {
- throw new AAIServiceException("resource-version is required for DELETE request");
- }
-
- try {
- URL requestUrl = null;
- HttpURLConnection conn = getConfiguredConnection(requestUrl = request.getRequestUrl(HttpMethod.DELETE, resourceVersion), HttpMethod.DELETE);
- logMetricRequest(requestId, "DELETE "+requestUrl.getPath(), "", requestUrl.getPath());
- conn.setDoOutput(true);
-
- // Check for errors
- String responseMessage = conn.getResponseMessage();
- int responseCode = conn.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = conn.getInputStream();
- } else {
- inputStream = conn.getErrorStream();
- }
-
- // Process the response
- LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
- logMetricResponse(requestId,responseCode, responseMessage);
-
- if(inputStream == null) inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
- BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
- String line = null;
-
- ObjectMapper mapper = getObjectMapper();
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, responseMessage, stringBuilder.toString());
- response = true;
- } else if(responseCode == HttpURLConnection.HTTP_NOT_FOUND ) {
- LOGwriteEndingTrace(responseCode, responseMessage, "Entry does not exist.");
- response = false;
- } else {
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("delete", exc);
- throw new AAIServiceException(exc);
- } finally {
- if(inputStream != null){
- try {
- inputStream.close();
- } catch(Exception exc) {
-
- }
- }
- }
- return response;
- }
-
- @Override
- public Object query(AAIRequest request, Class clas) throws AAIServiceException {
- Object response = null;
- InputStream inputStream = null;
- HttpURLConnection con = null;
- URL requestUrl = null;
- String requestId = UUID.randomUUID().toString();
-
- try {
- requestUrl = request.getRequestQueryUrl(HttpMethod.GET);
- con = getConfiguredConnection(requestUrl , HttpMethod.GET);
- logMetricRequest(requestId, "GET "+requestUrl.getPath(), "", requestUrl.getPath());
-
- // Check for errors
- String responseMessage = con.getResponseMessage();
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- logMetricResponse(requestId,responseCode, responseMessage);
- ObjectMapper mapper = getObjectMapper();
-
- if (responseCode == HttpURLConnection.HTTP_OK) {
- // Process the response
- BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
- response = mapper.readValue(reader, clas);
- LOGwriteEndingTrace(HttpURLConnection.HTTP_OK, "SUCCESS", mapper.writeValueAsString(response));
- } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
- LOGwriteEndingTrace(responseCode, "HTTP_NOT_FOUND", "Entry does not exist.");
- return response;
- } else {
- BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream ) );
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, "FAILURE", mapper.writeValueAsString(errorresponse));
- throw new AAIServiceException(responseCode, errorresponse);
- }
-
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("GET", exc);
- throw new AAIServiceException(exc);
- } finally {
- if(inputStream != null){
- try {
- inputStream.close();
- } catch(Exception exc) {
-
- }
- }
- if (con != null) {
- con.disconnect();
- }
- }
- return response;
- }
-
- @Override
- public Boolean patch(AAIRequest request, String resourceVersion) throws AAIServiceException {
- InputStream inputStream = null;
- String requestId = UUID.randomUUID().toString();
-
- try {
- AAIDatum instance = request.getRequestObject();
- if(instance instanceof ResourceVersion) {
- resourceVersion = ((ResourceVersion)instance).getResourceVersion();
- }
-
- URL requestUrl = null;
- HttpURLConnection con = getConfiguredConnection(requestUrl = request.getRequestUrl("PATCH", resourceVersion), "PATCH");
- ObjectMapper mapper = getObjectMapper();
- String json_text = request.toJSONString();
-
- LOGwriteDateTrace("data", json_text);
- logMetricRequest(requestId, "PATCH "+requestUrl.getPath(), json_text, requestUrl.getPath());
-
- if (json_text != null) {
- OutputStreamWriter osw = new OutputStreamWriter(con.getOutputStream());
- osw.write(json_text);
- osw.flush();
- osw.close();
- }
-
- // Check for errors
- String responseMessage = con.getResponseMessage();
- int responseCode = con.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- inputStream = con.getInputStream();
- } else {
- inputStream = con.getErrorStream();
- }
-
- LOG.info("HttpURLConnection result: " + responseCode + " : " + responseMessage);
- logMetricResponse(requestId,responseCode, responseMessage);
-
- // Process the response
- BufferedReader reader;
- String line = null;
- reader = new BufferedReader( new InputStreamReader( inputStream ) );
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-
- if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- LOGwriteEndingTrace(responseCode, responseMessage,
- (stringBuilder.length() > 0) ? stringBuilder.toString() : "{no-data}");
- return true;
- } else {
- StringBuilder stringBuilder = new StringBuilder();
-
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append("\n").append( line );
- }
- LOG.info(stringBuilder.toString());
-
-
- ErrorResponse errorresponse = mapper.readValue(reader, ErrorResponse.class);
- LOGwriteEndingTrace(responseCode, responseMessage, mapper.writeValueAsString(errorresponse));
-
- throw new AAIServiceException(responseCode, errorresponse);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("AAIRequestExecutor.patch", exc);
- throw new AAIServiceException(exc);
- } finally {
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (Exception exc) {
-
- }
- }
- }
- }
-
- @Override
- public Tenant requestTenantData(String tenant_id, String cloudOwner, String cloudRegionId) throws AAIServiceException {
- Tenant response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("tenant");
- request.addRequestProperty("tenant.tenant-id", tenant_id);
- request.addRequestProperty("cloud-region.cloud-owner", cloudOwner);
- request.addRequestProperty("cloud-region.cloud-region-id", cloudRegionId);
-
- String rv = executor.get(request);
- if(rv != null) {
- ObjectMapper mapper = getObjectMapper();
- response = mapper.readValue(rv, Tenant.class);
- }
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestTenantData", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
-
- @Override
- public Tenant requestTenantDataByName(String tenant_name, String cloudOwner, String cloudRegionId) throws AAIServiceException {
- Tenant response = null;
-
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("tenant");
- request.addRequestProperty("tenant.tenant-name", tenant_name);
- request.addRequestProperty("cloud-region.cloud-owner", cloudOwner);
- request.addRequestProperty("cloud-region.cloud-region-id", cloudRegionId);
- Object rv = executor.query(request, Tenant.class);
- if(rv == null)
- return (Tenant)null;
- else
- response = (Tenant)rv;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("requestTenantDataByName", exc);
- throw new AAIServiceException(exc);
- }
-
- return response;
- }
-
-
- @Override
- public boolean postTenantData(String tenant_id, String cloudOwner, String cloudRegionId, Tenant tenannt) throws AAIServiceException {
- try {
- AAIRequest request = AAIRequest.getRequestFromResource("tenant");
- request.addRequestProperty("tenant.tenant-id", tenant_id);
- request.addRequestProperty("cloud-region.cloud-owner", cloudOwner);
- request.addRequestProperty("cloud-region.cloud-region-id", cloudRegionId);
- request.setRequestObject(tenannt);
- Object response = executor.post(request);
- return true;
- } catch(AAIServiceException aaiexc) {
- throw aaiexc;
- } catch (Exception exc) {
- LOG.warn("postTenantData", exc);
- throw new AAIServiceException(exc);
- }
- }
-
-
@Override
public String getTenantIdFromVserverUrl(URL url) {
@@ -2795,7 +1117,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
@Override
- public AAIRequestExecutor getExecutor() {
+ public AAIExecutorInterface getExecutor() {
return executor;
}
@@ -2990,6 +1312,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(introspector, secondary));
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(Include.NON_EMPTY);
return mapper;
}
@@ -3000,8 +1323,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
String targetEntity = "A&AI";
String targetVirtualEntity = null;
- targetServiceName = "";
-
ml.logRequest(svcInstanceId, svcName, partnerName, targetEntity, targetServiceName, targetVirtualEntity, msg);
}
@@ -3052,6 +1373,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
String normResource = resource.split(":")[0];
switch(normResource){
+ case "custom-query":
case "formatted-query":
case "generic-query":
case "named-query":
@@ -3080,6 +1402,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
String normResource = resource.split(":")[0];
switch(normResource){
+ case "custom-query":
case "formatted-query":
case "generic-query":
case "named-query":
@@ -3108,6 +1431,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
String normResource = resource.split(":")[0];
switch(normResource){
+ case "custom-query":
case "formatted-query":
case "generic-query":
case "named-query":
@@ -3193,7 +1517,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
/* (non-Javadoc)
- * @see org.openecomp.sdnc.sli.aai.haha#query(org.openecomp.sdnc.sli.aai.AAIRequest)
+ * @see org.onap.ccsdk.sli.core.sli.aai.haha#query(org.onap.ccsdk.sli.core.sli.aai.AAIRequest)
*/
@Override
public String query(AAIRequest request) throws AAIServiceException {
@@ -3201,7 +1525,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
/* (non-Javadoc)
- * @see org.openecomp.sdnc.sli.aai.haha#save(org.openecomp.sdnc.sli.aai.AAIRequest)
+ * @see org.onap.ccsdk.sli.core.sli.aai.haha#save(org.onap.ccsdk.sli.core.sli.aai.AAIRequest)
*/
@Override
public String save(AAIRequest request) throws AAIServiceException {
@@ -3213,11 +1537,11 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
}
/* (non-Javadoc)
- * @see org.openecomp.sdnc.sli.aai.haha#delete(org.openecomp.sdnc.sli.aai.AAIRequest, java.lang.String)
+ * @see org.onap.ccsdk.sli.core.sli.aai.haha#delete(org.onap.ccsdk.sli.core.sli.aai.AAIRequest, java.lang.String)
*/
@Override
public boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException {
- return executor.patch(request, resourceVersion);
+ return executor.delete(request, resourceVersion);
}
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
index 0566aac7..126b9b26 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceUtils.java
@@ -22,6 +22,7 @@
package org.onap.ccsdk.sli.adaptors.aai;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -111,6 +112,16 @@ public class AAIServiceUtils {
return null;
}
+ public static Method getRelationshipListGetterMethodFromClassDefinition(Class resourceClass) {
+ Method getRelationshipListMethod = null;
+
+ try {
+ getRelationshipListMethod = resourceClass.getMethod("getRelationshipList");
+ } catch(Exception exc) {
+ getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
+ }
+ return getRelationshipListMethod;
+ }
private static Logger getLogger() {
return LOG;
@@ -311,6 +322,7 @@ public class AAIServiceUtils {
public static boolean isValidFormat(String resource, HashMap<String, String> nameValues) {
switch(resource){
+ case "custom-query":
case "formatted-query":
case "generic-query":
case "named-query":
@@ -329,10 +341,10 @@ public class AAIServiceUtils {
Set<String> keys = nameValues.keySet();
for(String key : keys) {
if(!key.contains(".")) {
- if("depth".equals(key) || "related-to".equals(key) || "related_to".equals(key) || "related-link".equals(key) || "related_link".equals(key) || "selflink".equals(key))
+ if("depth".equals(key) || "related-to".equals(key) || "related_to".equals(key) || "related-link".equals(key) || "related_link".equals(key) || "selflink".equals(key) || "resource_path".equals(key))
continue;
else {
- getLogger().warn(String.format("key %s is incompatible with resource type '%s'", key, resource));
+ getLogger().warn(String.format("key '%s' is incompatible with resource type '%s'", key, resource));
}
}
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java
index 98de85a5..6dd11238 100644
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericQueryRequest.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,9 +35,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class GenericQueryRequest extends AAIRequest {
public static final String GENERIC_SEARCH_PATH = "org.onap.ccsdk.sli.adaptors.aai.query.generic";
-
+
private final String generic_search_path;
-
+
public static final String START_NODE_TYPE = "start-node-type";
public static final String IDENTIFIER = "identifier";
public static final String VALUE = "value";
@@ -47,27 +47,6 @@ public class GenericQueryRequest extends AAIRequest {
generic_search_path = configProperties.getProperty(GENERIC_SEARCH_PATH);
}
-
-// @Override
-// public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
-//
-// String request_url = target_uri+generic_search_path;
-// String key = START_NODE_TYPE;
-//
-// String encoded_vnf = encodeQuery(requestProperties.getProperty(key));
-// request_url = request_url.replace("{vnf-id}", encoded_vnf) ;
-//
-// if(resourceVersion != null) {
-// request_url = request_url +"?resource-version="+resourceVersion;
-// }
-// URL http_req_url = new URL(request_url);
-//
-// aaiService.LOGwriteFirstTrace(method, http_req_url.toString());
-//
-//
-// return http_req_url;
-// }
-
@Override
public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
@@ -81,12 +60,12 @@ public class GenericQueryRequest extends AAIRequest {
URL http_req_url = new URL(request_url);
aaiService.LOGwriteFirstTrace(method, http_req_url.toString());
-
+
return http_req_url;
}
-
+
@Override
- public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
+ public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
return getRequestUrl(method, null);
}
@@ -126,19 +105,19 @@ public class GenericQueryRequest extends AAIRequest {
String encoded_vnf = encodeQuery(requestProperties.getProperty(key));
request_url = request_url.replace("{identifier}", encoded_vnf) ;
aaiService.LOGwriteDateTrace("identifier", requestProperties.getProperty(key));
-
+
key = VALUE;
encoded_vnf = encodeQuery(requestProperties.getProperty(key));
request_url = request_url.replace("{value}", encoded_vnf) ;
aaiService.LOGwriteDateTrace("value", requestProperties.getProperty(key));
-
+
key = START_NODE_TYPE;
encoded_vnf = encodeQuery(requestProperties.getProperty(key));
request_url = request_url.replace("{start-node-type}", encoded_vnf) ;
aaiService.LOGwriteDateTrace("start-node-type", requestProperties.getProperty(key));
-
+
return request_url;
}
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java
index dd192b79..a272cf07 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequest.java
@@ -24,7 +24,9 @@ package org.onap.ccsdk.sli.adaptors.aai;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -32,7 +34,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
+import javax.xml.bind.annotation.XmlType;
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
import org.openecomp.aai.inventory.v11.L3Network;
import org.openecomp.aai.inventory.v11.L3Networks;
@@ -153,10 +155,15 @@ public class GenericRequest extends AAIRequest {
Field field = fields[0];
String fieldName = field.getName();
XmlElement annotation = field.getAnnotation(XmlElement.class);
- String primaryId = annotation.name();
+ String primaryId = null;
+ if(annotation != null) {
+ primaryId = annotation.name();
if("##default".equals(primaryId)) {
primaryId = fieldName;
}
+ } else {
+ primaryId = fieldName;
+ }
String token = String.format("%s/{%s}", splitKey[0], primaryId);
@@ -208,7 +215,7 @@ public class GenericRequest extends AAIRequest {
}
@Override
- public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
+ public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
return this.getRequestUrl(method, null);
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java
index f1d55fa9..f7aaccb9 100644..100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/NodesQueryRequest.java
@@ -51,7 +51,7 @@ public class NodesQueryRequest extends AAIRequest {
// @Override
// public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
//
-// String request_url = target_uri+generic_search_path;
+// String request_url = targetUri+generic_search_path;
// String key = START_NODE_TYPE;
//
// String encoded_vnf = encodeQuery(requestProperties.getProperty(key));
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipListRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipListRequest.java
new file mode 100755
index 00000000..33e3167f
--- /dev/null
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipListRequest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 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=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.aai;
+
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.message.BasicNameValuePair;
+import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
+import org.openecomp.aai.inventory.v11.RelationshipList;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+
+public class RelationshipListRequest extends GenericRequest {
+
+ public static final String SELFLINK = "selflink";
+
+ public RelationshipListRequest(AAIRequest masterRequest) {
+ super(RelationshipList.class);
+ this.addMasterRequest(masterRequest);
+ }
+
+
+ @Override
+ public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
+
+ URL url = super.getRequestUrl(method, null);
+ URIBuilder builder = new URIBuilder(url.toURI());
+ String newPath = builder.getPath() + "/relationship-list";
+ builder.setPath(newPath);
+ if(resourceVersion != null) {
+ List<NameValuePair> queryList = builder.getQueryParams();
+ NameValuePair nvp = new BasicNameValuePair("resourceVersion", resourceVersion);
+ queryList.add(nvp);
+ }
+
+ aaiService.LOGwriteFirstTrace(method, builder.toString());
+
+ return builder.build().toURL();
+ }
+}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipRequest.java
index 2b1ce3f0..a73206d4 100644..100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/RelationshipRequest.java
@@ -3,7 +3,7 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,104 +23,45 @@ package org.onap.ccsdk.sli.adaptors.aai;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.util.List;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.message.BasicNameValuePair;
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
-import org.openecomp.aai.inventory.v11.RelationshipList;
+import org.openecomp.aai.inventory.v11.Relationship;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
-public class RelationshipRequest extends AAIRequest {
+public class RelationshipRequest extends GenericRequest {
- // tenant (1602)
- public static final String RELATIONSHIP_LIST_PATH = "org.onap.ccsdk.sli.adaptors.aai.path.relationship.list";
- public static final String RELATIONSHIP_LIST_QUERY_PATH = "org.onap.ccsdk.sli.adaptors.aai.path.relationship.list.query";
-
- private final String relationship_path;
- private final String relationship_query_path;
-
- public static final String RELATED_TO = "related-to";
- public static final String RELATIONSHIP_KEY = "relationship-key";
-
- public RelationshipRequest() {
- relationship_path = configProperties.getProperty(RELATIONSHIP_LIST_PATH, "/relationship-list/relationship");
- relationship_query_path = configProperties.getProperty(RELATIONSHIP_LIST_QUERY_PATH);
+ public RelationshipRequest(AAIRequest masterRequest) {
+ super(Relationship.class);
+ this.addMasterRequest(masterRequest);
}
@Override
- public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
-
- AAIRequest masterRequest = (AAIRequest)requestProperties.get(MASTER_REQUEST);
- URL masterURL = masterRequest.getRequestUrl(method, null);
-
- String request_url = masterURL.toString();
- request_url = request_url + relationship_path;
-
- if(request_url.contains("//")) {
- request_url = request_url.replaceAll("//", "/");
- }
-
- if(requestProperties.containsKey(RELATED_TO)) {
- String encoded_vnf = encodeQuery(requestProperties.getProperty(RELATED_TO));
- request_url = request_url.replace("{related-to}", encoded_vnf) ;
- }
-
-// if(resourceVersion != null) {
-// request_url = request_url +"?resource-version="+resourceVersion;
-// }
- URL http_req_url = new URL(request_url);
-
- aaiService.LOGwriteFirstTrace(method, http_req_url.toString());
- aaiService.LOGwriteDateTrace("related-to", requestProperties.getProperty(RELATED_TO));
+ public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
- return http_req_url;
- }
-
- @Override
- public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
-
- String request_url = targetUri+relationship_query_path;
- String encoded_vnf = encodeQuery(requestProperties.getProperty(RELATIONSHIP_KEY));
- request_url = request_url.replace("{tenant-name}", encoded_vnf) ;
- URL http_req_url = new URL(request_url);
- aaiService.LOGwriteFirstTrace(method, http_req_url.toString());
- aaiService.LOGwriteDateTrace("tenant_name", requestProperties.getProperty(RELATIONSHIP_KEY));
+ URL url = super.getRequestUrl(method, null);
+ URIBuilder builder = new URIBuilder(url.toURI());
+ String newPath = builder.getPath() + "/relationship-list/relationship";
+ builder.setPath(newPath);
+ if(resourceVersion != null) {
+ List<NameValuePair> queryList = builder.getQueryParams();
+ NameValuePair nvp = new BasicNameValuePair("resourceVersion", resourceVersion);
+ queryList.add(nvp);
+ }
+
+ aaiService.LOGwriteFirstTrace(method, builder.toString());
- return http_req_url;
- }
-
-
- @Override
- public String toJSONString() {
- ObjectMapper mapper = getObjectMapper();
- Object tenant = requestDatum;
- String json_text = null;
- try {
- json_text = mapper.writeValueAsString(tenant);
- } catch (JsonProcessingException exc) {
- handleException(this, exc);
- return null;
- }
- return json_text;
- }
-
-
- @Override
- public String[] getArgsList() {
- String[] args = {RELATED_TO, RELATIONSHIP_KEY};
- return args;
- }
-
-
- @Override
- public Class<? extends AAIDatum> getModelClass() {
- return RelationshipList.class;
- }
-
- public boolean isDeleteDataRequired() {
- return true;
+ return builder.build().toURL();
}
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java
index 5074b46e..789c1316 100644..100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/UpdateRequest.java
@@ -23,6 +23,7 @@ package org.onap.ccsdk.sli.adaptors.aai;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
@@ -44,12 +45,12 @@ public class UpdateRequest extends AAIRequest {
@Override
public URL getRequestUrl(String method, String resourceVersion)
- throws UnsupportedEncodingException, MalformedURLException {
+ throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
return request.getRequestUrl(method, resourceVersion);
}
@Override
- public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
+ public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
return request.getRequestQueryUrl(method);
}
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/query/Result.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/query/Result.java
index 0bff8608..302e0313 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/query/Result.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/query/Result.java
@@ -32,11 +32,13 @@ import javax.xml.bind.annotation.XmlType;
import org.openecomp.aai.inventory.v11.CloudRegion;
import org.openecomp.aai.inventory.v11.Complex;
+import org.openecomp.aai.inventory.v11.Configuration;
import org.openecomp.aai.inventory.v11.GenericVnf;
import org.openecomp.aai.inventory.v11.L3InterfaceIpv4AddressList;
import org.openecomp.aai.inventory.v11.L3InterfaceIpv6AddressList;
import org.openecomp.aai.inventory.v11.L3Network;
import org.openecomp.aai.inventory.v11.LInterface;
+//import org.openecomp.aai.inventory.v11.OwningEntity;
import org.openecomp.aai.inventory.v11.Pserver;
import org.openecomp.aai.inventory.v11.ServiceInstance;
import org.openecomp.aai.inventory.v11.Vnfc;
@@ -51,6 +53,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@XmlType(name = "", propOrder = {
"cloud-region",
"complex",
+ "configuration",
"generic-vnf",
"l3-interface-ipv4-address-list",
"l3-interface-ipv6-address-list",
@@ -69,6 +72,8 @@ public class Result {
private CloudRegion cloudRegion;
@XmlElement(name = "complex")
private Complex complex;
+ @XmlElement(name = "configuration")
+ private Configuration configuration;
@XmlElement(name = "generic-vnf")
private GenericVnf genericVnf;
@XmlElement(name = "l3-interface-ipv4-address-list")
@@ -79,6 +84,8 @@ public class Result {
private L3Network l3Network;
@XmlElement(name = "l-interface")
private LInterface lInterface;
+// @XmlElement(name = "owning-entity")
+// private OwningEntity owningEntity;
@XmlElement(name = "pserver")
private Pserver pserver;
@XmlElement(name = "service-instance")
@@ -110,6 +117,16 @@ public class Result {
this.complex = complex;
}
+ @XmlElement(name = "configuration")
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ @XmlElement(name = "configuration")
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
@XmlElement(name = "generic-vnf")
public GenericVnf getGenericVnf ()
{
@@ -161,6 +178,16 @@ public class Result {
this.lInterface = linterface;
}
+// @XmlElement(name = "owning-entity")
+// public OwningEntity getOwningEntity() {
+// return owningEntity;
+// }
+
+// @XmlElement(name = "owning-entity")
+// public void setOwningEntity(OwningEntity owningEntity) {
+// this.owningEntity = owningEntity;
+// }
+
@XmlElement(name = "pserver")
public Pserver getPserver() {
return pserver;
@@ -194,6 +221,7 @@ public class Result {
public Vserver getVserver() {
return vserver;
}
+
@XmlElement(name = "vserver")
public void setVserver(Vserver vserver) {
this.vserver = vserver;
diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequestTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequestTest.java
index 9d1f6a53..327e4c65 100755
--- a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequestTest.java
+++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/EchoRequestTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import org.junit.AfterClass;
@@ -66,9 +67,9 @@ public class EchoRequestTest {
try {
url = request.getRequestUrl("GET", null);
assertNotNull(url);
- } catch (UnsupportedEncodingException | MalformedURLException exc) {
+ } catch (UnsupportedEncodingException | MalformedURLException | URISyntaxException exc) {
LOG.error("Failed test", exc);
- }
+ }
}
diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequestTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequestTest.java
index 5f9fc7f8..eb84cfdf 100755
--- a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequestTest.java
+++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericRequestTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -37,7 +38,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
-import org.openecomp.aai.inventory.v11.GenericVnf;
import org.openecomp.aai.inventory.v11.LInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,23 +116,23 @@ public class GenericRequestTest {
}
}
- @Test
- public void test003() {
- LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
- try
- {
- String vnf_id = "4718302b-7884-4959-a499-f470c62418ff";
-
- GenericVnf genericVnf = client.requestGenericVnfData(vnf_id);
-
- client.deleteGenericVnfData(vnf_id, genericVnf.getResourceVersion());
-
- }
- catch (Throwable e)
- {
- LOG.error("Caught exception", e);
- }
- }
+// @Test
+// public void test003() {
+// LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
+// try
+// {
+// String vnf_id = "4718302b-7884-4959-a499-f470c62418ff";
+//
+// GenericVnf genericVnf = client.requestGenericVnfData(vnf_id);
+//
+// client.deleteGenericVnfData(vnf_id, genericVnf.getResourceVersion());
+//
+// }
+// catch (Throwable e)
+// {
+// LOG.error("Caught exception", e);
+// }
+// }
@Test
@@ -143,7 +143,7 @@ public class GenericRequestTest {
try {
url = request.getRequestUrl("GET", null);
assertNotNull(url);
- } catch (UnsupportedEncodingException | MalformedURLException exc) {
+ } catch (UnsupportedEncodingException | MalformedURLException | URISyntaxException exc) {
LOG.error("Failed test", exc);
}
diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/RegressionTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/RegressionTest.java
index 4563adfc..0e81e5b5 100755
--- a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/RegressionTest.java
+++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/RegressionTest.java
@@ -75,21 +75,21 @@ public class RegressionTest {
LOG.info("----------------------- AAIResourceTest.tearDown -----------------------");
}
- @Test
- public void R1510Test05GenericVnfDataRequestDelete() {
- LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
- try
- {
- String vnf_id = "bpsx0001v-7071";
- boolean response = client.deleteGenericVnfData(vnf_id, null);
- assertTrue(response);
-
- }
- catch (Throwable e)
- {
- assert(true);
- }
- }
+// @Test
+// public void R1510Test05GenericVnfDataRequestDelete() {
+// LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
+// try
+// {
+// String vnf_id = "bpsx0001v-7071";
+// boolean response = client.deleteGenericVnfData(vnf_id, null);
+// assertTrue(response);
+//
+// }
+// catch (Throwable e)
+// {
+// assert(true);
+// }
+// }
@Test
public void R1604TestWanConnectorSave01Request()
diff --git a/aai-service/provider/src/test/resources/aaiclient.properties b/aai-service/provider/src/test/resources/aaiclient.properties
index 84d851a4..43f5fff5 100755
--- a/aai-service/provider/src/test/resources/aaiclient.properties
+++ b/aai-service/provider/src/test/resources/aaiclient.properties
@@ -28,7 +28,7 @@
#
org.onap.ccsdk.sli.adaptors.aai.ssl.trust=/opt/bvc/tls-client/truststore.client.jks
org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=adminadmin
-org.onap.ccsdk.sli.adaptors.aai.ssl.key=/opt/bvc/tls-client/keystore.client.jks
+org.onap.ccsdk.sli.adaptors.aai.ssl.key=/opt/bvc/tls-client/keystore.client.p12
org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=adminadmin
org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=true
@@ -40,7 +40,8 @@ org.onap.ccsdk.sli.adaptors.aai.application=CCSDK
#
# Configuration file for A&AI Client
#
-org.onap.ccsdk.sli.adaptors.aai.uri=https://aai.api.simpledemo.openecomp.org:8443
+org.onap.ccsdk.sli.adaptors.aai.uri=https://au3txvcaaas10-eth2.auk3.aic.cip.att.com:8443
+#org.onap.ccsdk.sli.adaptors.aai.uri=https://aai.api.simpledemo.openecomp.org:8443
#org.onap.ccsdk.sli.adaptors.aai.uri=https://aai-int2.test.att.com:8443
#