aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-topology/src
diff options
context:
space:
mode:
authorShankaranarayanan Puzhavakath Narayanan <snarayanan@research.att.com>2019-03-27 17:57:52 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-27 17:57:52 +0000
commit3ebcfb3ec17ff645cf235b182a5973e9f202708d (patch)
tree2f189325e88dd66954df7d5c2132f2a32b6fba8e /cmso-topology/src
parent57cd7c0a197380b1773428c34cfbc9203780de9d (diff)
parent07aa9375d94dd61159c1ec57dfd96487b8ceb2e4 (diff)
Merge "Commit 4 for Define Topology API mS"
Diffstat (limited to 'cmso-topology/src')
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/CmsoEnvironmentPostProcessor.java56
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/JerseyConfiguration.java106
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/SecurityConfig.java59
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/SpringProfiles.java35
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/Availability.java32
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java221
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoClientFilters.java83
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java134
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminTool.java63
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminToolImpl.java60
-rw-r--r--cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheck.java62
11 files changed, 911 insertions, 0 deletions
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/CmsoEnvironmentPostProcessor.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/CmsoEnvironmentPostProcessor.java
new file mode 100644
index 0000000..e8d80bb
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/CmsoEnvironmentPostProcessor.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.optf.cmso.common.PropertiesManagement;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+
+public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor {
+ // TODO tested in ONAP springboot and this is called before all of the properties files have been
+ // loaded...
+ // perhaps there is a post post processor? Until this works. DB password will be in the clear in the
+ // proeprties files.
+ @Override
+ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
+ String pwd = environment.getProperty("cmso.database.password");
+ if (pwd != null) {
+ pwd = PropertiesManagement.getDecryptedValue(pwd);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("spring.datasource.password", pwd);
+ MapPropertySource propertySource = new MapPropertySource("abc", map);
+ MutablePropertySources proeprtySources = environment.getPropertySources();
+ proeprtySources.addLast(propertySource);
+ }
+ }
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/JerseyConfiguration.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/JerseyConfiguration.java
new file mode 100644
index 0000000..4a46505
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/JerseyConfiguration.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import java.util.logging.Logger;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.logging.LoggingFeature;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.onap.optf.cmso.topology.filters.CmsoContainerFilters;
+import org.onap.optf.cmso.topology.service.rs.AdminToolImpl;
+import org.onap.optf.cmso.topology.service.rs.HealthCheckImpl;
+import org.onap.optf.cmso.topology.service.rs.TopologyInterfaceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+@Component
+@ApplicationPath("/")
+public class JerseyConfiguration extends ResourceConfig {
+ private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
+
+ /**
+ * Object mapper.
+ *
+ * @return the object mapper
+ */
+ @Bean
+ @Primary
+ public ObjectMapper objectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
+ objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ return objectMapper;
+ }
+
+ /**
+ * Instantiates a new jersey configuration.
+ */
+ @Autowired
+ public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
+ register(HealthCheckImpl.class);
+ register(AdminToolImpl.class);
+ register(TopologyInterfaceImpl.class);
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);
+ // TODO: ONAP Conversion identify appropriate ONAP logging filters if any
+ // register(lrf, 6001);
+ // register(LogResponseFilter.class, 6004);
+
+ // TODO: Examine which logging features to enable
+ register(new LoggingFeature(log));
+ register(CmsoContainerFilters.class);
+ }
+
+ /**
+ * Jersey client.
+ *
+ * @return the client
+ */
+ @Bean
+ public Client jerseyClient() {
+ ClientConfig client = new ClientConfig();
+
+ // TODO: ONAP Conversion identify appropriate ONAP logging filters if any
+ // client.register(TransactionIdRequestFilter.class);
+ // client.register(TransactionIdResponseFilter.class);
+ // client.register(DateTimeParamConverterProvider.class);
+
+ return ClientBuilder.newClient(client);
+ }
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SecurityConfig.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SecurityConfig.java
new file mode 100644
index 0000000..dfd44a6
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SecurityConfig.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+@EnableWebSecurity
+@ComponentScan("org.onap.optf")
+@Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION)
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Autowired
+ private AuthProvider authProvider;
+
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+
+ auth.authenticationProvider(authProvider);
+ }
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+
+ http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic();
+
+ }
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SpringProfiles.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SpringProfiles.java
new file mode 100644
index 0000000..4e6455c
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/SpringProfiles.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ ******************************************************************************/
+
+package org.onap.optf.cmso.topology;
+
+public class SpringProfiles {
+
+ public static final String AAF_AUTHENTICATION = "aaf-auth";
+ public static final String PROPRIETARY__AUTHENTICATION = "proprietary-auth";
+
+ private SpringProfiles() {}
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/Availability.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/Availability.java
new file mode 100644
index 0000000..8915653
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/Availability.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ ******************************************************************************/
+
+package org.onap.optf.cmso.topology.common;
+
+public enum Availability {
+ full, partial, unavailable
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java
new file mode 100644
index 0000000..fd15b25
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ ******************************************************************************/
+
+
+package org.onap.optf.cmso.topology.common;
+
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import javax.ws.rs.core.Response.Status;
+import org.apache.log4j.Level;
+import org.onap.observations.ObservationInterface;
+
+public enum LogMessages implements ObservationInterface {
+
+ FETCH_TICKET("Fetch ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ CREATE_TICKET("Create Ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ CANCEL_TICKET("Cancel ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ UPDATE_TICKET("Update ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ GET_ACTIVE_TICKETS("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ SEARCH_TICKETS("Search tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+
+ TICKET_NOT_FOUND("Ticket not found id={0}", Status.NOT_FOUND, Level.INFO),
+ INVALID_ATTRIBUTE("Invalid attribute {0}={1}", Status.BAD_REQUEST, Level.INFO),
+ MISSING_REQUIRED_ATTRIBUTE("Missing required attribute '{0}'", Status.BAD_REQUEST, Level.INFO),
+ INVALID_REQUEST("The input data structure is incorrect", Status.BAD_REQUEST, Level.INFO),
+ REQUEST_TIMED_OUT("Request timed out.", Status.INTERNAL_SERVER_ERROR, Level.ERROR),
+ UNEXPECTED_EXCEPTION("Unexpected exception encountered during processing. Please contact support : {0}",
+ Status.INTERNAL_SERVER_ERROR, Level.ERROR),
+
+ UNDEFINED_FILTER_ATTRIBUTE("Undefined filter attribute {0}", Status.BAD_REQUEST, Level.INFO),
+ INVALID_DATE_FILTER("Invalid date filter provided {0}=(1}", Status.BAD_REQUEST, Level.INFO),
+
+ INCOMING_MESSAGE("Incoming message method={0} path={1}", Status.OK, Level.INFO, true, false),
+ INCOMING_MESSAGE_RESPONSE("Message response method={0} path={1} status={2}", Status.OK, Level.INFO, true, false),
+ OUTGOING_MESSAGE("Outgoing message method={0} path={1}", Status.OK, Level.INFO, true, false),
+ OUTGOING_MESSAGE_RETURNED("Outgoing message returned method={0} path={1} status={2}", Status.OK, Level.INFO, true,
+ false),
+
+ UNEXPECTED_RESPONSE("Unexpected response from {0} HTTP Status={1} : {2}", Status.OK, Level.INFO),
+ INVALID_CHANGE_WINDOW("Change window end time {1} must be after start time {0}", Status.OK, Level.INFO),
+ EXPECTED_EXCEPTION("Expected exception encountered during processing. {0}", Status.OK, Level.INFO),
+ UNABLE_TO_UPDATE_TICKET("Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}",
+ Status.OK, Level.INFO),
+ UNAUTHORIZED("Authorization failed.", Status.FORBIDDEN, Level.INFO),
+ UNAUTHENTICATED("Authentication failed.", Status.UNAUTHORIZED, Level.INFO),
+
+ ;
+ private final String defaultId;
+ private final String defaultMessage;
+ private final String defaultResolution;
+ private final String defaultAction;
+
+ private final Status status;
+ private final Level level;
+ private final Boolean audit;
+ private final Boolean metric;
+
+
+ private LogMessages(String message, Status code, Level lev) {
+ defaultMessage = message;
+ level = lev;
+ status = code;
+ this.defaultId = this.name();
+ this.defaultResolution = "No resolution needed";
+ this.defaultAction = "No action is required";
+ this.audit = false;
+ this.metric = false;
+ }
+
+ private LogMessages(String message, Status code, Level lev, Boolean audit, Boolean metric) {
+ defaultMessage = message;
+ level = lev;
+ status = code;
+ this.audit = audit;
+ this.metric = metric;
+ this.defaultId = this.name();
+ this.defaultResolution = "No resolution needed";
+ this.defaultAction = "No action is required";
+ }
+
+ private LogMessages(String message, Status code, Level lev, String id, String resolution, String action) {
+ level = lev;
+ status = code;
+ defaultMessage = message;
+ this.defaultId = id;
+ this.defaultResolution = resolution;
+ this.defaultAction = action;
+ this.audit = false;
+ this.metric = false;
+ }
+
+ static {
+ EELFResourceManager.loadMessageBundle("logmessages");
+ }
+
+ /**
+ * Gen properties.
+ *
+ * @return the string
+ */
+ public String genProperties() {
+ // Use this to regenerate properties file. The desire to change messages without updating code is
+ // well understood, but the developer should be able to code the defaults without having to update 2
+ // different files and
+ // get it wrong.
+ StringBuilder sb = new StringBuilder();
+ sb.append("# Generated from ").append(this.getClass().getName()).append("\n");
+ for (LogMessages lm : values()) {
+ sb.append(lm.name());
+ sb.append(" ").append(lm.defaultId);
+ sb.append("|").append(lm.defaultMessage);
+ sb.append("|").append(lm.defaultResolution);
+ sb.append("|").append(lm.defaultAction);
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+
+ // interface methods
+ @Override
+ public Level getLevel() {
+ return level;
+ }
+
+ @Override
+ public String getMessage() {
+ return defaultMessage;
+ }
+
+ @Override
+ public Status getStatus() {
+ return status;
+ }
+
+ @Override
+ public Enum<?> getValue() {
+ return this;
+ }
+
+ @Override
+ public String getDomain() {
+ return this.getClass().getSimpleName();
+ }
+
+ @Override
+ public Boolean getAudit() {
+ return audit;
+ }
+
+ @Override
+ public Boolean getMetric() {
+ return metric;
+ }
+
+ /**
+ * The main method.
+ *
+ * @param argv the arguments
+ */
+ public static void main(String[] argv) {
+ System.out.println(LogMessages.UNEXPECTED_EXCEPTION.genProperties());
+ try {
+ Files.write(Paths.get("src/main/resources/logmessages.properties"),
+ LogMessages.UNEXPECTED_EXCEPTION.genProperties().getBytes());
+ } catch (IOException e) {
+ EELFManager.getInstance().getDebugLogger().debug("Failed to update properties file.", e);
+
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append("<html><body><h1>Cell Site Selection Scheduler mS Observations</h1>\n<table border=\"1\">\n<tr>");
+ sb.append("<td>Code</td> ");
+ sb.append("<td>Log Level</td> ");
+ sb.append("<td>Message</td> ");
+ sb.append("</tr>\n");
+ for (LogMessages m : LogMessages.values()) {
+ if (m.level == Level.ERROR || m.level == Level.WARN || m.level == Level.FATAL) {
+ sb.append("<tr>");
+ sb.append("<td>").append(m.name()).append("</td> ");
+ sb.append("<td>").append(m.level).append("</td> ");
+ sb.append("<td>").append(m.defaultMessage).append("</td> ");
+ sb.append("</tr>\n");
+ }
+ }
+ try {
+ Files.write(Paths.get("logmessages.html"), sb.toString().getBytes());
+ } catch (IOException e) {
+ EELFManager.getInstance().getDebugLogger().debug("Failed to update properties html file.", e);
+
+ }
+
+ }
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoClientFilters.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoClientFilters.java
new file mode 100644
index 0000000..51d548e
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoClientFilters.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology.filters;
+
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.MultivaluedMap;
+import org.onap.observations.Mdc;
+import org.onap.observations.MessageHeaders;
+import org.onap.observations.MessageHeaders.HeadersEnum;
+import org.onap.observations.Observation;
+import org.onap.optf.cmso.topology.Application;
+import org.onap.optf.cmso.topology.common.LogMessages;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+
+// @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
+@Component
+public class CmsoClientFilters implements ClientRequestFilter, ClientResponseFilter {
+
+ private static EELFLogger log = EELFManager.getInstance().getLogger(Application.class);
+ private static String appId = "cmso";
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ // On the way back
+ Mdc.metricEnd(responseContext);
+ Mdc.setCaller(17);
+ Observation.report(LogMessages.OUTGOING_MESSAGE_RETURNED, requestContext.getMethod(),
+ requestContext.getUri().getPath().toString(), responseContext.getStatusInfo().toString());
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext) throws IOException {
+ // On the way out
+ Mdc.metricStart(requestContext);
+ Mdc.setCaller(17);
+ Observation.report(LogMessages.OUTGOING_MESSAGE, requestContext.getMethod(),
+ requestContext.getUri().getPath().toString());
+ MultivaluedMap<String, Object> headers = requestContext.getHeaders();
+
+ String transactionId = (String) headers.getFirst(MessageHeaders.HeadersEnum.TransactionID.toString());
+ String mdcId = MDC.get(MDC_KEY_REQUEST_ID);
+ if (transactionId == null || transactionId.equals("")) {
+ if (mdcId != null) {
+ headers.add(HeadersEnum.TransactionID.toString(), mdcId);
+ }
+ }
+ headers.add(HeadersEnum.FromAppID.toString(), appId);
+ }
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java
new file mode 100644
index 0000000..2418aec
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology.filters;
+
+import java.io.IOException;
+import java.util.UUID;
+import javax.annotation.Priority;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.ext.Provider;
+import org.onap.observations.Mdc;
+import org.onap.observations.MessageHeaders;
+import org.onap.observations.MessageHeaders.HeadersEnum;
+import org.onap.observations.Observation;
+import org.onap.optf.cmso.topology.common.LogMessages;
+import org.springframework.stereotype.Component;
+
+@Priority(1)
+@Provider
+@Component
+public class CmsoContainerFilters implements ContainerRequestFilter, ContainerResponseFilter {
+
+
+ @Context
+ private HttpServletRequest servletRequest;
+
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+ throws IOException {
+ try {
+ Mdc.auditEnd(requestContext, responseContext);
+ Observation.report(LogMessages.INCOMING_MESSAGE_RESPONSE, requestContext.getMethod(),
+ requestContext.getUriInfo().getPath().toString(),
+ responseContext.getStatusInfo().toString());
+ MultivaluedMap<String, String> reqHeaders = requestContext.getHeaders();
+ MultivaluedMap<String, Object> respHeaders = responseContext.getHeaders();
+ String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString());
+ respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion);
+ respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion);
+ respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion);
+
+ } catch (Exception e) {
+ if (e instanceof WebApplicationException) {
+ Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage());
+ } else {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage());
+ }
+ }
+ }
+
+ @Override
+ public void filter(ContainerRequestContext requestContext) throws IOException {
+ try {
+ // On the way in
+ Mdc.auditStart(requestContext, servletRequest);
+ Observation.report(LogMessages.INCOMING_MESSAGE, requestContext.getMethod(),
+ requestContext.getUriInfo().getPath().toString());
+
+ String majorVersion = requestContext.getUriInfo().getPath();
+ if (majorVersion != null) {
+
+ if (majorVersion.startsWith("dispatch/")) {
+ return;
+ }
+ majorVersion = majorVersion.replaceAll("/.*$", "");
+ }
+ if (!MessageHeaders.validateMajorVersion(majorVersion)) {
+ ResponseBuilder builder = null;
+ String response = "Unsupported Major version";
+ builder = Response.status(Response.Status.NOT_FOUND).entity(response);
+ throw new WebApplicationException(builder.build());
+ }
+ MultivaluedMap<String, String> headers = requestContext.getHeaders();
+ String transactionId = headers.getFirst(HeadersEnum.TransactionID.toString());
+ if (transactionId == null) {
+ transactionId = UUID.randomUUID().toString();
+ headers.add(HeadersEnum.TransactionID.toString(), transactionId);
+ }
+ String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString());
+ if (minorVersion == null) {
+ minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion);
+ headers.add(HeadersEnum.MinorVersion.toString(), minorVersion);
+ }
+ if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) {
+ ResponseBuilder builder = null;
+ String response = "Unsupported API version";
+ builder = Response.status(Response.Status.NOT_FOUND).entity(response);
+ throw new WebApplicationException(builder.build());
+
+ }
+ } catch (Exception e) {
+ if (e instanceof WebApplicationException) {
+ Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage());
+ throw e;
+ } else {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage());
+ }
+ }
+
+ }
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminTool.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminTool.java
new file mode 100644
index 0000000..032c6f8
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminTool.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology.service.rs;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+@Api("Administration")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface AdminTool {
+
+ // ******************************************************************
+ @GET
+ @Path("/admin/{id}")
+ @Produces({MediaType.TEXT_PLAIN})
+ @RequestMapping(value = "/{apiVersion}/admin/{id}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN)
+ @ApiOperation(value = "", notes = "Returns encrypted value of id.", response = String.class)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 400, message = "Request failed")})
+ public Response exec(@ApiParam(
+ value = "v1|v2") @PathVariable @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Identifier") @PathVariable @PathParam("id") String id);
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminToolImpl.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminToolImpl.java
new file mode 100644
index 0000000..8b1893e
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/AdminToolImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology.service.rs;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.onap.optf.cmso.common.PropertiesManagement;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class AdminToolImpl implements AdminTool {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);
+
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+ @Override
+ public Response exec(String apiVersion, String id) {
+ log.info("AdminTool.exec entered " + uri.getPath());
+ if (id.length() < 4) {
+ return Response.ok("").build();
+ }
+ String encrypted = PropertiesManagement.getEncryptedValue(id);
+ Response response = Response.ok(encrypted).build();
+ return response;
+ }
+
+}
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheck.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheck.java
new file mode 100644
index 0000000..d8d7943
--- /dev/null
+++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheck.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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.
+ */
+
+package org.onap.optf.cmso.topology.service.rs;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.optf.cmso.topology.service.rs.models.HealthCheckMessage;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Api("Administration")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface HealthCheck {
+
+ // ******************************************************************
+ @GET
+ @Path("/health")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/health", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "", notes = "Returns health status of server.", response = HealthCheckMessage.class)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 400, message = "Not healthy", response = HealthCheckMessage.class)})
+ public Response healthCheck(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Check Interfaces") @QueryParam("checkInterfaces") @DefaultValue(
+ value = "true") Boolean checkInterfaces);
+}