summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/openecomp/vid/scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/scheduler')
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObject.java44
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/GetTimeSlotsRestObject.java11
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostCreateNewVnfRestObject.java10
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObject.java10
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/RestObject.java39
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerProperties.java24
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrapper.java71
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/GetTimeSlotsWrapper.java5
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapper.java39
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapper.java38
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapper.java57
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInt.java42
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterface.java208
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceFactory.java15
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceIfc.java21
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerUtil.java100
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/scheduler/rest/RequestDetails.java106
17 files changed, 840 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObject.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObject.java
new file mode 100644
index 000000000..57b36830e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObject.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.scheduler;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public String uuid;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+}
+
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/GetTimeSlotsRestObject.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/GetTimeSlotsRestObject.java
new file mode 100644
index 000000000..614b557a0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/GetTimeSlotsRestObject.java
@@ -0,0 +1,11 @@
+package org.openecomp.vid.scheduler.RestObjects;
+
+public class GetTimeSlotsRestObject<T> extends org.openecomp.vid.scheduler.RestObject<T> {
+
+ public String uuid;
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostCreateNewVnfRestObject.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostCreateNewVnfRestObject.java
new file mode 100644
index 000000000..86cbab8a6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostCreateNewVnfRestObject.java
@@ -0,0 +1,10 @@
+package org.openecomp.vid.scheduler.RestObjects;
+
+public class PostCreateNewVnfRestObject<T> extends RestObject<T> {
+
+ public String uuid;
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObject.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObject.java
new file mode 100644
index 000000000..6fb56f67d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObject.java
@@ -0,0 +1,10 @@
+package org.openecomp.vid.scheduler.RestObjects;
+
+public class PostSubmitVnfChangeRestObject<T> extends RestObject<T> {
+
+ public String uuid;
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/RestObject.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/RestObject.java
new file mode 100644
index 000000000..2d0eec74d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/RestObjects/RestObject.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.scheduler.RestObjects;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+}
+
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerProperties.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerProperties.java
new file mode 100644
index 000000000..15855b7be
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerProperties.java
@@ -0,0 +1,24 @@
+package org.openecomp.vid.scheduler;
+
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+
+public class SchedulerProperties extends SystemProperties {
+
+ public static final String SCHEDULER_USER_NAME_VAL = "scheduler.user.name";
+
+ public static final String SCHEDULER_PASSWORD_VAL = "scheduler.password";
+
+ public static final String SCHEDULER_SERVER_URL_VAL = "scheduler.server.url";
+
+ public static final String SCHEDULER_CREATE_NEW_VNF_CHANGE_INSTANCE_VAL = "scheduler.create.new.vnf.change.instance";
+
+ public static final String SCHEDULER_GET_TIME_SLOTS = "scheduler.get.time.slots";
+
+ public static final String SCHEDULER_SUBMIT_NEW_VNF_CHANGE = "scheduler.submit.new.vnf.change";
+
+ public static final String SCHEDULER_GET_SCHEDULES = "scheduler.get.schedules";
+
+ public static final String GET_VERSION_BY_INVARIANT_ID = "aai_get_version_by_invariant_id";
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrapper.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrapper.java
new file mode 100644
index 000000000..5f148c06b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrapper.java
@@ -0,0 +1,71 @@
+package org.openecomp.vid.scheduler;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/**
+ * This wrapper encapsulates the Scheduler response
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity",
+ "uuid"
+})
+
+public class SchedulerResponseWrapper {
+
+ @JsonProperty("status")
+ private int status;
+
+ @JsonProperty("entity")
+ private String entity;
+
+ @JsonProperty("uuid")
+ private String uuid;
+
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ @JsonProperty("uuid")
+ public String getUuid() {
+ return uuid;
+ }
+
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ @JsonProperty("uuid")
+ public void setUuid(String v) {
+ this.uuid = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": \" " ).append(this.getEntity()).append("\" ,\"uuid\": \"" ).append(this.getUuid()).append("\"}");
+ return (b.toString());
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/GetTimeSlotsWrapper.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/GetTimeSlotsWrapper.java
new file mode 100644
index 000000000..e5001d41f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/GetTimeSlotsWrapper.java
@@ -0,0 +1,5 @@
+package org.openecomp.vid.scheduler.SchedulerResponseWrappers;
+
+public class GetTimeSlotsWrapper extends SchedulerResponseWrapper {
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapper.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapper.java
new file mode 100644
index 000000000..f1baeaf6e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapper.java
@@ -0,0 +1,39 @@
+package org.openecomp.vid.scheduler.SchedulerResponseWrappers;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "uuid"
+})
+public class PostCreateNewVnfWrapper extends SchedulerResponseWrapper {
+
+ @JsonProperty("uuid")
+ private String uuid;
+
+ @JsonProperty("uuid")
+ public String getUuid() {
+ return uuid;
+ }
+
+ @JsonProperty("uuid")
+ public void setUuid(String v) {
+ this.uuid = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": \" " ).append(this.getEntity()).append("\" ,\"uuid\": \"" ).append(this.getUuid()).append("\"}");
+ return (b.toString());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapper.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapper.java
new file mode 100644
index 000000000..86e4c0a74
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapper.java
@@ -0,0 +1,38 @@
+package org.openecomp.vid.scheduler.SchedulerResponseWrappers;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "uuid"
+})
+public class PostSubmitVnfChangeTimeSlotsWrapper extends SchedulerResponseWrapper {
+ @JsonProperty("uuid")
+ private String uuid;
+
+ @JsonProperty("uuid")
+ public String getUuid() {
+ return uuid;
+ }
+
+ @JsonProperty("uuid")
+ public void setUuid(String v) {
+ this.uuid = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": \" " ).append(this.getEntity()).append("\" ,\"uuid\": \"" ).append(this.getUuid()).append("\"}");
+ return (b.toString());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapper.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapper.java
new file mode 100644
index 000000000..081ed3dc4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapper.java
@@ -0,0 +1,57 @@
+package org.openecomp.vid.scheduler.SchedulerResponseWrappers;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/**
+ * This wrapper encapsulates the Scheduler response
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class SchedulerResponseWrapper {
+
+ @JsonProperty("status")
+ private int status;
+
+ @JsonProperty("entity")
+ private String entity;
+
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+
+ b.append(getStatus()).append(", \"entity\": " ).append(this.getEntity()).append("}");
+ return (b.toString());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInt.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInt.java
new file mode 100644
index 000000000..32b3a9c8c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInt.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.scheduler;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+public class SchedulerRestInt {
+
+ /** The logger. */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The request date format. */
+ public DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");
+
+ public SchedulerRestInt() {
+ requestDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+ }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterface.java
new file mode 100644
index 000000000..5f529f390
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterface.java
@@ -0,0 +1,208 @@
+package org.openecomp.vid.scheduler;
+
+import java.util.Collections;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.json.simple.JSONObject;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.openecomp.vid.client.HttpBasicClient;
+import org.openecomp.vid.client.HttpsBasicClient;
+import org.openecomp.vid.scheduler.SchedulerProperties;
+import org.openecomp.vid.scheduler.RestObjects.RestObject;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
+
+ private static Client client = null;
+
+ private MultivaluedHashMap<String, Object> commonHeaders;
+
+ /** The logger. */
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
+
+ public SchedulerRestInterface() {
+ super();
+ }
+
+ public void initRestClient()
+ {
+ System.out.println( "\t <== Starting to initialize rest client ");
+
+ final String username;
+ final String password;
+
+ /*Setting user name based on properties*/
+ String retrievedUsername = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_USER_NAME_VAL);
+ if(retrievedUsername.isEmpty()) {
+ username = "";
+ } else {
+ username = retrievedUsername;
+ }
+
+ /*Setting password based on properties*/
+ String retrievedPassword = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_PASSWORD_VAL);
+ if(retrievedPassword.isEmpty()) {
+ password = "";
+ } else {
+ if (retrievedPassword.contains("OBF:")) {
+ password = Password.deobfuscate(retrievedPassword);
+ } else {
+ password = retrievedPassword;
+ }
+ }
+
+ String authString = username + ":" + password;
+
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authStringEnc = new String(authEncBytes);
+
+ commonHeaders = new MultivaluedHashMap<String, Object> ();
+ commonHeaders.put("Authorization", Collections.singletonList((Object) ("Basic " + authStringEnc)));
+
+ try {
+ if ( !username.isEmpty() ) {
+
+ client = HttpsBasicClient.getClient();
+ }
+ else {
+
+ client = HttpBasicClient.getClient();
+ }
+ } catch (Exception e) {
+ System.out.println( " <== Unable to initialize rest client ");
+ }
+
+ System.out.println( "\t<== Client Initialized \n");
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Get (T t, String sourceId, String path, org.openecomp.vid.scheduler.RestObject<T> restObject ) throws Exception {
+
+ String methodName = "Get";
+ String url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+
+ System.out.println( "<== URL FOR GET : " + url + "\n");
+
+ initRestClient();
+
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .get();
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+
+ } else {
+ throw new Exception(methodName + " with status="+ status + ", url= " + url );
+ }
+
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Post(T t, JSONObject requestDetails, String path, RestObject<T> restObject) throws Exception {
+
+ String methodName = "Post";
+ String url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+ System.out.println( "<== URL FOR POST : " + url + "\n");
+
+ try {
+
+ initRestClient();
+
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+
+ System.out.println("<== " + methodName + " : No response entity, this is probably ok, e=" + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+
+ System.out.println( "<== " + methodName + " : REST api POST was successful!" + "\n");
+
+ } else {
+ System.out.println( "<== " + methodName + " : FAILED with http status : "+status+", url = " + url + "\n");
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println( "<== " + methodName + " : with url="+url+ ", Exception: " + e.toString() + "\n");
+ throw e;
+ }
+ }
+
+ @Override
+ public void logRequest(JSONObject requestDetails) {}
+
+ @SuppressWarnings("unchecked")
+ public <T> void Delete(T t, JSONObject requestDetails, String sourceID, String path, RestObject<T> restObject) {
+
+ String url="";
+ Response cres = null;
+
+ try {
+ initRestClient();
+
+ url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+ cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ //.entity(r)
+ .build("DELETE", Entity.entity(requestDetails, MediaType.APPLICATION_JSON)).invoke();
+ // .method("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON));
+ //.delete(Entity.entity(r, MediaType.APPLICATION_JSON));
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
+
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
+ {
+ return clazz.newInstance();
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceFactory.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceFactory.java
new file mode 100644
index 000000000..bf7bd8891
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceFactory.java
@@ -0,0 +1,15 @@
+
+package org.openecomp.vid.scheduler;
+
+public class SchedulerRestInterfaceFactory {
+
+
+ public static SchedulerRestInterfaceIfc getInstance () {
+ SchedulerRestInterfaceIfc obj = null;
+
+ obj = new SchedulerRestInterface();
+
+ return ( obj );
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceIfc.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceIfc.java
new file mode 100644
index 000000000..839ab348d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerRestInterfaceIfc.java
@@ -0,0 +1,21 @@
+
+package org.openecomp.vid.scheduler;
+
+import org.json.simple.JSONObject;
+import org.openecomp.vid.scheduler.RestObjects.RestObject;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface SchedulerRestInterfaceIfc {
+
+ public void initRestClient();
+
+ public <T> void Get (T t, String sourceId, String path, org.openecomp.vid.scheduler.RestObject<T> restObject ) throws Exception;
+
+ public <T> void Delete(T t, JSONObject requestDetails, String sourceID, String path, RestObject<T> restObject)
+ throws Exception;
+
+ public <T> void Post(T t, JSONObject r, String path, RestObject<T> restObject) throws Exception;
+
+ public void logRequest(JSONObject requestDetails);
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerUtil.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerUtil.java
new file mode 100644
index 000000000..f82f474f6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/SchedulerUtil.java
@@ -0,0 +1,100 @@
+package org.openecomp.vid.scheduler;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.vid.scheduler.SchedulerResponseWrappers.GetTimeSlotsWrapper;
+import org.openecomp.vid.scheduler.SchedulerResponseWrappers.PostCreateNewVnfWrapper;
+import org.openecomp.vid.scheduler.SchedulerResponseWrappers.PostSubmitVnfChangeTimeSlotsWrapper;
+import org.openecomp.vid.scheduler.SchedulerUtil;
+import org.openecomp.vid.scheduler.RestObjects.GetTimeSlotsRestObject;
+import org.openecomp.vid.scheduler.RestObjects.PostCreateNewVnfRestObject;
+import org.openecomp.vid.scheduler.RestObjects.PostSubmitVnfChangeRestObject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class SchedulerUtil {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerUtil.class);
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ public static GetTimeSlotsWrapper getTimeSlotsWrapResponse (GetTimeSlotsRestObject<String> rs) {
+
+ String resp_str = "";
+ int status = 0;
+
+ if ( rs != null ) {
+ resp_str = rs.get();
+ status = rs.getStatusCode();
+ }
+
+ GetTimeSlotsWrapper w = new GetTimeSlotsWrapper();
+
+ w.setEntity(resp_str);
+ w.setStatus (status);
+
+ return (w);
+ }
+
+ public static PostSubmitVnfChangeTimeSlotsWrapper postSubmitNewVnfWrapResponse (PostSubmitVnfChangeRestObject<String> rs) {
+
+ String resp_str = "";
+ int status = 0;
+ String uuid = "";
+
+ if ( rs != null ) {
+ resp_str = rs.get();
+ status = rs.getStatusCode();
+ uuid = rs.getUUID();
+ }
+
+ PostSubmitVnfChangeTimeSlotsWrapper w = new PostSubmitVnfChangeTimeSlotsWrapper();
+
+ w.setEntity(resp_str);
+ w.setStatus (status);
+ w.setUuid(uuid);
+
+ return (w);
+ }
+
+ public static PostCreateNewVnfWrapper postCreateNewVnfWrapResponse (PostCreateNewVnfRestObject<String> rs) {
+
+ String resp_str = "";
+ int status = 0;
+ String uuid = "";
+
+ if ( rs != null ) {
+ resp_str = rs.get();
+ status = rs.getStatusCode();
+ uuid = rs.getUUID();
+ }
+
+ PostCreateNewVnfWrapper w = new PostCreateNewVnfWrapper();
+
+ w.setEntity(resp_str);
+ w.setStatus (status);
+ w.setUuid(uuid);
+
+ return (w);
+ }
+
+ public static <T> String convertPojoToString ( T t ) throws com.fasterxml.jackson.core.JsonProcessingException {
+
+ String methodName = "convertPojoToString";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( t != null ) {
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse object as json");
+ }
+ }
+ return (r_json_str);
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/scheduler/rest/RequestDetails.java b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/rest/RequestDetails.java
new file mode 100644
index 000000000..746fd9b24
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/scheduler/rest/RequestDetails.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.scheduler.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+//import javax.annotation.Generated;
+
+import org.openecomp.vid.domain.mso.CloudConfiguration;
+import org.openecomp.vid.domain.mso.ModelInfo;
+import org.openecomp.vid.domain.mso.RequestInfo;
+import org.openecomp.vid.domain.mso.RequestParameters;
+import org.openecomp.vid.domain.mso.SubscriberInfo;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/*
+ * "domain" : "ChangeManagement",
+ "scheduleId" : "3569b875-d40e-4adb-a288-a74f4b59ec1c",
+ "scheduleName" : "VnfUpgrade/DWF",
+ "userId" : "jf9860@att.com",
+ "domainData" : {
+ "WorkflowName" : "HEAT Stack Software Update for vNFs"
+ },
+ "status" : "PendingOptimization",
+ "schedulingInfo" : {
+ "scheduleId" : "ChangeManagement.3569b875-d40e-4adb-a288-a74f4b59ec1c",
+ "normalDurationInSecs" : 60,
+ "AdditionalDurationInSecs" : 0,
+ "concurrencyLimit" : 10,
+ "policyId" : ["SNIRO.TimeLimitAndVerticalTopology"],
+ "groups" : [{
+ "groupId" : " group1",
+ "node" : ["satmo415vbc", "satmo455vbc"],
+ "changeWindows" : [{
+ "startTime" : "2017-02-15T01:00:00Z",
+ "finishTime" : "2017-02-15T02:00:00Z"
+ }
+ ]
+ }, {
+ "groupId" : " group2",
+ "node" : ["satmo555vbc"],
+ "changeWindows" : [{
+ "startTime" : "2017-02-15T01:00:00Z",
+ "finishTime" : "2017-02-15T02:00:00Z"
+ }, {
+ "startTime" : "2017-02-15T05:00:00Z",
+ "finishTime" : "2017-02-15T05:30:00Z"
+ }
+ ]
+ }
+ ]
+*/
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "domain",
+ "scheduleId",
+ "scheduleName",
+ "userId",
+ "domainData",
+ "status",
+ "schcedulingInfo"
+})
+public class RequestDetails {
+
+ @JsonProperty("domain")
+ private String domain;
+
+
+
+ @JsonProperty("domain")
+ public String getDomain() {
+ return domain;
+ }
+
+ @JsonProperty("domain")
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+}