*/
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));
}
}
*/
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));
}
}
//
private Enum<?> value = null;
- private Level level = null;;
+ private Level level = null;
private String message = null;
private Status status = null;
private String domain = null;
\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
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
}\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
}\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
/*
* 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;
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);
}
}
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
/*\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
@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
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
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
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
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
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
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
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
/*\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
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
return objectMapper;\r
}\r
\r
+ /**\r
+ * Instantiates a new jersey configuration.\r
+ */\r
@Autowired\r
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {\r
register(CmsoServiceImpl.class);\r
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
/*
* 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;
@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
* 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";
/*******************************************************************************
* 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;
\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
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
/*\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
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
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
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
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
// 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
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
\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
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
\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
// 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
/*\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
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
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
@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
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
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
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
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
@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
\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
// *******************************************************************\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
// 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
// *******************************************************************\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
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