summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-workflow/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src/main/java/org')
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookController.java19
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestController.java20
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookController.java74
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java89
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java5
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java18
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java9
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java117
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/controllers/WorkflowController.java79
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAO.java4
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImpl.java129
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/domain/WorkflowSchedule.java48
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/Workflow.java4
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/WorkflowLite.java4
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java19
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java33
-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
21 files changed, 383 insertions, 499 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookController.java
index d5f4288d..406acd80 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookController.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookController.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
*
@@ -37,12 +37,7 @@
*/
package org.onap.portalsdk.rnotebookintegration.controller;
-import javax.servlet.http.HttpServletRequest;
-
import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.service.UserProfileService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -53,16 +48,8 @@ import org.springframework.web.servlet.ModelAndView;
public class NotebookController extends RestrictedBaseController{
@RequestMapping(value = {"/notebook" }, method = RequestMethod.GET)
- public ModelAndView noteBook(HttpServletRequest request) {
-
- try {
-
- } catch (Exception e) {
-
-
- }
+ public ModelAndView noteBook() {
return new ModelAndView(getViewName());
}
-
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestController.java
index 973f8d05..e4da0ae3 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestController.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestController.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
*
@@ -36,11 +36,8 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-
package org.onap.portalsdk.rnotebookintegration.controller;
-import javax.servlet.http.HttpServletRequest;
-
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -48,13 +45,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
-@RequestMapping("/")
-public class NotebookTestController extends RestrictedBaseController{
-
- @RequestMapping(value = {"/nbooktest" }, method = RequestMethod.GET)
- public ModelAndView noteBook(HttpServletRequest request) {
+@RequestMapping("/")
+public class NotebookTestController extends RestrictedBaseController {
+
+ @RequestMapping(value = { "/nbooktest" }, method = RequestMethod.GET)
+ public ModelAndView noteBook() {
return new ModelAndView(getViewName());
}
-
-
+
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookController.java
index 9a178450..37e7c4de 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookController.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookController.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
*
@@ -37,82 +37,58 @@
*/
package org.onap.portalsdk.rnotebookintegration.controller;
-import java.util.HashMap;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.hibernate.validator.internal.util.privilegedactions.GetMethodFromPropertyName;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.controller.RestrictedRESTfulBaseController;
-import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.restful.domain.EcompUser;
-import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.web.support.JsonMessage;
-import org.onap.portalsdk.core.web.support.UserUtils;
import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
import org.onap.portalsdk.rnotebookintegration.service.RNoteBookIntegrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Controller
@RequestMapping("/rNotebook/")
-
public class RNoteBookController extends RestrictedRESTfulBaseController {
-
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RNoteBookController.class);
+
@Autowired
private RNoteBookIntegrationService rNoteBookIntegrationService;
-
-
public RNoteBookIntegrationService getrNoteBookIntegrationService() {
return rNoteBookIntegrationService;
}
-
-
- public void setrNoteBookIntegrationService(
- RNoteBookIntegrationService rNoteBookIntegrationService) {
+ public void setrNoteBookIntegrationService(RNoteBookIntegrationService rNoteBookIntegrationService) {
this.rNoteBookIntegrationService = rNoteBookIntegrationService;
}
-
-
@RequestMapping(value = { "authCr" }, method = RequestMethod.GET, produces = "application/json")
- public @ResponseBody ResponseEntity<String> getRNotebookCredentials (String token) throws Exception {
- //ObjectMapper mapper = new ObjectMapper();
- //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- //JsonNode root = mapper.readTree(request.getReader());
- //String token = root.get("authenticationToken").textValue();
-
+ @ResponseBody
+ public ResponseEntity<String> getRNotebookCredentials(String token) {
String returnJSON = "";
- try{
+ try {
returnJSON = this.getrNoteBookIntegrationService().getRNotebookCredentials(token);
- } catch(RNotebookIntegrationException re){
- if (re.getErrorCode().equals(RNotebookIntegrationException.ERROR_CODE_TOKEN_EXPIRED)){
- return new ResponseEntity<String>(JsonMessage.buildJsonResponse(false, re.getMessage()), HttpStatus.BAD_REQUEST);
+ } catch (RNotebookIntegrationException re) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getRNotebookCredentials failed 1", re);
+ if (re.getErrorCode().equals(RNotebookIntegrationException.ERROR_CODE_TOKEN_EXPIRED)) {
+ return new ResponseEntity<>(JsonMessage.buildJsonResponse(false, re.getMessage()),
+ HttpStatus.BAD_REQUEST);
+ } else {
+ return new ResponseEntity<>(JsonMessage.buildJsonResponse(false, re.getMessage()),
+ HttpStatus.BAD_REQUEST);
}
- else {
- return new ResponseEntity<String>(JsonMessage.buildJsonResponse(false, re.getMessage()), HttpStatus.BAD_REQUEST);
- }
- }
- catch (Exception e){
- return new ResponseEntity<String>(JsonMessage.buildJsonResponse(false, e.getMessage()), HttpStatus.BAD_REQUEST);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getRNotebookCredentials failed 2", e);
+ return new ResponseEntity<>(JsonMessage.buildJsonResponse(false, e.getMessage()),
+ HttpStatus.BAD_REQUEST);
}
-
- return new ResponseEntity<String>(returnJSON, HttpStatus.OK);
-
+
+ return new ResponseEntity<>(returnJSON, HttpStatus.OK);
}
-
-
+
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java
index 0268284c..4cad5b39 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEController.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
*
@@ -46,6 +46,7 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.portalsdk.core.web.support.UserUtils;
@@ -63,69 +64,55 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/rNotebookFE/")
public class RNoteBookFEController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RNoteBookController.class);
+
@Autowired
private RNoteBookIntegrationService rNoteBookIntegrationService;
-
-
public RNoteBookIntegrationService getrNoteBookIntegrationService() {
return rNoteBookIntegrationService;
}
-
-
- public void setrNoteBookIntegrationService(
- RNoteBookIntegrationService rNoteBookIntegrationService) {
+ public void setrNoteBookIntegrationService(RNoteBookIntegrationService rNoteBookIntegrationService) {
this.rNoteBookIntegrationService = rNoteBookIntegrationService;
}
-
+
@RequestMapping(value = { "authCr" }, method = RequestMethod.POST, produces = "application/json")
- public @ResponseBody ResponseEntity<String> saveRNotebookCredentials (@RequestBody String notebookId, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- //ObjectMapper mapper = new ObjectMapper();
- //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- //JsonNode root = mapper.readTree(request.getReader());
- //String token = root.get("authenticationToken").textValue();
- System.out.println("Notebook id "+notebookId);
- System.out.println("Query parameters "+request.getParameter("qparams"));
+ @ResponseBody
+ public ResponseEntity<String> saveRNotebookCredentials(@RequestBody String notebookId, HttpServletRequest request,
+ HttpServletResponse response) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "saveRNotebookCredentials: Notebook id {}", notebookId);
+ logger.debug(EELFLoggerDelegate.debugLogger, "saveRNotebookCredentials: Query parameters {}", request.getParameter("qparams"));
String retUrl = "";
- try{
-
+ try {
User user = UserUtils.getUserSession(request);
- user = (User) this.getDataAccessService().getDomainObject(User.class, user.getId(), null);
-
- EcompUser ecUser =UserUtils.convertToEcompUser(user);
-
- HashMap<String, String> map = new HashMap<String, String>();
- JSONObject jObject = new JSONObject(request.getParameter("qparams"));
- Iterator<?> keys = jObject.keys();
-
- while( keys.hasNext() ){
- String key = (String)keys.next();
- String value = jObject.getString(key);
- map.put(key, value);
-
- }
-
- System.out.println("json : "+jObject);
- System.out.println("map : "+map);
-
- // String token = this.getrNoteBookIntegrationService().saveRNotebookCredentials(notebookId, ecUser, new HashMap<String, String>());
- String token = this.getrNoteBookIntegrationService().saveRNotebookCredentials(notebookId, ecUser, map);
-
- String guard = SystemProperties.getProperty("guard_notebook_url");
-
+ user = (User) getDataAccessService().getDomainObject(User.class, user.getId(), null);
+ EcompUser ecUser = UserUtils.convertToEcompUser(user);
+ HashMap<String, String> map = new HashMap<>();
+ JSONObject jObject = new JSONObject(request.getParameter("qparams"));
+ Iterator<?> keys = jObject.keys();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ String value = jObject.getString(key);
+ map.put(key, value);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "saveRNotebookCredentials: json {}", jObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, "saveRNotebookCredentials: map {}", map);
+ String token = this.getrNoteBookIntegrationService().saveRNotebookCredentials(notebookId, ecUser, map);
+ final String guardNotebookUrl = "guard_notebook_url";
+ if (!SystemProperties.containsProperty(guardNotebookUrl))
+ throw new IllegalArgumentException("Failed to find property " + guardNotebookUrl);
+ String guard = SystemProperties.getProperty(guardNotebookUrl);
retUrl = guard + "id=" + token;
-
-
- } catch (RNotebookIntegrationException re){
- return new ResponseEntity<String>(re.getMessage(), HttpStatus.BAD_REQUEST);
- } catch (Exception e){
- return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST);
+ } catch (RNotebookIntegrationException re) {
+ logger.error(EELFLoggerDelegate.errorLogger, "saveRNotebookCredentials failed 1", re);
+ return new ResponseEntity<>(re.getMessage(), HttpStatus.BAD_REQUEST);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "saveRNotebookCredentials failed 2", e);
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}
-
- return new ResponseEntity<String>(retUrl, HttpStatus.OK);
-
+ return new ResponseEntity<>(retUrl, HttpStatus.OK);
}
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java
index 0744aab3..99d7085b 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.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
*
@@ -40,7 +40,6 @@ package org.onap.portalsdk.rnotebookintegration.domain;
import java.util.Date;
import java.util.Map;
-import org.onap.portalsdk.core.domain.User;
import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.portalsdk.core.restful.domain.EcompUser;
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java
index ff576725..d4ae7352 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.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
*
@@ -38,10 +38,18 @@
package org.onap.portalsdk.rnotebookintegration.exception;
public class RNotebookIntegrationException extends Exception {
+
+ private static final long serialVersionUID = -2930083784603307194L;
+
public static final String ERROR_CODE_TOKEN_EXPIRED = "ERROR_CODE_TOKEN_EXPIRED";
public static final String ERROR_CODE_TOKEN_INVALID = "ERROR_CODE_TOKEN_INVALID";
- String errorCode;
+ private final String errorCode;
+
+ public RNotebookIntegrationException(Exception ex){
+ super(ex);
+ this.errorCode = null;
+ }
public RNotebookIntegrationException(String errorCodeStr){
super(errorCodeStr);
@@ -52,8 +60,4 @@ public class RNotebookIntegrationException extends Exception {
return errorCode;
}
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java
index 11de7d25..15536c80 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.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
*
@@ -43,7 +43,8 @@ import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
public interface RNoteBookIntegrationService {
- public String getRNotebookCredentials(String token) throws RNotebookIntegrationException, Exception;
+
+ public String getRNotebookCredentials(String token) throws RNotebookIntegrationException;
- public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params) throws RNotebookIntegrationException, Exception;
+ public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params) throws RNotebookIntegrationException;
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java
index 8a21b71a..bac23706 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.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
*
@@ -37,7 +37,6 @@
*/
package org.onap.portalsdk.rnotebookintegration.service;
-import java.security.SecureRandom;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -46,28 +45,27 @@ import java.util.UUID;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.web.support.UserUtils;
import org.onap.portalsdk.rnotebookintegration.domain.RNoteBookCredentials;
import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Service("RNoteBookIntegrationService")
@Transactional
public class RNoteBookIntegrationServiceImpl implements RNoteBookIntegrationService {
-
- private final long tokenTTL = 50000L;
-
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RNoteBookIntegrationServiceImpl.class);
-
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate
+ .getLogger(RNoteBookIntegrationServiceImpl.class);
+
+ private static final long TOKEN_TTL = 50000L;
+
@Autowired
- private DataAccessService dataAccessService;
-
+ private DataAccessService dataAccessService;
+
public DataAccessService getDataAccessService() {
return dataAccessService;
}
@@ -75,89 +73,78 @@ public class RNoteBookIntegrationServiceImpl implements RNoteBookIntegrationServ
public void setDataAccessService(DataAccessService dataAccessService) {
this.dataAccessService = dataAccessService;
}
-
+
@Override
- public String getRNotebookCredentials(String token) throws RNotebookIntegrationException, Exception {
+ public String getRNotebookCredentials(String token) throws RNotebookIntegrationException {
String retString = "";
-
- try{
- RNoteBookCredentials notebookCredentials = (RNoteBookCredentials) this.getDataAccessService().getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>());
- if (notebookCredentials.getToken() == null || notebookCredentials.getToken().equals("")){
+
+ try {
+ RNoteBookCredentials notebookCredentials = (RNoteBookCredentials) this.getDataAccessService()
+ .getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>());
+ if (notebookCredentials.getToken() == null || "".equals(notebookCredentials.getToken())) {
throw new RNotebookIntegrationException(RNotebookIntegrationException.ERROR_CODE_TOKEN_INVALID);
}
Date currDate = new Date();
- if ((currDate.getTime() - notebookCredentials.getCreatedDate().getTime() > tokenTTL) || (notebookCredentials.getTokenReadDate() != null)){
+ if ((currDate.getTime() - notebookCredentials.getCreatedDate().getTime() > TOKEN_TTL)
+ || (notebookCredentials.getTokenReadDate() != null)) {
throw new RNotebookIntegrationException(RNotebookIntegrationException.ERROR_CODE_TOKEN_EXPIRED);
}
ObjectMapper mapper = new ObjectMapper();
-
- try{
+
+ try {
EcompUser userInfo = mapper.readValue(notebookCredentials.getUserString(), EcompUser.class);
- notebookCredentials.setUserInfo(userInfo);
- } catch(JsonMappingException me){
- logger.error("error converting string to user. from JSON" + me.getMessage());
- } catch(JsonParseException pe){
- logger.error("error converting string to user. from JSON" + pe.getMessage());
+ notebookCredentials.setUserInfo(userInfo);
+ } catch (JsonProcessingException me) {
+ logger.error(EELFLoggerDelegate.errorLogger, "error converting string to user. from JSON", me);
}
-
- try{
- Map<String, String> params = mapper.readValue(notebookCredentials.getParametersString(), HashMap.class);
+
+ try {
+ Map<String, String> params = mapper.readValue(notebookCredentials.getParametersString(), Map.class);
notebookCredentials.setParameters(params);
- } catch(JsonMappingException me){
- logger.error("error converting string to parameters. from JSON" + me.getMessage());
- } catch(JsonParseException pe){
- logger.error("error converting string to parameters. from JSON" + pe.getMessage());
+ } catch (JsonProcessingException me) {
+ logger.error(EELFLoggerDelegate.errorLogger, "error converting string to parameters. from JSON", me);
}
-
- //expiring the token
- try{
+
+ // expiring the token
+ try {
notebookCredentials.setTokenReadDate(new Date());
this.getDataAccessService().saveDomainObject(notebookCredentials, null);
- } catch(Exception e){
- logger.info("Error while expiring the token");
- logger.error(e.getMessage());
- throw new Exception();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Error while expiring the token", e);
+ throw new RNotebookIntegrationException(e);
}
- //notebookCredentials.setUserString(null);
retString = mapper.writeValueAsString(notebookCredentials);
- } catch(RNotebookIntegrationException re){
- logger.error(re.getMessage());
+ } catch (RNotebookIntegrationException re) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getRNotebookCredentials failed", re);
throw re;
- } catch(Exception e){
- logger.info("Error while parsing the rcloud notebook credentials");
- logger.error(e.getMessage());
- throw new Exception();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Error while parsing the rcloud notebook credentials", e);
+ throw new RNotebookIntegrationException(e);
}
-
- return retString;
+
+ return retString;
}
-
+
@Override
- public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params) throws RNotebookIntegrationException, Exception {
-
+ public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params)
+ throws RNotebookIntegrationException {
+
String token = "";
- try{
+ try {
token = UUID.randomUUID().toString();
-
ObjectMapper mapper = new ObjectMapper();
- ;
RNoteBookCredentials rc = new RNoteBookCredentials();
rc.setToken(token);
rc.setCreatedDate(new Date());
rc.setNotebookID(notebookId);
rc.setParametersString(mapper.writeValueAsString(params));
rc.setUserString(mapper.writeValueAsString(user));
-
this.getDataAccessService().saveDomainObject(rc, null);
-
- } catch(Exception e){
- logger.info("Error while parsing the rcloud notebook credentials");
- logger.error(e.getMessage());
- throw new Exception();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Error while parsing the rcloud notebook credentials", e);
+ throw new RNotebookIntegrationException(e);
}
-
- return token;
+ return token;
}
-
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/controllers/WorkflowController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/controllers/WorkflowController.java
index 2566868e..42386821 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/controllers/WorkflowController.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/controllers/WorkflowController.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
*
@@ -47,7 +47,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.json.JSONObject;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.domain.User;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -73,19 +72,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@RequestMapping("/")
public class WorkflowController extends RestrictedBaseController {
-
+
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowController.class);
@Autowired
private WorkflowService workflowService;
- // @Autowired
- // private CronJobService cronJobService;
@RequestMapping(value = { "workflows/saveCronJob" }, method = RequestMethod.POST)
public void saveCronJob(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
- // System.out.println("inside save cron job...");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -93,38 +89,33 @@ public class WorkflowController extends RestrictedBaseController {
WorkflowSchedule domainCronJobData = new WorkflowSchedule();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- domainCronJobData.setCronDetails(root.get("cronJobDataObj").get("startDateTime_CRON").textValue());
- domainCronJobData.setWorkflowKey(root.get("cronJobDataObj").get("workflowKey").textValue());
- domainCronJobData.setArguments(root.get("cronJobDataObj").get("workflow_arguments").textValue());
- domainCronJobData.setServerUrl(root.get("cronJobDataObj").get("workflow_server_url").textValue());
- domainCronJobData
- .setStartDateTime(dateFormat.parse(root.get("cronJobDataObj").get("startDateTime").textValue()));
- domainCronJobData
- .setEndDateTime(dateFormat.parse(root.get("cronJobDataObj").get("endDateTime").textValue()));
- domainCronJobData.setRecurrence(root.get("cronJobDataObj").get("recurrence").textValue());
-
+ final JsonNode cronJobDataObj = root.get("cronJobDataObj");
+ domainCronJobData.setCronDetails(cronJobDataObj.get("startDateTime_CRON").textValue());
+ domainCronJobData.setWorkflowKey(cronJobDataObj.get("workflowKey").textValue());
+ domainCronJobData.setArguments(cronJobDataObj.get("workflow_arguments").textValue());
+ domainCronJobData.setServerUrl(cronJobDataObj.get("workflow_server_url").textValue());
+ domainCronJobData.setStartDateTime(dateFormat.parse(cronJobDataObj.get("startDateTime").textValue()));
+ domainCronJobData.setEndDateTime(dateFormat.parse(cronJobDataObj.get("endDateTime").textValue()));
+ domainCronJobData.setRecurrence(cronJobDataObj.get("recurrence").textValue());
workflowService.saveCronJob(domainCronJobData);
-
- // response.getWriter().write("hello".toString());
-
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "saveCronJob failed", e);
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
out.write(e.getMessage());
-
}
}
@RequestMapping(value = { "workflows/list" }, method = RequestMethod.GET, produces = "application/json")
- public @ResponseBody String getWorkflowList() {
+ @ResponseBody
+ public String getWorkflowList() {
ObjectMapper mapper = new ObjectMapper();
List<Workflow> workflows = workflowService.getAllWorkflows();
- List<WorkflowLite> workflowLites = new ArrayList<WorkflowLite>();
+ List<WorkflowLite> workflowLites = new ArrayList<>();
try {
-
for (Workflow workflow : workflows) {
WorkflowLite wfl = new WorkflowLite();
wfl.setId(workflow.getId());
@@ -146,59 +137,43 @@ public class WorkflowController extends RestrictedBaseController {
return mapper.writeValueAsString(workflowLites);
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, "getWorkflowList failed", e);
}
return "";
}
@RequestMapping(value = "workflows/addWorkflow", method = RequestMethod.POST, consumes = "application/json")
- public @ResponseBody Workflow addWorkflow(@RequestBody Workflow workflow, HttpServletRequest request,
- HttpServletResponse response) {
+ @ResponseBody
+ public Workflow addWorkflow(@RequestBody Workflow workflow, HttpServletRequest request) {
String loginId = ((User) (request.getSession().getAttribute("user"))).getLoginId();
return workflowService.addWorkflow(workflow, loginId);
}
@RequestMapping(value = "workflows/editWorkflow", method = RequestMethod.POST, consumes = "application/json")
- public @ResponseBody Workflow editWorkflow(@RequestBody WorkflowLite workflow, HttpServletRequest request,
- HttpServletResponse response) {
+ @ResponseBody
+ public Workflow editWorkflow(@RequestBody WorkflowLite workflow, HttpServletRequest request) {
String loginId = ((User) (request.getSession().getAttribute("user"))).getLoginId();
return workflowService.editWorkflow(workflow, loginId);
}
- // @RequestMapping(value = "workflows/removeWorkflow", method =
- // RequestMethod.DELETE)
@RequestMapping(value = { "workflows/removeWorkflow" }, method = RequestMethod.POST, consumes = "application/json")
- public @ResponseBody void removeWorkflow(@RequestBody Long workflowId, HttpServletRequest request,
- HttpServletResponse response) {
-
- // System.out.println("Removing ... " + workflowId);
-
+ @ResponseBody
+ public String removeWorkflow(@RequestBody Long workflowId, HttpServletRequest request, HttpServletResponse response) {
workflowService.deleteWorkflow(workflowId);
-
response.setCharacterEncoding("UTF-8");
response.setContentType("application / json");
- PrintWriter out = null;
- try {
- request.setCharacterEncoding("UTF-8");
- out = response.getWriter();
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "removeWorkflow failed", e);
- }
-
- JSONObject j = new JSONObject("{removed: 123}");
- out.write(j.toString());
-
+ return "{removed: 123}";
}
@RequestMapping(value = "workflows/removeAllWorkflows", method = RequestMethod.DELETE)
- public @ResponseBody void removeAllWorkflows() {
- // workflowService.deleteAll();
+ @ResponseBody
+ public void removeAllWorkflows() {
+ throw new UnsupportedOperationException();
}
@RequestMapping(value = { "/workflows" }, method = RequestMethod.GET)
public ModelAndView getWorkflowPartialPage() {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
return new ModelAndView(getViewName(), "workflows", model);
}
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAO.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAO.java
index cb7b27a3..c3b805aa 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAO.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAO.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/dao/WorkflowDAOImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImpl.java
index 8fdb64fc..3208997f 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImpl.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImpl.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
*
@@ -45,83 +45,88 @@ import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.workflow.models.Workflow;
import org.onap.portalsdk.workflow.models.WorkflowLite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
+
@Repository
-public class WorkflowDAOImpl implements WorkflowDAO{
-
+public class WorkflowDAOImpl implements WorkflowDAO {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowDAOImpl.class);
+
@Autowired
private SessionFactory sessionFactory;
-
- public Workflow save(Workflow workflow, String creatorId){
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
-
- try{
- Query query = session.createQuery("from User where loginId =:loginId");
- query.setParameter("loginId", creatorId);
- User creator = (User)(query.list().get(0));
-
- workflow.setCreatedBy(creator);
- workflow.setCreated(new Date());
- }
- catch(Exception e){
- e.printStackTrace();
- }
-
- long id = (Long) session.save(workflow);
- Workflow savedWorkflow = (Workflow) session.get(Workflow.class, id);
- tx.commit();
- session.close();
- return savedWorkflow;
+
+ @Override
+ public Workflow save(Workflow workflow, String creatorId) {
+ Session session = this.sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+
+ try {
+ Query query = session.createQuery("from User where loginId =:loginId");
+ query.setParameter("loginId", creatorId);
+ User creator = (User) (query.list().get(0));
+ workflow.setCreatedBy(creator);
+ workflow.setCreated(new Date());
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "save failed", e);
+ }
+
+ long id = (Long) session.save(workflow);
+ Workflow savedWorkflow = (Workflow) session.get(Workflow.class, id);
+ tx.commit();
+ session.close();
+ return savedWorkflow;
}
-
- public List<Workflow> getWorkflows(){
+
+ @Override
+ public List<Workflow> getWorkflows() {
Session session = this.sessionFactory.openSession();
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
List<Workflow> workflows = session.createQuery("from Workflow").list();
- session.close();
- return workflows;
+ session.close();
+ return workflows;
}
@Override
public void delete(Long workflowId) {
Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- Query query = session.createQuery("delete from Workflow where id =:id");
- query.setParameter("id", workflowId);
- query.executeUpdate();
- tx.commit();
- session.close();
- }
+ Transaction tx = session.beginTransaction();
+ Query query = session.createQuery("delete from Workflow where id =:id");
+ query.setParameter("id", workflowId);
+ query.executeUpdate();
+ tx.commit();
+ session.close();
+ }
@Override
public Workflow edit(WorkflowLite workflowLight, String creatorId) {
- Session session = this.sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
-
- Query query = session.createQuery("from User where loginId =:loginId");
- query.setParameter("loginId", creatorId);
- User creator = (User)(query.list().get(0));
-
- Workflow workflowToModify = (Workflow) session.get(Workflow.class, workflowLight.getId());
-
- workflowToModify.setActive(workflowLight.getActive().equalsIgnoreCase("true") ? true : false );
- workflowToModify.setSuspendLink(workflowLight.getSuspendLink());
- workflowToModify.setRunLink(workflowLight.getRunLink());
- workflowToModify.setDescription(workflowLight.getDescription());
- workflowToModify.setWorkflowKey(workflowLight.getWorkflowKey());
- workflowToModify.setName(workflowLight.getName());
-
- workflowToModify.setModifiedBy(creator);
- workflowToModify.setLastUpdated(new Date());
-
- session.update(workflowToModify);
- Workflow savedWorkflow = (Workflow) session.get(Workflow.class, workflowLight.getId());
- tx.commit();
- session.close();
- return savedWorkflow;
+ Session session = this.sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+
+ Query query = session.createQuery("from User where loginId =:loginId");
+ query.setParameter("loginId", creatorId);
+ User creator = (User) (query.list().get(0));
+
+ Workflow workflowToModify = (Workflow) session.get(Workflow.class, workflowLight.getId());
+
+ final boolean active = "true".equalsIgnoreCase(workflowLight.getActive()) ? true : false;
+ workflowToModify.setActive(active);
+ workflowToModify.setSuspendLink(workflowLight.getSuspendLink());
+ workflowToModify.setRunLink(workflowLight.getRunLink());
+ workflowToModify.setDescription(workflowLight.getDescription());
+ workflowToModify.setWorkflowKey(workflowLight.getWorkflowKey());
+ workflowToModify.setName(workflowLight.getName());
+
+ workflowToModify.setModifiedBy(creator);
+ workflowToModify.setLastUpdated(new Date());
+
+ session.update(workflowToModify);
+ Workflow savedWorkflow = (Workflow) session.get(Workflow.class, workflowLight.getId());
+ tx.commit();
+ session.close();
+ return savedWorkflow;
}
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/domain/WorkflowSchedule.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/domain/WorkflowSchedule.java
index 58f1377a..ecc3ac6d 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/domain/WorkflowSchedule.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/domain/WorkflowSchedule.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
*
@@ -36,74 +36,90 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.portalsdk.workflow.domain;
+
import java.util.Date;
import org.onap.portalsdk.core.domain.support.DomainVo;
-public class WorkflowSchedule extends DomainVo{
- /**
- *
- */
+
+public class WorkflowSchedule extends DomainVo {
private static final long serialVersionUID = 1L;
private Long id;
- private String serverUrl;
- private String workflowKey;
- private String arguments;
- private String cronDetails;
- private Date endDateTime;
- private Date startDateTime;
- private String recurrence;
-
+ private String serverUrl;
+ private String workflowKey;
+ private String arguments;
+ private String cronDetails;
+ private Date endDateTime;
+ private Date startDateTime;
+ private String recurrence;
+
+ @Override
public Long getId() {
return id;
}
+
+ @Override
public void setId(Long id) {
this.id = id;
}
+
public String getServerUrl() {
return serverUrl;
}
+
public void setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
}
+
public String getWorkflowKey() {
return workflowKey;
}
+
public void setWorkflowKey(String workflowKey) {
this.workflowKey = workflowKey;
}
+
public String getArguments() {
return arguments;
}
+
public void setArguments(String arguments) {
this.arguments = arguments;
}
+
public String getCronDetails() {
return cronDetails;
}
+
public void setCronDetails(String cronDetails) {
this.cronDetails = cronDetails;
}
+
public Date getEndDateTime() {
return endDateTime;
}
+
public void setEndDateTime(Date endDateTime) {
this.endDateTime = endDateTime;
}
+
public Date getStartDateTime() {
return startDateTime;
}
+
public void setStartDateTime(Date startDateTime) {
this.startDateTime = startDateTime;
}
+
public String getRecurrence() {
return recurrence;
}
+
public void setRecurrence(String recurrence) {
this.recurrence = recurrence;
}
+
public static long getSerialversionuid() {
return serialVersionUID;
}
-
-
+
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/Workflow.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/Workflow.java
index 734b356f..76ba3d39 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/Workflow.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/Workflow.java
@@ -7,7 +7,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
*
@@ -20,7 +20,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/models/WorkflowLite.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/WorkflowLite.java
index 3f689095..1dfce84e 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/WorkflowLite.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/models/WorkflowLite.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/scheduler/WorkFlowScheduleJob.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java
index 3882865a..f9816c26 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJob.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
*
@@ -43,18 +43,15 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
-public class WorkFlowScheduleJob extends QuartzJobBean{
-
+public class WorkFlowScheduleJob extends QuartzJobBean {
+
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkFlowScheduleJob.class);
@Override
- protected void executeInternal(JobExecutionContext context)
- throws JobExecutionException {
-
- String serverUrl = (String)context.getMergedJobDataMap().get("serverUrl");
- String workflowKey = (String)context.getMergedJobDataMap().get("workflowKey");
- //String arguments = (String)context.getMergedJobDataMap().get("arguments");
- logger.info(EELFLoggerDelegate.debugLogger, ("Executing the job for the workflow " + workflowKey));
+ protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
+ String serverUrl = (String) context.getMergedJobDataMap().get("serverUrl");
+ String workflowKey = (String) context.getMergedJobDataMap().get("workflowKey");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Executing the job for the workflow {}", workflowKey);
WorkflowScheduleExecutor executor = new WorkflowScheduleExecutor(serverUrl, workflowKey);
executor.execute();
}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java
index 2412b992..2ac9cddb 100644
--- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.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
*
@@ -37,6 +37,7 @@
*/
package org.onap.portalsdk.workflow.scheduler;
+import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@@ -56,20 +57,16 @@ public class WorkFlowScheduleRegistry{
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkFlowScheduleRegistry.class);
- public WorkFlowScheduleRegistry() {
-
- }
-
private static final String groupName = "AppGroup";
private static final String jobName = "WorkflowScheduleJob";
private static final String triggerName = "WorkflowScheduleTrigger";
- // @Autowired
- // private SystemProperties systemProperties;
+ public WorkFlowScheduleRegistry() {
+ super();
+ }
// @Bean
public JobDetailFactoryBean jobDetailFactoryBean(Map<String, ?> contextInfoMap) {
-
JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
jobDetailFactory.setJobClass(WorkFlowScheduleJob.class);
jobDetailFactory.setJobDataAsMap(contextInfoMap);
@@ -81,13 +78,13 @@ public class WorkFlowScheduleRegistry{
// @Bean
public CronTriggerFactoryBean cronTriggerFactoryBean(JobDetailFactoryBean jobDetailFactory, Long id,
- String cronExpression, Date startDateTime, Date enddatetime) throws Exception {
+ String cronExpression, Date startDateTime, Date enddatetime) throws ParseException {
CronTriggerFactoryBean cronTriggerFactory = new CronTriggerFactoryBean();
cronTriggerFactory.setJobDetail(jobDetailFactory.getObject());
cronTriggerFactory.setStartDelay(3000);
cronTriggerFactory.setName(triggerName + "_" + id);
cronTriggerFactory.setGroup(groupName);
- logger.debug(EELFLoggerDelegate.debugLogger, (triggerName + " Scheduled: " + cronExpression));
+ logger.debug(EELFLoggerDelegate.debugLogger, triggerName + " Scheduled: " + cronExpression);
cronTriggerFactory.setCronExpression( cronExpression); //"0 * * * * ? *"
cronTriggerFactory.afterPropertiesSet();
@@ -96,27 +93,21 @@ public class WorkFlowScheduleRegistry{
cronTrigger.setEndTime(enddatetime);
Date fireAgainTime = cronTrigger.getFireTimeAfter(cronTrigger.getStartTime());
if (fireAgainTime == null)
- throw new Exception("Cron not added as it may not fire again " + " Expr: " + cronExpression + " End Time: "
+ throw new IllegalArgumentException("Cron not added as it may not fire again " + " Expr: " + cronExpression + " End Time: "
+ cronTrigger.getEndTime());
return cronTriggerFactory;
-
}
public CronTriggerFactoryBean setUpTrigger(Long wfId, String serverUrl, String workflowKey, String arguments,
- String startdatetimecron, Date startDateTime, Date enddatetime) throws Exception {
+ String startdatetimecron, Date startDateTime, Date enddatetime) throws ParseException {
- Map<String, String> contextInfo = new HashMap<String, String>();
+ Map<String, String> contextInfo = new HashMap<>();
contextInfo.put("serverUrl", serverUrl);
contextInfo.put("workflowKey", workflowKey);
contextInfo.put("arguments", arguments);
JobDetailFactoryBean jobDetailFactory = jobDetailFactoryBean(contextInfo);
-
CronTriggerFactoryBean cronTriggerFactory = cronTriggerFactoryBean(jobDetailFactory, wfId, startdatetimecron, startDateTime, enddatetime);
-
- logger.debug(EELFLoggerDelegate.debugLogger, (" Job to be Scheduled: " + contextInfo.get("workflowKey")));
-
- //cronTriggerFactory.
-
+ logger.debug(EELFLoggerDelegate.debugLogger, " Job to be Scheduled: " + contextInfo.get("workflowKey"));
return cronTriggerFactory;
}
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) {