summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
authorCharles Cole <cc847m@att.com>2017-10-16 12:05:08 -0500
committerCharles Cole <cc847m@att.com>2017-10-18 11:03:38 -0500
commit506267bf7e9d961f1a6b2a989ee8a23ca67b9d61 (patch)
tree7f9079c2a19bb5d01bf4f8a7ab84b7168d9a1cb9 /controlloop/common/model-impl
parentb2d602aaedfcc9356e07dd94b6baec70c38815b8 (diff)
Add support for AAI Named Query error handling
Errors from AAI after a Named query now throw an AAIEXception. This is caught in the template to allow the resources to be removed from memory and a final failure to be thrown. Issue-ID: POLICY-314 Change-Id: I319d29ef537b2d01ca288622aac1d9dbbe05f5eb Signed-off-by: Charles Cole <cc847m@att.com>
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java3
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequestError.java33
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java3
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceException.java39
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AAIException.java48
5 files changed, 124 insertions, 2 deletions
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java
index e373c1200..b295a0635 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java
@@ -56,7 +56,7 @@ public final class AAIManager {
logger.info(url);
logger.info(httpDetails.a.toString());
logger.info(httpDetails.b);
- if (httpDetails.a == 200) {
+ if (httpDetails.b != null) {
try {
AAINQResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQResponse.class);
return response;
@@ -64,7 +64,6 @@ public final class AAIManager {
logger.error("postQuery threw: ", e);
}
}
-
return null;
}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequestError.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequestError.java
new file mode 100644
index 000000000..f6439cc4a
--- /dev/null
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequestError.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.policy.aai;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQRequestError implements Serializable {
+
+ private static final long serialVersionUID = -7742674155387022932L;
+
+ @SerializedName("serviceException")
+ public AAINQServiceException serviceException;
+}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java
index 09f983094..527a12089 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java
@@ -36,6 +36,9 @@ public class AAINQResponse implements Serializable {
@SerializedName("inventory-response-item")
public List<AAINQInventoryResponseItem> inventoryResponseItems = new LinkedList<>();
+
+ @SerializedName("requestError")
+ public AAINQRequestError requestError;
public AAINQResponse() {
}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceException.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceException.java
new file mode 100644
index 000000000..64d407de4
--- /dev/null
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceException.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.policy.aai;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQServiceException implements Serializable {
+
+ private static final long serialVersionUID = 2858343404484338546L;
+
+ @SerializedName("messageId")
+ public String messageId;
+
+ @SerializedName("text")
+ public String text;
+
+ @SerializedName("variables")
+ public String[] variables;
+}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AAIException.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AAIException.java
new file mode 100644
index 000000000..7e65ece22
--- /dev/null
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AAIException.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.policy.aai.util;
+
+public class AAIException extends Exception {
+
+ private static final long serialVersionUID = 9220983727706207465L;
+
+ public AAIException() {
+ super();
+ }
+
+ public AAIException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public AAIException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AAIException(String message) {
+ super(message);
+ }
+
+ public AAIException(Throwable cause) {
+ super(cause);
+ }
+
+}