More Changes for checkstyle warnings 87/85087/1
authorJerry Flood <jflood@att.com>
Thu, 11 Apr 2019 16:05:57 +0000 (12:05 -0400)
committerJerry Flood <jflood@att.com>
Thu, 11 Apr 2019 16:06:14 +0000 (12:06 -0400)
Issue-ID: OPTFRA-474
Change-Id: Id2bb4e806cb5d16620b3cad2651ab9c90b007c5c
Signed-off-by: Jerry Flood <jflood@att.com>
16 files changed:
cmso-service/src/main/java/org/onap/observations/Mdc.java
cmso-service/src/main/java/org/onap/observations/ObservationObject.java
cmso-service/src/main/java/org/onap/optf/cmso/Application.java
cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java
cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java
cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java
cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java
cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java
cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java
cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java
cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java
cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java
cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java
cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java
cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java

index 28d0ec8..a27080a 100644 (file)
@@ -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));
         }
     }
index 17bd939..f1c1277 100644 (file)
@@ -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;
index 42e86f2..af1f88d 100644 (file)
@@ -17,6 +17,9 @@
 \r
 package org.onap.optf.cmso;\r
 \r
+import com.att.eelf.configuration.Configuration;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import java.net.InetAddress;\r
 import java.util.TimeZone;\r
 import javax.annotation.PostConstruct;\r
@@ -34,9 +37,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
 import org.springframework.context.annotation.Bean;\r
 import org.springframework.context.annotation.ComponentScan;\r
 import org.springframework.scheduling.annotation.EnableAsync;\r
-import com.att.eelf.configuration.Configuration;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
 \r
 @SpringBootApplication\r
 @ComponentScan(basePackages = {"org.onap.optf.cmso"})\r
@@ -61,11 +61,11 @@ public class Application extends SpringBootServletInitializer {
     }\r
 \r
     public static void main(String[] args) {\r
-        initMDCData();\r
+        initMdcData();\r
         SpringApplication.run(Application.class, args);\r
     }\r
 \r
-    protected static void initMDCData() {\r
+    protected static void initMdcData() {\r
         MDC.clear();\r
         try {\r
             MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());\r
@@ -78,6 +78,11 @@ public class Application extends SpringBootServletInitializer {
         }\r
     }\r
 \r
+    /**\r
+     * Servlet container.\r
+     *\r
+     * @return the servlet web server factory\r
+     */\r
     @Bean\r
     public ServletWebServerFactory servletContainer() {\r
         TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();\r
index 3d98897..1cff495 100644 (file)
@@ -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);
     }
 }
