<camel-spring-boot.version>2.20.0</camel-spring-boot.version>
<docker.location>${basedir}/target</docker.location>
<absoluteDistFilesRoot>/appl/${project.artifactId}</absoluteDistFilesRoot>
- <!-- For NO Versioning, REMOVE the /${project.version} from the <distFilesRoot>
- property, below. PLEASE, NOTE: If your ${project.version} is a "-SNAPSHOT"
- version, THIS will be used as your directory structure. If you do NOT want
- this, simply remove the "-SNAPSHOT" from your <version> declaration at the
+ <!-- For NO Versioning, REMOVE the /${project.version} from the <distFilesRoot>
+ property, below. PLEASE, NOTE: If your ${project.version} is a "-SNAPSHOT"
+ version, THIS will be used as your directory structure. If you do NOT want
+ this, simply remove the "-SNAPSHOT" from your <version> declaration at the
top of pom.xml -->
<distFilesRoot>/appl/${project.artifactId}/${project.version}</distFilesRoot>
<!-- For SOA Cloud Installation -->
<installOwnerGroup>aaiadmin</installOwnerGroup>
<ownerManagementGroup>com.att.csid.lab</ownerManagementGroup>
- <!-- Port Selection. A value of 0 will allow for dynamic port selection.
- For local testing, you may choose to hardcode this value to something like
+ <!-- Port Selection. A value of 0 will allow for dynamic port selection.
+ For local testing, you may choose to hardcode this value to something like
8080 -->
<serverPort>0</serverPort>
<sslport>9502</sslport>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
- <version>2.0.1</version>
+ <version>2.1</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<!--<version>1.3.0-SNAPSHOT</version>-->
<!--</dependency>-->
<!--<dependency>-->
- <!--<groupId>org.onap.aai.aai-common</groupId>-->
+ <!--<groupId>org.onap.aai.aai-common</groupId>-->
<!--<artifactId>aai-schema-ingest</artifactId>-->
<!--<version>1.2.2</version>-->
<!--<exclusions>-->
<version>1.1.0</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${version.com.google.guava}</version>
</configuration>
</plugin>
<!-- license plugin -->
- <!-- Uncomment this to add a license header to every source file
- <plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <header>License.txt</header>
- <includes>
- <include>src/main/java/**</include>
- <include>src/test/java/**</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>format</goal>
- </goals>
- <phase>process-sources</phase>
- </execution>
- </executions>
- </plugin> -->
+ <!-- Uncomment this to add a license header to every source file
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <header>License.txt</header>
+ <includes>
+ <include>src/main/java/**</include>
+ <include>src/test/java/**</include>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin> -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.entity;\r
+\r
+import com.google.gson.Gson;\r
+import com.google.gson.GsonBuilder;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import javax.ws.rs.core.Response.Status;\r
+import org.onap.aai.cl.api.Logger;\r
+import org.onap.aai.cl.eelf.LoggerFactory;\r
+import org.onap.aai.datarouter.exception.POAAuditException;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+\r
+/**\r
+ * Wrapper class for POMBA rest call message body\r
+ *\r
+ */\r
+public class POAAuditEvent\r
+{\r
+ private static final String ATTR_SERVICE_INST_LIST = "serviceInstanceList";\r
+\r
+ private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();\r
+ private List<POAServiceInstanceEntity> serviceInstanceList = new ArrayList<POAServiceInstanceEntity>();\r
+\r
+ private static Logger logger = LoggerFactory.getInstance().getLogger(POAAuditEvent.class.getName());\r
+\r
+ public String toJson() {\r
+ return gson.toJson(this);\r
+ }\r
+\r
+ public static POAAuditEvent fromJson(String payload) throws POAAuditException {\r
+ if (payload == null || payload.isEmpty()) {\r
+ throw new POAAuditException("Invalid Json Payload", Status.BAD_REQUEST);\r
+ }\r
+\r
+ try {\r
+ return gson.fromJson(payload, POAAuditEvent.class);\r
+ } catch (Exception ex) {\r
+ logger.debug("Invalid Json Payload: " + payload);\r
+ throw new POAAuditException("Invalid Json Payload", Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, ex.getMessage());\r
+ }\r
+ }\r
+\r
+ public List<POAServiceInstanceEntity> getServiceInstanceList() {\r
+ return serviceInstanceList;\r
+ }\r
+\r
+ public void setServiceInstanceList(List<POAServiceInstanceEntity> instances) {\r
+ this.serviceInstanceList = instances;\r
+ }\r
+\r
+\r
+ /**\r
+ * Validates this service instance list\r
+ * @throws POAAuditException if the list is absent or empty\r
+ */\r
+ public void validate() throws POAAuditException {\r
+\r
+ if((serviceInstanceList == null) || serviceInstanceList.isEmpty()) {\r
+ String error = "Missing attribute list: " + ATTR_SERVICE_INST_LIST;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "AuditEvent [serviceInstances=" + serviceInstanceList + "]";\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.entity;\r
+\r
+import com.google.gson.Gson;\r
+import com.google.gson.GsonBuilder;\r
+import javax.ws.rs.core.Response.Status;\r
+import org.onap.aai.cl.api.Logger;\r
+import org.onap.aai.cl.eelf.LoggerFactory;\r
+import org.onap.aai.datarouter.exception.POAAuditException;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+import org.onap.aai.datarouter.service.AuditService;\r
+\r
+/**\r
+ * This class includes the POMBA rest call message body which triggers the audit process\r
+ *\r
+ */\r
+public class POAServiceInstanceEntity\r
+{\r
+ private static final String ATTR_SERVICE_INST_ID = "serviceInstanceId";\r
+ private static final String ATTR_SERVICE_TYPE = "serviceType";\r
+ private static final String ATTR_MODEL_VERSION_ID = "modelVersionId";\r
+ private static final String ATTR_MODEL_INVARIANT_ID = "modelInvariantId";\r
+ private static final String ATTR_CUSTOMER_ID = "customerId";\r
+\r
+ private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();\r
+\r
+ private String xFromAppId;\r
+ private String xTransactionId;\r
+ private String serviceInstanceId;\r
+ private String serviceType;\r
+ private String modelVersionId;\r
+ private String modelInvariantId;\r
+ private String customerId;\r
+\r
+ private static Logger logger = LoggerFactory.getInstance().getLogger(POAServiceInstanceEntity.class.getName());\r
+\r
+\r
+ public String getxFromAppId() {\r
+ return xFromAppId;\r
+ }\r
+\r
+ public void setxFromAppId(String xFromAppId) {\r
+ this.xFromAppId = xFromAppId;\r
+ }\r
+\r
+ public String getxTransactionId() {\r
+ return xTransactionId;\r
+ }\r
+\r
+ public void setxTransactionId(String xTransactionId) {\r
+ this.xTransactionId = xTransactionId;\r
+ }\r
+\r
+ public String getServiceInstanceId() {\r
+ return serviceInstanceId;\r
+ }\r
+\r
+ public void setServiceInstanceId(String serviceInstanceId) {\r
+ this.serviceInstanceId = serviceInstanceId;\r
+ }\r
+\r
+ public String getServiceType() {\r
+ return serviceType;\r
+ }\r
+\r
+ public void setServiceType(String serviceType) {\r
+ this.serviceType = serviceType;\r
+ }\r
+\r
+ public String getModelVersionId() {\r
+ return modelVersionId;\r
+ }\r
+\r
+ public void setModelVersionId(String modelVersionId) {\r
+ this.modelVersionId = modelVersionId;\r
+ }\r
+\r
+ public String getModelInvariantId() {\r
+ return modelInvariantId;\r
+ }\r
+\r
+ public void setModelInvariantId(String modelInvariantId) {\r
+ this.modelInvariantId = modelInvariantId;\r
+ }\r
+\r
+ public String getCustomerId() {\r
+ return customerId;\r
+ }\r
+\r
+ public void setCustomerId(String customerId) {\r
+ this.customerId = customerId;\r
+ }\r
+\r
+\r
+ public String toJson() {\r
+ return gson.toJson(this);\r
+ }\r
+\r
+\r
+ public static POAServiceInstanceEntity fromJson(String payload) throws POAAuditException {\r
+\r
+ if (payload == null || payload.isEmpty()) {\r
+ throw new POAAuditException("Invalid Json Payload", Status.BAD_REQUEST);\r
+ }\r
+\r
+ try {\r
+ return gson.fromJson(payload, POAServiceInstanceEntity.class);\r
+ } catch (Exception ex) {\r
+ logger.debug("Invalid Json Payload: " + payload);\r
+ throw new POAAuditException("Invalid Json Payload", Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, ex.getMessage());\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Validates this service instance; only the attributes that are expected in request body are verified.\r
+ * @throws POAAuditException if the service instance is invalid\r
+ */\r
+ public void validate() throws POAAuditException {\r
+\r
+ if(serviceInstanceId == null || serviceInstanceId.isEmpty()) {\r
+ String error = "Missing attribute: " + ATTR_SERVICE_INST_ID;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+\r
+ if(serviceType == null || serviceType.isEmpty()) {\r
+ String error = "Missing attribute: " + ATTR_SERVICE_TYPE;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+\r
+ if(modelVersionId == null || modelVersionId.isEmpty()) {\r
+ String error = "Missing attribute: " + ATTR_MODEL_VERSION_ID;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+\r
+ if(modelInvariantId == null || modelInvariantId.isEmpty()) {\r
+ String error = "Missing attribute: " + ATTR_MODEL_INVARIANT_ID;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+\r
+ if(customerId == null || customerId.isEmpty()) {\r
+ String error = "Missing attribute: " + ATTR_CUSTOMER_ID;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+ }\r
+\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "ServiceInstance [xFromAppId=" + xFromAppId + ", xTransactionId=" + xTransactionId\r
+ + ", serviceInstanceId=" + serviceInstanceId + ", serviceType=" + serviceType + ", modelVersionId="\r
+ + modelVersionId + ", modelInvariantId=" + modelInvariantId + ", customerId=" + customerId + "]";\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.exception;\r
+\r
+import javax.ws.rs.core.Response.Status;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+\r
+/**\r
+ * This class is to handle the POMBA specific exception\r
+ *\r
+ */\r
+public class POAAuditException extends Exception {\r
+\r
+ private static final long serialVersionUID = 8162385108397238865L;\r
+\r
+ private Status httpStatus;\r
+ private DataRouterMsgs logCode;\r
+ private String[] logArguments;\r
+\r
+ public POAAuditException(String messageForResponse, Status httpStatus) {\r
+ super(messageForResponse);\r
+ this.setHttpStatus(httpStatus);\r
+ }\r
+\r
+ public POAAuditException(String message, Status httpStatus, Throwable cause) {\r
+ super(message, cause);\r
+ this.setHttpStatus(httpStatus);\r
+ }\r
+\r
+ public POAAuditException(Throwable cause) {\r
+ super(cause);\r
+ }\r
+\r
+ public POAAuditException(String message, Throwable cause) {\r
+ super(message, cause);\r
+ }\r
+\r
+ public POAAuditException(String message, Throwable cause, boolean enableSuppression,\r
+ boolean writableStackTrace) {\r
+ super(message, cause, enableSuppression, writableStackTrace);\r
+ }\r
+\r
+ public POAAuditException(String message, Status httpStatus, DataRouterMsgs logCode, String... logArgs) {\r
+ super(message);\r
+ this.setHttpStatus(httpStatus);\r
+ this.logCode = logCode;\r
+ logArguments = new String[logArgs.length];\r
+ int i = 0;\r
+ for(String arg : logArgs) {\r
+ logArguments[i++] = arg;\r
+ }\r
+ }\r
+\r
+ public Status getHttpStatus() {\r
+ return httpStatus;\r
+ }\r
+\r
+ public void setHttpStatus(Status httpStatus) {\r
+ this.httpStatus = httpStatus;\r
+ }\r
+\r
+ public DataRouterMsgs getLogCode() {\r
+ return logCode;\r
+ }\r
+\r
+ public String[] getLogArguments() {\r
+ return logArguments;\r
+ }\r
+}\r
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.aai.datarouter.logging;
-
-import com.att.eelf.i18n.EELFResourceManager;
-
-import org.onap.aai.cl.eelf.LogMessageEnum;
-
-public enum DataRouterMsgs implements LogMessageEnum {
-
- /** Data Layer Service started. */
- SERVICE_STARTED,
-
- /**
- * Data Layer Service failed to start.
- * Arguments: {0} = Exception message.
- */
- STARTUP_FAILURE,
-
- /**
- * File has been changed.
- * Arguments: {0} = File name.
- */
- FILE_CHANGED,
-
- /**
- * File has been reloaded.
- * Arguments: {0} = File name.
- */
- FILE_RELOADED,
-
- /**
- * Reports the configuration watcher interval.
- * Arguments: {0} = Interval
- */
- REPORT_CONFIG_WATCHER_INT,
-
- /**
- * Loading properties file.
- * Arguments: {0} = File name.
- */
- LOADING_PROPERTIES,
-
- /**
- * Properties file has been loaded.
- * Arguments: {0} = File name.
- */
- PROPERTIES_LOADED,
-
- /**
- * UEB no events received.
- * Arguments: {0} = Topic name
- */
- UEB_NO_EVENTS_RECEIVED,
-
- /**
- * Routing policies are being configured.
- */
- CONFIGURING_ROUTING_POLICIES,
-
- /**
- * A properties file could not be successfully loaded.
- * Arguments: {0} = File name.
- */
- LOAD_PROPERTIES_FAILURE,
-
- /**
- * Failed to register for an event topic with UEB.
- * Arguments: {0} = Topic {1} = Error reason
- */
- UEB_CONNECT_ERR,
-
- /**
- * An error occurred while trying to route a query.
- * Arguments: {0} = Query {1} = Error reason
- */
- QUERY_ROUTING_ERR,
-
- /**
- * Error in file monitor block.
- */
- FILE_MON_BLOCK_ERR,
-
- /**
- * Failure to create a property map.
- */
- CREATE_PROPERTY_MAP_ERR,
-
- /**
- * An error occurred reading from a file stream.
- */
- FILE_STREAM_ERR,
-
- /**
- * An error occurred while trying to configure a routing policy.
- * Arguments: {0} = policy name {1} = source of the routing policy {2} = action of the routing
- * policy
- */
- ROUTING_POLICY_CONFIGURATION_ERROR,
-
- /**
- * Received request {0} {1} from {2}. Sending response: {3}
- * Arguments: {0} = operation {1} = target URL {2} = source {3} = response code
- */
- PROCESS_REST_REQUEST,
-
- /**
- * Index {0} may not exist in the search data store. Attempting to create it now.
- */
- CREATE_MISSING_INDEX,
-
- /**
- * Processed event {0}. Result: {1}
- * Arguments: {0} = event topic {1} = result
- */
- PROCESS_EVENT,
-
- /**
- * Arguments: {0} = Error
- */
-
- BAD_REST_REQUEST,
-
- /**
- * Arguments: {0} = Search index URL {1} = Reason
- */
- FAIL_TO_CREATE_SEARCH_INDEX,
-
- /**
- * Arguments: {0} = Successfully created index at endpoint
- */
- SEARCH_INDEX_CREATE_SUCCESS,
-
- INVALID_OXM_FILE,
-
- INVALID_OXM_DIR,
- LOAD_OXM_ERROR,
-
- /**
- * Arguments: {0} = origin payload
- */
- INVALID_ORIGIN_PAYLOAD,
-
- /**
- * Arguments: {0} = Origin URL {1} = Target outbound URL
- */
- ROUTING_FROM_TO,
-
- /**
- * Arguments: {0} = Target outbound URL, {1} = Response
- */
- ROUTING_RESPONSE,
-
- /**
- * Failed to create or update document in index {0}. Cause: {1}
- *
- * Arguments:
- * {0} = Index name
- * {1} = Failure cause
- */
- FAIL_TO_CREATE_UPDATE_DOC,
-
- /**
- * Arguments: {0} = Operation, {1} = Time in ms
- */
- OP_TIME,
-
- /** Arguments: {0} = Schema file location */
- READING_JSON_SCHEMA_ERROR,
-
- /** Arguments: {0} = Error message */
- JSON_CONVERSION_ERROR;
-
- /**
- * Static initializer to ensure the resource bundles for this class are loaded...
- */
- static {
- EELFResourceManager.loadMessageBundle("logging/DataRouterMsgs");
- }
-}
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.logging;\r
+\r
+import com.att.eelf.i18n.EELFResourceManager;\r
+import org.onap.aai.cl.eelf.LogMessageEnum;\r
+\r
+public enum DataRouterMsgs implements LogMessageEnum {\r
+\r
+ /** Data Layer Service started. */\r
+ SERVICE_STARTED,\r
+\r
+ /**\r
+ * Data Layer Service failed to start.\r
+ * Arguments: {0} = Exception message.\r
+ */\r
+ STARTUP_FAILURE,\r
+\r
+ /**\r
+ * File has been changed.\r
+ * Arguments: {0} = File name.\r
+ */\r
+ FILE_CHANGED,\r
+\r
+ /**\r
+ * File has been reloaded.\r
+ * Arguments: {0} = File name.\r
+ */\r
+ FILE_RELOADED,\r
+\r
+ /**\r
+ * Reports the configuration watcher interval.\r
+ * Arguments: {0} = Interval\r
+ */\r
+ REPORT_CONFIG_WATCHER_INT,\r
+\r
+ /**\r
+ * Loading properties file.\r
+ * Arguments: {0} = File name.\r
+ */\r
+ LOADING_PROPERTIES,\r
+\r
+ /**\r
+ * Properties file has been loaded.\r
+ * Arguments: {0} = File name.\r
+ */\r
+ PROPERTIES_LOADED,\r
+\r
+ /**\r
+ * UEB no events received.\r
+ * Arguments: {0} = Topic name\r
+ */\r
+ UEB_NO_EVENTS_RECEIVED,\r
+\r
+ /**\r
+ * Routing policies are being configured.\r
+ */\r
+ CONFIGURING_ROUTING_POLICIES,\r
+\r
+ /**\r
+ * A properties file could not be successfully loaded.\r
+ * Arguments: {0} = File name.\r
+ */\r
+ LOAD_PROPERTIES_FAILURE,\r
+\r
+ /**\r
+ * Failed to register for an event topic with UEB.\r
+ * Arguments: {0} = Topic {1} = Error reason\r
+ */\r
+ UEB_CONNECT_ERR,\r
+\r
+ /**\r
+ * An error occurred while trying to route a query.\r
+ * Arguments: {0} = Query {1} = Error reason\r
+ */\r
+ QUERY_ROUTING_ERR,\r
+\r
+ /**\r
+ * Error in file monitor block.\r
+ */\r
+ FILE_MON_BLOCK_ERR,\r
+\r
+ /**\r
+ * Failure to create a property map.\r
+ */\r
+ CREATE_PROPERTY_MAP_ERR,\r
+\r
+ /**\r
+ * An error occurred reading from a file stream.\r
+ */\r
+ FILE_STREAM_ERR,\r
+\r
+ /**\r
+ * An error occurred while trying to configure a routing policy.\r
+ * Arguments: {0} = policy name {1} = source of the routing policy {2} = action of the routing\r
+ * policy\r
+ */\r
+ ROUTING_POLICY_CONFIGURATION_ERROR,\r
+\r
+ /**\r
+ * Received request {0} {1} from {2}. Sending response: {3}\r
+ * Arguments: {0} = operation {1} = target URL {2} = source {3} = response code\r
+ */\r
+ PROCESS_REST_REQUEST,\r
+\r
+ /**\r
+ * Index {0} may not exist in the search data store. Attempting to create it now.\r
+ */\r
+ CREATE_MISSING_INDEX,\r
+\r
+ /**\r
+ * Processed event {0}. Result: {1}\r
+ * Arguments: {0} = event topic {1} = result\r
+ */\r
+ PROCESS_EVENT,\r
+\r
+ /**\r
+ * Arguments: {0} = Error\r
+ */\r
+\r
+ BAD_REST_REQUEST,\r
+\r
+ /**\r
+ * Arguments: {0} = Search index URL {1} = Reason\r
+ */\r
+ FAIL_TO_CREATE_SEARCH_INDEX,\r
+\r
+ /**\r
+ * Arguments: {0} = Successfully created index at endpoint\r
+ */\r
+ SEARCH_INDEX_CREATE_SUCCESS,\r
+\r
+ INVALID_OXM_FILE,\r
+\r
+ INVALID_OXM_DIR,\r
+ LOAD_OXM_ERROR,\r
+\r
+ /**\r
+ * Arguments: {0} = origin payload\r
+ */\r
+ INVALID_ORIGIN_PAYLOAD,\r
+\r
+ /**\r
+ * Arguments: {0} = Origin URL {1} = Target outbound URL\r
+ */\r
+ ROUTING_FROM_TO,\r
+\r
+ /**\r
+ * Arguments: {0} = Target outbound URL, {1} = Response\r
+ */\r
+ ROUTING_RESPONSE,\r
+\r
+ /**\r
+ * Failed to create or update document in index {0}. Cause: {1}\r
+ *\r
+ * Arguments:\r
+ * {0} = Index name\r
+ * {1} = Failure cause\r
+ */\r
+ FAIL_TO_CREATE_UPDATE_DOC,\r
+\r
+ /**\r
+ * Arguments: {0} = Operation, {1} = Time in ms\r
+ */\r
+ OP_TIME,\r
+\r
+ /** Arguments: {0} = Schema file location */\r
+ READING_JSON_SCHEMA_ERROR,\r
+\r
+ /** Arguments: {0} = Error message */\r
+ JSON_CONVERSION_ERROR,\r
+\r
+ /**\r
+ * Operation: {0}; URI: {1}; Exception: {2}\r
+ */\r
+ EXCEPTION_DURING_METHOD_CALL,\r
+\r
+ /**\r
+ * Failed to publish {0} event(s) to DMaaP; cause: {1}\r
+ * Arguments: {0} = number of events; {1} = cause\r
+ */\r
+ FAIL_TO_SEND_TO_DMAAP,\r
+\r
+ /**\r
+ * Failed to authenticate: {0}\r
+ * Arguments: {0} = reason\r
+ */\r
+ FAIL_TO_AUTHENTICATE,\r
+\r
+ /**\r
+ * Invalid value for configuration '{0}'; using default value {1}\r
+ * Arguments: {0} config attribute; {1} default value\r
+ */\r
+ WARN_USING_DEFAULT;\r
+ /**\r
+ * Static initializer to ensure the resource bundles for this class are loaded...\r
+ */\r
+ static {\r
+ EELFResourceManager.loadMessageBundle("logging/DataRouterMsgs");\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.logging;\r
+\r
+import com.att.eelf.i18n.EELFResourceManager;\r
+import org.onap.aai.cl.eelf.LogMessageEnum;\r
+\r
+/**\r
+ * ENUM class to handle ElasticSearch validation log message\r
+ *\r
+ */\r
+public enum ServiceIntegrityValidationsMsgs implements LogMessageEnum {\r
+\r
+ /**\r
+ * Arguments: N/A\r
+ */\r
+ SI_POLICY_REGISTRATION,\r
+ /**\r
+ * Arguments:\r
+ * {0} = Result\r
+ * {1} = Additional information\r
+ */\r
+ SI_POLICY_DECISION,\r
+\r
+ /**\r
+ * {0} = Operation\r
+ * {1} = Time for operation to complete\r
+ */\r
+ OPERATION_RESULT_ERRORS,\r
+\r
+ /**\r
+ * Arguments:\r
+ * {0} = Payload\r
+ * {1} = Error\r
+ */\r
+ DOCUMENT_STORE_PAYLOAD_FAILURE;\r
+\r
+\r
+ /**\r
+ * Static initializer to ensure the resource bundles for this class are loaded...\r
+ */\r
+ static {\r
+ EELFResourceManager.loadMessageBundle("logging/ServiceIntegrityValidationsMsgs");\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.policy;\r
+\r
+import com.google.gson.JsonArray;\r
+import com.google.gson.JsonElement;\r
+import com.google.gson.JsonObject;\r
+import com.google.gson.JsonParser;\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.apache.camel.Exchange;\r
+import org.onap.aai.cl.api.Logger;\r
+import org.onap.aai.cl.eelf.LoggerFactory;\r
+import org.onap.aai.cl.mdc.MdcContext;\r
+import org.onap.aai.restclient.client.Headers;\r
+import org.onap.aai.datarouter.logging.ServiceIntegrityValidationsMsgs;\r
+import org.onap.aai.datarouter.util.SearchServiceAgent;\r
+import org.slf4j.MDC;\r
+\r
+/**\r
+ * This class handles the logic which transformers the POA-AUDIT-RESULT event message to the ElasticSearch validation/violation message\r
+ * in order to prepare two Json structures, one for validation index and one for violation index and then submit POST request to\r
+ * Search-Data-Service to insert the document into ES.\r
+ *\r
+ */\r
+public class ServiceIntegrityValidationPolicy {\r
+\r
+ private static final String SERVICE_VALIDATION_SCHEMA_FILE = "auditservice_validation_schema.json";\r
+ private static final String SERVICE_VIOLATION_SCHEMA_FILE = "auditservice_violation_schema.json";\r
+\r
+ private static Logger logger = LoggerFactory.getInstance()\r
+ .getLogger(ServiceIntegrityValidationPolicy.class.getSimpleName());\r
+\r
+ private static JsonParser jsonParser = new JsonParser();\r
+\r
+ private String validationIndexName = null;\r
+ private String violationIndexName = null;\r
+\r
+ private SearchServiceAgent searchAgent = null;\r
+\r
+ public ServiceIntegrityValidationPolicy(String searchCertPath,\r
+ String searchCertTruststore,\r
+ String searchCertPassword,\r
+ String searchBaseURL,\r
+ String endpoint,\r
+ String validationIndexName,\r
+ String violationIndexName) {\r
+ searchAgent = new SearchServiceAgent(searchCertPath,\r
+ searchCertTruststore,\r
+ searchCertPassword,\r
+ concatSubURI(searchBaseURL, endpoint),\r
+ "documents",\r
+ logger);\r
+\r
+ this.validationIndexName = validationIndexName;\r
+ this.violationIndexName = violationIndexName;\r
+ }\r
+\r
+ public void startup(){\r
+\r
+ searchAgent.createSearchIndex(validationIndexName, SERVICE_VALIDATION_SCHEMA_FILE);\r
+ searchAgent.createSearchIndex(violationIndexName, SERVICE_VIOLATION_SCHEMA_FILE);\r
+\r
+ logger.info(ServiceIntegrityValidationsMsgs.SI_POLICY_REGISTRATION);\r
+ }\r
+\r
+ public void process(Exchange exchange) throws Exception {\r
+\r
+ logger.debug("Invoking ServiceIntegrityViolationPolicy with payload" + exchange.getIn().getBody());\r
+\r
+ String payload = (String)exchange.getIn().getBody();\r
+\r
+ JsonObject serviceValidation = jsonParser.parse(payload).getAsJsonObject();\r
+ JsonElement serviceViolationsElement = serviceValidation.get("violations");\r
+ // Calculate the document id to use for this entity.\r
+ JsonElement id = serviceValidation.get("validationId");\r
+\r
+ if(serviceViolationsElement == null || serviceViolationsElement.getAsJsonArray().size() == 0) {\r
+ serviceValidation.addProperty("result", "Pass");\r
+ logger.debug("Service integrity validation event processing for event with ID " + id + " as a Pass due to no violations.");\r
+ }else {\r
+ serviceValidation.addProperty("result", "Fail");\r
+ logger.debug("Service integrity validation event processing for event with ID " + id + " as a Fail due to one or more violations.");\r
+ }\r
+\r
+ if(serviceViolationsElement != null) {\r
+ JsonArray violationsArray = serviceViolationsElement.getAsJsonArray();\r
+ Iterator<JsonElement> vit = violationsArray.iterator();\r
+ while(vit.hasNext()) {\r
+ JsonObject currentViolation = vit.next().getAsJsonObject();\r
+ JsonObject oldViolationDetails = currentViolation.getAsJsonObject("violationDetails");\r
+ JsonObject newViolationDetails = new JsonObject();\r
+ for (Map.Entry<String, JsonElement> e : oldViolationDetails.entrySet()) {\r
+ String oldKey = e.getKey();\r
+ String newKey = oldKey.replace(".","-");\r
+ newViolationDetails.add(newKey,e.getValue());\r
+ }\r
+ currentViolation.remove("violationDetails");\r
+ currentViolation.remove("modelName");\r
+ currentViolation.add("violationDetails",newViolationDetails);\r
+ logger.debug("new violation:" + currentViolation.toString());\r
+ JsonObject formattedViolation = buildViolation(serviceValidation, currentViolation);\r
+\r
+ handleSearchDataServiceOperation(violationIndexName, null, formattedViolation.toString(), "POST");\r
+\r
+ }\r
+ }\r
+ logger.debug("validation: " + serviceValidation.toString());\r
+\r
+ JsonObject formattedValidation = buildValidation(serviceValidation);\r
+ // Persist the entity that we received from the event to the Search Service.\r
+ handleSearchDataServiceOperation(validationIndexName, id.getAsString(), formattedValidation.toString(), "PUT");\r
+\r
+ }\r
+\r
+\r
+ private JsonObject buildViolation(JsonObject validation, JsonObject violation) {\r
+ JsonObject formattedViolation = new JsonObject();\r
+\r
+ formattedViolation.addProperty("validationId", validation.get("validationId").getAsString());\r
+ formattedViolation.addProperty("validationTimestamp", validation.get("validationTimestamp").getAsString());\r
+ formattedViolation.addProperty("modelVersionId", validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("modelVersionId").getAsString());\r
+ formattedViolation.addProperty("modelInvariantId", validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("modelInvariantId").getAsString());\r
+ formattedViolation.addProperty("serviceInstanceId",validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("serviceInstanceId").getAsString());\r
+\r
+ formattedViolation.addProperty("violationId", violation.get("violationId").getAsString());\r
+ formattedViolation.addProperty("violationTimestamp", validation.get("validationTimestamp").getAsString());\r
+ formattedViolation.addProperty("category", violation.get("category").getAsString());\r
+ formattedViolation.addProperty("severity", violation.get("severity").getAsString());\r
+ formattedViolation.addProperty("violationType", violation.get("violationType").getAsString());\r
+ formattedViolation.addProperty("validationRule", violation.get("validationRule").getAsString());\r
+ formattedViolation.addProperty("message", violation.get("errorMessage").getAsString());\r
+\r
+ //formattedViolation.add("violationDetails",violation.get("violationDetails"));\r
+ return formattedViolation;\r
+ }\r
+\r
+ private JsonObject buildValidation(JsonObject validation) {\r
+ JsonObject formattedValidation = new JsonObject();\r
+\r
+ formattedValidation.add("violations", validation.get("violations"));\r
+ formattedValidation.addProperty("validationId", validation.get("validationId").getAsString());\r
+ formattedValidation.addProperty("validationTimestamp", validation.get("validationTimestamp").getAsString());\r
+ formattedValidation.addProperty("modelVersionId", validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("modelVersionId").getAsString());\r
+ formattedValidation.addProperty("modelInvariantId", validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("modelInvariantId").getAsString());\r
+ formattedValidation.addProperty("serviceInstanceId",validation.get("entity").getAsJsonObject().get("poa-event").getAsJsonObject().get("serviceInstanceId").getAsString());\r
+\r
+ try {\r
+ formattedValidation.addProperty("modelName", validation.get("entity").getAsJsonObject().get("context-list").getAsJsonObject().get("sdc").getAsJsonObject().get("service").getAsJsonObject().get("name").getAsString());\r
+ logger.debug("model name: " + validation.get("entity").getAsJsonObject().get("context-list").getAsJsonObject().get("sdc").getAsJsonObject().get("service").getAsJsonObject().get("name").getAsString());\r
+ }catch (NullPointerException ex){\r
+ ex.printStackTrace();\r
+ formattedValidation.addProperty("modelName","");\r
+ }\r
+\r
+ return formattedValidation;\r
+ }\r
+\r
+\r
+ private static String concatSubURI(String... suburis) {\r
+ String finalURI = "";\r
+\r
+ for (String suburi : suburis) {\r
+\r
+ if (suburi != null) {\r
+ // Remove any leading / since we only want to append /\r
+ suburi = suburi.replaceFirst("^/*", "");\r
+\r
+ // Add a trailing / if one isn't already there\r
+ finalURI += suburi.endsWith("/") ? suburi : suburi + "/";\r
+ }\r
+ }\r
+\r
+ return finalURI;\r
+ }\r
+\r
+\r
+ public void handleSearchDataServiceOperation(String index, String id, String payload, String action) {\r
+\r
+ Map<String, List<String>> headers = new HashMap<>();\r
+ headers.put(Headers.FROM_APP_ID, Arrays.asList("DataRouter"));\r
+ headers.put(Headers.TRANSACTION_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));\r
+\r
+ if (action.equalsIgnoreCase("PUT")) {\r
+ searchAgent.putDocument(index, id, payload, headers);\r
+\r
+ }else if (action.equalsIgnoreCase("POST")) {\r
+ searchAgent.postDocument(index, payload, headers);\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.service;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.UUID;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.ws.rs.Consumes;\r
+import javax.ws.rs.Encoded;\r
+import javax.ws.rs.POST;\r
+import javax.ws.rs.Path;\r
+import javax.ws.rs.PathParam;\r
+import javax.ws.rs.Produces;\r
+import javax.ws.rs.core.Context;\r
+import javax.ws.rs.core.HttpHeaders;\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.Response;\r
+import javax.ws.rs.core.Response.Status;\r
+import javax.ws.rs.core.UriInfo;\r
+import org.onap.aai.cl.api.Logger;\r
+import org.onap.aai.cl.eelf.LoggerFactory;\r
+import org.onap.aai.cl.mdc.MdcContext;\r
+import org.onap.aai.datarouter.entity.POAAuditEvent;\r
+import org.onap.aai.datarouter.entity.POAServiceInstanceEntity;\r
+import org.onap.aai.datarouter.exception.POAAuditException;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+import org.onap.aai.datarouter.util.LoggingUtil;\r
+import org.onap.aai.event.api.EventPublisher;\r
+import org.onap.aai.datarouter.util.DataRouterConstants;\r
+import org.onap.aai.restclient.client.Headers;\r
+\r
+\r
+\r
+public class AuditService {\r
+\r
+ private static Logger logger = LoggerFactory.getInstance().getLogger(AuditService.class.getName());\r
+ private static Logger auditLogger = LoggerFactory.getInstance().getAuditLogger(AuditService.class.getName());\r
+\r
+ private static final String MEDIA_TYPE = MediaType.APPLICATION_JSON;\r
+ private static final String DATA_ROUTER_APP = "Data-Router";\r
+ private static final String UNKNOWN_APP = "[unknown_app_id]";\r
+ private static final String RESULT_OK = "200 OK";\r
+\r
+ private EventPublisher publisher;\r
+\r
+ public AuditService(EventPublisher publisher) throws Exception {\r
+ this.publisher = publisher;\r
+ }\r
+\r
+\r
+ /**\r
+ * Handles an incoming post-orchestration audit request.\r
+ * Generates and posts audit events to DMaaP.\r
+ *\r
+ * @param content - JSON structure containing the request payload\r
+ * @param uri - Http request uri\r
+ * @param headers - Http request headers\r
+ * @param uriInfo - Http URI info field\r
+ * @param req - Http request structure.\r
+ * @return - Standard HTTP response.\r
+ *\r
+ */\r
+ @POST\r
+ @Path("/orchestration-event/")\r
+ @Consumes({MediaType.APPLICATION_JSON})\r
+ @Produces({MediaType.APPLICATION_JSON})\r
+ public Response triggerPOA(String content,\r
+ @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo uriInfo,\r
+ @Context HttpServletRequest req) {\r
+\r
+ logger.debug("Incoming request..." + content);\r
+ Response response = null;\r
+ try {\r
+ Map<String, String> headerAttributes = initializeLogging(req, headers);\r
+\r
+ List<String> serviceInstanceEvents = generateServiceInstanceEvents(headerAttributes, content);\r
+ processEvent(serviceInstanceEvents);\r
+\r
+ response = Response.status(Status.OK).entity(RESULT_OK).type(MEDIA_TYPE).build();\r
+ LoggingUtil.logRestRequest(logger, auditLogger, req, response);\r
+\r
+ } catch(POAAuditException e) {\r
+ response = Response.status(e.getHttpStatus()).entity(e.getMessage()).build();\r
+ LoggingUtil.logRestRequest(logger, auditLogger, req, response, e);\r
+ } finally {\r
+ LoggingUtil.closeMdc();\r
+ }\r
+ return response;\r
+ }\r
+\r
+\r
+ /**\r
+ * Initialize MDC logging using attributes from the request\r
+ * @param httpReq\r
+ * @param httpHeaders\r
+ * @return Returns a map of required header attributes\r
+ * @throws POAAuditException\r
+ */\r
+ private Map<String, String> initializeLogging(HttpServletRequest httpReq, HttpHeaders httpHeaders) throws POAAuditException {\r
+\r
+ Map<String, String> headers = new HashMap<String, String>();\r
+ String remoteAddr = httpReq.getRemoteAddr();\r
+\r
+ if (httpHeaders.getRequestHeaders() == null) {\r
+ String error="Missing Header";\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+ String transactionId = httpHeaders.getRequestHeaders().getFirst(Headers.TRANSACTION_ID);\r
+ if((transactionId == null) || transactionId.trim().isEmpty()) {\r
+ transactionId = UUID.randomUUID().toString();\r
+ logger.debug("Header " + Headers.TRANSACTION_ID + "not present in request, generating new value: " + transactionId);\r
+ }\r
+ headers.put(Headers.TRANSACTION_ID, transactionId);\r
+\r
+ String fromAppId = httpHeaders.getRequestHeaders().getFirst(Headers.FROM_APP_ID);\r
+ if((fromAppId == null) || fromAppId.trim().isEmpty()) {\r
+ // initialize the context before throwing the exception\r
+ MdcContext.initialize(transactionId, DataRouterConstants.DATA_ROUTER_SERVICE_NAME, "", UNKNOWN_APP, remoteAddr);\r
+ String error = "Missing header attribute: " + Headers.FROM_APP_ID;\r
+ throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ }\r
+ headers.put(Headers.FROM_APP_ID, fromAppId);\r
+\r
+ LoggingUtil.initMdc(transactionId, fromAppId, remoteAddr);\r
+\r
+ return headers;\r
+ }\r
+\r
+\r
+\r
+ /**\r
+ * Extracts service instances and generates a list of events\r
+ * @param eventHeaders\r
+ * @param requestBody\r
+ * @return Returns a list of service instances\r
+ * @throws POAAuditException if the request contains errors\r
+ */\r
+ private List<String> generateServiceInstanceEvents(Map<String, String> eventHeaders, String requestBody) throws POAAuditException {\r
+\r
+ POAAuditEvent auditEvent = POAAuditEvent.fromJson(requestBody);\r
+ auditEvent.validate();\r
+\r
+ List<String> eventMessages = new ArrayList<String>();\r
+ for (POAServiceInstanceEntity serviceInstance: auditEvent.getServiceInstanceList()) {\r
+ serviceInstance.validate();\r
+ serviceInstance.setxFromAppId(DATA_ROUTER_APP);\r
+ serviceInstance.setxTransactionId(eventHeaders.get(Headers.TRANSACTION_ID));\r
+ eventMessages.add(serviceInstance.toJson());\r
+ }\r
+ return eventMessages;\r
+ }\r
+\r
+\r
+ /**\r
+ * Publish events to DMaaP.\r
+ * @param eventMessages\r
+ * @throws POAAuditException\r
+ *\r
+ * Note: The Default Transport Type in the DMaaPEventPublisher is defined as "HTTPAAF". Based on the deployment of DMaap, currently\r
+ * by default the "HTTPAUTH" transport type is supported.\r
+ */\r
+ private void processEvent(List<String> eventMessages) throws POAAuditException {\r
+\r
+ int messagesSent = 0;\r
+ try {\r
+ messagesSent = publisher.sendSync(eventMessages);\r
+ logger.debug("The number of messages successfully sent: "+ messagesSent);\r
+\r
+ if (messagesSent > 0) {\r
+ logger.debug("Published Message: " + eventMessages);\r
+ } else {\r
+ String exceptionStr = String.format("Failed to publish %d event(s) to DMaaP", eventMessages.size());\r
+ logger.debug(exceptionStr);\r
+ }\r
+\r
+\r
+ } catch (Exception e) {\r
+ throw new POAAuditException("Failed to publish event to DMaaP: " + e.getMessage(), Status.INTERNAL_SERVER_ERROR,\r
+ DataRouterMsgs.EXCEPTION_DURING_METHOD_CALL, e.getMessage());\r
+ }\r
+\r
+ }\r
+}\r
+\r
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.aai.datarouter.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataRouterProperties {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DataRouterProperties.class);
-
- private static Properties properties;
-
- static {
- File file = new File(DataRouterConstants.DR_CONFIG_FILE);
- loadProperties(file);
- }
-
- static void loadProperties(File file) {
- properties = new Properties();
- try (InputStream props = new FileInputStream(file)) {
- properties.load(props);
- } catch (FileNotFoundException e) {
- LOGGER.error("FileNotFoundException: ", e);
- } catch (IOException e) {
- LOGGER.error("IOException: ", e);
- }
- }
-
- public static String get(String key) {
- return properties.getProperty(key);
- }
-
-}
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.util;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Properties;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class DataRouterProperties {\r
+\r
+ private static final Logger LOGGER = LoggerFactory.getLogger(DataRouterProperties.class);\r
+\r
+ private static Properties properties;\r
+\r
+ static {\r
+ File file = new File(DataRouterConstants.DR_CONFIG_FILE);\r
+ loadProperties(file);\r
+ }\r
+\r
+ static void loadProperties(File file) {\r
+ properties = new Properties();\r
+ try (InputStream props = new FileInputStream(file)) {\r
+ properties.load(props);\r
+ } catch (FileNotFoundException e) {\r
+ LOGGER.error("FileNotFoundException: ", e);\r
+ } catch (IOException e) {\r
+ LOGGER.error("IOException: ", e);\r
+ }\r
+ }\r
+\r
+ public static String get(String key) {\r
+ return properties.getProperty(key);\r
+ }\r
+\r
+ public static String get(String key, String defaultValue) {\r
+ return properties.getProperty(key, defaultValue);\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.util;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.ws.rs.core.Response;\r
+import org.onap.aai.cl.api.LogFields;\r
+import org.onap.aai.cl.api.LogLine;\r
+import org.onap.aai.cl.api.Logger;\r
+import org.onap.aai.cl.mdc.MdcContext;\r
+import org.onap.aai.datarouter.exception.POAAuditException;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+import org.onap.aai.datarouter.util.DataRouterConstants;\r
+import org.slf4j.MDC;\r
+\r
+public class LoggingUtil {\r
+\r
+ private static String UNKNOWN = "unknown";\r
+\r
+ /**\r
+ * Initializes MDC context.\r
+ * Called when request processing begins.\r
+ * @param httpReq\r
+ * @param headers\r
+ */\r
+ public static void initMdc(String transactionId, String fromAppId, String remoteAddr) {\r
+ MdcContext.initialize(transactionId, DataRouterConstants.DATA_ROUTER_SERVICE_NAME, "", fromAppId, remoteAddr);\r
+ }\r
+\r
+ /**\r
+ * Clears the MDC context.\r
+ * Called when request processing ends.\r
+ */\r
+ public static void closeMdc() {\r
+ MDC.clear();\r
+ }\r
+\r
+\r
+ /**\r
+ * Generates error and audit logs\r
+ */\r
+ public static void logRestRequest(Logger logger, Logger auditLogger, HttpServletRequest req, Response response) {\r
+ logRestRequest(logger, auditLogger, req, response, null);\r
+ }\r
+\r
+\r
+ /**\r
+ * Generates error and audit logs\r
+ * @param logger\r
+ * @param auditLogger\r
+ * @param req\r
+ * @param response\r
+ * @param exception\r
+ */\r
+ public static void logRestRequest(Logger logger, Logger auditLogger, HttpServletRequest req, Response response, POAAuditException exception) {\r
+\r
+ String respStatusString = UNKNOWN;\r
+ if(Response.Status.fromStatusCode(response.getStatus()) != null) {\r
+ respStatusString = Response.Status.fromStatusCode(response.getStatus()).toString();\r
+ }\r
+\r
+ LogFields logFields = new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, response.getStatus())\r
+ .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, respStatusString);\r
+\r
+ if((exception != null) && (exception.getLogCode() != null)) {\r
+ logger.error(exception.getLogCode(), exception.getLogArguments());\r
+ auditLogger.error(exception.getLogCode(), logFields, exception.getLogArguments());\r
+ }\r
+\r
+ String status = Integer.toString(response.getStatus());\r
+ String method = (req != null) ? req.getMethod() : UNKNOWN;\r
+ String reqUrl = (req != null) ? req.getRequestURL().toString() : UNKNOWN;\r
+ String remoteHost = (req != null) ? req.getRemoteHost() : UNKNOWN;\r
+\r
+ logger.info(DataRouterMsgs.PROCESS_REST_REQUEST, method, reqUrl, remoteHost, status);\r
+ auditLogger.info(DataRouterMsgs.PROCESS_REST_REQUEST, logFields, method, reqUrl, remoteHost, status);\r
+ }\r
+}\r
--- /dev/null
+{\r
+ "fields": [\r
+ {"name": "validationId", "data-type": "string", "searchable": "false"},\r
+ {"name": "validationTimestamp", "data-type": "date", "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM\/dd\/yyyy||yyyyMMdd'T'HHmmssZ"},\r
+ {"name": "modelVersionId", "data-type": "string"},\r
+ {"name": "modelInvariantId", "data-type": "string"},\r
+ {"name": "serviceInstanceId", "data-type": "string"},\r
+ {"name": "result", "data-type": "string"},\r
+ {"name": "violations", "data-type": "nested", "sub-fields": [\r
+ {"name": "violationId", "data-type": "string", "searchable": "false"},\r
+ {"name": "violationTimestamp", "data-type": "date", "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM\/dd\/yyyy||yyyyMMdd'T'HHmmssZ"}, \r
+ {"name": "modelName", "data-type": "string"},\r
+ {"name": "category", "data-type": "string", "searchable": "false"},\r
+ {"name": "severity", "data-type": "string", "searchable": "false"},\r
+ {"name": "violationType", "data-type": "string", "searchable": "false"},\r
+ {"name": "validationRule", "data-type": "string"},\r
+ {"name": "errorMessage", "data-type": "string"}\r
+ ]}\r
+ ]\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "fields": [\r
+ {"name": "validationId", "data-type": "string", "searchable": "false"},\r
+ {"name": "validationTimestamp", "data-type": "date", "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM\/dd\/yyyy||yyyyMMdd'T'HHmmssZ"},\r
+ {"name": "modelVersionId", "data-type": "string"},\r
+ {"name": "modelInvariantId", "data-type": "string"},\r
+ {"name": "serviceInstanceId", "data-type": "string"},\r
+ {"name": "violationId", "data-type": "string", "searchable": "false"},\r
+ {"name": "violationTimestamp", "data-type": "date", "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM\/dd\/yyyy||yyyyMMdd'T'HHmmssZ"},\r
+ {"name": "category", "data-type": "string", "searchable": "false"},\r
+ {"name": "severity", "data-type": "string", "searchable": "false"},\r
+ {"name": "violationType", "data-type": "string", "searchable": "false"},\r
+ {"name": "validationRule", "data-type": "string"},\r
+ {"name": "message", "data-type": "string"}\r
+ ]\r
+}
\ No newline at end of file
--- /dev/null
+#Resource key=Error Code|Message text|Resolution text |Description text\r
+#######\r
+#Newlines can be utilized to add some clarity ensuring continuing line\r
+#has atleast one leading space\r
+#ResourceKey=\\r
+# ERR0000E\\r
+# Sample error msg txt\\r
+# Sample resolution msg\\r
+# Sample description txt\r
+#\r
+######\r
+#Error code classification category\r
+#000 Info/Debug\r
+#100 Permission errors\r
+#200 Availability errors/Timeouts\r
+#300 Data errors\r
+#400 Schema Interface type/validation errors\r
+#500 Business process errors\r
+#900 Unknown errors\r
+#\r
+########################################################################\r
+\r
+SI_POLICY_REGISTRATION=\\r
+ SI0000I|\\r
+ Service Integrity Validation policy successfully registered.\r
+ \r
+SI_POLICY_DECISION=\\r
+ SI0001I|\\r
+ Service Integrity Validation policy resulted in {0}. {1}\r
+\r
+OPERATION_RESULT_ERRORS=\\r
+ SI0002I|\\r
+ Operation {0} completed in {1} ms with some errors\r
+\r
+DOCUMENT_STORE_PAYLOAD_FAILURE=\\r
+ SI0301E|\\r
+ Failed to store Service Integrity Violation event in Document Store. Policy payload: {0} with error: {1}
\ No newline at end of file
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.entity;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import javax.ws.rs.core.Response.Status;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.aai.datarouter.exception.POAAuditException;\r
+\r
+public class POAServiceInstanceEntityTest {\r
+\r
+ @Test\r
+ public void testPOAServiceInstanceEntity(){\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+ String xFromAppId ="REST-client";\r
+ String xTransactionId = "aaa111cccc4444";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+ svcEntity.setxFromAppId(xFromAppId);\r
+ svcEntity.setxTransactionId(xTransactionId);\r
+\r
+ Assert.assertEquals(svcInstanceId, svcEntity.getServiceInstanceId());\r
+ Assert.assertEquals(modelVersionId, svcEntity.getModelVersionId());\r
+ Assert.assertEquals(modelInvariantId, svcEntity.getModelInvariantId());\r
+\r
+ Assert.assertEquals(customerId, svcEntity.getCustomerId());\r
+ Assert.assertEquals(serviceType, svcEntity.getServiceType());\r
+ Assert.assertEquals(xFromAppId, svcEntity.getxFromAppId());\r
+ Assert.assertEquals(xTransactionId, svcEntity.getxTransactionId());\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testNullServiceInstanceId() throws POAAuditException {\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(null);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testEmptyServiceInstanceId() throws POAAuditException {\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId("");\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testNullModelVersionId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(null);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testEmptyModelVersionId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId("");\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testNullModelInvariantId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(null);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testEmptyModelInvariantId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String customerId = "global-customer-01";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId("");\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testNullServiceType() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType(null);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testEmptyServiceType() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String customerId = "global-customer-01";\r
+\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(customerId);\r
+ svcEntity.setServiceType("");\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testNullCustomerId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId(null);\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testEmptyCustomerId() throws POAAuditException {\r
+ String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
+ String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
+ String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
+ String serviceType = "vFW";\r
+\r
+ POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
+ svcEntity.setServiceInstanceId(svcInstanceId);\r
+ svcEntity.setModelVersionId(modelVersionId);\r
+ svcEntity.setModelInvariantId(modelInvariantId);\r
+ svcEntity.setCustomerId("");\r
+ svcEntity.setServiceType(serviceType);\r
+\r
+ try {\r
+ svcEntity.validate();\r
+ } catch (POAAuditException e) {\r
+ assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.exception;\r
+\r
+import javax.ws.rs.core.Response;\r
+import javax.ws.rs.core.Response.Status;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.aai.datarouter.logging.DataRouterMsgs;\r
+\r
+public class POAAuditExceptionTest {\r
+\r
+ @Test\r
+ public void testPOAAuditExceptionWith400() {\r
+ String error = "Missing attribute: serviceInstanceId ";\r
+\r
+ POAAuditException exception1 = new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
+ Assert.assertEquals(Response.Status.BAD_REQUEST, exception1.getHttpStatus());\r
+ Assert.assertEquals(DataRouterMsgs.BAD_REST_REQUEST, exception1.getLogCode());\r
+ }\r
+\r
+\r
+ @Test\r
+ public void testPOAAuditExceptionWith500() {\r
+ String error = "Failed to to create event publisher ";\r
+ String OPERATION = "POST to DMaaP";\r
+ POAAuditException exception1 = new POAAuditException(error, Status.INTERNAL_SERVER_ERROR, DataRouterMsgs.EXCEPTION_DURING_METHOD_CALL, OPERATION);\r
+\r
+ Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR, exception1.getHttpStatus());\r
+ Assert.assertEquals(DataRouterMsgs.EXCEPTION_DURING_METHOD_CALL, exception1.getLogCode());\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.policy;\r
+\r
+\r
+public class ServiceIntegrityValidationPolicyStubbed extends ServiceIntegrityValidationPolicy{\r
+\r
+ private InMemorySearchDatastore searchDb;\r
+\r
+ public ServiceIntegrityValidationPolicyStubbed(String searchCertPath, String searchCertTruststore,\r
+ String searchCertPassword, String searchBaseURL, String endpoint, String validationIndexName,\r
+ String violationIndexName) {\r
+ super(searchCertPath, searchCertTruststore, searchCertPassword, searchBaseURL, endpoint, validationIndexName,\r
+ violationIndexName);\r
+\r
+ }\r
+\r
+\r
+ public InMemorySearchDatastore getSearchDb() {\r
+ return searchDb;\r
+ }\r
+\r
+\r
+ public ServiceIntegrityValidationPolicyStubbed withSearchDb(InMemorySearchDatastore searchDb) {\r
+ this.searchDb = searchDb;\r
+ return this;\r
+ }\r
+\r
+\r
+ public void handleSearchDataServiceOperation(String index, String id, String payload, String action) {\r
+\r
+ //Stub out the actual call to Search Data service and instead store/update documents in memory\r
+ try {\r
+ switch (action.toLowerCase()) {\r
+ case "put":\r
+ searchDb.put(index, payload); // validation message\r
+ break;\r
+ case "post":\r
+ searchDb.put(index, payload); // violation message\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ } catch (Exception ex) {\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.policy;\r
+\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Matchers.anyObject;\r
+import static org.mockito.Matchers.anyString;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+\r
+import org.apache.camel.Exchange;\r
+import org.apache.camel.Message;\r
+import org.apache.commons.io.IOUtils;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.onap.aai.datarouter.policy.EntityEventPolicy;\r
+import org.onap.aai.datarouter.policy.EntityEventPolicyConfig;\r
+import org.onap.aai.datarouter.util.NodeUtils;\r
+import org.onap.aai.datarouter.util.SearchServiceAgent;\r
+import org.powermock.api.mockito.PowerMockito;\r
+\r
+\r
+public class ServiceIntegrityValidationPolicyTest {\r
+ private ServiceIntegrityValidationPolicy policy;\r
+ private String eventJson;\r
+ private String validationJson;\r
+ private String violationjson;\r
+\r
+ private InMemorySearchDatastore searchDb;\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Before\r
+ public void init() throws Exception {\r
+\r
+ String searchCertPath = "";\r
+ String searchCertTruststore ="";\r
+ String searchCertPassword = "password";\r
+ String searchBaseURL = "";\r
+ String endpoint = "services/search-data-service/v1/search/indexes/";\r
+ String validationIndexName = "service-validations";\r
+ String violationIndexName = "service-violations";\r
+\r
+\r
+ searchDb = new InMemorySearchDatastore();\r
+ policy = new ServiceIntegrityValidationPolicyStubbed(searchCertPath, searchCertTruststore,\r
+ searchCertPassword, searchBaseURL, endpoint, validationIndexName, violationIndexName).withSearchDb(searchDb);\r
+\r
+ FileInputStream event = new FileInputStream( new File("src/test/resources/poa_audit_result.json"));\r
+ eventJson = IOUtils.toString(event, "UTF-8");\r
+\r
+ FileInputStream validation = new FileInputStream( new File("src/test/resources/poa_auditservice_validation.json"));\r
+ validationJson = IOUtils.toString(validation, "UTF-8");\r
+\r
+ FileInputStream violation = new FileInputStream( new File("src/test/resources/poa_auditservice_violation.json"));\r
+ violationjson = IOUtils.toString(violation, "UTF-8");\r
+\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testProcess() throws Exception {\r
+\r
+ policy.process(getExchangeEvent(validationJson));\r
+ policy.process(getExchangeEvent(violationjson));\r
+\r
+ assertNotNull(searchDb.get("service-validations"));\r
+ assertNotNull(searchDb.get("service-violations"));\r
+\r
+ }\r
+\r
+\r
+\r
+ private Exchange getExchangeEvent(String outputJson){\r
+\r
+ Exchange exchange = PowerMockito.mock(Exchange.class);\r
+ Message inMessage = PowerMockito.mock(Message.class);\r
+ Message outMessage = PowerMockito.mock(Message.class);\r
+ PowerMockito.when(exchange.getIn()).thenReturn(inMessage);\r
+ PowerMockito.when(inMessage.getBody()).thenReturn(eventJson);\r
+\r
+ PowerMockito.when(exchange.getOut()).thenReturn(outMessage);\r
+ PowerMockito.when(outMessage.getBody()).thenReturn(outputJson);\r
+\r
+ PowerMockito.doNothing().when(outMessage).setBody(anyObject());\r
+ PowerMockito.doNothing().when(outMessage).setHeader(anyString(), anyObject());\r
+\r
+ return exchange;\r
+\r
+ }\r
+\r
+\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017-2018 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.aai.datarouter.service;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import org.apache.commons.io.IOUtils;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.onap.aai.datarouter.entity.POAAuditEvent;\r
+import org.onap.aai.datarouter.entity.POAServiceInstanceEntity;\r
+\r
+\r
+public class AuditServiceTest {\r
+\r
+ private String eventJson;\r
+\r
+\r
+ @Before\r
+ public void init() throws Exception {\r
+ FileInputStream event = new FileInputStream( new File("src/test/resources/poa_event.json"));\r
+ eventJson = IOUtils.toString(event, "UTF-8");\r
+ }\r
+\r
+ @Test\r
+ public void testPOAEvent() throws Exception {\r
+\r
+ POAAuditEvent auditEvent = POAAuditEvent.fromJson(eventJson);\r
+\r
+ List<String> eventMessages = new ArrayList<String>();\r
+ for (POAServiceInstanceEntity serviceInstance: auditEvent.getServiceInstanceList()) {\r
+ serviceInstance.validate();\r
+ serviceInstance.setxFromAppId("data-router");\r
+ serviceInstance.setxTransactionId("111222888");\r
+ eventMessages.add(serviceInstance.toJson());\r
+ }\r
+\r
+ assertEquals(2, eventMessages.size());\r
+ }\r
+\r
+\r
+\r
+}\r
--- /dev/null
+{\r
+ "validationId": "f825a232-b95b-425e-8ab0-bad4b913f770",\r
+ "validationTimestamp": "20180726T130520Z",\r
+ "entityType": "poa-entity",\r
+ "resourceVersion": null,\r
+ "violations": [\r
+ {\r
+ "severity": "CRITICAL",\r
+ "modelName": null,\r
+ "violationType": "Rule",\r
+ "validationRule": "Verify AAI nf-naming-code",\r
+ "violationDetails": {\r
+ "context-list.aai.vf-list[*]": [\r
+ {\r
+ "vnfc-list": [],\r
+ "name": "USBBBBmtwnjVVHP058",\r
+ "type": "HP",\r
+ "vf-module-list": [\r
+ {\r
+ "min-instances": 0,\r
+ "max-instances": 1,\r
+ "uuid": "null",\r
+ "invariant-id": "null"\r
+ }\r
+ ]\r
+ }\r
+ ]\r
+ },\r
+ "errorMessage": "The nf-naming-code is not populated in AAI VNF instance",\r
+ "category": "INVALID_VALUE",\r
+ "violationId": "b3ebe9ed846d3e1b07aad757cdd07cbec9d7012cab88d86889805b964cb70693"\r
+ },\r
+ {\r
+ "severity": "INFO",\r
+ "modelName": null,\r
+ "violationType": "Rule",\r
+ "validationRule": "port-mirroring-AAI-vnfc-type-exists-in-SDC-SUCCESS",\r
+ "violationDetails": {\r
+ "context-list.aai.vf-list[*]": [\r
+ {\r
+ "vnfc-list": [],\r
+ "name": "USBBBBmtwnjVVHP058",\r
+ "type": "HP",\r
+ "vf-module-list": [\r
+ {\r
+ "min-instances": 0,\r
+ "max-instances": 1,\r
+ "uuid": "null",\r
+ "invariant-id": "null"\r
+ }\r
+ ]\r
+ }\r
+ ],\r
+ "context-list.sdc.vf-list[*]": [\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "IP_Mux_Demux",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_IP_Mux_Demux_7-27 0",\r
+ "type": "org.openecomp.resource.vf.IpMuxDemux727",\r
+ "uuid": "166c8608-a448-4413-8768-44bb2611f44b",\r
+ "invariant-id": "302b5f0c-f0c7-458e-a9f6-a4e49d40eba9",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "TEST",\r
+ "uuid": "14f2ee54-dc70-4193-af20-6c726897d3fa",\r
+ "invariant-id": "988b7048-4f46-4938-b6fd-b4e7ee1aec09"\r
+ }\r
+ ],\r
+ "name": "vHNF for SNIRO 0",\r
+ "type": "org.openecomp.resource.vf.VhnfForSniro",\r
+ "uuid": "68c00070-7f27-433b-b344-3b743e969039",\r
+ "invariant-id": "0c1522b2-fcd6-4718-8610-ed243ebb4659",\r
+ "vf-module-list": [\r
+ {\r
+ "min-instances": 1,\r
+ "max-instances": 1,\r
+ "uuid": "1b6ccf7b-6217-45f7-a193-9f05422ddf35",\r
+ "invariant-id": "e428d1d8-3260-4ba8-9ca6-c400ee3ca085"\r
+ }\r
+ ]\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "Tunnel_XConn",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_Tunnel_XConn_7-27 0",\r
+ "type": "org.openecomp.resource.vf.TunnelXconn727",\r
+ "uuid": "1c05f81c-e2f1-4480-946e-56b01d8ef368",\r
+ "invariant-id": "d7db10ac-ed6e-456b-a57a-509384a3d70c",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "Tunnel_XConn",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_Tunnel_XConn_7-27 1",\r
+ "type": "org.openecomp.resource.vf.TunnelXconn727",\r
+ "uuid": "1c05f81c-e2f1-4480-946e-56b01d8ef368",\r
+ "invariant-id": "d7db10ac-ed6e-456b-a57a-509384a3d70c",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "service_admin",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_service_admin_7-27 1",\r
+ "type": "org.openecomp.resource.vf.ServiceAdmin727",\r
+ "uuid": "a02eaa28-62af-47ee-aac2-e66079a91a4d",\r
+ "invariant-id": "d39bf435-c760-4d42-9882-65371db9c7bb",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "IP_Mux_Demux",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_IP_Mux_Demux_7-27 1",\r
+ "type": "org.openecomp.resource.vf.IpMuxDemux727",\r
+ "uuid": "166c8608-a448-4413-8768-44bb2611f44b",\r
+ "invariant-id": "302b5f0c-f0c7-458e-a9f6-a4e49d40eba9",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "service_admin",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_service_admin_7-27 0",\r
+ "type": "org.openecomp.resource.vf.ServiceAdmin727",\r
+ "uuid": "a02eaa28-62af-47ee-aac2-e66079a91a4d",\r
+ "invariant-id": "d39bf435-c760-4d42-9882-65371db9c7bb",\r
+ "vf-module-list": []\r
+ }\r
+ ]\r
+ },\r
+ "errorMessage": "Every vnfc type specified in sdc has been created in AAI",\r
+ "category": "SUCCESS",\r
+ "violationId": "bfe9ba434a231a0bd263f0753c517fc503639fc5210847f61c591e98e6dafbfa"\r
+ }\r
+ ],\r
+ "entityId": {\r
+\r
+ },\r
+ "entityLink": "",\r
+ "entity": {\r
+ "poa-event": {\r
+ "serviceType": "HNPORTAL",\r
+ "modelVersionId": "f8cd30d9-6583-4cc9-8b41-48ca67689ba1",\r
+ "modelInvariantId": "b4b1177c-4b1f-48b9-85fd-a57804df88ce",\r
+ "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77",\r
+ "serviceInstanceId": "6133b7a8-da74-40c5-8a67-b458e0c0beb7",\r
+ "xTransactionId": "2309039=x",\r
+ "xFromAppId": "Data-Router"\r
+ },\r
+ "context-list": {\r
+ "sdc": {\r
+ "vf-list": [\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "IP_Mux_Demux",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_IP_Mux_Demux_7-27 0",\r
+ "type": "org.openecomp.resource.vf.IpMuxDemux727",\r
+ "uuid": "166c8608-a448-4413-8768-44bb2611f44b",\r
+ "invariant-id": "302b5f0c-f0c7-458e-a9f6-a4e49d40eba9",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "TEST",\r
+ "uuid": "14f2ee54-dc70-4193-af20-6c726897d3fa",\r
+ "invariant-id": "988b7048-4f46-4938-b6fd-b4e7ee1aec09"\r
+ }\r
+ ],\r
+ "name": "vHNF for SNIRO 0",\r
+ "type": "org.openecomp.resource.vf.VhnfForSniro",\r
+ "uuid": "68c00070-7f27-433b-b344-3b743e969039",\r
+ "invariant-id": "0c1522b2-fcd6-4718-8610-ed243ebb4659",\r
+ "vf-module-list": [\r
+ {\r
+ "min-instances": 1,\r
+ "max-instances": 1,\r
+ "uuid": "1b6ccf7b-6217-45f7-a193-9f05422ddf35",\r
+ "invariant-id": "e428d1d8-3260-4ba8-9ca6-c400ee3ca085"\r
+ }\r
+ ]\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "Tunnel_XConn",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_Tunnel_XConn_7-27 0",\r
+ "type": "org.openecomp.resource.vf.TunnelXconn727",\r
+ "uuid": "1c05f81c-e2f1-4480-946e-56b01d8ef368",\r
+ "invariant-id": "d7db10ac-ed6e-456b-a57a-509384a3d70c",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "Tunnel_XConn",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_Tunnel_XConn_7-27 1",\r
+ "type": "org.openecomp.resource.vf.TunnelXconn727",\r
+ "uuid": "1c05f81c-e2f1-4480-946e-56b01d8ef368",\r
+ "invariant-id": "d7db10ac-ed6e-456b-a57a-509384a3d70c",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "service_admin",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_service_admin_7-27 1",\r
+ "type": "org.openecomp.resource.vf.ServiceAdmin727",\r
+ "uuid": "a02eaa28-62af-47ee-aac2-e66079a91a4d",\r
+ "invariant-id": "d39bf435-c760-4d42-9882-65371db9c7bb",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "IP_Mux_Demux",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Sec_IP_Mux_Demux_7-27 1",\r
+ "type": "org.openecomp.resource.vf.IpMuxDemux727",\r
+ "uuid": "166c8608-a448-4413-8768-44bb2611f44b",\r
+ "invariant-id": "302b5f0c-f0c7-458e-a9f6-a4e49d40eba9",\r
+ "vf-module-list": []\r
+ },\r
+ {\r
+ "vnfc-list": [\r
+ {\r
+ "name": "service_admin",\r
+ "uuid": "85311c4a-e105-450e-9e54-756e9a3b3354",\r
+ "invariant-id": "ae2cbc96-5094-4fe6-9bd0-f87c56a92576"\r
+ }\r
+ ],\r
+ "name": "Pri_service_admin_7-27 0",\r
+ "type": "org.openecomp.resource.vf.ServiceAdmin727",\r
+ "uuid": "a02eaa28-62af-47ee-aac2-e66079a91a4d",\r
+ "invariant-id": "d39bf435-c760-4d42-9882-65371db9c7bb",\r
+ "vf-module-list": []\r
+ }\r
+ ],\r
+ "service": {\r
+ "name": "SD-WAN_7-27",\r
+ "uuid": "f8cd30d9-6583-4cc9-8b41-48ca67689ba1",\r
+ "invariant-id": "b4b1177c-4b1f-48b9-85fd-a57804df88ce"\r
+ }\r
+ },\r
+ "sdnc": {\r
+ "vf-list": [\r
+ {\r
+ "vnfc-list": [],\r
+ "name": "null",\r
+ "type": "null",\r
+ "uuid": "null",\r
+ "invariant-id": "null",\r
+ "vf-module-list": []\r
+ }\r
+ ],\r
+ "service": {\r
+ "name": "null",\r
+ "uuid": "null",\r
+ "invariant-id": "null"\r
+ }\r
+ },\r
+ "aai": {\r
+ "vf-list": [\r
+ {\r
+ "vnfc-list": [],\r
+ "name": "USBBBBmtwnjVVHP058",\r
+ "type": "HP",\r
+ "vf-module-list": [\r
+ {\r
+ "min-instances": 0,\r
+ "max-instances": 1,\r
+ "uuid": "null",\r
+ "invariant-id": "null"\r
+ }\r
+ ]\r
+ }\r
+ ],\r
+ "service": {\r
+ "uuid": "f8cd30d9-6583-4cc9-8b41-48ca67689ba1",\r
+ "invariant-id": "b4b1177c-4b1f-48b9-85fd-a57804df88ce"\r
+ }\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "violations": [\r
+ {\r
+ "severity": "CRITICAL",\r
+ "modelName": "string",\r
+ "violationType": "Rule",\r
+ "validationRule": "Default rule: Validate that vnf-type AAI VF instance matches vnf-type in SDN-C",\r
+ "errorMessage": "The vnf-type AAI VF instance does not match vnf-type in SDN-C",\r
+ "category": "INVALID_VALUE",\r
+ "violationId": "8b601abb25d5a1de57f18a76dfe387acfe5d3a80b808b536f9a87bd26cad4839"\r
+ },\r
+ {\r
+ "severity": "CRITICAL",\r
+ "modelName": "string ",\r
+ "violationType": "Rule",\r
+ "validationRule": "Default rule: Validate that vnf-name AAI VF instance matches vnf-name in SDN-C",\r
+ "errorMessage": "The vnf-name AAI VF instance does not match vnf-name in SDN-C",\r
+ "category": "INVALID_VALUE",\r
+ "violationId": "21ea7130f41b60b8611682fdfb7155706728b2b8d9b7152a7fcc976ae28fe31c"\r
+ }\r
+ ],\r
+ "validationId": "648c9c29-d820-483b-848e-7cb99a8c1281",\r
+ "validationTimestamp": "20180726T184111Z",\r
+ "modelVersionId": "f9f9a036-ee93-4d92-b779-a533463dba01",\r
+ "modelInvariantId": "726625ea-62be-4fe6-af5b-07862919232f",\r
+ "serviceInstanceId": "617745d3-1ccb-49f1-94ee-2d1aec00ff68"\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "validationId": "b65a3abf-c95a-4917-bf70-50f588dc4c09",\r
+ "validationTimestamp": "20180531T161324Z",\r
+ "modelVersionId": "e9851a43-c068-4eb2-9fe7-2d123bd94ff0",\r
+ "modelInvariantId": "4fd21763-23ed-4f69-8654-e121626df327",\r
+ "serviceInstanceId": "b06270ab-99e6-4a58-9bc0-db2df5c36f4d",\r
+ "violationId": "596314f8158658eed4e12991b87409e21b57818cd62c2e6da4c42a61b3b9c29c",\r
+ "violationTimestamp": "20180724T161324Z",\r
+ "category": "INVALID_VALUE",\r
+ "severity": "CRITICAL",\r
+ "violationType": "Rule",\r
+ "validationRule": "Default rule: Validate that vnf-type AAI VF instance matches vnf-type in SDN-C",\r
+ "message": "The vnf-type AAI VF instance does not match vnf-type in SDN-C"\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "serviceInstanceList": [\r
+ {\r
+ "serviceInstanceId": "24602405-7714-4c64-81da-9e182a3eba59",\r
+ "modelVersionId": "2f836857-d399-4de3-a6f8-e4a09d3017eb",\r
+ "modelInvariantId": "8c383ba3-20c3-4196-b092-c8c007ef7ddc",\r
+ "serviceType": "Mobility",\r
+ "customerId": "some.customer.id1"\r
+ },\r
+ {\r
+ "serviceInstanceId": "1111-744444-4c64-81da-9e182a3eba59",\r
+ "modelVersionId": "3333dfef836857-d399-4de3-a6f8-e4a09d3017eb",\r
+ "modelInvariantId": "7c5tba-20c3-4196-b092-c8c007ef7ddc",\r
+ "serviceType": "some.service.type",\r
+ "customerId": "some.customer.id2"\r
+ }\r
+ ]\r
+}
\ No newline at end of file