summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java17
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java7
-rw-r--r--src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java41
-rw-r--r--src/main/java/org/onap/clamp/clds/service/LogService.java38
-rw-r--r--src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java295
5 files changed, 42 insertions, 356 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index 4fc68e1d0..0304a6806 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -36,6 +36,8 @@ import javax.ws.rs.client.ClientBuilder;
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
import org.apache.catalina.connector.Connector;
import org.camunda.bpm.spring.boot.starter.webapp.CamundaBpmWebappAutoConfiguration;
+import org.onap.clamp.clds.model.prop.Holmes;
+import org.onap.clamp.clds.model.prop.ModelProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
@@ -43,6 +45,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoC
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -57,8 +60,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
@ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" })
-@EnableAutoConfiguration(exclude = { CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
- JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class,
+@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class,
+ HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class })
@EnableAsync
public class Application extends SpringBootServletInitializer {
@@ -92,11 +95,19 @@ public class Application extends SpringBootServletInitializer {
return application.sources(Application.class);
}
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
+ // This is to load the system.properties file parameters
SystemPropertiesLoader.addSystemProperties();
+ // This is to initialize some Onap Clamp components
+ initializeComponents();
+ // Start the Spring application
SpringApplication.run(Application.class, args); // NOSONAR
}
+ private static void initializeComponents() {
+ ModelProperties.registerModelElement(Holmes.class, Holmes.getType());
+ }
+
@Bean
public ServletRegistrationBean servletRegistrationBean() {
ServletRegistrationBean registration = new ServletRegistrationBean();
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
index fa0ca9615..c00deea66 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
@@ -52,6 +52,7 @@ import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.refprop.RefProp;
import org.onap.clamp.clds.transform.XslTransformer;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
@@ -67,7 +68,7 @@ public class CldsConfiguration {
private ApplicationContext context;
/**
- * Clds Identity databse DataSource configuration
+ * Clds Identity database DataSource configuration
*/
@Bean(name = "cldsDataSource")
@ConfigurationProperties(prefix = "spring.datasource.cldsdb")
@@ -86,9 +87,9 @@ public class CldsConfiguration {
}
@Bean(name = "cldsDao")
- public CldsDao getCldsDao() {
+ public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
CldsDao cldsDao = new CldsDao();
- cldsDao.setDataSource(cldsDataSource());
+ cldsDao.setDataSource(dataSource);
return cldsDao;
}
diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
index ac25400db..dc0de326b 100644
--- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
+++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
@@ -46,28 +46,28 @@ import org.onap.clamp.clds.service.CldsService;
* Parse model properties.
*/
public class ModelProperties {
- protected static final EELFLogger logger = EELFManager.getInstance()
+ protected static final EELFLogger logger = EELFManager.getInstance()
.getLogger(CldsService.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance()
+ protected static final EELFLogger auditLogger = EELFManager.getInstance()
.getAuditLogger();
- private ModelBpmn modelBpmn;
- private JsonNode modelJson;
+ private ModelBpmn modelBpmn;
+ private JsonNode modelJson;
- private final String modelName;
- private final String controlName;
- private final String actionCd;
+ private final String modelName;
+ private final String controlName;
+ private final String actionCd;
// Flag indicate whether it is triggered by Validation Test button from UI
- private final boolean isTest;
+ private final boolean isTest;
- private Global global;
+ private Global global;
private final Map<String, AbstractModelElement> modelElements = new ConcurrentHashMap<>();
- private String currentModelElementId;
- private String policyUniqueId;
+ private String currentModelElementId;
+ private String policyUniqueId;
- private static final Object lock = new Object();
+ private static final Object lock = new Object();
private static Map<Class<? extends AbstractModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
static {
@@ -84,21 +84,28 @@ public class ModelProperties {
* parse them all - parse them on demand if requested.)
*
* @param modelName
+ * The model name coming form the UI
* @param controlName
+ * The closed loop name coming from the UI
* @param actionCd
+ * Type of operation PUT,UPDATE,DELETE
* @param isTest
- * @param modelBpmnPropText
+ * The test flag coming from the UI (for validation only, no
+ * query are physically executed)
+ * @param modelBpmnText
+ * The BPMN flow in JSON from the UI
* @param modelPropText
- * @throws JsonProcessingException
+ * The BPMN parameters for all boxes defined in modelBpmnTest
* @throws IOException
+ * In case there is an issue with the JSON decoding
*/
- public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest,
- String modelBpmnPropText, String modelPropText) throws IOException {
+ public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnText,
+ String modelPropText) throws IOException {
this.modelName = modelName;
this.controlName = controlName;
this.actionCd = actionCd;
this.isTest = isTest;
- modelBpmn = ModelBpmn.create(modelBpmnPropText);
+ modelBpmn = ModelBpmn.create(modelBpmnText);
modelJson = new ObjectMapper().readTree(modelPropText);
instantiateMissingModelElements();
diff --git a/src/main/java/org/onap/clamp/clds/service/LogService.java b/src/main/java/org/onap/clamp/clds/service/LogService.java
deleted file mode 100644
index 1c3d9dc67..000000000
--- a/src/main/java/org/onap/clamp/clds/service/LogService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-
-package org.onap.clamp.clds.service;
-
-public interface LogService {
-
- String logMessage(String logMessageText, String javamail, String springmail, String commonsmail);
-
- String postLogMessage(String histEventList);
-
- String createLogMessage(String startTime, String endTime, String serviceName);
-
- String createLogMessageUsingHistory(String procInstId, String histEventList);
-
- String CreateHistLog(String procInstId);
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java
deleted file mode 100644
index 2f02aa6ab..000000000
--- a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-
-package org.onap.clamp.clds.service;
-
-import com.att.ajsc.camunda.core.AttCamundaHistoryEvent;
-import com.att.ajsc.camunda.core.AttCamundaService;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.Gson;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.ws.rs.core.Context;
-
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.SimpleEmail;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.camunda.bpm.engine.HistoryService;
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.history.HistoricActivityInstance;
-import org.camunda.bpm.engine.impl.history.event.HistoricActivityInstanceEventEntity;
-import org.camunda.bpm.engine.runtime.ProcessInstance;
-import org.onap.clamp.clds.common.LogMessages;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.mail.MailException;
-import org.springframework.mail.SimpleMailMessage;
-import org.springframework.mail.javamail.JavaMailSenderImpl;
-import org.springframework.stereotype.Service;
-
-@Service
-public class LogServiceImpl implements LogService {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogServiceImpl.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- @Autowired
- private RuntimeService runtimeService;
-
- @Autowired
- private HistoryService historyService;
-
- @Context
- private MessageContext context;
-
- public void setRuntimeService(RuntimeService runtimeService) {
- this.runtimeService = runtimeService;
- }
-
- public LogServiceImpl() {
- // needed for instantiation
- }
-
- @Override
- public String logMessage(String logMessageText, String javamail, String springmail, String commonsmail) {
- logger.info("Value of contexxt : " + context);
- String convId = null;
- if (context != null) {
- convId = context.getHttpServletRequest().getHeader("X-CSI-ConversationId");
- if (convId == null) {
- convId = (String) context.getHttpServletRequest().getAttribute("X-CSI-ConversationId");
- }
- context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing");
- AttCamundaService.setHttpRequest(context.getHttpServletRequest());
- }
- // input variables to example camunda process
- Map<String, Object> variables = new HashMap<>();
- variables.put("logMessageText", logMessageText);
- if (convId != null) {
- variables.put("conversationId", convId);
- }
-
- // BEGIN - added for send mail testing
- // also added the following to the method signature: ,
- // @QueryParam("javamail") String javamail, @QueryParam("springmail")
- // String springmail, @QueryParam("commonsmail") String commonsmail
- // if javamail parameter provided, assume it contains an email address.
- // use Java Mail to send an email from that address, to that address
- if (javamail != null && javamail.length() > 0) {
- variables.put("javamail", javamail);
- try {
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.sbc.com"); // eMail.setHostName
- Session session = Session.getInstance(props);
- MimeMessage msg = new MimeMessage(session);
-
- msg.setFrom(new InternetAddress(javamail)); // eMail.setFrom
-
- InternetAddress[] fromAddresses = { new InternetAddress(javamail) };
- msg.setReplyTo(fromAddresses); // eMail.addReplyTo
- msg.setSubject("test message using javax.mail"); // eMail.setSubject
- msg.setText(logMessageText); // eMail.setMsg
-
- msg.addRecipient(Message.RecipientType.TO, new InternetAddress(javamail)); // eMail.addTo
- Transport.send(msg);
- } catch (MessagingException e) {
- logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e);
- }
- }
-
- // if springmail parameter provided, assume it contains an email
- // address.
- // use Spring Mail to send an email from that address, to that address
- if (springmail != null && springmail.length() > 0) {
- variables.put("springmail", springmail);
- JavaMailSenderImpl sender = new JavaMailSenderImpl();
- SimpleMailMessage smsg = new SimpleMailMessage();
-
- try {
- sender.setHost("smtp.sbc.com"); // eMail.setHostName
- smsg.setFrom(springmail); // eMail.setFrom
- smsg.setReplyTo(springmail); // eMail.addReplyTo
- smsg.setSubject("test message using spring mail"); // eMail.setSubject
- smsg.setText(logMessageText); // eMail.setMsg
- smsg.setTo(springmail); // eMail.addTo
- sender.send(smsg);
- } catch (MailException e) {
- logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e);
- }
- }
-
- // if commonsmail parameter provided, assume it contains an email
- // address.
- // use Apache Commons Mail to send an email from that address, to that
- // address
- if (commonsmail != null && commonsmail.length() > 0) {
- variables.put("commonsmail", commonsmail);
- Email email = new SimpleEmail();
- try {
- email.setHostName("smtp.sbc.com");
- email.setFrom(commonsmail);
- email.addReplyTo(commonsmail);
- email.setSubject("test message using commons mail");
- email.setMsg(logMessageText);
- email.addTo(commonsmail);
- java.net.URL classUrl = this.getClass().getResource("com.sun.mail.util.TraceInputStream");
- if (classUrl != null) {
- logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile());
- } else {
- logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS_NULL);
- }
- email.send();
- } catch (Exception e) {
- logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e);
- }
- }
- // END - added for send mail testing
-
- // execute example camunda process, log-message-wf
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("log-message-wf", variables);
- AttCamundaService.setHttpRequest(null);
- // return text message of what was done
- return "Started processDefinitionId=" + pi.getProcessDefinitionId() + ", processInstanceId="
- + pi.getProcessInstanceId() + ", to log message: " + logMessageText;
- }
-
- @Override
- public String postLogMessage(String histEventList) {
- String message = "no logs Created";
- logger.info("value of history events:" + histEventList);
- Gson gson = new Gson();
- AttCamundaHistoryEvent attCamundaHistoryEvent = gson.fromJson(histEventList, AttCamundaHistoryEvent.class);
- if (attCamundaHistoryEvent != null && attCamundaHistoryEvent.getProcInstId() != null) {
- logger.info(LogMessages.PROCESS_INSTANCE_ID, attCamundaHistoryEvent.getProcInstId());
- if (context != null && context.getHttpServletRequest() != null
- && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) {
- context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing");
- List<HistoricActivityInstance> histActInstList = historyService.createHistoricActivityInstanceQuery()
- .processInstanceId(attCamundaHistoryEvent.getProcInstId()).list();
-
- if (histActInstList != null && histActInstList.size() > 0) {
- for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) {
- if (currHistoricActivityInstance != null
- && currHistoricActivityInstance.getActivityName() != null
- && currHistoricActivityInstance.getStartTime() != null
- && currHistoricActivityInstance.getEndTime() != null) {
- logger.info("value of serviceTrack:" + currHistoricActivityInstance);
- message = "Log Entry Created";
- logger.info(message);
- }
- }
- }
- if (attCamundaHistoryEvent.getHistoryEventList() != null
- && attCamundaHistoryEvent.getHistoryEventList().size() > 0) {
- List<HistoricActivityInstanceEventEntity> historyEventList = attCamundaHistoryEvent
- .getHistoryEventList();
- for (HistoricActivityInstanceEventEntity actiEvent : historyEventList) {
- // resolve null pointer exception if
- // actiEvent.getActivityName()
- message = "Log Entry Created";
- }
- }
- }
- }
- return message;
- }
-
- @Override
- public String createLogMessage(String startTime, String endTime, String serviceName) {
- String message = "no logs Created";
-
- if (context != null && context.getHttpServletRequest() != null
- && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) {
- context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds");
- /*
- * PerformanceTrackingBean trackingBean =(PerformanceTrackingBean)
- * context.getHttpServletRequest().getAttribute(
- * "PERFORMANCE_TRACKER_BEAN");
- * PerformanceTracking.addInvokeServiceTrack(trackingBean,
- * serviceName, Long.valueOf(startTime), Long.valueOf(endTime),
- * "Completed", 500, 1000) ;
- */
- message = "Log Entry Created";
- }
- // return text message of what was done
- return message;
- }
-
- @Override
- public String createLogMessageUsingHistory(String procInstId, String histEventList) {
- String message = "no logs Created";
- logger.info("value of history events:" + histEventList);
- logger.info("value of events:" + histEventList + ":" + histEventList);
- if (context != null && context.getHttpServletRequest() != null
- && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) {
- context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing");
- List<HistoricActivityInstance> histActInstList = historyService.createHistoricActivityInstanceQuery()
- .processInstanceId(procInstId).list();
-
- if (histActInstList != null && histActInstList.size() > 0) {
- for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) {
- if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null
- && currHistoricActivityInstance.getStartTime() != null
- && currHistoricActivityInstance.getEndTime() != null) {
- logger.info("value of serviceTrack:" + currHistoricActivityInstance);
- message = "Log Entry Created";
- logger.info(message);
- }
- }
- }
- }
- return message;
- }
-
- @Override
- public String CreateHistLog(String procInstId) {
- String message = "no logs Created";
- if (context != null && context.getHttpServletRequest() != null
- && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) {
- List<HistoricActivityInstance> histActInstList = historyService.createHistoricActivityInstanceQuery()
- .processInstanceId(procInstId).list();
-
- if (histActInstList != null && histActInstList.size() > 0) {
- for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) {
- if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null
- && currHistoricActivityInstance.getStartTime() != null
- && currHistoricActivityInstance.getEndTime() != null) {
- logger.info("value of serviceTrack:" + currHistoricActivityInstance);
- context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds");
- message = "Log Entry Created";
- }
- }
- }
- }
- return message;
- }
-}