diff options
author | Jerry Flood <jflood@att.com> | 2019-04-11 12:05:57 -0400 |
---|---|---|
committer | Jerry Flood <jflood@att.com> | 2019-04-11 12:06:14 -0400 |
commit | 134ae90b8d8f5b19d9915adbc9b1a70d8c27540e (patch) | |
tree | 335735075dbaf4ef34bded22db009078e3dea3c0 | |
parent | eb2a20678582c568346b0f3e75254b511d0379c3 (diff) |
More Changes for checkstyle warnings
Issue-ID: OPTFRA-474
Change-Id: Id2bb4e806cb5d16620b3cad2651ab9c90b007c5c
Signed-off-by: Jerry Flood <jflood@att.com>
16 files changed, 295 insertions, 128 deletions
diff --git a/cmso-service/src/main/java/org/onap/observations/Mdc.java b/cmso-service/src/main/java/org/onap/observations/Mdc.java index 28d0ec8..a27080a 100644 --- a/cmso-service/src/main/java/org/onap/observations/Mdc.java +++ b/cmso-service/src/main/java/org/onap/observations/Mdc.java @@ -114,8 +114,7 @@ public class Mdc { */ public static void setCaller(int back) { String caller = MDC.get(Enum.ClassName.name()); - if (caller == null) - { + if (caller == null) { MDC.put(Enum.ClassName.name(), getCaller(back)); } } @@ -187,8 +186,7 @@ public class Mdc { */ public static void restore(Map<String, String> mdcSave) { MDC.clear(); - for (String name : mdcSave.keySet()) - { + for (String name : mdcSave.keySet()) { MDC.put(name, mdcSave.get(name)); } } diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java index 17bd939..f1c1277 100644 --- a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java @@ -45,7 +45,7 @@ public class ObservationObject implements ObservationInterface { // private Enum<?> value = null; - private Level level = null;; + private Level level = null; private String message = null; private Status status = null; private String domain = null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java index 42e86f2..af1f88d 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java @@ -17,6 +17,9 @@ package org.onap.optf.cmso;
+import com.att.eelf.configuration.Configuration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.net.InetAddress;
import java.util.TimeZone;
import javax.annotation.PostConstruct;
@@ -34,9 +37,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
-import com.att.eelf.configuration.Configuration;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
@SpringBootApplication
@ComponentScan(basePackages = {"org.onap.optf.cmso"})
@@ -61,11 +61,11 @@ public class Application extends SpringBootServletInitializer { }
public static void main(String[] args) {
- initMDCData();
+ initMdcData();
SpringApplication.run(Application.class, args);
}
- protected static void initMDCData() {
+ protected static void initMdcData() {
MDC.clear();
try {
MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
@@ -78,6 +78,11 @@ public class Application extends SpringBootServletInitializer { }
}
+ /**
+ * Servlet container.
+ *
+ * @return the servlet web server factory
+ */
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java index 3d98897..1cff495 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java @@ -1,35 +1,37 @@ /* * Copyright © 2018 AT&T Intellectual Property. * Modifications Copyright © 2019 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; +import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; @@ -38,29 +40,24 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; -import java.util.ArrayList; - @Component @Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION) -public class AuthProvider - implements AuthenticationProvider { - - @Autowired - Environment env; - +public class AuthProvider implements AuthenticationProvider { + + @Autowired + Environment env; + @Override public Authentication authenticate(Authentication authentication) { String name = authentication.getName(); String password = authentication.getCredentials().toString(); - //TODO check credentials until we enable AAF - return new UsernamePasswordAuthenticationToken( - name, password, new ArrayList<>()); + // TODO check credentials until we enable AAF + return new UsernamePasswordAuthenticationToken(name, password, new ArrayList<>()); } - + @Override public boolean supports(Class<?> authentication) { - return authentication.equals( - UsernamePasswordAuthenticationToken.class); + return authentication.equals(UsernamePasswordAuthenticationToken.class); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java index 2de080e..d77886e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java @@ -27,8 +27,10 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources;
public class CMSEnvironmentPostProcessor 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.
+ // 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");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java index 5ae3f05..6a8b0ca 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * 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.
@@ -54,6 +54,11 @@ public class CMSQuartzConfiguration { @Autowired
Environment env;
+ /**
+ * Eventq trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean eventqTriggerFactoryBean() {
@@ -66,6 +71,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Eventq detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean eventqDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -73,6 +83,11 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Status trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean statusTriggerFactoryBean() {
@@ -85,6 +100,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Status detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean statusDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -92,6 +112,11 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Optimizer trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean optimizerTriggerFactoryBean() {
@@ -104,6 +129,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Optimizer detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean optimizerDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -111,6 +141,12 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Job factory.
+ *
+ * @param applicationContext the application context
+ * @return the job factory
+ */
@Bean
public JobFactory jobFactory(ApplicationContext applicationContext) {
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
@@ -118,6 +154,12 @@ public class CMSQuartzConfiguration { return jobFactory;
}
+ /**
+ * Cmso factory bean.
+ *
+ * @param jobFactory the job factory
+ * @return the scheduler factory bean
+ */
@Bean
public SchedulerFactoryBean cmsoFactoryBean(JobFactory jobFactory) {
SchedulerFactoryBean cmso = new SchedulerFactoryBean();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java index 46db256..2ba5fa3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java @@ -1,27 +1,27 @@ /*
* 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.
@@ -31,6 +31,11 @@ package org.onap.optf.cmso;
+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;
@@ -51,17 +56,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
-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;
@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() {
@@ -73,6 +78,9 @@ public class JerseyConfiguration extends ResourceConfig { return objectMapper;
}
+ /**
+ * Instantiates a new jersey configuration.
+ */
@Autowired
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
register(CmsoServiceImpl.class);
@@ -92,6 +100,11 @@ public class JerseyConfiguration extends ResourceConfig { register(CmsoContainerFilters.class);
}
+ /**
+ * Jersey client.
+ *
+ * @return the client
+ */
@Bean
public Client jerseyClient() {
ClientConfig client = new ClientConfig();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java index ef12a6d..01ca120 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java @@ -1,33 +1,34 @@ /* * 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; import org.springframework.beans.factory.annotation.Autowired; @@ -44,20 +45,20 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur @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(); - + } }
\ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java index a2fdc69..f4cb73e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java @@ -17,10 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.cmso; -public class SpringProfiles -{ +public class SpringProfiles { public static final String AAF_AUTHENTICATION = "aaf-auth"; public static final String PROPRIETARY__AUTHENTICATION = "proprietary-auth"; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java index f3b36f5..e632a6d 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java @@ -1,32 +1,33 @@ /******************************************************************************* * 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.aaf; import java.io.IOException; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java index 62eaec2..d560f50 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java @@ -31,6 +31,9 @@ package org.onap.optf.cmso.common;
+/**
+ * The Enum CMSStatusEnum.
+ */
public enum CMSStatusEnum {
PendingSchedule("Pending Schedule",
"Schedule request as been accepted. Pending determination of recommended schedule."),
@@ -63,24 +66,44 @@ public enum CMSStatusEnum { this.description = description;
}
+ /**
+ * To string.
+ *
+ * @return the string
+ */
@Override
public String toString() {
return text;
}
+ /**
+ * From string.
+ *
+ * @param text the text
+ * @return the CMS status enum
+ */
public CMSStatusEnum fromString(String text) {
- for (CMSStatusEnum e : CMSStatusEnum.values())
- if (e.text.equals(text))
+ for (CMSStatusEnum e : CMSStatusEnum.values()) {
+ if (e.text.equals(text)) {
return e;
+ }
+ }
return null;
}
+ /**
+ * The main method.
+ *
+ * @param argv the arguments
+ */
// To include in the AID.
- public static void main(String argv[]) {
+ public static void main(String[] argv) {
StringBuilder sb = new StringBuilder();
sb.append("<html><body><table border=\"1\">\n");
- for (CMSStatusEnum v : CMSStatusEnum.values())
- sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description).append("</td></tr>\n");
+ for (CMSStatusEnum v : CMSStatusEnum.values()) {
+ sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description)
+ .append("</td></tr>\n");
+ }
sb.append("</table></body></html>\n");
System.out.println(sb.toString());
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java index 3230933..d18ded4 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * 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.
@@ -47,6 +47,8 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; import static com.att.eelf.configuration.Configuration.MDC_STATUS_CODE;
import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY;
import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME;
+
+import com.att.eelf.utils.Stopwatch;
import java.net.InetAddress;
import java.net.URI;
import java.util.Date;
@@ -57,7 +59,6 @@ import javax.ws.rs.core.Response; import org.onap.optf.cmso.filters.MessageHeaders;
import org.quartz.JobExecutionContext;
import org.slf4j.MDC;
-import com.att.eelf.utils.Stopwatch;
/**
* EELF logging MDC fields not defined in the MDC Configuration (i.e.
@@ -90,6 +91,12 @@ public class Mdc { ErrorCode, ErrorDescription, Timer,
}
+ /**
+ * Begin.
+ *
+ * @param request the request
+ * @param requestId the request id
+ */
public static void begin(HttpServletRequest request, String requestId) {
MDC.clear();
Stopwatch.start();
@@ -143,11 +150,17 @@ public class Mdc { if (transactionId == null) {
transactionId = requestId;
}
- if (transactionId == null)
+ if (transactionId == null) {
transactionId = "Unknown";
+ }
MDC.put(MDC_KEY_REQUEST_ID, transactionId);
}
+ /**
+ * End.
+ *
+ * @param response the response
+ */
public static void end(Response response) {
Stopwatch.stop();
// MDC.put(MDC_ALERT_SEVERITY, "");
@@ -168,8 +181,9 @@ public class Mdc { // MDC.put(MDC_SERVICE_INSTANCE_ID, "");
// MDC.put(MDC_SERVICE_NAME, "");
MDC.put(MDC_STATUS_CODE, "COMPLETE");
- if (response.getStatus() == 500)
+ if (response.getStatus() == 500) {
MDC.put(MDC_STATUS_CODE, "ERROR");
+ }
// MDC.put(MDC_TARGET_ENTITY, "");
// MDC.put(MDC_TARGET_SERVICE_NAME, "");
// MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");
@@ -191,6 +205,11 @@ public class Mdc { return stackTraceElements[back].getClassName() + "." + stackTraceElements[back].getMethodName();
}
+ /**
+ * Quartz job begin.
+ *
+ * @param context the context
+ */
public static void quartzJobBegin(JobExecutionContext context) {
MDC.clear();
Stopwatch.start();
@@ -235,6 +254,11 @@ public class Mdc { }
+ /**
+ * Quartz job end.
+ *
+ * @param context the context
+ */
public static void quartzJobEnd(JobExecutionContext context) {
Stopwatch.stop();
// MDC.put(MDC_ALERT_SEVERITY, "");
@@ -278,12 +302,24 @@ public class Mdc { return save;
}
+ /**
+ * Restore.
+ *
+ * @param mdcSave the mdc save
+ */
public static void restore(Map<String, String> mdcSave) {
MDC.clear();
- for (String name : mdcSave.keySet())
+ for (String name : mdcSave.keySet()) {
MDC.put(name, mdcSave.get(name));
+ }
}
+ /**
+ * Metric start.
+ *
+ * @param requestId the request id
+ * @param url the url
+ */
public static void metricStart(String requestId, String url) {
MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));
// MDC.put(MDC_ELAPSED_TIME, String.valueOf(Stopwatch.getDuration()));
@@ -321,6 +357,11 @@ public class Mdc { }
+ /**
+ * Metric end.
+ *
+ * @param response the response
+ */
public static void metricEnd(Response response) {
// MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));
@@ -349,8 +390,9 @@ public class Mdc { // MDC.put(MDC_SERVICE_INSTANCE_ID, "UNKNOWN");
// MDC.put(MDC_SERVICE_NAME, "cmso");
MDC.put(MDC_STATUS_CODE, "COMPLETE");
- if (response.getStatus() == 500)
+ if (response.getStatus() == 500) {
MDC.put(MDC_STATUS_CODE, "ERROR");
+ }
// MDC.put(MDC_TARGET_ENTITY, "");
// MDC.put(MDC_TARGET_SERVICE_NAME, "");
// MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java index c49d02f..d59177f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * 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.
@@ -31,12 +31,12 @@ package org.onap.optf.cmso.common.exceptions;
+import com.att.eelf.i18n.EELFResourceManager;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response.Status;
import org.onap.optf.cmso.common.CMSRequestError;
import org.onap.optf.cmso.common.LogMessages;
-import com.att.eelf.i18n.EELFResourceManager;
public class CMSException extends Exception {
private static final long serialVersionUID = 1L;
@@ -46,12 +46,20 @@ public class CMSException extends Exception { protected LogMessages messageCode;
protected Status status;
+ /**
+ * Instantiates a new CMS exception.
+ *
+ * @param status the status
+ * @param messageCode the message code
+ * @param args the args
+ */
public CMSException(Status status, LogMessages messageCode, String... args) {
super(EELFResourceManager.format(messageCode, args));
this.status = status;
this.messageCode = messageCode;
- for (String arg : args)
+ for (String arg : args) {
variables.add(arg);
+ }
requestError = new CMSRequestError(messageCode.name(), getMessage(), variables);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java index d726107..2835b2f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java @@ -71,13 +71,13 @@ public class CMSOClient { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
+ ChangeManagementScheduleDAO cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDAO cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDAO scheduleDao;
@Autowired
@@ -89,19 +89,27 @@ public class CMSOClient { @Autowired
TmClient tmClient;
+ /**
+ * Dispatch.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
public void dispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {
try {
String url = env.getProperty("so.url");
- if (!url.endsWith("/"))
+ if (!url.endsWith("/")) {
url += "/";
+ }
url = url + "schedule/" + cmSchedule.getVnfName();
String callbackData = cmSchedule.getRequest();
String user = env.getProperty("so.user", "");
String pass = pm.getProperty("so.pass", "");
Client client = ClientBuilder.newClient();
- if (!user.equals(""))
+ if (!user.equals("")) {
client.register(new BasicAuthenticatorFilter(user, pass));
+ }
client.register(new CmsoClientFilters());
WebTarget target = client.target(url);
ObjectMapper om = new ObjectMapper();
@@ -205,19 +213,27 @@ public class CMSOClient { private void updateTicket(ChangeManagementSchedule cmSchedule, Schedule schedule) {
try {
String changeId = cmSchedule.getTmChangeId();
- if (changeId != null && !changeId.equals(""))
+ if (changeId != null && !changeId.equals("")) {
tmClient.updateTicket(schedule, cmSchedule, changeId);
+ }
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
}
}
+ /**
+ * Update schedule status.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
@Transactional
public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- cmScheduleDAO.save(cmSchedule);
- if (schedule != null)
- scheduleDAO.save(schedule);
+ cmScheduleDao.save(cmSchedule);
+ if (schedule != null) {
+ scheduleDao.save(schedule);
+ }
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java index 256878c..435f11a 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java @@ -80,10 +80,10 @@ public class CmJob implements Job { ChangeManagementScheduleDAO cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDAO cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDAO scheduleDao;
@Autowired
TmClient tmClient;
@@ -113,6 +113,11 @@ public class CmJob implements Job { debug.debug(LogMessages.CM_JOB, "Exited");
}
+ /**
+ * Loopback.
+ *
+ * @param id the id
+ */
public void loopback(String id) {
Map<String, String> mdcSave = Mdc.save();
try {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java index 49be23a..3d987b1 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java @@ -72,13 +72,13 @@ public class DispatchJob { CMSOClient vidClient;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
+ ChangeManagementScheduleDAO cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDAO cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDAO scheduleDao;
@Autowired
TmClient tmClient;
@@ -86,19 +86,26 @@ public class DispatchJob { @Autowired
Environment env;
+ /**
+ * Execute.
+ *
+ * @param id the id
+ * @throws JobExecutionException the job execution exception
+ */
public void execute(UUID id) throws JobExecutionException {
debug.debug(LogMessages.CM_JOB, "Entered");
try {
// No other instance can read this cmso until we are done.
- ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id);
+ ChangeManagementSchedule cmSchedule = cmScheduleDao.lockOne(id);
cmSchedule.setDispatcherInstance(InetAddress.getLocalHost().getHostAddress());
- ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);
+ ChangeManagementGroup group = cmGroupDao.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);
if (group != null) {
- Schedule schedule = scheduleDAO.findById(group.getSchedulesUuid()).orElse(null);
+ Schedule schedule = scheduleDao.findById(group.getSchedulesUuid()).orElse(null);
if (schedule != null) {
schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString());
- if (safeToDispatch(cmSchedule, schedule))
+ if (safeToDispatch(cmSchedule, schedule)) {
vidClient.dispatch(cmSchedule, schedule);
+ }
}
}
@@ -111,7 +118,6 @@ public class DispatchJob { private boolean safeToDispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);
Boolean scheduleImmediateEnabled = env.getProperty("cmso.cm.dispatch.immediate.enabled", Boolean.class, false);
// *******************************************************************
@@ -122,7 +128,6 @@ public class DispatchJob { // *******************************************************************
// Validate that the state is accurate.
// Another instance may have dispatched
- Long startTime = cmSchedule.getStartTimeMillis();
if (!cmSchedule.getStatus().equals(CMSStatusEnum.Scheduled.toString())
&& !cmSchedule.getStatus().equals(CMSStatusEnum.ScheduledImmediate.toString())) {
log.info("Attempt to dispatch an event that is in the incorrect state scheduleId={0}, vnf={1}, status={2}",
@@ -169,6 +174,8 @@ public class DispatchJob { // Do not account for lead time. This should be inconsequential, maybe????
//
long now = System.currentTimeMillis();
+ Long startTime = cmSchedule.getStartTimeMillis();
+
long startMillis = startTime;
if (now > startMillis) {
String message = EELFResourceManager.format(LogMessages.SCHEDULE_PAST_DUE, schedule.getScheduleId(),
@@ -184,6 +191,7 @@ public class DispatchJob { // *******************************************************************
// (Sleep until actual dispatch time...)
// leadTime allows for preparing call to VID to the start of workflow.
+ Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);
long sleep = (startMillis - leadTime) - System.currentTimeMillis();
if (sleep > 0L) {
try {
@@ -241,10 +249,16 @@ public class DispatchJob { return false;
}
+ /**
+ * Update schedule status.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
@Transactional
public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- cmScheduleDAO.save(cmSchedule);
- scheduleDAO.save(schedule);
+ cmScheduleDao.save(cmSchedule);
+ scheduleDao.save(schedule);
}
|