summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services')
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleExecutor.java92
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleService.java4
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java93
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowService.java4
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowServiceImpl.java18
5 files changed, 87 insertions, 124 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleExecutor.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleExecutor.java
index 90b9e96a..b97a00b4 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleExecutor.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleExecutor.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * 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
*
@@ -48,7 +48,7 @@ import java.nio.charset.Charset;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
public class WorkflowScheduleExecutor {
-
+
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowScheduleExecutor.class);
private String serverURL;
@@ -56,22 +56,18 @@ public class WorkflowScheduleExecutor {
private String myUrl;
private String payload;
- //constructor
- public WorkflowScheduleExecutor(String serverURL,String workflowKey){
+ public WorkflowScheduleExecutor(String serverURL, String workflowKey) {
this.serverURL = serverURL;
this.workflowKey = workflowKey;
- this.myUrl = this.serverURL + "/engine-rest/process-definition/key/" + this.workflowKey + "/submit-form";;
- this.payload="{\"variables\":{}}";
+ this.myUrl = this.serverURL + "/engine-rest/process-definition/key/" + this.workflowKey + "/submit-form";
+ ;
+ this.payload = "{\"variables\":{}}";
}
-
- public static void main(String [] args) throws Exception {
- }
-
public void execute() {
- POST_fromURL(myUrl,payload);
+ POST_fromURL(myUrl, payload);
}
-
+
public static String get_fromURL(String myURL) {
logger.debug(EELFLoggerDelegate.debugLogger, "get_fromURL: Requested URL {}", myURL);
StringBuilder sb = new StringBuilder();
@@ -83,8 +79,7 @@ public class WorkflowScheduleExecutor {
if (urlConn != null)
urlConn.setReadTimeout(60 * 1000);
if (urlConn != null && urlConn.getInputStream() != null) {
- in = new InputStreamReader(urlConn.getInputStream(),
- Charset.defaultCharset());
+ in = new InputStreamReader(urlConn.getInputStream(), Charset.defaultCharset());
BufferedReader bufferedReader = new BufferedReader(in);
int cp;
while ((cp = bufferedReader.read()) != -1)
@@ -93,46 +88,43 @@ public class WorkflowScheduleExecutor {
in.close();
}
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "get_fromURL failed", e);
- throw new RuntimeException("Exception while calling URL:"+ myURL, e);
- }
- finally {
+ logger.error(EELFLoggerDelegate.errorLogger, "get_fromURL failed", e);
+ throw new RuntimeException("Exception while calling URL:" + myURL, e);
+ } finally {
try {
if (in != null)
in.close();
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "get_fromURL close failed", e);
- }
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "get_fromURL close failed", e);
+ }
}
return sb.toString();
}
-
-
- public static String POST_fromURL(String myURL, String payload) {
- String line;
- StringBuffer jsonString = new StringBuffer();
- try {
- URL url = new URL(myURL);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setDoInput(true);
- connection.setDoOutput(true);
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Accept", "application/json");
- connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
- OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
- writer.write(payload);
- writer.close();
- BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- while ((line = br.readLine()) != null) {
- jsonString.append(line);
- }
- br.close();
- connection.disconnect();
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "POST_fromURL failed", e);
- throw new RuntimeException(e.getMessage());
- }
- return jsonString.toString();
- }
+ public static String POST_fromURL(String myURL, String payload) {
+ String line;
+ StringBuilder jsonString = new StringBuilder();
+ try {
+ URL url = new URL(myURL);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Accept", "application/json");
+ connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+ OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
+ writer.write(payload);
+ writer.close();
+ BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ while ((line = br.readLine()) != null) {
+ jsonString.append(line);
+ }
+ br.close();
+ connection.disconnect();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "POST_fromURL failed", e);
+ throw new RuntimeException(e.getMessage());
+ }
+ return jsonString.toString();
+ }
} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleService.java
index 1a64812d..c4513dd7 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleService.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleService.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * 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
*
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java
index 73da941c..b7a21a4e 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * 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
*
@@ -56,63 +56,56 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-
-
@Service("workflowScheduleService")
@Transactional
-public class WorkflowScheduleServiceImpl implements WorkflowScheduleService{
-
+public class WorkflowScheduleServiceImpl implements WorkflowScheduleService {
+
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowScheduleServiceImpl.class);
-
+
@Autowired
- private DataAccessService dataAccessService;
-
+ private DataAccessService dataAccessService;
+
@Autowired
private WorkFlowScheduleRegistry workflowRegistry;
-
+
@Autowired
private ApplicationContext appContext;
-
+ @Override
public List<WorkflowSchedule> findAll() {
-
- /* List<WorkflowSchedule> allworkflows = getDataAccessService().getList(WorkflowSchedule.class, null);
- for (WorkflowSchedule ws : allworkflows) {
-
- System.out.println("Key:"+ws.getWorkflowKey()+" "+"CronDetails:"+ws.getStartdatetimecron());
- } */
@SuppressWarnings("unchecked")
List<WorkflowSchedule> list = getDataAccessService().getList(WorkflowSchedule.class, null);
return list;
}
-
-
- public void saveWorkflowSchedule(WorkflowSchedule ws){
-
+
+ @Override
+ public void saveWorkflowSchedule(WorkflowSchedule ws) {
getDataAccessService().saveDomainObject(ws, null);
- logger.info(EELFLoggerDelegate.debugLogger, ("Workflow Scheduled " + ws.getId() + " " + ws.getEndDateTime()));
- triggerWorkflowScheduling((SchedulerFactoryBean)appContext.getBean(SchedulerFactoryBean.class),ws);
-
+ logger.info(EELFLoggerDelegate.debugLogger, "Workflow Scheduled " + ws.getId() + " " + ws.getEndDateTime());
+ triggerWorkflowScheduling((SchedulerFactoryBean) appContext.getBean(SchedulerFactoryBean.class), ws);
}
-
+
+ @Override
public void triggerWorkflowScheduling(SchedulerFactoryBean schedulerBean, WorkflowSchedule ws) {
-
try {
- final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(), ws.getWorkflowKey(),ws.getArguments(),ws.getCronDetails(), ws.getStartDateTime(),ws.getEndDateTime());
- schedulerBean.getScheduler().scheduleJob((JobDetail)triggerBean.getJobDataMap().get("jobDetail"),triggerBean.getObject());
+ final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(),
+ ws.getWorkflowKey(), ws.getArguments(), ws.getCronDetails(), ws.getStartDateTime(),
+ ws.getEndDateTime());
+ schedulerBean.getScheduler().scheduleJob((JobDetail) triggerBean.getJobDataMap().get("jobDetail"),
+ triggerBean.getObject());
} catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("Error scheduling work flow with Id" + ws.getId() + e.getMessage()));
+ logger.error(EELFLoggerDelegate.errorLogger, "Error scheduling work flow with Id" + ws.getId(), e);
}
-
}
-
+
+ @Override
public List<Trigger> triggerWorkflowScheduling() {
-
- Date date = new Date();
- List<Trigger> triggers = new ArrayList<Trigger>();
-
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ Date date = new Date();
+ List<Trigger> triggers = new ArrayList<>();
+
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (getDataAccessService() != null) {
@SuppressWarnings("unchecked")
@@ -120,42 +113,32 @@ public class WorkflowScheduleServiceImpl implements WorkflowScheduleService{
.executeQuery("From WorkflowSchedule where endDateTime > '" + dateFormat.format(date) + "'", null);
for (WorkflowSchedule ws : allWorkflows) {
- logger.info(EELFLoggerDelegate.debugLogger, ("Workflow Scheduled " + ws.getId() + "/ End Time: " + ws.getEndDateTime()));
-
+ logger.info(EELFLoggerDelegate.debugLogger,
+ "Workflow Scheduled " + ws.getId() + "/ End Time: " + ws.getEndDateTime());
try {
-
- final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(), ws.getWorkflowKey(),ws.getArguments(), ws.getCronDetails(), ws.getStartDateTime(),ws.getEndDateTime());
-
+ final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(),
+ ws.getServerUrl(), ws.getWorkflowKey(), ws.getArguments(), ws.getCronDetails(),
+ ws.getStartDateTime(), ws.getEndDateTime());
triggers.add(triggerBean.getObject());
-
- //schedulerBean.getScheduler().scheduleJob(trigger);
-
-
} catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("Error scheduling work flow with Id" + ws.getId() + e.getMessage()));
+ logger.error(EELFLoggerDelegate.errorLogger, "Error scheduling work flow with Id" + ws.getId(), e);
}
-
-
}
}
-
+
return triggers;
}
-
-
+
public DataAccessService getDataAccessService() {
return dataAccessService;
}
-
public void setDataAccessService(DataAccessService dataAccessService) {
this.dataAccessService = dataAccessService;
}
@Override
public WorkflowSchedule getWorkflowScheduleByKey(Long key) {
- return (WorkflowSchedule)(getDataAccessService().getDomainObject(WorkflowSchedule.class, key, null));
+ return (WorkflowSchedule) (getDataAccessService().getDomainObject(WorkflowSchedule.class, key, null));
}
}
-
-
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowService.java
index a246273b..42346280 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowService.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowService.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * 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
*
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowServiceImpl.java
index b12aba87..72adba91 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowServiceImpl.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowServiceImpl.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * 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
*
@@ -52,26 +52,14 @@ public class WorkflowServiceImpl implements WorkflowService {
@Autowired
private WorkflowDAO workflowDAO;
-
- //@Autowired
- //private DataAccessService dataAccessService;
-
+
@Autowired
private WorkflowScheduleService workflowScheduleService;
@Override
public void saveCronJob(WorkflowSchedule domainCronJobData) {
- // TODO Auto-generated method stub
workflowScheduleService.saveWorkflowSchedule(domainCronJobData);
-/* triggerWorkflowScheduling((SchedulerFactoryBean)appContext.getBean(SchedulerFactoryBean.class),domainCronJobData);
-*/ }
-
- /*
- private DataAccessService getDataAccessService() {
- // TODO Auto-generated method stub
- return dataAccessService;
}
- */
@Override
public Workflow addWorkflow(Workflow workflow, String creatorId) {