aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/org/onap/vid/model
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation/src/main/java/org/onap/vid/model')
-rw-r--r--vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java141
-rw-r--r--vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java80
-rw-r--r--vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java60
-rw-r--r--vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java15
-rw-r--r--vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java119
5 files changed, 415 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java
new file mode 100644
index 000000000..b012628e0
--- /dev/null
+++ b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java
@@ -0,0 +1,141 @@
+package org.onap.vid.model.asyncInstantiation;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+import java.util.UUID;
+
+
+public class JobAuditStatus {
+
+ public JobAuditStatus(){}
+
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){
+ this.jobId = jobId;
+ this.jobStatus = jobStatus;
+ this.source = source;
+ this.isFinal = isFinal();
+ }
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal) {
+ this(jobId, jobStatus, source);
+ this.requestId = requestId;
+ this.additionalInfo = additionalInfo;
+ this.isFinal = isFinal;
+ }
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal, String instanceName) {
+ this(jobId, jobStatus, source, requestId, additionalInfo, isFinal);
+ this.instanceName = instanceName;
+ }
+
+ public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo, Boolean isFinal, String instanceType) {
+ this.instanceType = instanceType;
+ this.instanceName = instanceName;
+ this.jobStatus = jobStatus;
+ this.requestId = requestId;
+ this.additionalInfo = additionalInfo;
+ this.isFinal = isFinal;
+ }
+
+
+
+
+
+ public enum SourceStatus {
+ MSO,
+ VID
+ }
+
+ private UUID jobId;
+ private String jobStatus;
+ private SourceStatus source;
+ private UUID requestId;
+ private String additionalInfo;
+ private String instanceName;
+ private String instanceType;
+
+ public String getInstanceType() {return instanceType;}
+
+ public void setInstanceType(String instanceType) {this.instanceType = instanceType; }
+
+ private Boolean isFinal;
+
+ public String getJobStatus() {
+ return jobStatus;
+ }
+
+ public UUID getJobId() {
+ return jobId;
+ }
+
+ public SourceStatus getSource() {
+ return source;
+ }
+
+ public String getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public Boolean isFinal(){
+ return isFinal;
+ }
+
+ public void setFinal(Boolean aFinal) {
+ isFinal = aFinal;
+ }
+
+ @Override
+ public String toString() {
+ return "JobAuditStatus{" +
+ "jobId=" + jobId +
+ ", jobStatus='" + jobStatus + '\'' +
+ ", source=" + source +
+ ", requestId=" + requestId +
+ ", additionalInfo='" + additionalInfo + '\'' +
+ ", instanceName='" + instanceName + '\'' +
+ ", isFinal=" + isFinal +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (!(o instanceof JobAuditStatus)) return false;
+
+ JobAuditStatus that = (JobAuditStatus) o;
+
+ return new EqualsBuilder()
+ .append(jobId, that.jobId)
+ .append(jobStatus, that.jobStatus)
+ .append(source, that.source)
+ .append(requestId, that.requestId)
+ .append(additionalInfo, that.additionalInfo)
+ .append(instanceName, that.instanceName)
+ .append(isFinal, that.isFinal)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(jobId)
+ .append(jobStatus)
+ .append(source)
+ .append(requestId)
+ .append(additionalInfo)
+ .append(instanceName)
+ .append(isFinal)
+ .toHashCode();
+ }
+}
diff --git a/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java
new file mode 100644
index 000000000..8f40fc098
--- /dev/null
+++ b/vid-automation/src/main/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java
@@ -0,0 +1,80 @@
+package org.onap.vid.model.asyncInstantiation;
+
+
+import vid.automation.test.model.JobStatus;
+import vid.automation.test.model.ServiceAction;
+
+import java.util.Date;
+
+public class ServiceInfo {
+
+ public String jobId;
+ public String templateId;
+ public String userId;
+ public JobStatus jobStatus;
+ public Date statusModifiedDate;
+ public boolean hidden;
+ public boolean pause;
+ public String owningEntityId;
+ public String owningEntityName;
+ public String project;
+ public String aicZoneId;
+ public String aicZoneName;
+ public String tenantId;
+ public String tenantName;
+ public String regionId;
+ public String regionName;
+ public String serviceType;
+ public String subscriberName;
+ public String serviceInstanceId;
+ public String serviceInstanceName;
+ public String serviceModelId;
+ public String serviceModelName;
+ public String serviceModelVersion;
+ public Date createdBulkDate;
+ public ServiceAction action;
+ public boolean isRetryEnabled;
+
+ public ServiceInfo(){
+
+ }
+
+ public ServiceInfo(String userId, JobStatus jobStatus, boolean pause, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, String jobId, String templateId, ServiceAction action, boolean isRetryEnabled) {
+ this.userId = userId;
+ this.jobStatus = jobStatus;
+ this.pause = pause;
+ this.owningEntityId = owningEntityId;
+ this.owningEntityName = owningEntityName;
+ this.project = project;
+ this.aicZoneId = aicZoneId;
+ this.aicZoneName = aicZoneName;
+ this.tenantId = tenantId;
+ this.tenantName = tenantName;
+ this.regionId = regionId;
+ this.regionName = regionName;
+ this.serviceType = serviceType;
+ this.subscriberName = subscriberName;
+ this.serviceInstanceId = serviceInstanceId;
+ this.serviceInstanceName = serviceInstanceName;
+ this.serviceModelId = serviceModelId;
+ this.serviceModelName = serviceModelName;
+ this.serviceModelVersion = serviceModelVersion;
+ this.jobId = jobId;
+ this.templateId = templateId;
+ this.action = action;
+ this.isRetryEnabled = isRetryEnabled;
+ }
+
+ public JobStatus getJobStatus() {
+ return jobStatus;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+}
diff --git a/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java
new file mode 100644
index 000000000..40bf86b26
--- /dev/null
+++ b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapper2.java
@@ -0,0 +1,60 @@
+package org.onap.vid.model.mso;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+/*
+This is a brother of MsoResponseWrapper. I (Ittay) think it's better.
+It is generic, immutable, and has some knowledge about RestObject.
+The serialized "entity" field may be either String or nested object.
+ */
+public class MsoResponseWrapper2<T> implements MsoResponseWrapperInterface {
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ private final int status;
+ private final T entity;
+ private final String raw;
+
+ public MsoResponseWrapper2(RestObject<T> msoResponse) {
+ this.status = msoResponse.getStatusCode();
+ this.entity = msoResponse.get();
+ this.raw = msoResponse.getRaw();
+ }
+
+ public MsoResponseWrapper2(
+ @JsonProperty(value = "status", required = true) int status,
+ @JsonProperty(value = "entity", required = true) T entity) {
+ this.status = status;
+ this.entity = entity;
+ this.raw = null;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getResponse() {
+ try {
+ return objectMapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ return getEntity() != null ? getEntity().toString() : null;
+ }
+ }
+
+ @JsonProperty
+ public Object getEntity() {
+ return entity != null ? entity : raw;
+ }
+
+}
diff --git a/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java
new file mode 100644
index 000000000..8a20ff187
--- /dev/null
+++ b/vid-automation/src/main/java/org/onap/vid/model/mso/MsoResponseWrapperInterface.java
@@ -0,0 +1,15 @@
+package org.onap.vid.model.mso;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public interface MsoResponseWrapperInterface {
+ @JsonProperty("entity")
+ Object getEntity();
+
+ @JsonProperty("status")
+ int getStatus();
+
+ @JsonIgnore
+ String getResponse();
+}
diff --git a/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java b/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java
new file mode 100644
index 000000000..043766dac
--- /dev/null
+++ b/vid-automation/src/main/java/org/onap/vid/model/mso/RestObject.java
@@ -0,0 +1,119 @@
+/*-
+ * ============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.onap.vid.model.mso;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.MoreObjects;
+
+import javax.ws.rs.core.Response;
+
+/**
+ * The Class RestObject.
+ *
+ * @param <T> the generic type
+ */
+public class RestObject<T> {
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ /**
+ * Generic version of the RestObject class.
+ *
+ */
+ // T stands for "Type"
+ private T t;
+
+ // The string source of t, if available
+ private String rawT;
+
+ /** The status code. */
+ private int statusCode= 0;
+
+ public RestObject() {
+ }
+
+ public RestObject(Response cres, Class<?> tClass) {
+
+ String rawEntity = null;
+ try {
+ cres.bufferEntity();
+ rawEntity = cres.readEntity(String.class);
+ T t = (T) objectMapper.readValue(rawEntity, tClass);
+ this.set(t);
+ }
+ catch ( Exception e ) {
+ try {
+ this.setRaw(rawEntity);
+ } catch (Exception e2) {
+ }
+ }
+
+ int status = cres.getStatus();
+ this.setStatusCode (status);
+ }
+
+
+ /**
+ * Sets the.
+ *
+ * @param t the t
+ */
+ public void set(T t) { this.t = t; }
+
+ /**
+ * Gets the.
+ *
+ * @return the t
+ */
+ public T get() { return t; }
+
+ /**
+ * Sets the status code.
+ *
+ * @param v the new status code
+ */
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ /**
+ * Gets the status code.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() { return this.statusCode; }
+
+ public String getRaw() {
+ return rawT;
+ }
+
+ public void setRaw(String rawT) {
+ this.rawT = rawT;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("t", t)
+ .add("rawT", rawT)
+ .add("statusCode", statusCode)
+ .toString();
+ }
+}
+