From 38f720752af4d4aad8c4e467a288d9048659f688 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Wed, 14 Mar 2018 02:07:32 -0400 Subject: AT&T 1712 and 1802 release code This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty --- .../exceptions/MsoBlueprintAlreadyExists.java | 33 +++++++++ .../cloudify/exceptions/MsoCloudifyException.java | 86 ++++++++++++++++++++++ .../exceptions/MsoCloudifyManagerNotFound.java | 33 +++++++++ .../cloudify/exceptions/MsoCloudifyTimeout.java | 64 ++++++++++++++++ .../exceptions/MsoCloudifyWorkflowException.java | 54 ++++++++++++++ .../exceptions/MsoDeploymentAlreadyExists.java | 33 +++++++++ 6 files changed, 303 insertions(+) create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoBlueprintAlreadyExists.java create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyException.java create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyManagerNotFound.java create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeout.java create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowException.java create mode 100644 adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoDeploymentAlreadyExists.java (limited to 'adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions') diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoBlueprintAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoBlueprintAlreadyExists.java new file mode 100644 index 0000000000..1bdd6f3850 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoBlueprintAlreadyExists.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +public class MsoBlueprintAlreadyExists extends MsoCloudifyException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoCloudifyException instance + public MsoBlueprintAlreadyExists (String blueprintId, String cloud) { + // Set the detailed error as the Exception 'message' + super(409, "Conflict", "Blueprint " + blueprintId + " already exists in Cloudify Manager supporting cloud site + " + cloud); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyException.java new file mode 100644 index 0000000000..f2469f4706 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyException.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * OpenStack exception. + */ +public class MsoCloudifyException extends MsoException +{ + + /** + * Serialization id. + */ + private static final long serialVersionUID = 3313636124141766495L; + + private int statusCode; + private String statusMessage; + private String errorDetail; + private boolean pendingWorkflow; + + /** + * Constructor to create a new MsoOpenstackException instance + * @param code the error code + * @param message the error message + * @param detail error details + */ + public MsoCloudifyException (int code, String message, String detail) { + // Set the detailed error as the Exception 'message' + super(detail); + super.category = MsoExceptionCategory.OPENSTACK; + + this.statusCode = code; + this.statusMessage = message; + this.errorDetail = detail; + this.pendingWorkflow = false; + } + + /** + * Constructor to propagate the caught exception (mostly for stack trace) + * @param code the error code + * @param message the error message + * @param detail error details + * @param e the cause + */ + public MsoCloudifyException (int code, String message, String detail, Exception e) { + // Set the detailed error as the Exception 'message' + super(detail, e); + super.category = MsoExceptionCategory.OPENSTACK; + + this.statusCode = code; + this.statusMessage = message; + this.errorDetail = detail; + this.pendingWorkflow = false; + } + + public void setPendingWorkflow (boolean pendingWorkflow) { + this.pendingWorkflow = pendingWorkflow; + } + + @Override + public String toString () { + String error = "" + statusCode + " " + statusMessage + ": " + errorDetail + (pendingWorkflow ? " [workflow pending]" : ""); + return error; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyManagerNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyManagerNotFound.java new file mode 100644 index 0000000000..601e5b78ea --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyManagerNotFound.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +public class MsoCloudifyManagerNotFound extends MsoCloudifyException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoCloudifyException instance + public MsoCloudifyManagerNotFound (String cloudSiteId) { + // Set the detailed error as the Exception 'message' + super(0, "Cloudify Manager Not Found", "No Cloudify Manager configured for cloud site " + cloudSiteId); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeout.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeout.java new file mode 100644 index 0000000000..ba1e2a721b --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeout.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +import org.openecomp.mso.cloudify.v3.model.Execution; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; + +/** + * MSO Exception when a Cloudify workflow execution times out waiting for completion. + * Exception includes the last known state of the workflow execution. + */ +public class MsoCloudifyTimeout extends MsoException +{ + + /** + * Serialization id. + */ + private static final long serialVersionUID = 3313636124141766495L; + + private Execution execution; + + /** + * Constructor to create a new MsoOpenstackException instance + * @param code the error code + * @param message the error message + * @param detail error details + */ + public MsoCloudifyTimeout (Execution execution) { + // Set the detailed error as the Exception 'message' + super("Cloudify Workflow Timeout for workflow " + execution.getWorkflowId() + " on deployment " + execution.getDeploymentId()); + super.category = MsoExceptionCategory.OPENSTACK; + + this.execution = execution; + } + + public Execution getExecution() { + return this.execution; + } + + @Override + public String toString () { + String error = "Workflow timeout: workflow=" + execution.getWorkflowId() + ",deployment=" + execution.getDeploymentId(); + return error; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowException.java new file mode 100644 index 0000000000..a397135667 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +/** + * Reports an error with a Cloudify Workflow execution. + * @author JC1348 + * + */ +public class MsoCloudifyWorkflowException extends MsoCloudifyException { + + private static final long serialVersionUID = 1L; + + private String workflowStatus; + private boolean workflowStillRunning = false; + + // Constructor to create a new MsoCloudifyException instance + public MsoCloudifyWorkflowException (String message, String deploymentId, String workflowId, String workflowStatus) + { + super(0, "Workflow Exception", "Workflow " + workflowId + " failed on deployment " + deploymentId + ": " + message); + this.workflowStatus = workflowStatus; + if (workflowStatus.equals("pending") || workflowStatus.equals("started") || + workflowStatus.equals("cancelling") || workflowStatus.equals("force_cancelling")) + { + workflowStillRunning = true; + } + } + + public String getWorkflowStatus() { + return workflowStatus; + } + + public boolean isWorkflowStillRunning () { + return workflowStillRunning; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoDeploymentAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoDeploymentAlreadyExists.java new file mode 100644 index 0000000000..37f97a8ce9 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloudify/exceptions/MsoDeploymentAlreadyExists.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.mso.cloudify.exceptions; + +public class MsoDeploymentAlreadyExists extends MsoCloudifyException { + + private static final long serialVersionUID = 1L; + + // Constructor to create a new MsoCloudifyException instance + public MsoDeploymentAlreadyExists (String deploymentId, String cloud) { + // Set the detailed error as the Exception 'message' + super(409, "Conflict", "Deployment " + deploymentId + " already exists in Cloudify Manager suppporting cloud " + cloud); + } + +} -- cgit 1.2.3-korg