index 2de080e..d77886e 100644 (file)
@@ -27,8 +27,10 @@ import org.springframework.core.env.MapPropertySource;
 import org.springframework.core.env.MutablePropertySources;\r
 \r
 public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor {\r
-    // TODO tested in ONAP springboot and this is called before all of the properties files have been loaded...\r
-       //      perhaps there is a post post processor? Until this works. DB password will be in the clear in the proeprties files.\r
+    // TODO tested in ONAP springboot and this is called before all of the properties files have been\r
+    // loaded...\r
+    // perhaps there is a post post processor? Until this works. DB password will be in the clear in the\r
+    // proeprties files.\r
     @Override\r
     public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {\r
         String pwd = environment.getProperty("cmso.database.password");\r
index 5ae3f05..6a8b0ca 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
+ * Copyright  2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright  2018 IBM.\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
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \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
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\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
@@ -54,6 +54,11 @@ public class CMSQuartzConfiguration {
     @Autowired\r
     Environment env;\r
 \r
+    /**\r
+     * Eventq trigger factory bean.\r
+     *\r
+     * @return the simple trigger factory bean\r
+     */\r
     @Bean\r
     public SimpleTriggerFactoryBean eventqTriggerFactoryBean() {\r
 \r
@@ -66,6 +71,11 @@ public class CMSQuartzConfiguration {
         return stFactory;\r
     }\r
 \r
+    /**\r
+     * Eventq detail factory bean.\r
+     *\r
+     * @return the job detail factory bean\r
+     */\r
     @Bean\r
     public JobDetailFactoryBean eventqDetailFactoryBean() {\r
         JobDetailFactoryBean factory = new JobDetailFactoryBean();\r
@@ -73,6 +83,11 @@ public class CMSQuartzConfiguration {
         return factory;\r
     }\r
 \r
+    /**\r
+     * Status trigger factory bean.\r
+     *\r
+     * @return the simple trigger factory bean\r
+     */\r
     @Bean\r
     public SimpleTriggerFactoryBean statusTriggerFactoryBean() {\r
 \r
@@ -85,6 +100,11 @@ public class CMSQuartzConfiguration {
         return stFactory;\r
     }\r
 \r
+    /**\r
+     * Status detail factory bean.\r
+     *\r
+     * @return the job detail factory bean\r
+     */\r
     @Bean\r
     public JobDetailFactoryBean statusDetailFactoryBean() {\r
         JobDetailFactoryBean factory = new JobDetailFactoryBean();\r
@@ -92,6 +112,11 @@ public class CMSQuartzConfiguration {
         return factory;\r
     }\r
 \r
+    /**\r
+     * Optimizer trigger factory bean.\r
+     *\r
+     * @return the simple trigger factory bean\r
+     */\r
     @Bean\r
     public SimpleTriggerFactoryBean optimizerTriggerFactoryBean() {\r
 \r
@@ -104,6 +129,11 @@ public class CMSQuartzConfiguration {
         return stFactory;\r
     }\r
 \r
+    /**\r
+     * Optimizer detail factory bean.\r
+     *\r
+     * @return the job detail factory bean\r
+     */\r
     @Bean\r
     public JobDetailFactoryBean optimizerDetailFactoryBean() {\r
         JobDetailFactoryBean factory = new JobDetailFactoryBean();\r
@@ -111,6 +141,12 @@ public class CMSQuartzConfiguration {
         return factory;\r
     }\r
 \r
+    /**\r
+     * Job factory.\r
+     *\r
+     * @param applicationContext the application context\r
+     * @return the job factory\r
+     */\r
     @Bean\r
     public JobFactory jobFactory(ApplicationContext applicationContext) {\r
         AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();\r
@@ -118,6 +154,12 @@ public class CMSQuartzConfiguration {
         return jobFactory;\r
     }\r
 \r
+    /**\r
+     * Cmso factory bean.\r
+     *\r
+     * @param jobFactory the job factory\r
+     * @return the scheduler factory bean\r
+     */\r
     @Bean\r
     public SchedulerFactoryBean cmsoFactoryBean(JobFactory jobFactory) {\r
         SchedulerFactoryBean cmso = new SchedulerFactoryBean();\r
index 46db256..2ba5fa3 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
  * Copyright © 2017-2019 AT&T Intellectual Property.\r
  * Modifications Copyright © 2018 IBM.\r
- * \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
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \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
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\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
 \r
 package org.onap.optf.cmso;\r
 \r
+import com.fasterxml.jackson.annotation.JsonInclude;\r
+import com.fasterxml.jackson.databind.DeserializationFeature;\r
+import com.fasterxml.jackson.databind.MapperFeature;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.fasterxml.jackson.databind.SerializationFeature;\r
 import java.util.logging.Logger;\r
 import javax.ws.rs.ApplicationPath;\r
 import javax.ws.rs.client.Client;\r
@@ -51,17 +56,17 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;\r
 import org.springframework.context.annotation.Primary;\r
 import org.springframework.stereotype.Component;\r
-import com.fasterxml.jackson.annotation.JsonInclude;\r
-import com.fasterxml.jackson.databind.DeserializationFeature;\r
-import com.fasterxml.jackson.databind.MapperFeature;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.SerializationFeature;\r
 \r
 @Component\r
 @ApplicationPath("/")\r
 public class JerseyConfiguration extends ResourceConfig {\r
     private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());\r
 \r
+    /**\r
+     * Object mapper.\r
+     *\r
+     * @return the object mapper\r
+     */\r
     @Bean\r
     @Primary\r
     public ObjectMapper objectMapper() {\r
@@ -73,6 +78,9 @@ public class JerseyConfiguration extends ResourceConfig {
         return objectMapper;\r
     }\r
 \r
+    /**\r
+     * Instantiates a new jersey configuration.\r
+     */\r
     @Autowired\r
     public JerseyConfiguration( /* LogRequestFilter lrf */ ) {\r
         register(CmsoServiceImpl.class);\r
@@ -92,6 +100,11 @@ public class JerseyConfiguration extends ResourceConfig {
         register(CmsoContainerFilters.class);\r
     }\r
 \r
+    /**\r
+     * Jersey client.\r
+     *\r
+     * @return the client\r
+     */\r
     @Bean\r
     public Client jerseyClient() {\r
         ClientConfig client = new ClientConfig();\r
index ef12a6d..01ca120 100644 (file)
@@ -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
index a2fdc69..f4cb73e 100644 (file)
  * 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";
index f3b36f5..e632a6d 100644 (file)
@@ -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;
index 62eaec2..d560f50 100644 (file)
@@ -31,6 +31,9 @@
 \r
 package org.onap.optf.cmso.common;\r
 \r
+/**\r
+ * The Enum CMSStatusEnum.\r
+ */\r
 public enum CMSStatusEnum {\r
     PendingSchedule("Pending Schedule",\r
                     "Schedule request as been accepted. Pending determination of recommended schedule."),\r
@@ -63,24 +66,44 @@ public enum CMSStatusEnum {
         this.description = description;\r
     }\r
 \r
+    /**\r
+     * To string.\r
+     *\r
+     * @return the string\r
+     */\r
     @Override\r
     public String toString() {\r
         return text;\r
     }\r
 \r
+    /**\r
+     * From string.\r
+     *\r
+     * @param text the text\r
+     * @return the CMS status enum\r
+     */\r
     public CMSStatusEnum fromString(String text) {\r
-        for (CMSStatusEnum e : CMSStatusEnum.values())\r
-            if (e.text.equals(text))\r
+        for (CMSStatusEnum e : CMSStatusEnum.values()) {\r
+            if (e.text.equals(text)) {\r
                 return e;\r
+            }\r
+        }\r
         return null;\r
     }\r
 \r
+    /**\r
+     * The main method.\r
+     *\r
+     * @param argv the arguments\r
+     */\r
     // To include in the AID.\r
-    public static void main(String argv[]) {\r
+    public static void main(String[] argv) {\r
         StringBuilder sb = new StringBuilder();\r
         sb.append("<html><body><table border=\"1\">\n");\r
-        for (CMSStatusEnum v : CMSStatusEnum.values())\r
-            sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description).append("</td></tr>\n");\r
+        for (CMSStatusEnum v : CMSStatusEnum.values()) {\r
+            sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description)\r
+            .append("</td></tr>\n");\r
+        }\r
         sb.append("</table></body></html>\n");\r
         System.out.println(sb.toString());\r
     }\r
index 3230933..d18ded4 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
+ * Copyright  2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright  2018 IBM.\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
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \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
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\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
@@ -47,6 +47,8 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
 import static com.att.eelf.configuration.Configuration.MDC_STATUS_CODE;\r
 import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY;\r
 import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME;\r
+\r
+import com.att.eelf.utils.Stopwatch;\r
 import java.net.InetAddress;\r
 import java.net.URI;\r
 import java.util.Date;\r
@@ -57,7 +59,6 @@ import javax.ws.rs.core.Response;
 import org.onap.optf.cmso.filters.MessageHeaders;\r
 import org.quartz.JobExecutionContext;\r
 import org.slf4j.MDC;\r
-import com.att.eelf.utils.Stopwatch;\r
 \r
 /**\r
  * EELF logging MDC fields not defined in the MDC Configuration (i.e.\r
@@ -90,6 +91,12 @@ public class Mdc {
         ErrorCode, ErrorDescription, Timer,\r
     }\r
 \r
+    /**\r
+     * Begin.\r
+     *\r
+     * @param request the request\r
+     * @param requestId the request id\r
+     */\r
     public static void begin(HttpServletRequest request, String requestId) {\r
         MDC.clear();\r
         Stopwatch.start();\r
@@ -143,11 +150,17 @@ public class Mdc {
         if (transactionId == null) {\r
             transactionId = requestId;\r
         }\r
-        if (transactionId == null)\r
+        if (transactionId == null) {\r
             transactionId = "Unknown";\r
+        }\r
         MDC.put(MDC_KEY_REQUEST_ID, transactionId);\r
     }\r
 \r
+    /**\r
+     * End.\r
+     *\r
+     * @param response the response\r
+     */\r
     public static void end(Response response) {\r
         Stopwatch.stop();\r
         // MDC.put(MDC_ALERT_SEVERITY, "");\r
@@ -168,8 +181,9 @@ public class Mdc {
         // MDC.put(MDC_SERVICE_INSTANCE_ID, "");\r
         // MDC.put(MDC_SERVICE_NAME, "");\r
         MDC.put(MDC_STATUS_CODE, "COMPLETE");\r
-        if (response.getStatus() == 500)\r
+        if (response.getStatus() == 500) {\r
             MDC.put(MDC_STATUS_CODE, "ERROR");\r
+        }\r
         // MDC.put(MDC_TARGET_ENTITY, "");\r
         // MDC.put(MDC_TARGET_SERVICE_NAME, "");\r
         // MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");\r
@@ -191,6 +205,11 @@ public class Mdc {
         return stackTraceElements[back].getClassName() + "." + stackTraceElements[back].getMethodName();\r
     }\r
 \r
+    /**\r
+     * Quartz job begin.\r
+     *\r
+     * @param context the context\r
+     */\r
     public static void quartzJobBegin(JobExecutionContext context) {\r
         MDC.clear();\r
         Stopwatch.start();\r
@@ -235,6 +254,11 @@ public class Mdc {
 \r
     }\r
 \r
+    /**\r
+     * Quartz job end.\r
+     *\r
+     * @param context the context\r
+     */\r
     public static void quartzJobEnd(JobExecutionContext context) {\r
         Stopwatch.stop();\r
         // MDC.put(MDC_ALERT_SEVERITY, "");\r
@@ -278,12 +302,24 @@ public class Mdc {
         return save;\r
     }\r
 \r
+    /**\r
+     * Restore.\r
+     *\r
+     * @param mdcSave the mdc save\r
+     */\r
     public static void restore(Map<String, String> mdcSave) {\r
         MDC.clear();\r
-        for (String name : mdcSave.keySet())\r
+        for (String name : mdcSave.keySet()) {\r
             MDC.put(name, mdcSave.get(name));\r
+        }\r
     }\r
 \r
+    /**\r
+     * Metric start.\r
+     *\r
+     * @param requestId the request id\r
+     * @param url the url\r
+     */\r
     public static void metricStart(String requestId, String url) {\r
         MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));\r
         // MDC.put(MDC_ELAPSED_TIME, String.valueOf(Stopwatch.getDuration()));\r
@@ -321,6 +357,11 @@ public class Mdc {
 \r
     }\r
 \r
+    /**\r
+     * Metric end.\r
+     *\r
+     * @param response the response\r
+     */\r
     public static void metricEnd(Response response) {\r
 \r
         // MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));\r
@@ -349,8 +390,9 @@ public class Mdc {
         // MDC.put(MDC_SERVICE_INSTANCE_ID, "UNKNOWN");\r
         // MDC.put(MDC_SERVICE_NAME, "cmso");\r
         MDC.put(MDC_STATUS_CODE, "COMPLETE");\r
-        if (response.getStatus() == 500)\r
+        if (response.getStatus() == 500) {\r
             MDC.put(MDC_STATUS_CODE, "ERROR");\r
+        }\r
         // MDC.put(MDC_TARGET_ENTITY, "");\r
         // MDC.put(MDC_TARGET_SERVICE_NAME, "");\r
         // MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");\r
index c49d02f..d59177f 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
+ * Copyright  2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright  2018 IBM.\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
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \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
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\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
 \r
 package org.onap.optf.cmso.common.exceptions;\r
 \r
+import com.att.eelf.i18n.EELFResourceManager;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
 import javax.ws.rs.core.Response.Status;\r
 import org.onap.optf.cmso.common.CMSRequestError;\r
 import org.onap.optf.cmso.common.LogMessages;\r
-import com.att.eelf.i18n.EELFResourceManager;\r
 \r
 public class CMSException extends Exception {\r
     private static final long serialVersionUID = 1L;\r
@@ -46,12 +46,20 @@ public class CMSException extends Exception {
     protected LogMessages messageCode;\r
     protected Status status;\r
 \r
+    /**\r
+     * Instantiates a new CMS exception.\r
+     *\r
+     * @param status the status\r
+     * @param messageCode the message code\r
+     * @param args the args\r
+     */\r
     public CMSException(Status status, LogMessages messageCode, String... args) {\r
         super(EELFResourceManager.format(messageCode, args));\r
         this.status = status;\r
         this.messageCode = messageCode;\r
-        for (String arg : args)\r
+        for (String arg : args) {\r
             variables.add(arg);\r
+        }\r
         requestError = new CMSRequestError(messageCode.name(), getMessage(), variables);\r
     }\r
 \r
index d726107..2835b2f 100644 (file)
@@ -71,13 +71,13 @@ public class CMSOClient {
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
 \r
     @Autowired\r
-    ChangeManagementScheduleDAO cmScheduleDAO;\r
+    ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
-    ChangeManagementGroupDAO cmGroupDAO;\r
+    ChangeManagementGroupDAO cmGroupDao;\r
 \r
     @Autowired\r
-    ScheduleDAO scheduleDAO;\r
+    ScheduleDAO scheduleDao;\r
 \r
 \r
     @Autowired\r
@@ -89,19 +89,27 @@ public class CMSOClient {
     @Autowired\r
     TmClient tmClient;\r
 \r
+    /**\r
+     * Dispatch.\r
+     *\r
+     * @param cmSchedule the cm schedule\r
+     * @param schedule the schedule\r
+     */\r
     public void dispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {\r
         try {\r
 \r
             String url = env.getProperty("so.url");\r
-            if (!url.endsWith("/"))\r
+            if (!url.endsWith("/")) {\r
                 url += "/";\r
+            }\r
             url = url + "schedule/" + cmSchedule.getVnfName();\r
             String callbackData = cmSchedule.getRequest();\r
             String user = env.getProperty("so.user", "");\r
             String pass = pm.getProperty("so.pass", "");\r
             Client client = ClientBuilder.newClient();\r
-            if (!user.equals(""))\r
+            if (!user.equals("")) {\r
                 client.register(new BasicAuthenticatorFilter(user, pass));\r
+            }\r
             client.register(new CmsoClientFilters());\r
             WebTarget target = client.target(url);\r
             ObjectMapper om = new ObjectMapper();\r
@@ -205,19 +213,27 @@ public class CMSOClient {
     private void updateTicket(ChangeManagementSchedule cmSchedule, Schedule schedule) {\r
         try {\r
             String changeId = cmSchedule.getTmChangeId();\r
-            if (changeId != null && !changeId.equals(""))\r
+            if (changeId != null && !changeId.equals("")) {\r
                 tmClient.updateTicket(schedule, cmSchedule, changeId);\r
+            }\r
         } catch (Exception e) {\r
             errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
             debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
         }\r
     }\r
 \r
+    /**\r
+     * Update schedule status.\r
+     *\r
+     * @param cmSchedule the cm schedule\r
+     * @param schedule the schedule\r
+     */\r
     @Transactional\r
     public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {\r
-        cmScheduleDAO.save(cmSchedule);\r
-        if (schedule != null)\r
-            scheduleDAO.save(schedule);\r
+        cmScheduleDao.save(cmSchedule);\r
+        if (schedule != null) {\r
+            scheduleDao.save(schedule);\r
+        }\r
 \r
     }\r
 }\r
index 256878c..435f11a 100644 (file)
@@ -80,10 +80,10 @@ public class CmJob implements Job {
     ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
-    ChangeManagementGroupDAO cmGroupDAO;\r
+    ChangeManagementGroupDAO cmGroupDao;\r
 \r
     @Autowired\r
-    ScheduleDAO scheduleDAO;\r
+    ScheduleDAO scheduleDao;\r
 \r
     @Autowired\r
     TmClient tmClient;\r
@@ -113,6 +113,11 @@ public class CmJob implements Job {
         debug.debug(LogMessages.CM_JOB, "Exited");\r
     }\r
 \r
+    /**\r
+     * Loopback.\r
+     *\r
+     * @param id the id\r
+     */\r
     public void loopback(String id) {\r
         Map<String, String> mdcSave = Mdc.save();\r
         try {\r
index 49be23a..3d987b1 100644 (file)
@@ -72,13 +72,13 @@ public class DispatchJob {
     CMSOClient vidClient;\r
 \r
     @Autowired\r
-    ChangeManagementScheduleDAO cmScheduleDAO;\r
+    ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
-    ChangeManagementGroupDAO cmGroupDAO;\r
+    ChangeManagementGroupDAO cmGroupDao;\r
 \r
     @Autowired\r
-    ScheduleDAO scheduleDAO;\r
+    ScheduleDAO scheduleDao;\r
 \r
     @Autowired\r
     TmClient tmClient;\r
@@ -86,19 +86,26 @@ public class DispatchJob {
     @Autowired\r
     Environment env;\r
 \r
+    /**\r
+     * Execute.\r
+     *\r
+     * @param id the id\r
+     * @throws JobExecutionException the job execution exception\r
+     */\r
     public void execute(UUID id) throws JobExecutionException {\r
         debug.debug(LogMessages.CM_JOB, "Entered");\r
         try {\r
             // No other instance can read this cmso until we are done.\r
-            ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id);\r
+            ChangeManagementSchedule cmSchedule = cmScheduleDao.lockOne(id);\r
             cmSchedule.setDispatcherInstance(InetAddress.getLocalHost().getHostAddress());\r
-            ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);\r
+            ChangeManagementGroup group = cmGroupDao.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);\r
             if (group != null) {\r
-                Schedule schedule = scheduleDAO.findById(group.getSchedulesUuid()).orElse(null);\r
+                Schedule schedule = scheduleDao.findById(group.getSchedulesUuid()).orElse(null);\r
                 if (schedule != null) {\r
                     schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString());\r
-                    if (safeToDispatch(cmSchedule, schedule))\r
+                    if (safeToDispatch(cmSchedule, schedule)) {\r
                         vidClient.dispatch(cmSchedule, schedule);\r
+                    }\r
                 }\r
             }\r
 \r
@@ -111,7 +118,6 @@ public class DispatchJob {
 \r
     private boolean safeToDispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {\r
 \r
-        Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);\r
         Boolean scheduleImmediateEnabled = env.getProperty("cmso.cm.dispatch.immediate.enabled", Boolean.class, false);\r
 \r
         // *******************************************************************\r
@@ -122,7 +128,6 @@ public class DispatchJob {
         // *******************************************************************\r
         // Validate that the state is accurate.\r
         // Another instance may have dispatched\r
-        Long startTime = cmSchedule.getStartTimeMillis();\r
         if (!cmSchedule.getStatus().equals(CMSStatusEnum.Scheduled.toString())\r
                 && !cmSchedule.getStatus().equals(CMSStatusEnum.ScheduledImmediate.toString())) {\r
             log.info("Attempt to dispatch an event that is in the incorrect state scheduleId={0}, vnf={1}, status={2}",\r
@@ -169,6 +174,8 @@ public class DispatchJob {
         // Do not account for lead time. This should be inconsequential, maybe????\r
         //\r
         long now = System.currentTimeMillis();\r
+        Long startTime = cmSchedule.getStartTimeMillis();\r
+\r
         long startMillis = startTime;\r
         if (now > startMillis) {\r
             String message = EELFResourceManager.format(LogMessages.SCHEDULE_PAST_DUE, schedule.getScheduleId(),\r
@@ -184,6 +191,7 @@ public class DispatchJob {
         // *******************************************************************\r
         // (Sleep until actual dispatch time...)\r
         // leadTime allows for preparing call to VID to the start of workflow.\r
+        Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);\r
         long sleep = (startMillis - leadTime) - System.currentTimeMillis();\r
         if (sleep > 0L) {\r
             try {\r
@@ -241,10 +249,16 @@ public class DispatchJob {
         return false;\r
     }\r
 \r
+    /**\r
+     * Update schedule status.\r
+     *\r
+     * @param cmSchedule the cm schedule\r
+     * @param schedule the schedule\r
+     */\r
     @Transactional\r
     public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {\r
-        cmScheduleDAO.save(cmSchedule);\r
-        scheduleDAO.save(schedule);\r
+        cmScheduleDao.save(cmSchedule);\r
+        scheduleDao.save(schedule);\r
 \r
     }\r
 \r