summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-workflow/src
diff options
context:
space:
mode:
authorTATTAVARADA <statta@research.att.com>2017-04-27 07:53:18 -0400
committerst782s <statta@research.att.com>2017-04-27 08:31:27 -0400
commit6beb446925c967aca92f5513adf36c5db77c00d6 (patch)
tree9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/epsdk-workflow/src
parent246b225194e3e8dc1926294de591a94fd9787fa7 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src')
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookController.java53
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookTestController.java55
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookController.java100
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java113
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java94
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java41
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java31
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java146
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/controllers/WorkflowController.java183
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAO.java32
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAOImpl.java109
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/domain/WorkflowSchedule.java91
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/Workflow.java203
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/WorkflowLite.java174
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java45
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java107
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleExecutor.java108
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleService.java34
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java144
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowService.java16
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowServiceImpl.java77
-rw-r--r--ecomp-sdk/epsdk-workflow/src/main/resources/RNoteBookIntegration.hbm.xml43
22 files changed, 1999 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookController.java
new file mode 100644
index 00000000..8b8ad5c9
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookController.java
@@ -0,0 +1,53 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.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;
+import org.springframework.web.servlet.ModelAndView;
+
+@Controller
+@RequestMapping("/")
+public class NotebookController extends RestrictedBaseController{
+ @Autowired
+ UserProfileService service;
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(NotebookController.class);
+
+ @RequestMapping(value = {"/notebook" }, method = RequestMethod.GET)
+ public ModelAndView noteBook(HttpServletRequest request) {
+
+ try {
+
+ } catch (Exception e) {
+
+
+ }
+ return new ModelAndView(getViewName());
+ }
+
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookTestController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookTestController.java
new file mode 100644
index 00000000..ac56b6c6
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/NotebookTestController.java
@@ -0,0 +1,55 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+
+
+package org.openecomp.portalsdk.rnotebookintegration.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.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;
+import org.springframework.web.servlet.ModelAndView;
+
+@Controller
+@RequestMapping("/")
+public class NotebookTestController extends RestrictedBaseController{
+ @Autowired
+ UserProfileService service;
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(NotebookTestController.class);
+
+ @RequestMapping(value = {"/nbooktest" }, method = RequestMethod.GET)
+ public ModelAndView noteBook(HttpServletRequest request) {
+
+ try {
+
+ } catch (Exception e) {
+
+
+ }
+ return new ModelAndView(getViewName());
+ }
+
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookController.java
new file mode 100644
index 00000000..00d97268
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookController.java
@@ -0,0 +1,100 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.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.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.controller.RestrictedRESTfulBaseController;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.openecomp.portalsdk.core.web.support.JsonMessage;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.openecomp.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+import org.openecomp.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 {
+
+ @Autowired
+ private RNoteBookIntegrationService rNoteBookIntegrationService;
+
+
+
+ public RNoteBookIntegrationService getrNoteBookIntegrationService() {
+ return 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();
+
+ String returnJSON = "";
+ 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);
+ }
+ 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);
+ }
+
+ return new ResponseEntity<String>(returnJSON, HttpStatus.OK);
+
+ }
+
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java
new file mode 100644
index 00000000..3b0fcc49
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/controller/RNoteBookFEController.java
@@ -0,0 +1,113 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.controller;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.json.JSONObject;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.openecomp.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+import org.openecomp.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;
+
+@Controller
+@RequestMapping("/rNotebookFE/")
+public class RNoteBookFEController extends RestrictedBaseController {
+ @Autowired
+ private RNoteBookIntegrationService rNoteBookIntegrationService;
+
+
+
+ public RNoteBookIntegrationService getrNoteBookIntegrationService() {
+ return 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"));
+ String retUrl = "";
+ 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");
+
+ 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);
+ }
+
+ return new ResponseEntity<String>(retUrl, HttpStatus.OK);
+
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java
new file mode 100644
index 00000000..d2928495
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/domain/RNoteBookCredentials.java
@@ -0,0 +1,94 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.domain;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.domain.support.DomainVo;
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class RNoteBookCredentials extends DomainVo {
+ private EcompUser userInfo;
+ private String token;
+ private Date createdDate;
+ private String notebookID;
+ private Map<String, String> parameters;
+ private Date tokenReadDate;
+ @JsonIgnore
+ private String userString;
+ @JsonIgnore
+ private String parametersString;
+
+ public String getToken() {
+ return token;
+ }
+ public void setToken(String token) {
+ this.token = token;
+ }
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+ public String getNotebookID() {
+ return notebookID;
+ }
+ public EcompUser getUserInfo() {
+ return userInfo;
+ }
+ public void setUserInfo(EcompUser userInfo) {
+ this.userInfo = userInfo;
+ }
+ public void setNotebookID(String notebookID) {
+ this.notebookID = notebookID;
+ }
+ public String getUserString() {
+ return userString;
+ }
+ public void setUserString(String userString) {
+ this.userString = userString;
+ }
+ public Map<String, String> getParameters() {
+ return parameters;
+ }
+ public void setParameters(Map<String, String> parameters) {
+ this.parameters = parameters;
+ }
+ public String getParametersString() {
+ return parametersString;
+ }
+ public void setParametersString(String parametersString) {
+ this.parametersString = parametersString;
+ }
+ public Date getTokenReadDate() {
+ return tokenReadDate;
+ }
+ public void setTokenReadDate(Date tokenReadDate) {
+ this.tokenReadDate = tokenReadDate;
+ }
+
+
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java
new file mode 100644
index 00000000..b2742641
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/exception/RNotebookIntegrationException.java
@@ -0,0 +1,41 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.exception;
+
+public class RNotebookIntegrationException extends Exception {
+ 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;
+
+ public RNotebookIntegrationException(String errorCodeStr){
+ super(errorCodeStr);
+ this.errorCode = errorCodeStr;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java
new file mode 100644
index 00000000..2b1e3c9e
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationService.java
@@ -0,0 +1,31 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.service;
+
+import java.util.Map;
+
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.openecomp.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+
+public interface RNoteBookIntegrationService {
+ public String getRNotebookCredentials(String token) throws RNotebookIntegrationException, Exception;
+
+ public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params) throws RNotebookIntegrationException, Exception;
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java
new file mode 100644
index 00000000..fe21cd13
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImpl.java
@@ -0,0 +1,146 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.rnotebookintegration.service;
+
+import java.security.SecureRandom;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.openecomp.portalsdk.core.service.DataAccessService;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.openecomp.portalsdk.rnotebookintegration.domain.RNoteBookCredentials;
+import org.openecomp.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.databind.ObjectMapper;
+
+@Service("RNoteBookIntegrationService")
+@Transactional
+public class RNoteBookIntegrationServiceImpl implements RNoteBookIntegrationService {
+
+ private final long tokenTTL = 50000L;
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RNoteBookIntegrationServiceImpl.class);
+
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ public DataAccessService getDataAccessService() {
+ return dataAccessService;
+ }
+
+ public void setDataAccessService(DataAccessService dataAccessService) {
+ this.dataAccessService = dataAccessService;
+ }
+
+ @Override
+ public String getRNotebookCredentials(String token) throws RNotebookIntegrationException, Exception {
+ String retString = "";
+
+ try{
+ RNoteBookCredentials notebookCredentials = (RNoteBookCredentials) this.getDataAccessService().getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>());
+ if (notebookCredentials.getToken() == null || notebookCredentials.getToken().equals("")){
+ throw new RNotebookIntegrationException(RNotebookIntegrationException.ERROR_CODE_TOKEN_INVALID);
+ }
+ Date currDate = new Date();
+ if ((currDate.getTime() - notebookCredentials.getCreatedDate().getTime() > tokenTTL) || (notebookCredentials.getTokenReadDate() != null)){
+ throw new RNotebookIntegrationException(RNotebookIntegrationException.ERROR_CODE_TOKEN_EXPIRED);
+ }
+ ObjectMapper mapper = new ObjectMapper();
+
+ 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());
+ }
+
+ try{
+ Map<String, String> params = mapper.readValue(notebookCredentials.getParametersString(), HashMap.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());
+ }
+
+ //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();
+ }
+ //notebookCredentials.setUserString(null);
+ retString = mapper.writeValueAsString(notebookCredentials);
+ } catch(RNotebookIntegrationException re){
+ logger.error(re.getMessage());
+ throw re;
+ } catch(Exception e){
+ logger.info("Error while parsing the rcloud notebook credentials");
+ logger.error(e.getMessage());
+ throw new Exception();
+ }
+
+ return retString;
+ }
+
+ @Override
+ public String saveRNotebookCredentials(String notebookId, EcompUser user, Map<String, String> params) throws RNotebookIntegrationException, Exception {
+
+ String token = "";
+ 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();
+ }
+
+ return token;
+ }
+
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/controllers/WorkflowController.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/controllers/WorkflowController.java
new file mode 100644
index 00000000..ca2b3885
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/controllers/WorkflowController.java
@@ -0,0 +1,183 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.controllers;
+
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.json.JSONObject;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.workflow.domain.WorkflowSchedule;
+import org.openecomp.portalsdk.workflow.models.Workflow;
+import org.openecomp.portalsdk.workflow.models.WorkflowLite;
+import org.openecomp.portalsdk.workflow.services.WorkflowService;
+import org.springframework.beans.factory.annotation.Autowired;
+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 org.springframework.web.servlet.ModelAndView;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * Created by Ikram on 02/15/2016.
+ */
+@Controller
+@RequestMapping("/")
+public class WorkflowController extends RestrictedBaseController {
+
+ @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());
+
+ 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());
+
+ workflowService.saveCronJob(domainCronJobData);
+
+ // response.getWriter().write("hello".toString());
+
+ } catch (Exception 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() {
+ ObjectMapper mapper = new ObjectMapper();
+ List<Workflow> workflows = workflowService.getAllWorkflows();
+ List<WorkflowLite> workflowLites = new ArrayList<WorkflowLite>();
+
+ try {
+
+ for (Workflow workflow : workflows) {
+ WorkflowLite wfl = new WorkflowLite();
+ wfl.setId(workflow.getId());
+ wfl.setName(workflow.getName());
+ wfl.setDescription(workflow.getDescription());
+ wfl.setActive(workflow.getActive() == null ? "" : workflow.getActive().toString());
+ wfl.setCreated(workflow.getCreated() == null ? "" : workflow.getCreated().toString());
+ wfl.setCreatedBy(workflow.getCreatedBy() == null ? ""
+ : workflow.getCreatedBy().getFirstName() + " " + workflow.getCreatedBy().getLastName());
+ wfl.setModifiedBy(workflow.getModifiedBy() == null ? ""
+ : workflow.getModifiedBy().getFirstName() + " " + workflow.getCreatedBy().getLastName());
+ wfl.setLastUpdated(workflow.getLastUpdated() == null ? "" : workflow.getLastUpdated().toString());
+ wfl.setWorkflowKey(workflow.getWorkflowKey());
+ wfl.setRunLink(workflow.getRunLink());
+ wfl.setSuspendLink(workflow.getSuspendLink());
+
+ workflowLites.add(wfl);
+ }
+
+ return mapper.writeValueAsString(workflowLites);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ @RequestMapping(value = "workflows/addWorkflow", method = RequestMethod.POST, consumes = "application/json")
+ public @ResponseBody Workflow addWorkflow(@RequestBody Workflow workflow, HttpServletRequest request,
+ HttpServletResponse response) {
+ 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) {
+ 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);
+
+ 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) {
+ e.printStackTrace();
+ }
+
+ JSONObject j = new JSONObject("{removed: 123}");
+ out.write(j.toString());
+
+ }
+
+ @RequestMapping(value = "workflows/removeAllWorkflows", method = RequestMethod.DELETE)
+ public @ResponseBody void removeAllWorkflows() {
+ // workflowService.deleteAll();
+ }
+
+ @RequestMapping(value = { "/workflows" }, method = RequestMethod.GET)
+ public ModelAndView getWorkflowPartialPage() {
+ Map<String, Object> model = new HashMap<String, Object>();
+ return new ModelAndView(getViewName(), "workflows", model);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAO.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAO.java
new file mode 100644
index 00000000..435ac9a6
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAO.java
@@ -0,0 +1,32 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.dao;
+
+import java.util.List;
+
+import org.openecomp.portalsdk.workflow.models.Workflow;
+import org.openecomp.portalsdk.workflow.models.WorkflowLite;
+
+public interface WorkflowDAO {
+ public List<Workflow> getWorkflows();
+ public Workflow save(Workflow workflow, String creatorId);
+ public Workflow edit(WorkflowLite workflow, String creatorId);
+ public void delete(Long workflow);
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAOImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAOImpl.java
new file mode 100644
index 00000000..a3382dbb
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/dao/WorkflowDAOImpl.java
@@ -0,0 +1,109 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.workflow.models.Workflow;
+import org.openecomp.portalsdk.workflow.models.WorkflowLite;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+@Repository
+public class WorkflowDAOImpl implements WorkflowDAO{
+
+ @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;
+ }
+
+ public List<Workflow> getWorkflows(){
+ Session session = this.sessionFactory.openSession();
+ @SuppressWarnings("unchecked")
+ List<Workflow> workflows = session.createQuery("from Workflow").list();
+ 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();
+ }
+
+ @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;
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/domain/WorkflowSchedule.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/domain/WorkflowSchedule.java
new file mode 100644
index 00000000..e8c619f5
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/domain/WorkflowSchedule.java
@@ -0,0 +1,91 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.domain;
+import java.util.Date;
+
+import org.openecomp.portalsdk.core.domain.support.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;
+
+ public Long getId() {
+ return id;
+ }
+ 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/openecomp/portalsdk/workflow/models/Workflow.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/Workflow.java
new file mode 100644
index 00000000..3193f9cd
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/Workflow.java
@@ -0,0 +1,203 @@
+
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.models;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import org.openecomp.portalsdk.core.domain.User;
+
+@Entity
+@Table(name = "fn_workflow")
+public class Workflow implements Serializable{
+
+ private static final long serialVersionUID = -3155065449938005856L;
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue
+ private Long id;
+
+ @Column
+ private String name;
+
+ @Column (name = "workflow_key")
+ private String workflowKey;
+
+ @Column
+ private String description;
+
+ @Column(name = "created")
+ private Date created;
+
+ @OneToOne(fetch = FetchType.EAGER)//, cascade = CascadeType.ALL)
+ @JoinColumn(name = "created_by")
+ private User createdBy;
+
+ @Column(name = "modified")
+ private Date lastUpdated;
+
+ @OneToOne(fetch = FetchType.EAGER)//, cascade = CascadeType.ALL)
+ @JoinColumn(name = "modified_by")
+ private User modifiedBy;
+
+ @Column(name = "active_yn")
+ private Boolean active;
+
+ @Column(name = "run_link")
+ private String runLink;
+
+ @Column(name = "suspend_link")
+ private String suspendLink;
+
+ @Column(name = "modified_link")
+ private String modifiedLink;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getRunLink() {
+ return runLink;
+ }
+
+ public void setRunLink(String runLink) {
+ this.runLink = runLink;
+ }
+
+ public String getSuspendLink() {
+ return suspendLink;
+ }
+
+ public void setSuspendLink(String suspendLink) {
+ this.suspendLink = suspendLink;
+ }
+
+ public String getModifiedLink() {
+ return modifiedLink;
+ }
+
+ public void setModifiedLink(String modifiedLink) {
+ this.modifiedLink = modifiedLink;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public User getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(User createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public User getModifiedBy() {
+ return modifiedBy;
+ }
+
+ public void setModifiedBy(User modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public String getWorkflowKey() {
+ return workflowKey;
+ }
+
+ public void setWorkflowKey(String workflowKey) {
+ this.workflowKey = workflowKey;
+ }
+
+ public Boolean getActive() {
+ return active;
+ }
+
+ public void setActive(Boolean active) {
+ this.active = active;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Workflow other = (Workflow) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/WorkflowLite.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/WorkflowLite.java
new file mode 100644
index 00000000..c3b727d9
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/models/WorkflowLite.java
@@ -0,0 +1,174 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.models;
+
+
+import java.io.Serializable;
+
+public class WorkflowLite implements Serializable{
+
+ private static final long serialVersionUID = -3155065449938005856L;
+
+ private Long id;
+
+ private String name;
+
+ private String workflowKey;
+
+ private String description;
+
+ private String created;
+
+ private String createdBy;
+
+ private String lastUpdated;
+
+ private String modifiedBy;
+
+ private String active;
+
+ private String runLink;
+
+ private String suspendLink;
+
+ private String modifiedLink;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getWorkflowKey() {
+ return workflowKey;
+ }
+
+ public void setWorkflowKey(String workflowKey) {
+ this.workflowKey = workflowKey;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCreated() {
+ return created;
+ }
+
+ public void setCreated(String created) {
+ this.created = created;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public String getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(String lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public String getModifiedBy() {
+ return modifiedBy;
+ }
+
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public String getActive() {
+ return active;
+ }
+
+ public void setActive(String active) {
+ this.active = active;
+ }
+
+ public String getRunLink() {
+ return runLink;
+ }
+
+ public void setRunLink(String runLink) {
+ this.runLink = runLink;
+ }
+
+ public String getSuspendLink() {
+ return suspendLink;
+ }
+
+ public void setSuspendLink(String suspendLink) {
+ this.suspendLink = suspendLink;
+ }
+
+ public String getModifiedLink() {
+ return modifiedLink;
+ }
+
+ public void setModifiedLink(String modifiedLink) {
+ this.modifiedLink = modifiedLink;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ WorkflowLite other = (WorkflowLite) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java
new file mode 100644
index 00000000..d90ee05b
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleJob.java
@@ -0,0 +1,45 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.scheduler;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.workflow.services.WorkflowScheduleExecutor;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+
+public class WorkFlowScheduleJob extends QuartzJobBean{
+
+ 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));
+ WorkflowScheduleExecutor executor = new WorkflowScheduleExecutor(serverUrl, workflowKey);
+ executor.execute();
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java
new file mode 100644
index 00000000..bf29f59a
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/scheduler/WorkFlowScheduleRegistry.java
@@ -0,0 +1,107 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.scheduler;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.quartz.impl.triggers.CronTriggerImpl;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
+import org.springframework.scheduling.quartz.JobDetailFactoryBean;
+import org.springframework.stereotype.Component;
+
+@Component
+@DependsOn({"systemProperties"})
+public class WorkFlowScheduleRegistry{
+
+
+ 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;
+
+ // @Bean
+ public JobDetailFactoryBean jobDetailFactoryBean(Map<String, ?> contextInfoMap) {
+
+ JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
+ jobDetailFactory.setJobClass(WorkFlowScheduleJob.class);
+ jobDetailFactory.setJobDataAsMap(contextInfoMap);
+ jobDetailFactory.setGroup(groupName);
+ jobDetailFactory.setName(jobName + "_" + UUID.randomUUID());
+ jobDetailFactory.afterPropertiesSet();
+ return jobDetailFactory;
+ }
+
+ // @Bean
+ public CronTriggerFactoryBean cronTriggerFactoryBean(JobDetailFactoryBean jobDetailFactory, Long id,
+ String cronExpression, Date startDateTime, Date enddatetime) throws Exception {
+ 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));
+ cronTriggerFactory.setCronExpression( cronExpression); //"0 * * * * ? *"
+ cronTriggerFactory.afterPropertiesSet();
+
+ final CronTriggerImpl cronTrigger = (CronTriggerImpl) cronTriggerFactory.getObject();
+ cronTrigger.setStartTime(startDateTime == null ? Calendar.getInstance().getTime() : startDateTime);
+ 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: "
+ + cronTrigger.getEndTime());
+ return cronTriggerFactory;
+
+ }
+
+ public CronTriggerFactoryBean setUpTrigger(Long wfId, String serverUrl, String workflowKey, String arguments,
+ String startdatetimecron, Date startDateTime, Date enddatetime) throws Exception {
+
+ Map<String, String> contextInfo = new HashMap<String, String>();
+ 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.
+
+ return cronTriggerFactory;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleExecutor.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleExecutor.java
new file mode 100644
index 00000000..ea04e69e
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleExecutor.java
@@ -0,0 +1,108 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.services;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.Charset;
+
+public class WorkflowScheduleExecutor {
+ private String serverURL;
+ private String workflowKey;
+ private String myUrl;
+ private String payload;
+
+ //constructor
+ 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\":{}}";
+ }
+
+ public static void main(String [] args) throws Exception {
+
+ }
+
+ public void execute() {
+ POST_fromURL(myUrl,payload);
+ }
+
+ public static String get_fromURL(String myURL) {
+ System.out.println("Requeted URL:" + myURL);
+ StringBuilder sb = new StringBuilder();
+ URLConnection urlConn = null;
+ InputStreamReader in = null;
+ try {
+ URL url = new URL(myURL);
+ urlConn = url.openConnection();
+ if (urlConn != null)
+ urlConn.setReadTimeout(60 * 1000);
+ if (urlConn != null && urlConn.getInputStream() != null) {
+ in = new InputStreamReader(urlConn.getInputStream(),
+ Charset.defaultCharset());
+ BufferedReader bufferedReader = new BufferedReader(in);
+ if (bufferedReader != null) {
+ int cp;
+ while ((cp = bufferedReader.read()) != -1) {
+ sb.append((char) cp);
+ }
+ bufferedReader.close();
+ }
+ }
+ in.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Exception while calling URL:"+ myURL, 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) {
+ 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/openecomp/portalsdk/workflow/services/WorkflowScheduleService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleService.java
new file mode 100644
index 00000000..d04b72be
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleService.java
@@ -0,0 +1,34 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.services;
+
+import java.util.List;
+
+import org.openecomp.portalsdk.workflow.domain.WorkflowSchedule;
+import org.quartz.Trigger;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
+public interface WorkflowScheduleService {
+ List<WorkflowSchedule> findAll();
+ WorkflowSchedule getWorkflowScheduleByKey(Long key);
+ void saveWorkflowSchedule(WorkflowSchedule ws);
+ public void triggerWorkflowScheduling(SchedulerFactoryBean schedulerBean, WorkflowSchedule ws);
+ public List<Trigger> triggerWorkflowScheduling();
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java
new file mode 100644
index 00000000..1d0c58a7
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java
@@ -0,0 +1,144 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.services;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.service.DataAccessService;
+import org.openecomp.portalsdk.workflow.domain.WorkflowSchedule;
+import org.openecomp.portalsdk.workflow.scheduler.WorkFlowScheduleRegistry;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
+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{
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowScheduleServiceImpl.class);
+
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ @Autowired
+ private WorkFlowScheduleRegistry workflowRegistry;
+
+ @Autowired
+ private ApplicationContext appContext;
+
+
+ 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){
+
+ getDataAccessService().saveDomainObject(ws, null);
+ logger.info(EELFLoggerDelegate.debugLogger, ("Workflow Scheduled " + ws.getId() + " " + ws.getEndDateTime()));
+ triggerWorkflowScheduling((SchedulerFactoryBean)appContext.getBean(SchedulerFactoryBean.class),ws);
+
+ }
+
+ 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());
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Error scheduling work flow with Id" + ws.getId() + e.getMessage()));
+ }
+
+ }
+
+ public List<Trigger> triggerWorkflowScheduling() {
+
+ Date date = new Date();
+ List<Trigger> triggers = new ArrayList<Trigger>();
+
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ if (getDataAccessService() != null) {
+ @SuppressWarnings("unchecked")
+ List<WorkflowSchedule> allWorkflows = getDataAccessService()
+ .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()));
+
+ try {
+
+ 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()));
+ }
+
+
+ }
+ }
+
+ 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));
+ }
+}
+
+
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowService.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowService.java
new file mode 100644
index 00000000..7bf133a7
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowService.java
@@ -0,0 +1,16 @@
+package org.openecomp.portalsdk.workflow.services;
+
+import java.util.List;
+
+import org.openecomp.portalsdk.workflow.domain.WorkflowSchedule;
+import org.openecomp.portalsdk.workflow.models.Workflow;
+import org.openecomp.portalsdk.workflow.models.WorkflowLite;
+
+
+public interface WorkflowService {
+ public void saveCronJob(WorkflowSchedule domainCronJobData);
+ public Workflow addWorkflow(Workflow workflow, String creatorId);
+ public Workflow editWorkflow(WorkflowLite worklow, String creatorId);
+ public void deleteWorkflow(Long worklow);
+ public List<Workflow> getAllWorkflows();
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowServiceImpl.java
new file mode 100644
index 00000000..b27d2e2d
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/openecomp/portalsdk/workflow/services/WorkflowServiceImpl.java
@@ -0,0 +1,77 @@
+/*-
+ * ================================================================================
+ * eCOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalsdk.workflow.services;
+
+import java.util.List;
+
+import org.openecomp.portalsdk.workflow.dao.WorkflowDAO;
+import org.openecomp.portalsdk.workflow.domain.WorkflowSchedule;
+import org.openecomp.portalsdk.workflow.models.Workflow;
+import org.openecomp.portalsdk.workflow.models.WorkflowLite;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service("workflowService")
+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) {
+ return workflowDAO.save(workflow, creatorId);
+ }
+
+ @Override
+ public Workflow editWorkflow(WorkflowLite workflow, String creatorId) {
+ return workflowDAO.edit(workflow, creatorId);
+ }
+
+ @Override
+ public void deleteWorkflow(Long workflowId) {
+ workflowDAO.delete(workflowId);
+ }
+
+ @Override
+ public List<Workflow> getAllWorkflows() {
+ return workflowDAO.getWorkflows();
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/main/resources/RNoteBookIntegration.hbm.xml b/ecomp-sdk/epsdk-workflow/src/main/resources/RNoteBookIntegration.hbm.xml
new file mode 100644
index 00000000..44b7986f
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/main/resources/RNoteBookIntegration.hbm.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+ ================================================================================
+ eCOMP Portal SDK
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ================================================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.portalsdk.rnotebookintegration.domain">
+
+
+ <!-- WorkflowSchedule mapping details -->
+ <class name="RNoteBookCredentials" table="rcloudinvocation">
+ <id name="token" column="ID">
+
+ </id>
+ <property name="createdDate" column="created"/>
+ <property name="userString" column="userInfo"/>
+ <property name="notebookID" column="notebookID"/>
+ <property name="parametersString" column="parameters"/>
+ <property name="tokenReadDate" column="tokenreaddate"/>
+ </class>
+
+
+
+</hibernate-mapping>