diff options
346 files changed, 9316 insertions, 5881 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index bb235ffb2c..2bb9ad240f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,39 +1,176 @@ -/* -* ============LICENSE_START========================================== -* =================================================================== -* Copyright © 2017 AT&T Intellectual Property. All rights reserved. -* =================================================================== -* -* Unless otherwise specified, all software contained herein is licensed -* under the Apache License, Version 2.0 (the “License”); -* you may not use this software except in compliance with the License. -* You may obtain a copy of the License at -* -* 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. -* -* -* -* Unless otherwise specified, all documentation contained herein is licensed -* under the Creative Commons License, Attribution 4.0 Intl. (the “License”); -* you may not use this documentation except in compliance with the License. -* You may obtain a copy of the License at -* -* https://creativecommons.org/licenses/by/4.0/ -* -* Unless required by applicable law or agreed to in writing, documentation -* 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============================================ -* -* ECOMP is a trademark and service mark of AT&T Intellectual Property. -* -*/ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index dd1159f6d1..cd0a688018 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <name>mso-adapter-utils</name> <description>Common MSO utilities, including Openstack client wrappers.</description> @@ -44,32 +44,44 @@ <dependencies> <dependency> +<!-- + <groupId>org.onap.so.libs.openstack-java-sdk</groupId> +--> <groupId>org.openecomp.so.libs.openstack-java-sdk</groupId> <artifactId>keystone-client</artifactId> <version>${openstack.version}</version> </dependency> <dependency> +<!-- + <groupId>org.onap.so.libs.openstack-java-sdk</groupId> +--> <groupId>org.openecomp.so.libs.openstack-java-sdk</groupId> <artifactId>heat-client</artifactId> <version>${openstack.version}</version> </dependency> <dependency> +<!-- + <groupId>org.onap.so.libs.openstack-java-sdk</groupId> +--> <groupId>org.openecomp.so.libs.openstack-java-sdk</groupId> <artifactId>quantum-client</artifactId> <version>${openstack.version}</version> </dependency> <dependency> +<!-- + <groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId> +--> <groupId>org.openecomp.so.libs.openstack-java-sdk.client-connectors</groupId> <artifactId>http-connector</artifactId> <version>${openstack.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java index 79fe8fda8e..445c135dab 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java @@ -185,12 +185,12 @@ public class CloudConfigFactory implements Serializable { StringBuffer response = new StringBuffer (); response.append ("Cloud Sites:\n"); for (CloudSite site : cloudConfig.getCloudSites ().values ()) { - response.append (site.toString () + "\n"); + response.append(site.toString()).append("\n"); } response.append ("\n\nCloud Identity Services:\n"); for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { - response.append (identity.toString () + "\n"); + response.append(identity.toString()).append("\n"); } return Response.status (200).entity (response).build (); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java index d0ba7e09fc..3dd4cbfc9c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java @@ -23,28 +23,23 @@ package org.openecomp.mso.cloud; -import java.io.IOException; -import java.net.URISyntaxException; +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; import java.security.GeneralSecurityException; - import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.openecomp.mso.openstack.exceptions.MsoAdapterException; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; -import org.openecomp.mso.openstack.utils.MsoTenantUtils; -import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory; import org.openecomp.mso.cloud.authentication.AuthenticationMethodFactory; import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper; import org.openecomp.mso.cloud.authentication.wrappers.UsernamePasswordWrapper; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; - -import com.woorea.openstack.keystone.model.authentication.UsernamePassword; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; +import org.openecomp.mso.openstack.utils.MsoTenantUtils; +import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory; import org.openecomp.mso.utils.CryptoUtils; -import com.woorea.openstack.keystone.model.Authentication; /** * JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity @@ -143,15 +138,11 @@ public class CloudIdentity { } } } - - public Authentication getAuthentication () throws MsoException { + + public Authentication getAuthentication() { if (this.getIdentityAuthenticationType() != null) { - try { return AuthenticationMethodFactory.getAuthenticationFor(this); - } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | IOException | URISyntaxException e) { - throw new MsoAdapterException("Could not retrieve authentication for " + this.identityAuthenticationType, e); - } - } else { // Fallback + } else { return new UsernamePassword(this.getMsoId(), this.getMsoPass()); } } @@ -236,29 +227,18 @@ public class CloudIdentity { public void setIdentityAuthenticationType(IdentityAuthenticationType identityAuthenticationType) { this.identityAuthenticationType = identityAuthenticationType; } - + @Override public String toString () { - StringBuilder stringBuilder = new StringBuilder (); - stringBuilder.append ("Cloud Identity Service: id=") - .append (id) - .append (", identityUrl=") - .append (this.identityUrl) - .append (", msoId=") - .append (msoId) - .append (", adminTenant=") - .append (adminTenant) - .append (", memberRole=") - .append (memberRole) - .append (", tenantMetadata=") - .append (tenantMetadata) - .append (", identityServerType=") - .append (identityServerType == null ? "null" : identityServerType.toString()) - .append (", identityAuthenticationType=") - .append (identityAuthenticationType == null ? "null" : identityAuthenticationType.toString()); - - return stringBuilder.toString (); - } + return "Cloud Identity Service: id=" + id + + ", identityUrl=" + this.identityUrl + + ", msoId=" + msoId + + ", adminTenant=" + adminTenant + + ", memberRole=" + memberRole + + ", tenantMetadata=" + tenantMetadata + + ", identityServerType=" + (identityServerType == null ? "null" : identityServerType.toString()) + + ", identityAuthenticationType=" + (identityAuthenticationType == null ? "null" : identityAuthenticationType.toString()); + } public static String encryptPassword (String msoPass) { try { diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java index 85cb2967d6..c9be2c7949 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java @@ -23,18 +23,13 @@ package org.openecomp.mso.cloud.authentication;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import com.woorea.openstack.keystone.model.Authentication;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import org.openecomp.mso.cloud.CloudIdentity;
-import com.woorea.openstack.keystone.model.Authentication;
-
/**
* This factory manages all the wrappers associated to authentication types.
- *
*/
public final class AuthenticationMethodFactory {
@@ -58,7 +53,7 @@ public final class AuthenticationMethodFactory { }
}
- public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException {
+ public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
throw new IllegalArgumentException("Cloud identity cannot be null");
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java index 5cf5587481..e82306b6cd 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java @@ -35,16 +35,6 @@ import com.woorea.openstack.keystone.model.Authentication; */
public class RackspaceAPIKeyWrapper extends AuthenticationWrapper {
- /**
- *
- */
- public RackspaceAPIKeyWrapper() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
- */
@Override
public Authentication getAuthentication(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java index 5fd3e521f0..a1beabe564 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java @@ -32,19 +32,9 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword; /**
* This class implements the authentication wrapper for Openstack provided for
* user name and password authentication.
- *
*/
public class UsernamePasswordWrapper extends AuthenticationWrapper {
- /**
- *
- */
- public UsernamePasswordWrapper() {
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
- */
@Override
public Authentication getAuthentication(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java index 2cda8f99e2..64460b20bb 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java @@ -139,15 +139,13 @@ public class NetworkInfo { @Override public String toString() { - final StringBuilder sb = new StringBuilder("NetworkInfo{"); - sb.append("name='").append(name).append('\''); - sb.append(", id='").append(id).append('\''); - sb.append(", status=").append(status); - sb.append(", provider='").append(provider).append('\''); - sb.append(", vlans=").append(vlans); - sb.append(", subnets=").append(subnets); - sb.append('}'); - return sb.toString(); + return "NetworkInfo{" + "name='" + name + '\'' + + ", id='" + id + '\'' + + ", status=" + status + + ", provider='" + provider + '\'' + + ", vlans=" + vlans + + ", subnets=" + subnets + + '}'; } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java index 600985e310..506b62994d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java @@ -67,10 +67,8 @@ public class StackInfo { if (stack.getStackStatus() == null) { this.status = HeatStatus.INIT; - } else if (heatStatusMap.containsKey(stack.getStackStatus())) { - this.status = heatStatusMap.get(stack.getStackStatus()); } else { - this.status = HeatStatus.UNKNOWN; + this.status = heatStatusMap.getOrDefault(stack.getStackStatus(), HeatStatus.UNKNOWN); } if (stack.getOutputs() != null) { this.outputs = new HashMap<>(); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java index 8aa8d3f5e8..eead8439d4 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java @@ -68,16 +68,13 @@ public class MsoOpenstackException extends MsoException this.statusMessage = message; this.errorDetail = detail; } - + @Override - public String toString () { - StringBuilder error = new StringBuilder(); - error.append(""); - error.append(statusCode); - error.append(" "); - error.append(statusMessage); - error.append(": "); - error.append(errorDetail); - return error.toString(); + public String toString() { + return statusCode + + " " + + statusMessage + + ": " + + errorDetail; } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java index 269f6b0cdf..7d6de317ad 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java @@ -129,6 +129,7 @@ public class MsoCommonUtils { Thread.sleep (retryDelay * 1000L); } catch (InterruptedException e1) { logger.debug ("Thread interrupted while sleeping", e1); + Thread.currentThread().interrupt(); } } else @@ -144,6 +145,7 @@ public class MsoCommonUtils { Thread.sleep (retryDelay * 1000L); } catch (InterruptedException e1) { logger.debug ("Thread interrupted while sleeping", e1); + Thread.currentThread().interrupt(); } } else diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java index 69da437797..04dbf523d0 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java @@ -65,11 +65,9 @@ public class MsoHeatEnvironmentEntry { @Override public String toString() { - final StringBuilder sb = new StringBuilder("MsoHeatEnvironmentEntry{"); - sb.append("parameters=").append(parameters); - sb.append(", resourceRegistryEntryRaw='").append(resourceRegistryEntryRaw).append('\''); - sb.append('}'); - return sb.toString(); + return "MsoHeatEnvironmentEntry{" + "parameters=" + parameters + + ", resourceRegistryEntryRaw='" + resourceRegistryEntryRaw + '\'' + + '}'; } public String getRawEntry() { diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java index a2e605f897..a0c9b7a105 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java @@ -59,12 +59,10 @@ public class MsoHeatEnvironmentResource { @Override public String toString() { - StringBuilder str = new StringBuilder(); - str.append("\""); - str.append(this.name); - str.append("\": "); - str.append(this.value); - return str.toString(); + return "\"" + + this.name + + "\": " + + this.value; } @Override diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index acc6d72f63..6862492d7e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java @@ -143,7 +143,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String tenantId, String stackName, String heatTemplate, - Map <String, ? extends Object> stackInputs, + Map <String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes) throws MsoException { // Just call the new method with the environment & files variable set to null @@ -165,7 +165,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String tenantId, String stackName, String heatTemplate, - Map <String, ? extends Object> stackInputs, + Map <String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes, String environment) throws MsoException { @@ -188,7 +188,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String tenantId, String stackName, String heatTemplate, - Map <String, ? extends Object> stackInputs, + Map <String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes, String environment, @@ -211,7 +211,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String tenantId, String stackName, String heatTemplate, - Map <String, ? extends Object> stackInputs, + Map <String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes, String environment, @@ -275,7 +275,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String tenantId, String stackName, String heatTemplate, - Map <String, ? extends Object> stackInputs, + Map <String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes, String environment, @@ -886,7 +886,7 @@ public class MsoHeatUtils extends MsoCommonUtils { public Map <String, Object> validateStackParams (Map <String, Object> inputParams, HeatTemplate heatTemplate) throws IllegalArgumentException { // Check that required parameters have been supplied for this template type - String missingParams = null; + StringBuilder missingParams = null; List <String> paramList = new ArrayList <> (); // TODO: Enhance DB to support defaults for Heat Template parameters @@ -894,9 +894,9 @@ public class MsoHeatUtils extends MsoCommonUtils { for (HeatTemplateParam parm : heatTemplate.getParameters ()) { if (parm.isRequired () && !inputParams.containsKey (parm.getParamName ())) { if (missingParams == null) { - missingParams = parm.getParamName (); + missingParams = new StringBuilder(parm.getParamName()); } else { - missingParams += "," + parm.getParamName (); + missingParams.append("," + parm.getParamName()); } } paramList.add (parm.getParamName ()); @@ -1106,11 +1106,8 @@ public class MsoHeatUtils extends MsoCommonUtils { } public boolean isExpired () { - if (expires == null) { - return true; - } + return expires == null || System.currentTimeMillis() > expires.getTimeInMillis(); - return System.currentTimeMillis() > expires.getTimeInMillis(); } } @@ -1217,18 +1214,18 @@ public class MsoHeatUtils extends MsoCommonUtils { } else { for (String key : params.keySet()) { if (params.get(key) instanceof String) { - sb.append("\n" + key + "=" + (String) params.get(key)); + sb.append("\n").append(key).append("=").append((String) params.get(key)); } else if (params.get(key) instanceof JsonNode) { String jsonStringOut = this.convertNode((JsonNode)params.get(key)); - sb.append("\n" + key + "=" + jsonStringOut); + sb.append("\n").append(key).append("=").append(jsonStringOut); } else if (params.get(key) instanceof Integer) { String integerOut = "" + params.get(key); - sb.append("\n" + key + "=" + integerOut); + sb.append("\n").append(key).append("=").append(integerOut); } else { try { String str = params.get(key).toString(); - sb.append("\n" + key + "=" + str); + sb.append("\n").append(key).append("=").append(str); } catch (Exception e) { LOGGER.debug("Exception :",e); } @@ -1243,8 +1240,6 @@ public class MsoHeatUtils extends MsoCommonUtils { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); final String json = JSON_MAPPER.writeValueAsString(obj); return json; - } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage(), jpe); } catch (Exception e) { LOGGER.debug("Error converting json to string " + e.getMessage(), e); } @@ -1272,16 +1267,16 @@ public class MsoHeatUtils extends MsoCommonUtils { int counter = 0; sb.append("OUTPUTS:\n"); for (String key : outputs.keySet()) { - sb.append("outputs[" + counter++ + "]: " + key + "="); + sb.append("outputs[").append(counter++).append("]: ").append(key).append("="); Object obj = outputs.get(key); if (obj instanceof String) { - sb.append((String)obj +" (a string)"); + sb.append((String) obj).append(" (a string)"); } else if (obj instanceof JsonNode) { - sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)"); + sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)"); } else if (obj instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(obj); - sb.append(str + " (a java.util.LinkedHashMap)"); + sb.append(str).append(" (a java.util.LinkedHashMap)"); } catch (Exception e) { LOGGER.debug("Exception :",e); sb.append("(a LinkedHashMap value that would not convert nicely)"); @@ -1439,7 +1434,7 @@ public class MsoHeatUtils extends MsoCommonUtils { if (inputs == null) { LOGGER.debug("convertInputMap - inputs is null - nothing to do here"); - return new HashMap<String, Object>(); + return new HashMap<>(); } LOGGER.debug("convertInputMap in MsoHeatUtils called, with " + inputs.size() + " inputs, and template " + template.getArtifactUuid()); @@ -1548,7 +1543,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } } else if ("boolean".equalsIgnoreCase(type)) { String booleanString = inputs.get(key); - Boolean aBool = new Boolean(booleanString); + Boolean aBool = Boolean.valueOf(booleanString); if (alias) newInputs.put(realName, aBool); else diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java index 2465b30eca..75bb00351c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -230,7 +230,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { if (haveFiles && haveHeatFiles) { // Let's do this here - not in the bean LOGGER.debug ("Found files AND heatFiles - combine and add!"); - Map <String, Object> combinedFiles = new HashMap <String, Object> (); + Map <String, Object> combinedFiles = new HashMap<>(); for (String keyString : files.keySet ()) { combinedFiles.put (keyString, files.get (keyString)); } @@ -358,23 +358,23 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { sb.append("(outputs is empty)"); return sb; } - Map<String, Object> outputs = new HashMap<String,Object>(); + Map<String, Object> outputs = new HashMap<>(); for (Output outputItem : outputList) { outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue()); } int counter = 0; sb.append("OUTPUTS:\n"); for (String key : outputs.keySet()) { - sb.append("outputs[" + counter++ + "]: " + key + "="); + sb.append("outputs[").append(counter++).append("]: ").append(key).append("="); Object obj = outputs.get(key); if (obj instanceof String) { - sb.append((String)obj +" (a string)"); + sb.append((String) obj).append(" (a string)"); } else if (obj instanceof JsonNode) { - sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)"); + sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)"); } else if (obj instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(obj); - sb.append(str + " (a java.util.LinkedHashMap)"); + sb.append(str).append(" (a java.util.LinkedHashMap)"); } catch (Exception e) { LOGGER.debug("Exception :", e); sb.append("(a LinkedHashMap value that would not convert nicely)"); @@ -428,8 +428,6 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); final String json = JSON_MAPPER.writeValueAsString(obj); return json; - } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage(), jpe); } catch (Exception e) { LOGGER.debug("Error converting json to string " + e.getMessage(), e); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java index be36d67e0b..3b710032c1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java @@ -209,7 +209,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } - Map <String, String> metadata = new HashMap <String, String> (); + Map <String, String> metadata = new HashMap<>(); if (cloudSite.getIdentityService ().hasTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps); @@ -255,7 +255,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } - Map <String, String> metadata = new HashMap <String, String> (); + Map <String, String> metadata = new HashMap<>(); if (cloudSite.getIdentityService ().hasTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps); @@ -567,11 +567,8 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } public boolean isExpired () { - if (expires == null) { - return true; - } + return expires == null || System.currentTimeMillis() > expires.getTimeInMillis(); - return System.currentTimeMillis() > expires.getTimeInMillis(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java index 50a594663e..9eba799e18 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java @@ -63,7 +63,7 @@ public class MsoNeutronUtils extends MsoCommonUtils // token will be used until it expires. // // The cache key is "tenantId:cloudId" - private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<String,NeutronCacheEntry>(); + private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<>(); // Fetch cloud configuration each time (may be cached in CloudConfig class) private CloudConfig cloudConfig; @@ -129,7 +129,7 @@ public class MsoNeutronUtils extends MsoCommonUtils } } else if (type == NetworkType.MULTI_PROVIDER) { if (provider != null && vlans != null && vlans.size() > 0) { - List<Segment> segments = new ArrayList<Segment>(vlans.size()); + List<Segment> segments = new ArrayList<>(vlans.size()); for (int vlan : vlans) { Segment segment = new Segment(); segment.setProviderPhysicalNetwork (provider); @@ -297,7 +297,7 @@ public class MsoNeutronUtils extends MsoCommonUtils } } else if (type == NetworkType.MULTI_PROVIDER) { if (provider != null && vlans != null && vlans.size() > 0) { - List<Segment> segments = new ArrayList<Segment>(vlans.size()); + List<Segment> segments = new ArrayList<>(vlans.size()); for (int vlan : vlans) { Segment segment = new Segment(); segment.setProviderPhysicalNetwork (provider); @@ -559,11 +559,7 @@ public class MsoNeutronUtils extends MsoCommonUtils } public boolean isExpired() { - if (expires == null) { - return true; - } - - return System.currentTimeMillis() > expires.getTimeInMillis(); + return expires == null || System.currentTimeMillis() > expires.getTimeInMillis(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java index c227d72f0c..8002087ddd 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java @@ -27,6 +27,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; @@ -73,33 +74,32 @@ public class MsoYamlEditorWithEnvt { if (resourceMap == null) { return paramSet; } - Iterator <Entry <String, Object>> it = resourceMap.entrySet().iterator(); - - while (it.hasNext()) { - MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); - Map.Entry <String, Object> pair = it.next(); - String value; - Object obj = pair.getValue(); - if (obj instanceof java.lang.String) { - value = yaml.dump(obj); - // but this adds an extra '\n' at the end - which won't hurt - but we don't need it - value = value.substring(0, value.length() - 1); - } else if (obj instanceof java.util.LinkedHashMap) { - //Handle that it's json - try { - value = JSON_MAPPER.writeValueAsString(obj); - } catch (Exception e) { - LOGGER.debug("Exception:", e); - value = "_BAD_JSON_MAPPING"; - } - } else { - //this handles integers/longs/floats/etc. - value = String.valueOf(obj); - } - hep.setName((String) pair.getKey()); - hep.setValue(value); - paramSet.add(hep); - } + + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); + Entry<String, Object> pair = stringObjectEntry; + String value; + Object obj = pair.getValue(); + if (obj instanceof String) { + value = yaml.dump(obj); + // but this adds an extra '\n' at the end - which won't hurt - but we don't need it + value = value.substring(0, value.length() - 1); + } else if (obj instanceof LinkedHashMap) { + //Handle that it's json + try { + value = JSON_MAPPER.writeValueAsString(obj); + } catch (Exception e) { + LOGGER.debug("Exception:", e); + value = "_BAD_JSON_MAPPING"; + } + } else { + //this handles integers/longs/floats/etc. + value = String.valueOf(obj); + } + hep.setName((String) pair.getKey()); + hep.setValue(value); + paramSet.add(hep); + } return paramSet; } public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() { @@ -107,15 +107,14 @@ public class MsoYamlEditorWithEnvt { Set<MsoHeatEnvironmentResource> resourceList = new HashSet<>(); @SuppressWarnings("unchecked") Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry"); - Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator(); - - while (it.hasNext()) { - MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource(); - Map.Entry<String, Object> pair = it.next(); - her.setName((String) pair.getKey()); - her.setValue((String) pair.getValue()); - resourceList.add(her); - } + + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource(); + Entry<String, Object> pair = stringObjectEntry; + her.setName((String) pair.getKey()); + her.setValue((String) pair.getValue()); + resourceList.add(her); + } return resourceList; } catch (Exception e) { LOGGER.debug("Exception:", e); @@ -126,35 +125,34 @@ public class MsoYamlEditorWithEnvt { Set <HeatTemplateParam> paramSet = new HashSet <> (); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - HeatTemplateParam param = new HeatTemplateParam (); - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + HeatTemplateParam param = new HeatTemplateParam(); + Entry<String, Object> pair = stringObjectEntry; @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); String value = null; try { - value = resourceEntry.get ("default"); - } catch (java.lang.ClassCastException cce) { + value = resourceEntry.get("default"); + } catch (ClassCastException cce) { LOGGER.debug("Exception:", cce); - // This exception only - the value is an integer. For what we're doing - // here - we don't care - so set value to something - and it will - // get marked as not being required - which is correct. - //System.out.println("cce exception!"); - value = "300"; - // okay + // This exception only - the value is an integer. For what we're doing + // here - we don't care - so set value to something - and it will + // get marked as not being required - which is correct. + //System.out.println("cce exception!"); + value = "300"; + // okay } - param.setParamName ((String) pair.getKey ()); + param.setParamName((String) pair.getKey()); if (value != null) { - param.setRequired (false); + param.setRequired(false); } else { - param.setRequired (true); + param.setRequired(true); } - value = resourceEntry.get ("type"); - param.setParamType (value); + value = resourceEntry.get("type"); + param.setParamType(value); - paramSet.add (param); + paramSet.add(param); } return paramSet; diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java index 6fd95d5948..c2d4f9ba60 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java @@ -60,7 +60,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { public final void testCreateStackBadCloudConfig() throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { - msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String, Object>(), + msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10); } catch (MsoCloudSiteNotFound e) { @@ -74,7 +74,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { public final void testCreateStackFailedConnectionHeatClient() throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10); } catch (MsoIOException e) { @@ -86,7 +86,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { public final void testCreateStackFailedConnection() throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10); } catch (MsoIOException e) { @@ -97,7 +97,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { @Test public final void createStackSuccessWithEnvironment() throws MsoException { try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10, + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, "environment"); } catch (MsoIOException e) { @@ -108,8 +108,8 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { @Test public final void createStackSuccessWithFiles() throws MsoException { try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10, - "environment", new HashMap<String, Object>()); + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, + "environment", new HashMap<>()); } catch (MsoIOException e) { } @@ -119,8 +119,8 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { @Test public final void createStackSuccessWithHeatFiles() throws MsoException { try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10, - "environment", new HashMap<String, Object>(), new HashMap<String, Object>()); + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, + "environment", new HashMap<>(), new HashMap<>()); } catch (MsoIOException e) { } @@ -131,7 +131,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { CreateStackParam param = new CreateStackParam(); param.setDisableRollback(false); param.setEnvironment("environment"); - param.setFiles(new HashMap<String, Object>()); + param.setFiles(new HashMap<>()); param.setParameters(new HashMap<>()); param.setStackName("stackName"); param.setTemplate("template"); diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java new file mode 100644 index 0000000000..2cfce276d8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java @@ -0,0 +1,103 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.woorea.openstack.keystone.model.Authentication; +import org.junit.Test; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudIdentity.IdentityAuthenticationType; +import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper; + +public class AuthenticationMethodFactoryTest { + + private static final Class WRAPPER_CLASS = RackspaceAPIKeyWrapper.class; + private static final String AUTHENTICATION_TYPE = "authenticationTest"; + + @Test + public void register_NoExceptionThrown() throws IllegalAccessException, InstantiationException { + AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, WRAPPER_CLASS); + } + + @Test + public void register_throwExceptionWhenAuthTypeIsNull() throws InstantiationException, IllegalAccessException { + try { + AuthenticationMethodFactory.register(null, WRAPPER_CLASS); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null " + + "or an empty name string"); + } + } + + @Test + public void register_throwExceptionWhenAuthTypeIsEmpty() throws InstantiationException, IllegalAccessException { + try { + AuthenticationMethodFactory.register("", WRAPPER_CLASS); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null " + + "or an empty name string"); + } + } + + @Test + public void register_throwExceptionWhenWrapperIsNull() throws IllegalAccessException, InstantiationException { + try { + AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, null); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).isNotEmpty() + .contains("Wrapper Class to register for Authentication cannot be null"); + } + } + + @Test + public void getAuthentication_NoExceptionThrown() { + CloudIdentity cloudIdentity = new CloudIdentity(); + cloudIdentity.setIdentityAuthenticationType(IdentityAuthenticationType.RACKSPACE_APIKEY); + cloudIdentity.setMsoId("msoIdTest"); + cloudIdentity.setMsoPass("123"); + Authentication result = AuthenticationMethodFactory.getAuthenticationFor(cloudIdentity); + assertThat(result).isNotNull(); + } + + @Test + public void getAuthentication_ThrowExWhenCloudSiteIsNull() { + try { + AuthenticationMethodFactory.getAuthenticationFor(null); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).isNotEmpty().contains("Cloud identity cannot be null"); + } + } + + @Test + public void getAuthentication_ThrowExWhenIdentityAuthenticationTypeIsNotSet() { + try { + AuthenticationMethodFactory.getAuthenticationFor(new CloudIdentity()); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).isNotEmpty() + .contains("Cloud identity authentication type cannot be null or empty"); + } + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java index ccfede7297..b6c1c7373f 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java @@ -25,16 +25,11 @@ package org.openecomp.mso.cloud.authentication; import static org.junit.Assert.assertTrue;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
import org.junit.Test;
import org.openecomp.mso.cloud.CloudIdentity;
import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
/**
* A few JUnit tests to evaluate the new factory that manages authentication
@@ -50,52 +45,15 @@ public class AuthenticationMethodTest { public AuthenticationMethodTest() {
// TODO Auto-generated constructor stub
}
-
- @Test
- public void testCustomRackspaceAuth() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("test");
-
- try {
- Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
- | URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testCoreUsernamePasswordAuth() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("someuser");
-
- try {
- Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
- | URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
+
@Test
public void testCustomRackspaceAuthFromCloudIdentity() {
CloudIdentity ci = new CloudIdentity();
ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
ci.setMsoId("test");
-
- try {
- Authentication auth = ci.getAuthentication();
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- } catch (MsoException e) {
- e.printStackTrace();
- }
+ Authentication auth = ci.getAuthentication();
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
}
@Test
@@ -104,12 +62,7 @@ public class AuthenticationMethodTest { ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
ci.setMsoId("someuser");
-
- try {
- Authentication auth = ci.getAuthentication();
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- } catch (MsoException e) {
- e.printStackTrace();
- }
+ Authentication auth = ci.getAuthentication();
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java new file mode 100644 index 0000000000..33f91c641e --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.wrappers; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.woorea.openstack.keystone.model.Authentication; +import org.junit.Test; +import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; + +public class RackspaceAPIKeyWrapperTest { + + @Test + public void getAuthenticationSuccessful() { + RackspaceAPIKeyWrapper testedObject = new RackspaceAPIKeyWrapper(); + Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity()); + + assertThat(authentication).isInstanceOf(RackspaceAuthentication.class); + RackspaceAuthentication rackspaceAuthentication = (RackspaceAuthentication) authentication; + assertThat(rackspaceAuthentication.getToken().getUsername()) + .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID); + assertThat(rackspaceAuthentication.getToken().getApiKey()) + .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS); + } + + @Test + public void getAuthenticationThrowsException() { + assertThatThrownBy(() -> new RackspaceAPIKeyWrapper().getAuthentication(null)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java new file mode 100644 index 0000000000..0cfe287dfe --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.wrappers; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; +import org.junit.Test; + +public class UsernamePasswordWrapperTest { + + @Test + public void getAuthenticationSuccessful() { + UsernamePasswordWrapper testedObject = new UsernamePasswordWrapper(); + Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity()); + + assertThat(authentication).isInstanceOf(UsernamePassword.class); + UsernamePassword usernamePassword = (UsernamePassword) authentication; + assertThat(usernamePassword.getPasswordCredentials().getUsername()) + .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID); + assertThat(usernamePassword.getPasswordCredentials().getPassword()) + .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS); + } + + @Test + public void getAuthenticationThrowsException() { + assertThatThrownBy(() -> new UsernamePasswordWrapper().getAuthentication(null)). + isInstanceOf(IllegalArgumentException.class). + hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java new file mode 100644 index 0000000000..3cbc48d090 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.wrappers; + +import org.openecomp.mso.cloud.CloudIdentity; + +final class WrapperTestUtility { + + static final String CLOUD_IDENTITY_MSO_ID = "msoIdTest"; + static final String CLOUD_IDENTITY_MSO_PASS = "msoPassTest"; + static final String EXCEPTION_MESSAGE = "Provided cloud identity is null, cannot extract username and " + + "password"; + + private WrapperTestUtility() { + } + + static CloudIdentity createCloudIdentity() { + CloudIdentity cloudIdentity = new CloudIdentity(); + cloudIdentity.setMsoId(CLOUD_IDENTITY_MSO_ID); + cloudIdentity.setMsoPass(CloudIdentity.encryptPassword(CLOUD_IDENTITY_MSO_PASS)); + return cloudIdentity; + } +} diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml index f10500d2ca..98cd1831c1 100644 --- a/adapters/mso-adapters-rest-interface/pom.xml +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <packaging>jar</packaging> <name>mso-adapters-rest-interface</name> @@ -44,7 +44,7 @@ <version>3.0.19.Final</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java index 5c3470acd9..9efaee921f 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java @@ -433,7 +433,7 @@ public class BeanTest { m.invoke(obj); } else if (types.length == 1) { String type = types[0].getTypeName(); - if (type.indexOf("<") != -1) { + if (type.contains("<")) { type = type.substring(0, type.indexOf("<")); } Class paramCls = Class.forName(type); diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index c9590ee1a1..9bacb17a51 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-catalog-db-adapter</artifactId> <packaging>war</packaging> @@ -65,7 +65,7 @@ <dependencies> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> @@ -95,7 +95,7 @@ <version>3.0.16.Final</version> </dependency> <!--<dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency>--> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java index 668f73816d..c1c5aee8f1 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java @@ -52,34 +52,39 @@ Once the network-level distribution artifacts are defined, similar updates can b import java.util.ArrayList; import java.util.List; + import javax.ws.rs.GET; import javax.ws.rs.HEAD; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; -import org.apache.http.HttpStatus; +import javax.ws.rs.core.Response; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; +import org.apache.http.HttpStatus; +import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery; import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException; import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory; -import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery; -import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs; -import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks; -import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder; import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryResourceRecipe; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceCsar; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks; +import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs; import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryVfModule; import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; -import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.openecomp.mso.db.catalog.beans.Recipe; import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.db.catalog.beans.ToscaCsar; +import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; +import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; /** * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1) @@ -425,45 +430,144 @@ public class CatalogDbAdapterRest { QueryVfModule qryResp; int respStatus = HttpStatus.SC_OK; List<VfModuleCustomization> ret = null; - CatalogDatabase db = CatalogDatabase.getInstance(); - - try{ - if(vfModuleModelName != null && !"".equals(vfModuleModelName)){ - LOGGER.debug ("Query vfModules by vfModuleModuleName: " + vfModuleModelName); - VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName); - if(vfModule != null){ - ret = new ArrayList<>(1); - ret.add(vfModule); + + try (CatalogDatabase db = CatalogDatabase.getInstance()) { + if (vfModuleModelName != null && !"".equals(vfModuleModelName)) { + LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName); + VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName); + if (vfModule != null) { + ret = new ArrayList<>(1); + ret.add(vfModule); + } + } else { + throw (new Exception("Incoming parameter is null or blank")); + } + if (ret == null || ret.isEmpty()) { + LOGGER.debug("vfModules not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryVfModule(); + } else { + LOGGER.debug("vfModules found"); + qryResp = new QueryVfModule(ret); + LOGGER.debug("vfModules query Results is: " + qryResp); + LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false)); + } + LOGGER.debug("Query vfModules exit"); + return Response + .status(respStatus) + .entity(qryResp.JSON2(false, false)) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", + e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) { + }) + .build(); + } + } + + /** + * Get the tosca csar info from catalog + * <br> + * + * @param smUuid service model uuid + * @return the tosca csar information of the serivce. + * @since ONAP Beijing Release + */ + @GET + @Path("serviceToscaCsar") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) { + int respStatus = HttpStatus.SC_OK; + String entity = ""; + try (CatalogDatabase db = CatalogDatabase.getInstance()) { + if (smUuid != null && !"".equals(smUuid)) { + LOGGER.debug("Query Csar by service model uuid: " + smUuid); + ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid); + if (toscaCsar != null) { + QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar); + entity = serviceCsar.JSON2(false, false); + } else { + respStatus = HttpStatus.SC_NOT_FOUND; + } + } else { + throw (new Exception("Incoming parameter is null or blank")); + } + LOGGER.debug("Query Csar exit"); + return Response + .status(respStatus) + .entity(entity) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) { + }) + .build(); + } + } + + /** + * Get the resource recipe info from catalog + * <br> + * + * @param rmUuid resource model uuid + * @return the recipe information of the resource. + * @since ONAP Beijing Release + */ + @GET + @Path("resourceRecipe") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) { + int respStatus = HttpStatus.SC_OK; + String entity = ""; + try (CatalogDatabase db = CatalogDatabase.getInstance()) { + if (rmUuid != null && !"".equals(rmUuid)) { + LOGGER.debug("Query recipe by resource model uuid: " + rmUuid); + //check vnf and network and ar, the resource could be any resource. + Recipe recipe = db.getVnfRecipeByModuleUuid(rmUuid, action); + if (null == recipe) { + recipe = db.getNetworkRecipeByModuleUuid(rmUuid, action); } - }else{ - throw(new Exception("Incoming parameter is null or blank")); - } - if(ret == null || ret.isEmpty()){ - LOGGER.debug ("vfModules not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryVfModule(); - }else{ - LOGGER.debug ("vfModules found"); - qryResp = new QueryVfModule(ret); - LOGGER.debug ("vfModules query Results is: "+ qryResp); - LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false)); + if (null == recipe) { + recipe = db.getArRecipeByModuleUuid(rmUuid, action); + } + if (recipe != null) { + QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); + entity = resourceRecipe.JSON2(false, false); + } else { + respStatus = HttpStatus.SC_NOT_FOUND; + } + } else { + throw (new Exception("Incoming parameter is null or blank")); } - LOGGER.debug ("Query vfModules exit"); + LOGGER.debug("Query recipe exit"); return Response - .status(respStatus) - .entity(qryResp.JSON2(false, false)) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - }catch(Exception e){ - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + .status(respStatus) + .entity(entity) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) {}) - .build(); - }finally { - db.close(); + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) { + }) + .build(); } - } - + } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java index a74cf07b89..4a8233bb03 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -46,21 +46,21 @@ public abstract class CatalogQuery { } protected String setTemplate(String template, Map<String, String> valueMap) { - LOGGER.debug ("CatalogQuery setTemplate"); + LOGGER.debug("CatalogQuery setTemplate"); StringBuffer result = new StringBuffer(); String pattern = "<.*>"; Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(template); - LOGGER.debug ("CatalogQuery template:"+ template); - while(m.find()) { - String key = template.substring(m.start()+1, m.end()-1); - LOGGER.debug ("CatalogQuery key:"+ key+ " contains key? "+ valueMap.containsKey(key)); - m.appendReplacement(result, valueMap.containsKey(key)? valueMap.get(key): "\"TBD\""); + LOGGER.debug("CatalogQuery template:" + template); + while (m.find()) { + String key = template.substring(m.start() + 1, m.end() - 1); + LOGGER.debug("CatalogQuery key:" + key + " contains key? " + valueMap.containsKey(key)); + m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")); } m.appendTail(result); - LOGGER.debug ("CatalogQuery return:"+ result.toString()); + LOGGER.debug("CatalogQuery return:" + result.toString()); return result.toString(); } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 9a82ed2c6e..f7758c315c 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -62,30 +62,30 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (AllottedResourceCustomization o : allottedResourceCustomization) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceAllottedResources\": ["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceAllottedResources\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; if (this.allottedResourceCustomization != null) { for (AllottedResourceCustomization o : allottedResourceCustomization) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean arNull = o.getAllottedResource() == null ? true : false; @@ -104,14 +104,14 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode()); put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUuid()); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java new file mode 100644 index 0000000000..5be6970554 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java @@ -0,0 +1,72 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.adapters.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.mso.db.catalog.beans.Recipe;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryResourceRecipe extends CatalogQuery{
+
+ private Recipe resourceRecipe;
+
+ public QueryResourceRecipe(Recipe resourceRecipe){
+ this.resourceRecipe =resourceRecipe;
+ }
+
+ private final String template =
+ "\t{\n"+
+ "\t\t\"id\" : <ID>,\n"+
+ "\t\t\"action\" : <ACTION>,\n"+
+ "\t\t\"orchestrationUri\" : <ORCHESTRATION_URI>,\n"+
+ "\t\t\"recipeTimeout\" : <RECIPE_TIMEOUT>,\n"+
+ "\t\t\"paramXSD\" : <PARAM_XSD>,\n"+
+ "\t\t\"description\" : <DESCRIPTION>\n"+
+ "\t}";
+
+ @Override
+ public String toString() {
+
+ return resourceRecipe.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ put(valueMap, "ID", null == resourceRecipe ? null : resourceRecipe.getId());
+ put(valueMap, "ACTION", null == resourceRecipe ? null : resourceRecipe.getAction());
+ put(valueMap, "ORCHESTRATION_URI", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
+ put(valueMap, "RECIPE_TIMEOUT", null == resourceRecipe ? null : resourceRecipe.getRecipeTimeout());
+ put(valueMap, "PARAM_XSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
+ put(valueMap, "DESCRIPTION", null == resourceRecipe ? null : resourceRecipe.getDescription());
+ return this.setTemplate(template, valueMap);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java new file mode 100644 index 0000000000..6b1eb836d9 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java @@ -0,0 +1,72 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.adapters.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryServiceCsar extends CatalogQuery{
+
+ private ToscaCsar toscaCsar;
+
+ public QueryServiceCsar(ToscaCsar toscaCsar){
+ this.toscaCsar = toscaCsar;
+ }
+
+ private final String template =
+ "\t{\n"+
+ "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+
+ "\t\t\"name\" : <NAME>,\n"+
+ "\t\t\"version\" : <VERSION>,\n"+
+ "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n"+
+ "\t\t\"url\" : <URL>,\n"+
+ "\t\t\"description\" : <DESCRIPTION>\n"+
+ "\t}";
+
+ @Override
+ public String toString() {
+
+ return toscaCsar.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
+ put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
+ put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
+ put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
+ put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
+ put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
+ return this.setTemplate(template, valueMap);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index 59c601ef19..c04068d680 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -67,30 +67,30 @@ public class QueryServiceNetworks extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (NetworkResourceCustomization o : serviceNetworks) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceNetworks\": ["); - //if (isArray) buf.append("["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceNetworks\": ["); + Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (NetworkResourceCustomization o : serviceNetworks) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean nrNull = o.getNetworkResource() == null ? true : false; put(valueMap, "MODEL_NAME", nrNull ? null : o.getNetworkResource().getModelName()); put(valueMap, "MODEL_UUID", nrNull ? null : o.getNetworkResource().getModelUUID()); @@ -104,12 +104,12 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index cfbb781ae8..f0d4327950 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -72,29 +72,29 @@ public class QueryServiceVnfs extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VnfResourceCustomization o : serviceVnfs) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean isEmbed) { - StringBuilder buf = new StringBuilder(); - if (!isEmbed && isArray) buf.append("{ "); - if (isArray) buf.append("\"serviceVnfs\": ["); + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) sb.append("{ "); + if (isArray) sb.append("\"serviceVnfs\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VnfResourceCustomization o : serviceVnfs) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean vrNull = o.getVnfResource() == null ? true : false; @@ -113,12 +113,12 @@ public class QueryServiceVnfs extends CatalogQuery { String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - if (!isEmbed && isArray) buf.append("}"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + if (!isEmbed && isArray) sb.append("}"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java index 309aa0641a..fe0f0cbc17 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java @@ -69,28 +69,28 @@ public class QueryVfModule extends CatalogQuery { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VfModuleCustomization o : vfModules) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); first = false; - buf.append(o); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; + sb.append(o); } - return buf.toString(); + return sb.toString(); } @Override public String JSON2(boolean isArray, boolean x) { - StringBuilder buf = new StringBuilder(); - if (isArray) buf.append("\"vfModules\": ["); + StringBuilder sb = new StringBuilder(); + if (isArray) sb.append("\"vfModules\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VfModuleCustomization o : vfModules) { - if (first) buf.append("\n"); first = false; + if (first) sb.append("\n"); first = false; boolean vfNull = o.getVfModule() == null ? true : false; boolean hasVolumeGroup = false; @@ -104,16 +104,16 @@ public class QueryVfModule extends CatalogQuery { put(valueMap, "MODEL_INVARIANT_ID", vfNull ? null : o.getVfModule().getModelInvariantUuid()); put(valueMap, "MODEL_VERSION", vfNull ? null : o.getVfModule().getVersion()); put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); - put(valueMap, "IS_BASE", vfNull ? false : new Boolean(o.getVfModule().isBase()? true: false)); - put(valueMap, "VF_MODULE_LABEL", o.getLabel()); + put(valueMap, "IS_BASE", vfNull ? false : o.getVfModule().isBase() ? true : false); + put(valueMap, "VF_MODULE_LABEL", o.getLabel()); put(valueMap, "INITIAL_COUNT", o.getInitialCount()); - put(valueMap, "HAS_VOLUME_GROUP", new Boolean(hasVolumeGroup)); + put(valueMap, "HAS_VOLUME_GROUP", hasVolumeGroup); - buf.append(sep+ this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(template, valueMap)); sep = ",\n"; } - if (!first) buf.append("\n"); - if (isArray) buf.append("]"); - return buf.toString(); + if (!first) sb.append("\n"); + if (isArray) sb.append("]"); + return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java index ff713991f9..00a5cafb29 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java @@ -58,17 +58,17 @@ public class QueryVfModules { @Override public String toString () { - StringBuilder buf = new StringBuilder(); + StringBuilder sb = new StringBuilder(); boolean first = true; int i = 1; for (VfModule o : vfModules) { - buf.append(i+"\t"); - if (!first) buf.append("\n"); + sb.append(i).append("\t"); + if (!first) sb.append("\n"); first = false; - buf.append(o); + sb.append(o); } - return buf.toString(); + return sb.toString(); } public String toJsonString() { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java index 31a58329d6..31594905fd 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java @@ -70,7 +70,7 @@ public class CatalogDbAdapterRestClassTest { * */ // set up mock return value - paramList = new ArrayList<VnfResourceCustomization>(); + paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); d1.setModelInstanceName("ciVFOnboarded-FNAT-aab06c41 1"); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java index 33f5553115..ae5e663777 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java @@ -114,7 +114,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<VnfResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<VnfResourceCustomization>(); + paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); d1.setModelInstanceName("RG_6-26_mog11 0"); @@ -154,7 +154,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<VnfResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<VnfResourceCustomization>(); + paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setVnfResourceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); d1.setModelInstanceName("RG_6-26_mog11 0"); @@ -198,7 +198,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<VnfResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<VnfResourceCustomization>(); + paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); d1.setModelInstanceName("RG_6-26_mog11 0"); @@ -242,7 +242,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<NetworkResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<NetworkResourceCustomization>(); + paramList = new ArrayList<>(); NetworkResourceCustomization d1 = new NetworkResourceCustomization(); d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); @@ -282,7 +282,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<NetworkResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<NetworkResourceCustomization>(); + paramList = new ArrayList<>(); NetworkResourceCustomization d1 = new NetworkResourceCustomization(); d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); @@ -322,7 +322,7 @@ public class CatalogDbAdapterRestHttpTest { try { ArrayList<NetworkResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<NetworkResourceCustomization>(); + paramList = new ArrayList<>(); NetworkResourceCustomization d1 = new NetworkResourceCustomization(); d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); @@ -367,7 +367,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<AllottedResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<AllottedResourceCustomization>(); + paramList = new ArrayList<>(); AllottedResourceCustomization d1 = new AllottedResourceCustomization(); d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); @@ -409,7 +409,7 @@ public class CatalogDbAdapterRestHttpTest { try { List<AllottedResourceCustomization> paramList; // set up mock return value - paramList = new ArrayList<AllottedResourceCustomization>(); + paramList = new ArrayList<>(); AllottedResourceCustomization d1 = new AllottedResourceCustomization(); d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java index 31e828d19a..ee2c8db577 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java @@ -49,7 +49,7 @@ public class CatalogQueryTest { CatalogQuery mockCatalogQuery = Mockito.mock(CatalogQuery.class); Mockito.doCallRealMethod().when(mockCatalogQuery).setTemplate(Mockito.anyString(), Mockito.anyMapOf(String.class, String.class)); - Map<String,String> valueMap = new HashMap<String,String>(); + Map<String,String> valueMap = new HashMap<>(); valueMap.put("somekey", "somevalue"); String ret = mockCatalogQuery.setTemplate("<somekey>", valueMap); @@ -60,7 +60,7 @@ public class CatalogQueryTest { @Test public void smartToJson_Test() { - List<VnfResourceCustomization> paramList = new ArrayList<VnfResourceCustomization>(); + List<VnfResourceCustomization> paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); d1.setModelInstanceName("RG_6-26_mog11 0"); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java index 71352b5272..0d86a6cf10 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java @@ -43,7 +43,7 @@ public class QueryAllottedResourceCustomizationTest { public void JSON2_Test() { List<AllottedResourceCustomization> paramList; - paramList = new ArrayList<AllottedResourceCustomization>(); + paramList = new ArrayList<>(); AllottedResourceCustomization d1 = new AllottedResourceCustomization(); d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java index dfbc2dc384..3a767a8609 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java @@ -47,7 +47,7 @@ public class QueryServiceMarcoHolderTest { svc.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9"); svc.setModelName("Testing Model One"); ArrayList<NetworkResourceCustomization> paramList; - paramList = new ArrayList<NetworkResourceCustomization>(); + paramList = new ArrayList<>(); NetworkResourceCustomization d1 = new NetworkResourceCustomization(); d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java index b237dbe0a8..1c855eaa72 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java @@ -45,7 +45,7 @@ public class QueryServiceNetworksTest { public void JSON2_Test() { ArrayList<NetworkResourceCustomization> paramList; - paramList = new ArrayList<NetworkResourceCustomization>(); + paramList = new ArrayList<>(); NetworkResourceCustomization d1 = new NetworkResourceCustomization(); d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); paramList.add(d1); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java index 262fe06988..8c8fc967da 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java @@ -44,7 +44,7 @@ public class QueryServiceVnfsTest { public void JSON2_Test() { List<VnfResourceCustomization> paramList; - paramList = new ArrayList<VnfResourceCustomization>(); + paramList = new ArrayList<>(); VnfResourceCustomization d1 = new VnfResourceCustomization(); d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); diff --git a/adapters/mso-network-adapter-async-client/pom.xml b/adapters/mso-network-adapter-async-client/pom.xml index cc1ae6ea30..9920c729a1 100644 --- a/adapters/mso-network-adapter-async-client/pom.xml +++ b/adapters/mso-network-adapter-async-client/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version> + <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-network-adapter-async-client</artifactId>
<packaging>jar</packaging>
<name>mso-network-adapter-async-client</name>
diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml index 48b5b3ebd4..48a19bda6e 100644 --- a/adapters/mso-network-adapter/pom.xml +++ b/adapters/mso-network-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-network-adapter</artifactId> <packaging>war</packaging> <name>mso-network-adapter</name> @@ -53,7 +53,7 @@ <version>2.2.7</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> @@ -106,17 +106,17 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-network-adapter-async-client</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> @@ -145,7 +145,7 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java index 2c04ae9d6b..6063956af9 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java @@ -288,39 +288,45 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } // Get a handle to the Catalog Database - CatalogDatabase db = getCatalogDB (); // Make sure DB connection is always closed - try { - NetworkResource networkResource = networkCheck (db, - startTime, - networkType, - modelCustomizationUuid, - networkName, - physicalNetworkName, - vlans, - routeTargets, - cloudSiteOpt.get()); - String mode = networkResource.getOrchestrationMode (); - NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ()); - - if (NEUTRON_MODE.equals (mode)) { + try (CatalogDatabase db = getCatalogDB()) { + NetworkResource networkResource = networkCheck(db, + startTime, + networkType, + modelCustomizationUuid, + networkName, + physicalNetworkName, + vlans, + routeTargets, + cloudSiteOpt.get()); + String mode = networkResource.getOrchestrationMode(); + NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType()); + + if (NEUTRON_MODE.equals(mode)) { // Use an MsoNeutronUtils for all neutron commands - MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); // See if the Network already exists (by name) NetworkInfo netInfo = null; - long queryNetworkStarttime = System.currentTimeMillis (); + long queryNetworkStarttime = System.currentTimeMillis(); try { - netInfo = neutron.queryNetwork (networkName, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); + netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId); + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", + "QueryNetwork", null); } catch (MsoException me) { - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null); - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me); - me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); - throw new NetworkException (me); + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", + "OpenStack", "QueryNetwork", null); + LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", + me); + me.addContext(CREATE_NETWORK_CONTEXT); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); + throw new NetworkException(me); } if (netInfo != null) { @@ -328,49 +334,59 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Otherwise, return an exception. if (failIfExists != null && failIfExists) { String error = "Create Nework: Network " + networkName - + " already exists in " - + cloudSiteId - + "/" - + tenantId - + " with ID " + netInfo.getId(); - LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + + " already exists in " + + cloudSiteId + + "/" + + tenantId + + " with ID " + netInfo.getId(); + LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, + "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, + error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } else { // Populate the outputs from the existing network. - networkId.value = netInfo.getId (); - neutronNetworkId.value = netInfo.getId (); + networkId.value = netInfo.getId(); + neutronNetworkId.value = netInfo.getId(); rollback.value = networkRollback; // Default rollback - no updates performed - String msg = "Found Existing network, status=" + netInfo.getStatus () + " for Neutron mode"; - LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); + String msg = "Found Existing network, status=" + netInfo.getStatus() + " for Neutron mode"; + LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", + MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus()); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + msg); } return; } - long createNetworkStarttime = System.currentTimeMillis (); + long createNetworkStarttime = System.currentTimeMillis(); try { - netInfo = neutron.createNetwork (cloudSiteId, - tenantId, - neutronNetworkType, - networkName, - physicalNetworkName, - vlans); - LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "CreateNetwork", null); + netInfo = neutron.createNetwork(cloudSiteId, + tenantId, + neutronNetworkType, + networkName, + physicalNetworkName, + vlans); + LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", + "CreateNetwork", null); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", "OpenStack", "CreateNetwork", null); - String error = "Create Network: type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - - throw new NetworkException (me); + me.addContext(CREATE_NETWORK_CONTEXT); + LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", + "OpenStack", "CreateNetwork", null); + String error = "Create Network: type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + + throw new NetworkException(me); } // Note: ignoring MsoNetworkAlreadyExists because we already checked. @@ -378,263 +394,287 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // If reach this point, network creation is successful. // Since directly created via Neutron, networkId tracked by MSO is the same // as the neutron network ID. - networkId.value = netInfo.getId (); - neutronNetworkId.value = netInfo.getId (); + networkId.value = netInfo.getId(); + neutronNetworkId.value = netInfo.getId(); - networkRollback.setNetworkCreated (true); - networkRollback.setNetworkId (netInfo.getId ()); - networkRollback.setNeutronNetworkId (netInfo.getId ()); - networkRollback.setNetworkType (networkType); + networkRollback.setNetworkCreated(true); + networkRollback.setNetworkId(netInfo.getId()); + networkRollback.setNeutronNetworkId(netInfo.getId()); + networkRollback.setNetworkType(networkType); - LOGGER.debug ("Network " + networkName + " created, id = " + netInfo.getId ()); - } else if ("HEAT".equals (mode)) { + LOGGER.debug("Network " + networkName + " created, id = " + netInfo.getId()); + } else if ("HEAT".equals(mode)) { // Use an MsoHeatUtils for all Heat commands - MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, + cloudConfigFactory); //HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ()); - HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID()); + HeatTemplate heatTemplate = db + .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID()); if (heatTemplate == null) { String error = "Network error - undefined Heat Template. Network Type = " + networkType; - LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type = " + networkType); - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this - // error, - // configuration - // must be fixed - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, + "Openstack", "", MsoLogger.ErrorCode.DataError, + "Network error - undefined Heat Template. Network Type = " + networkType); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this + // error, + // configuration + // must be fixed + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); + throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString()); // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate (); - template = template.replaceAll ("\r\n", "\n"); + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); - boolean aic3template=false; + boolean aic3template = false; String aic3nw = AIC3_NW; try { - aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW); - } catch (MsoPropertiesException e) { - String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; - LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e); - } + aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER) + .getProperty(AIC3_NW_PROPERTY, AIC3_NW); + } catch (MsoPropertiesException e) { + String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, + "Exception - Unable to get properties", e); + } if (template.contains(aic3nw)) - aic3template = true; + aic3template = true; // First, look up to see if the Network already exists (by name). // For HEAT orchestration of networks, the stack name will always match the network name StackInfo heatStack = null; - long queryNetworkStarttime = System.currentTimeMillis (); + long queryNetworkStarttime = System.currentTimeMillis(); try { - heatStack = heat.queryStack (cloudSiteId, tenantId, networkName); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); + heatStack = heat.queryStack(cloudSiteId, tenantId, networkName); + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", + "QueryNetwork", null); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", "OpenStack", "QueryNetwork", null); - String error = "Create Network (heat): query network " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + me.addContext(CREATE_NETWORK_CONTEXT); + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", + "OpenStack", "QueryNetwork", null); + String error = "Create Network (heat): query network " + networkName + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } - if (heatStack != null && (heatStack.getStatus () != HeatStatus.NOTFOUND)) { + if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) { // Stack exists. Return success or error depending on input directive if (failIfExists != null && failIfExists) { String error = "CreateNetwork: Stack " + networkName - + " already exists in " - + cloudSiteId - + "/" - + tenantId - + " as " + heatStack.getCanonicalName(); - LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Network already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + + " already exists in " + + cloudSiteId + + "/" + + tenantId + + " as " + heatStack.getCanonicalName(); + LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", + MsoLogger.ErrorCode.DataError, "Network already exists"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, + error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } else { // Populate the outputs from the existing stack. - networkId.value = heatStack.getCanonicalName (); - neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID); + networkId.value = heatStack.getCanonicalName(); + neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); rollback.value = networkRollback; // Default rollback - no updates performed - if (aic3template) - { - networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); + if (aic3template) { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } - Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <> (); + Map<String, Object> outputs = heatStack.getOutputs(); + Map<String, String> sMap = new HashMap<>(); if (outputs != null) { - for (String key : outputs.keySet ()) { - if (key != null && key.startsWith ("subnet")) { - if (aic3template) //one subnet_id output - { - Map <String, String> map = getSubnetUUId(key, outputs, subnets); - sMap.putAll(map); - } - else //multiples subnet_%aaid% outputs - { - String subnetUUId = (String) outputs.get(key); - sMap.put (key.substring("subnet_id_".length()), subnetUUId); - } - } - } + for (String key : outputs.keySet()) { + if (key != null && key.startsWith("subnet")) { + if (aic3template) //one subnet_id output + { + Map<String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } else //multiples subnet_%aaid% outputs + { + String subnetUUId = (String) outputs.get(key); + sMap.put(key.substring("subnet_id_".length()), subnetUUId); + } + } + } } subnetIdMap.value = sMap; - LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack"); + LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", + MsoLogger.ErrorCode.DataError, + "Found Existing network stack, status=" + heatStack.getStatus()); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, + "Found Existing network stack"); } return; } // Ready to deploy the new Network // Build the common set of HEAT template parameters - Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType, - networkName, - physicalNetworkName, - vlans, - routeTargets, - shared, - external, - aic3template); + Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType, + networkName, + physicalNetworkName, + vlans, + routeTargets, + shared, + external, + aic3template); // Validate (and update) the input parameters against the DB definition // Shouldn't happen unless DB config is wrong, since all networks use same inputs // and inputs were already validated. try { - stackParams = heat.validateStackParams (stackParams, heatTemplate); + stackParams = heat.validateStackParams(stackParams, heatTemplate); } catch (IllegalArgumentException e) { - String error = "Create Network: Configuration Error: " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e); - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this - // error, - // configuration - // must be fixed - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + String error = "Create Network: Configuration Error: " + e.getMessage(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", + MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this + // error, + // configuration + // must be fixed + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, + error); // Input parameters were not valid - throw new NetworkException (error, MsoExceptionCategory.INTERNAL); + throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } if (subnets != null) { - try { - if (aic3template) - { - template = mergeSubnetsAIC3 (template, subnets, stackParams); - } - else - { - template = mergeSubnets (template, subnets); - } - } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging subnets", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); - throw new NetworkException (me); - } + try { + if (aic3template) { + template = mergeSubnetsAIC3(template, subnets, stackParams); + } else { + template = mergeSubnets(template, subnets); + } + } catch (MsoException me) { + me.addContext(CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat): type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, + tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, + "Exception Create Network, merging subnets", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException(me); + } } if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) { try { - mergePolicyRefs (policyFqdns, stackParams); + mergePolicyRefs(policyFqdns, stackParams); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging policyRefs", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); - throw new NetworkException (me); + me.addContext(CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, + tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, + "Exception Create Network, merging policyRefs", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException(me); } } if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { try { - mergeRouteTableRefs (routeTableFqdns, stackParams); + mergeRouteTableRefs(routeTableFqdns, stackParams); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging routeTableRefs", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); - throw new NetworkException (me); + me.addContext(CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, + tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, + "Exception Create Network, merging routeTableRefs", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); + throw new NetworkException(me); } } // Deploy the network stack // Ignore MsoStackAlreadyExists exception because we already checked. try { - if (backout == null) - backout = true; - heatStack = heat.createStack (cloudSiteId, - tenantId, - networkName, - template, - stackParams, - true, - heatTemplate.getTimeoutMinutes (), - null, - null, - null, - backout.booleanValue()); + if (backout == null) + backout = true; + heatStack = heat.createStack(cloudSiteId, + tenantId, + networkName, + template, + stackParams, + true, + heatTemplate.getTimeoutMinutes(), + null, + null, + null, + backout.booleanValue()); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception creating network", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + me.addContext(CREATE_NETWORK_CONTEXT); + String error = "Create Network (heat): type " + neutronNetworkType + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", + MsoLogger.ErrorCode.DataError, "Exception creating network", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } // Reach this point if createStack is successful. // For Heat-based orchestration, the MSO-tracked network ID is the heat stack, // and the neutronNetworkId is the network UUID returned in stack outputs. - networkId.value = heatStack.getCanonicalName (); - neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID); - if (aic3template) - { - networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); + networkId.value = heatStack.getCanonicalName(); + neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); + if (aic3template) { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } - Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <> (); + Map<String, Object> outputs = heatStack.getOutputs(); + Map<String, String> sMap = new HashMap<>(); if (outputs != null) { - for (String key : outputs.keySet ()) { - if (key != null && key.startsWith ("subnet")) { - if (aic3template) //one subnet output expected - { - Map <String, String> map = getSubnetUUId(key, outputs, subnets); - sMap.putAll(map); - } - else //multiples subnet_%aaid% outputs allowed - { - String subnetUUId = (String) outputs.get(key); - sMap.put (key.substring("subnet_id_".length()), subnetUUId); - } + for (String key : outputs.keySet()) { + if (key != null && key.startsWith("subnet")) { + if (aic3template) //one subnet output expected + { + Map<String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } else //multiples subnet_%aaid% outputs allowed + { + String subnetUUId = (String) outputs.get(key); + sMap.put(key.substring("subnet_id_".length()), subnetUUId); + } } } } @@ -642,15 +682,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { rollback.value = networkRollback; // Populate remaining rollback info and response parameters. - networkRollback.setNetworkStackId (heatStack.getCanonicalName ()); - networkRollback.setNeutronNetworkId ((String) heatStack.getOutputs ().get (NETWORK_ID)); - networkRollback.setNetworkCreated (true); - networkRollback.setNetworkType (networkType); + networkRollback.setNetworkStackId(heatStack.getCanonicalName()); + networkRollback.setNeutronNetworkId((String) heatStack.getOutputs().get(NETWORK_ID)); + networkRollback.setNetworkCreated(true); + networkRollback.setNetworkType(networkType); - LOGGER.debug ("Network " + networkName + " successfully created via HEAT"); + LOGGER.debug("Network " + networkName + " successfully created via HEAT"); } - } finally { - db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network"); return; @@ -803,19 +841,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } // Get a handle to the Catalog Database - CatalogDatabase db = getCatalogDB (); // Make sure DB connection is always closed - try { + try (CatalogDatabase db = getCatalogDB()) { NetworkResource networkResource = networkCheck(db, - startTime, - networkType, - modelCustomizationUuid, - networkName, - physicalNetworkName, - vlans, - routeTargets, - cloudSiteOpt.get()); + startTime, + networkType, + modelCustomizationUuid, + networkName, + physicalNetworkName, + vlans, + routeTargets, + cloudSiteOpt.get()); String mode = networkResource.getOrchestrationMode(); NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType()); @@ -830,54 +867,66 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.queryNetwork(networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null); + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "QueryNetwork", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "Update Network (neutron): query " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); - LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); + LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", + "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException(me); } if (netInfo == null) { String error = "Update Nework: Network " + networkId - + " does not exist in " - + cloudSiteId - + "/" - + tenantId; - LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Network not found"); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + + " does not exist in " + + cloudSiteId + + "/" + + tenantId; + LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Network not found"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); // Does not exist. Throw an exception (can't update a non-existent network) throw new NetworkException(error, MsoExceptionCategory.USERDATA); } long updateNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.updateNetwork(cloudSiteId, - tenantId, - networkId, - neutronNetworkType, - physicalNetworkName, - vlans); - LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateNetwork", null); + tenantId, + networkId, + neutronNetworkType, + physicalNetworkName, + vlans); + LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "UpdateNetwork", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "Update Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me); - LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", + "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me); + LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException(me); } @@ -894,7 +943,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } else if ("HEAT".equals(mode)) { // Use an MsoHeatUtils for all Heat commands - MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory); + MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, + cloudConfigFactory); // First, look up to see that the Network already exists. // For Heat-based orchestration, the networkId is the network Stack ID. @@ -902,30 +952,37 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryStackStarttime = System.currentTimeMillis(); try { heatStack = heat.queryStack(cloudSiteId, tenantId, networkName); - LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null); + LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "QueryStack", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "UpdateNetwork (heat): query " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); + LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", + "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException(me); } if (heatStack == null || (heatStack.getStatus() == HeatStatus.NOTFOUND)) { String error = "UpdateNetwork: Stack " + networkName - + " does not exist in " - + cloudSiteId - + "/" - + tenantId; - LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Network not found"); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + + " does not exist in " + + cloudSiteId + + "/" + + tenantId; + LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", + "queryStack", MsoLogger.ErrorCode.DataError, "Network not found"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); // Network stack does not exist. Return an error throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -943,7 +1000,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { try { previousVlans.add(Integer.parseInt(vlan)); } catch (NumberFormatException e) { - LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); + LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", + MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); } } } @@ -952,12 +1010,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Ready to deploy the updated Network via Heat //HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ()); - HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID()); + HeatTemplate heatTemplate = db + .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID()); if (heatTemplate == null) { String error = "Network error - undefined Heat Template. Network Type=" + networkType; - LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type=" + networkType); + LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, + "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, + "Network error - undefined Heat Template. Network Type=" + networkType); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } @@ -970,23 +1032,25 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { boolean aic3template = false; String aic3nw = AIC3_NW; try { - aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW); + aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER) + .getProperty(AIC3_NW_PROPERTY, AIC3_NW); } catch (MsoPropertiesException e) { String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER; - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, + "Exception - Unable to get properties", e); } if (template.contains(aic3nw)) aic3template = true; // Build the common set of HEAT template parameters Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType, - networkName, - physicalNetworkName, - vlans, - routeTargets, - shared, - external, - aic3template); + networkName, + physicalNetworkName, + vlans, + routeTargets, + shared, + external, + aic3template); // Validate (and update) the input parameters against the DB definition // Shouldn't happen unless DB config is wrong, since all networks use same inputs @@ -994,9 +1058,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams = heat.validateStackParams(stackParams, heatTemplate); } catch (IllegalArgumentException e) { String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType; - LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error"); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error"); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, + error); throw new NetworkException(error, MsoExceptionCategory.INTERNAL, e); } @@ -1010,14 +1076,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "Update Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeSubnets ", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, + tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, + "Exception - UpdateNetwork mergeSubnets ", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); throw new NetworkException(me); } } @@ -1028,14 +1097,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergePolicyRefs", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, + tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, + "Exception - UpdateNetwork mergePolicyRefs", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); throw new NetworkException(me); } } @@ -1046,14 +1118,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeRouteTableRefs", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, + tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, + "Exception - UpdateNetwork mergeRouteTableRefs", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.InternalError, error); throw new NetworkException(me); } } @@ -1063,19 +1138,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long updateStackStarttime = System.currentTimeMillis(); try { heatStack = heat.updateStack(cloudSiteId, - tenantId, - networkId, - template, - stackParams, - true, - heatTemplate.getTimeoutMinutes()); - LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", null); + tenantId, + networkId, + template, + stackParams, + true, + heatTemplate.getTimeoutMinutes()); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "UpdateStack", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - update network", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); + LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception - update network", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); throw new NetworkException(me); } @@ -1101,10 +1181,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Reach this point if createStack is successful. // Populate remaining rollback info and response parameters. networkRollback.setNetworkStackId(heatStack.getCanonicalName()); - if(null != outputs) { + if (null != outputs) { networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); - } - else { + } else { LOGGER.debug("outputs is NULL"); } networkRollback.setNetworkType(networkType); @@ -1117,8 +1196,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.debug("Network " + networkId + " successfully updated via HEAT"); } - } finally { - db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network"); return; @@ -1472,97 +1549,102 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long startTime = System.currentTimeMillis (); // Get a handle to the Catalog Database - CatalogDatabase db = getCatalogDB (); // Make sure DB connection is always closed - try { - if (isNullOrEmpty (cloudSiteId) - || isNullOrEmpty(tenantId) - || isNullOrEmpty(networkId)) { + try (CatalogDatabase db = getCatalogDB()) { + if (isNullOrEmpty(cloudSiteId) + || isNullOrEmpty(tenantId) + || isNullOrEmpty(networkId)) { String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId"; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new NetworkException (error, MsoExceptionCategory.USERDATA); + LOGGER.error(MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", + MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + throw new NetworkException(error, MsoExceptionCategory.USERDATA); } // Retrieve the Network Resource definition NetworkResource networkResource = null; if (isNullOrEmpty(modelCustomizationUuid)) { - networkResource = db.getNetworkResource (networkType); - } - else if (!isNullOrEmpty(networkType)) - { + networkResource = db.getNetworkResource(networkType); + } else if (!isNullOrEmpty(networkType)) { networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); } String mode = ""; if (networkResource != null) { - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString()); - mode = networkResource.getOrchestrationMode (); + mode = networkResource.getOrchestrationMode(); } - if (NEUTRON_MODE.equals (mode)) { + if (NEUTRON_MODE.equals(mode)) { // Use MsoNeutronUtils for all NEUTRON commands - MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); - long deleteNetworkStarttime = System.currentTimeMillis (); + MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + long deleteNetworkStarttime = System.currentTimeMillis(); try { // The deleteNetwork function in MsoNeutronUtils returns success if the network // was not found. So don't bother to query first. - boolean deleted = neutron.deleteNetwork (networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); + boolean deleted = neutron.deleteNetwork(networkId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "DeleteNetwork", null); networkDeleted.value = deleted; } catch (MsoException me) { - me.addContext ("DeleteNetwork"); - String error = "Delete Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + me.addContext("DeleteNetwork"); + String error = "Delete Network (neutron): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); + LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", + MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } } else { // DEFAULT to ("HEAT".equals (mode)) - long deleteStackStarttime = System.currentTimeMillis (); + long deleteStackStarttime = System.currentTimeMillis(); // Use MsoHeatUtils for all HEAT commands - MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, + cloudConfigFactory); try { // The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted. // So query first to report back if stack WAS deleted or just NOTOFUND - StackInfo heatStack = null; - heatStack = heat.queryStack(cloudSiteId, tenantId, networkId); - if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) - { - heat.deleteStack (tenantId, cloudSiteId, networkId, true); - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); - networkDeleted.value = true; - } - else - { - networkDeleted.value = false; - } + StackInfo heatStack = null; + heatStack = heat.queryStack(cloudSiteId, tenantId, networkId); + if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) { + heat.deleteStack(tenantId, cloudSiteId, networkId, true); + LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "DeleteStack", null); + networkDeleted.value = true; + } else { + networkDeleted.value = false; + } } catch (MsoException me) { - me.addContext ("DeleteNetwork"); - String error = "Delete Network (heat): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + me.addContext("DeleteNetwork"); + String error = "Delete Network (heat): " + networkId + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); + LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", + MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } } - } finally { - db.close (); } // On success, nothing is returned. @@ -1608,80 +1690,89 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // rollback may be null (e.g. if network already existed when Create was called) // Get a handle to the Catalog Database - CatalogDatabase db = getCatalogDB (); // Make sure DB connection is always closed - try { + try (CatalogDatabase db = getCatalogDB()) { // Retrieve the Network Resource definition NetworkResource networkResource = null; if (isNullOrEmpty(modelCustomizationUuid)) { - networkResource = db.getNetworkResource (networkType); - } - else - { + networkResource = db.getNetworkResource(networkType); + } else { networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); } String mode = ""; if (networkResource != null) { - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString()); - mode = networkResource.getOrchestrationMode (); + mode = networkResource.getOrchestrationMode(); } - if (rollback.getNetworkCreated ()) { + if (rollback.getNetworkCreated()) { // Rolling back a newly created network, so delete it. - if (NEUTRON_MODE.equals (mode)) { + if (NEUTRON_MODE.equals(mode)) { // Use MsoNeutronUtils for all NEUTRON commands - MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); - long deleteNetworkStarttime = System.currentTimeMillis (); + MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); + long deleteNetworkStarttime = System.currentTimeMillis(); try { // The deleteNetwork function in MsoNeutronUtils returns success if the network // was not found. So don't bother to query first. - neutron.deleteNetwork (networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); + neutron.deleteNetwork(networkId, tenantId, cloudSiteId); + LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "DeleteNetwork", null); } catch (MsoException me) { - me.addContext ("RollbackNetwork"); + me.addContext("RollbackNetwork"); String error = "Rollback Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); + LOGGER + .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", + me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } } else { // DEFAULT to if ("HEAT".equals (mode)) // Use MsoHeatUtils for all HEAT commands - MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory); - long deleteStackStarttime = System.currentTimeMillis (); + MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, + cloudConfigFactory); + long deleteStackStarttime = System.currentTimeMillis(); try { // The deleteStack function in MsoHeatUtils returns success if the stack // was not found. So don't bother to query first. - heat.deleteStack (tenantId, cloudSiteId, networkId, true); - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); + heat.deleteStack(tenantId, cloudSiteId, networkId, true); + LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", + "DeleteStack", null); } catch (MsoException me) { - me.addContext ("RollbackNetwork"); + me.addContext("RollbackNetwork"); String error = "Rollback Network (heat): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new NetworkException (me); + + " in " + + cloudSiteId + + "/" + + tenantId + + ": " + + me; + LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); + LOGGER + .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error); + throw new NetworkException(me); } } } - } finally { - db.close (); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network"); return; @@ -1747,20 +1838,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams.put (VLANS, csl); } if (routeTargets != null && !routeTargets.isEmpty()) { - StringBuilder buf = new StringBuilder (); + StringBuilder sb = new StringBuilder (); String sep = ""; for (String rt : routeTargets) { if (!isNullOrEmpty(rt)) { if (aic3template) - buf.append (sep).append ("target:" + rt); + sb.append(sep).append("target:").append(rt); else - buf.append (sep).append (rt); + sb.append (sep).append (rt); sep = ","; } } - String csl = buf.toString (); + String csl = sb.toString (); stackParams.put ("route_targets", csl); } @@ -1985,16 +2076,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n" + " value: {get_resource: subnet_%subnetId%}\n"; - String curR; + StringBuilder curR; String curO; StringBuilder resourcesBuf = new StringBuilder (); StringBuilder outputsBuf = new StringBuilder (); for (Subnet subnet : subnets) { // build template for each subnet - curR = resourceTempl; + curR = new StringBuilder(resourceTempl); if (subnet.getSubnetId () != null) { - curR = curR.replace ("%subnetId%", subnet.getSubnetId ()); + curR = new StringBuilder(curR.toString().replace("%subnetId%", subnet.getSubnetId())); } else { String error = "Missing Required AAI SubnetId for subnet in HEAT Template"; LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required AAI ID for subnet in HEAT Template"); @@ -2002,13 +2093,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } if (subnet.getSubnetName () != null) { - curR = curR.replace ("%name%", subnet.getSubnetName ()); + curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetName())); } else { - curR = curR.replace ("%name%", subnet.getSubnetId ()); + curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetId())); } if (subnet.getCidr () != null) { - curR = curR.replace ("%cidr%", subnet.getCidr ()); + curR = new StringBuilder(curR.toString().replace("%cidr%", subnet.getCidr())); } else { String error = "Missing Required cidr for subnet in HEAT Template"; LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required cidr for subnet in HEAT Template"); @@ -2016,23 +2107,23 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } if (subnet.getIpVersion () != null) { - curR = curR + " ip_version: " + subnet.getIpVersion () + "\n"; + curR.append(" ip_version: " + subnet.getIpVersion() + "\n"); } if (subnet.getEnableDHCP () != null) { - curR = curR + " enable_dhcp: " + Boolean.toString (subnet.getEnableDHCP ()) + "\n"; + curR.append(" enable_dhcp: ").append(Boolean.toString(subnet.getEnableDHCP())).append("\n"); } if (subnet.getGatewayIp () != null && !subnet.getGatewayIp ().isEmpty() ) { - curR = curR + " gateway_ip: " + subnet.getGatewayIp () + "\n"; + curR.append(" gateway_ip: " + subnet.getGatewayIp() + "\n"); } if (subnet.getAllocationPools() != null) { - curR = curR + " allocation_pools:\n"; + curR.append(" allocation_pools:\n"); for (Pool pool : subnet.getAllocationPools()) { if (!isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd())) { - curR = curR + " - start: " + pool.getStart () + "\n"; - curR = curR + " end: " + pool.getEnd () + "\n"; + curR.append(" - start: " + pool.getStart() + "\n"); + curR.append(" end: " + pool.getEnd() + "\n"); } } } diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java index e96e416d65..ae198142bd 100644 --- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java +++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java @@ -71,7 +71,7 @@ public class NetworkBeansTest { contrailSubnet.setAddrFromStart(true);
contrailSubnet.setDefaultGateway("defaultGateway");
contrailSubnet.setEnableDhcp(true);
- contrailSubnet.setPools(new ArrayList<ContrailSubnetPool>());
+ contrailSubnet.setPools(new ArrayList<>());
contrailSubnet.setSubnet(new ContrailSubnetIp());
contrailSubnet.setSubnetName("subnetName");
contrailSubnet.getAllocationPools();
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index ed8b2b3b88..8bec34e785 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-requests-db-adapter</artifactId> <packaging>war</packaging> @@ -15,7 +15,7 @@ <dependencies> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-requests-db</artifactId> <version>${project.version}</version> </dependency> @@ -40,7 +40,7 @@ </exclusions> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> @@ -85,7 +85,7 @@ <version>2.2.7</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 0b404d76bd..99f6e86b00 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -333,7 +333,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { * * @param serviceId * @param operationId - * @param resourceUUID + * @param resourceTemplateUUID * @return * @throws MsoRequestsDbException * @since ONAP Amsterdam Release @@ -350,7 +350,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { * * @param serviceId * @param operationId - * @param resourceUUID + * @param resourceTemplateUUID * @param operationType * @param resourceInstanceID * @param jobId @@ -363,13 +363,13 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { */ @Override public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID, - String operType, String resourceInstanceID, String jobId, String status, String progress, + String operationType, String resourceInstanceID, String jobId, String status, String progress, String errorCode, String statusDescription) throws MsoRequestsDbException { ResourceOperationStatus resStatus = new ResourceOperationStatus(); resStatus.setServiceId(serviceId); resStatus.setOperationId(operationId); resStatus.setResourceTemplateUUID(resourceTemplateUUID); - resStatus.setOperType(operType); + resStatus.setOperType(operationType); resStatus.setResourceInstanceID(resourceInstanceID); resStatus.setJobId(jobId); resStatus.setStatus(status); diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index e7cb4d5318..b0457e968e 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-sdnc-adapter</artifactId> <packaging>war</packaging> <name>mso-sdnc-adapter</name> @@ -67,7 +67,7 @@ </build> <dependencies> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> @@ -91,12 +91,12 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java index 97f30bea6b..55a2156c50 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -142,7 +142,7 @@ public class SDNCRestClient implements Runnable { DataOutputStream out = null; BufferedReader in = null; SDNCResponse sdncResp = new SDNCResponse(rt.getReqId()); - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", ""); msoLogger.debug("SDNC Request Body:\n" + sdncReqBody); @@ -197,7 +197,7 @@ public class SDNCRestClient implements Runnable { //default sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); String respMsg = "Error processing request to SDNC. "; - String sdncErrMsg = ""; + StringBuilder sdncErrMsg = new StringBuilder(); if (e instanceof java.net.SocketTimeoutException ) { @@ -229,7 +229,7 @@ public class SDNCRestClient implements Runnable { String eType = null; try { eType = xpath.evaluate("error-type", error); - sdncErrMsg = ". SDNC Returned-[error-type:" + eType; + sdncErrMsg = new StringBuilder(". SDNC Returned-[error-type:" + eType); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } @@ -237,7 +237,7 @@ public class SDNCRestClient implements Runnable { String eTag = null; try { eTag = xpath.evaluate( "error-tag", error); - sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag; + sdncErrMsg.append(", error-tag:").append(eTag); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } @@ -245,7 +245,7 @@ public class SDNCRestClient implements Runnable { String eMsg = null; try { eMsg = xpath.evaluate("error-message", error); - sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]"; + sdncErrMsg.append(", error-message:").append(eMsg).append("]"); } catch (Exception e3) { msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java index 262d23bd09..fa257164cf 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java @@ -154,12 +154,7 @@ public abstract class SDNCConnector { LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); return createResponseFromContent(statusCode, statusMessage, responseContent, rt); - } catch (SocketTimeoutException e) { - String errMsg = "Request to SDNC timed out"; - logError(errMsg, e); - return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt); - - } catch (ConnectTimeoutException e) { + } catch (SocketTimeoutException | ConnectTimeoutException e) { String errMsg = "Request to SDNC timed out"; logError(errMsg, e); return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt); @@ -257,7 +252,7 @@ public abstract class SDNCConnector { // </error> // </errors> - String output = null; + StringBuilder output = null; try { XPathFactory xpathFactory = XPathFactory.newInstance(); @@ -306,9 +301,9 @@ public abstract class SDNCConnector { if (!info.isEmpty()) { if (output == null) { - output = "[" + info + "]"; + output = new StringBuilder("[" + info + "]"); } else { - output += " [" + info + "]"; + output.append(" [").append(info).append("]"); } } } @@ -317,6 +312,6 @@ public abstract class SDNCConnector { MsoLogger.ErrorCode.DataError, "Exception while analyzing errors", e); } - return output; + return output.toString(); } } diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java new file mode 100644 index 0000000000..fa96b7983e --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.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.adapters.sdnc; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest; +import org.openecomp.mso.adapters.sdnc.RequestHeader; + + +public class SDNCAdapterRequestTest { + + static Object sd= new SDNCAdapterRequest(); + static RequestHeader rh=new RequestHeader(); + + @BeforeClass + public static final void RHeader() + { + rh.setCallbackUrl("callback"); + rh.setMsoAction ("action"); + rh.setRequestId ("reqid"); + rh.setSvcAction ("svcAction"); + rh.setSvcInstanceId ("svcId"); + rh.setSvcOperation ("op"); + } + @Test + public final void testtoString(){ + ((SDNCAdapterRequest) sd).setRequestData("data"); + ((SDNCAdapterRequest) sd).setRequestHeader(rh); + assert (((SDNCAdapterRequest) sd).getRequestData()!= null) ; + assert(((SDNCAdapterRequest) sd).getRequestData().equals("data")); + assert(((SDNCAdapterRequest) sd).getRequestHeader().equals(rh)); + } + +} diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java new file mode 100644 index 0000000000..88d2b950b9 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java @@ -0,0 +1,47 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.adapters.sdnc.client; + +import org.junit.Test; +import org.openecomp.mso.adapters.sdnc.client.CallbackHeader; + +public class CallbackHeaderTest { + + static CallbackHeader cb = new CallbackHeader(); + + @Test + public final void testCallbackHeader() { + cb.setRequestId("413658f4-7f42-482e-b834-23a5c15657da-1474471336781"); + cb.setResponseCode("200"); + cb.setResponseMessage("OK"); + assert (cb.getRequestId() != null); + assert (cb.getResponseCode() != null); + assert (cb.getResponseMessage() != null); + assert (cb.getRequestId().equals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781")); + assert (cb.getResponseCode().equals("200")); + assert (cb.getResponseMessage().equals("OK")); + } + + @Test + public void testtoString() { + assert (cb.toString() != null); + } +} diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java new file mode 100644 index 0000000000..63aa49cf54 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java @@ -0,0 +1,53 @@ +/*- + * ============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.adapters.sdnc.client; + +import org.junit.Test; +import org.openecomp.mso.adapters.sdnc.client.CallbackHeader; +import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest; + +public class SDNCAdapterCallbackRequestTest { + + static SDNCAdapterCallbackRequest sdc = new SDNCAdapterCallbackRequest(); + static CallbackHeader ch = new CallbackHeader("413658f4-7f42-482e-b834-23a5c15657da-1474471336781","200","OK"); + + @Test + public void testSDNCAdapterCallbackRequest() + { + sdc.setCallbackHeader(ch); + sdc.setRequestData("data"); + assert(sdc.getCallbackHeader()!=null); + assert(sdc.getRequestData()!=null); + assert(sdc.getCallbackHeader().equals(ch)); + assert(sdc.getRequestData().equals("data")); + + } + + @Test + public void testtoString() + { + assert(ch.toString()!=null); + } + +} + + diff --git a/adapters/mso-tenant-adapter/pom.xml b/adapters/mso-tenant-adapter/pom.xml index 1479b2865e..916c3a7afd 100644 --- a/adapters/mso-tenant-adapter/pom.xml +++ b/adapters/mso-tenant-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-tenant-adapter</artifactId> <packaging>war</packaging> <name>mso-tenant-adapter</name> @@ -72,7 +72,7 @@ <version>2.2.7</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> @@ -119,12 +119,12 @@ </build> <dependencies> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> @@ -147,7 +147,7 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java index 5d0752a3af..2a33ebc50c 100644 --- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java +++ b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java @@ -39,11 +39,11 @@ public class TenantTest { MsoTenantAdapter tenantAdapter = new MsoTenantAdapterImpl(); - Holder<String> tenantId = new Holder<String>(); - Holder<String> tenantName = new Holder<String>(); - Holder<Map<String,String>> tenantMetadata = new Holder<Map<String,String>>(); - Holder<Boolean> tenantDeleted = new Holder<Boolean>(); - Holder<TenantRollback> rollback = new Holder<TenantRollback>(); + Holder<String> tenantId = new Holder<>(); + Holder<String> tenantName = new Holder<>(); + Holder<Map<String,String>> tenantMetadata = new Holder<>(); + Holder<Boolean> tenantDeleted = new Holder<>(); + Holder<TenantRollback> rollback = new Holder<>(); try { tenantAdapter.queryTenant (cloudId, "934a4ac9c4bd4b8d9d8ab3ef900281b0", null, tenantId, tenantName, tenantMetadata); diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index abd8ce4c29..e851edf72e 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-vfc-adapter</artifactId> <packaging>war</packaging> <name>mso-vfc-adapter</name> @@ -38,12 +38,12 @@ <version>2.0</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> @@ -72,12 +72,12 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-requests-db</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java index 48da1aba71..5f779dd085 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java @@ -60,7 +60,7 @@ public class VfcAdapterRest { /** * Create a NS <br> * - * @param servletReq the http request + * @param data the http request * @return * @since ONAP Amsterdam Release */ diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java index 61966d07f2..30d42ae387 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java @@ -39,7 +39,7 @@ public class ApplicationException extends Exception { * </p> * * @param errorCode error status - * @param errorDetail error detail + * @param errorMsg error detail * @since ONAP Amsterdam Release 2017-9-6 */ public ApplicationException(int errorCode, String errorMsg) { diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java index afee1bbfaa..fcbbf8515a 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java @@ -166,12 +166,7 @@ public class RestfulUtil { method = null; return createResponse(statusCode, responseContent); - } catch(SocketTimeoutException e) { - String errMsg = "Request to VFC timed out"; - logError(errMsg, e); - return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); - - } catch(ConnectTimeoutException e) { + } catch(SocketTimeoutException | ConnectTimeoutException e) { String errMsg = "Request to VFC timed out"; logError(errMsg, e); return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java index c79d09e09a..13727bdc49 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java @@ -47,7 +47,7 @@ public class ValidateUtil { * Assert String parameter.<br/>
*
* @param paramValue parameter data
- * @param name of parameter
+ * @param paramName parameter name
* @since ONAP Amsterdam Release 2017-9-6
*/
public static void assertStringNotNull(String paramValue, String paramName)
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java index 95d3bf610f..759ceedd0f 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java @@ -60,7 +60,7 @@ public class VfcAdapterTest { /** * mock get request body <br> * - * @param request + * @param fileName * @return * @since ONAP Amsterdam Release */ @@ -71,7 +71,6 @@ public class VfcAdapterTest { /** * Mock the request body form a file <br> * - * @param fileName * @since ONAP Amsterdam Release */ private void mockRestfulUtil() { diff --git a/adapters/mso-vnf-adapter-async-client/pom.xml b/adapters/mso-vnf-adapter-async-client/pom.xml index 4a20257b4a..e6217fc1c0 100644 --- a/adapters/mso-vnf-adapter-async-client/pom.xml +++ b/adapters/mso-vnf-adapter-async-client/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version> + <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter-async-client</artifactId>
<packaging>jar</packaging>
<name>mso-vnf-adapter-async-client</name>
diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index 9116e57a11..9a290f4f00 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version> + <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter</artifactId>
<packaging>war</packaging>
<name>mso-vnf-adapter</name>
@@ -56,7 +56,7 @@ </executions>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
@@ -107,17 +107,17 @@ </build>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter-async-client</artifactId>
<version>${project.version}</version>
</dependency>
@@ -140,7 +140,7 @@ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
@@ -157,7 +157,7 @@ <scope>test</scope>
</dependency>
<!-- <dependency> -->
- <!-- <groupId>org.openecomp.so</groupId> -->
+ <!-- <groupId>org.onap.so</groupId> -->
<!-- <artifactId>mso-catalog-db</artifactId> -->
<!-- <version>${project.version}</version> -->
<!-- </dependency> -->
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java index 4842580d85..5c654298fb 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -371,8 +371,9 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { * @param cloudSiteId CLLI code of the cloud site in which to delete * @param tenantId Openstack tenant identifier * @param vnfName VNF Name or Openstack ID + * @param messageId * @param msoRequest Request tracking information for logs - * @param notificationURL the target URL for asynchronous response + * @param notificationUrl the target URL for asynchronous response */ @Override public void deleteVnfA (String cloudSiteId, diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 7fe09be2b6..9022c26ccd 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -295,7 +295,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vnfExists.value = Boolean.FALSE; status.value = VnfStatus.NOTFOUND; vnfId.value = null; - outputs.value = new HashMap <String, String> (); // Return as an empty map + outputs.value = new HashMap<>(); // Return as an empty map LOGGER.debug ("VNF " + vnfName + " not found"); } else { @@ -465,7 +465,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private boolean callHeatbridge(String heatStackId) { String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge"; String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; - long waitTimeMs = 10000l; + long waitTimeMs = 10000L; try { String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; String[] envp = null; @@ -508,7 +508,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("Exception :",e); outputString = "Unable to call toString() on the value for " + str; } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); + sb.append("\t\nitem ").append(i++).append(": '").append(str).append("'='").append(outputString) + .append("'"); } } LOGGER.debug(sb.toString()); @@ -524,7 +525,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sb.append("\tEMPTY"); } else { for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + sb.append("\titem ").append(i++).append(": ").append(str).append("=").append(inputs.get(str)); } } LOGGER.debug(sb.toString()); @@ -535,8 +536,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); final String json = JSON_MAPPER.writeValueAsString(obj); return json; - } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage(),jpe); } catch (Exception e) { LOGGER.debug("Error converting json to string " + e.getMessage(),e); } @@ -547,7 +546,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (objectMap == null) { return null; } - Map<String, String> stringMap = new HashMap<String, String>(); + Map<String, String> stringMap = new HashMap<>(); for (String key : objectMap.keySet()) { if (!stringMap.containsKey(key)) { Object obj = objectMap.get(key); @@ -822,9 +821,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Ready to deploy the new VNF - CatalogDatabase db = CatalogDatabase.getInstance(); - - try { + try (CatalogDatabase db = CatalogDatabase.getInstance()) { // Retrieve the VF VfModule vf = null; VnfResource vnfResource = null; @@ -838,10 +835,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vf = db.getVfModuleByModelCustomizationUuid(mcu); if (vf == null) { LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu); - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; + String error = + "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", + MsoLogger.ErrorCode.DataError, + "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { LOGGER.debug("Found vfModuleCust entry " + vfmc.toString()); @@ -852,7 +853,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("This is *not* a BASE VF request!"); if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + LOGGER.debug( + "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } } @@ -911,12 +913,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (vnfResource == null) { String error = "Create VNF: Unknown VNF Type: " + vnfType; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", - vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } LOGGER.debug("Got VNF module definition from Catalog: " - + vnfResource.toString()); + + vnfResource.toString()); } // By here - we have either a vf or vnfResource @@ -929,7 +932,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vnfResource = db.getVnfResourceById(vnfResourceId); vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + LOGGER.debug( + "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); } } } @@ -940,7 +944,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e); minVersionVnf = null; maxVersionVnf = null; } @@ -973,17 +977,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { moreThanMax = aicV.isMoreRecentThan(maxVersionVnf); equalToMax = aicV.isTheSameVersion(maxVersionVnf); } catch (Exception e) { - LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e); + LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + + " - will default to not check", e); doNotTest = true; } if (!doNotTest) { if ((moreThanMin || equalToMin) // aic >= min - && (equalToMax || !(moreThanMax))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); + && (equalToMax || !(moreThanMax))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource + .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + + cloudSiteOpt.get().getAic_version()); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + String error = + "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource + .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -995,7 +1008,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); } } else { - LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); + LOGGER.debug( + "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); } // End Version check 1607 @@ -1017,7 +1031,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } else { if (isVolumeRequest) { - LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); + LOGGER.debug( + "DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); /* VnfComponent vnfComponent = null; vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME"); @@ -1039,11 +1054,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) HeatTemplate heatTemplate = null; if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) { - String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); @@ -1051,11 +1069,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == null) { String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, + "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } LOGGER.debug("Got HEAT Template from DB"); @@ -1064,45 +1085,49 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String heatEnvironmentString = null; if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) { - LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); + LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid); if (heatEnvironment == null) { String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType - + ", Environment ID=" - + heatEnvironmentArtifactUuid; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + + ", Environment ID=" + + heatEnvironmentArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", + String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", + MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); - heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); - LOGGER.debug ("after parsing: " + heatEnvironmentString); + LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString()); + heatEnvironmentString = heatEnvironment + .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug("after parsing: " + heatEnvironmentString); } } else { - LOGGER.debug ("no environment parameter found for this Type " + vfModuleType); + LOGGER.debug("no environment parameter found for this Type " + vfModuleType); } // 1510 - Add the files: for nested templates *if* there are any - LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" - + heatTemplate.getArtifactUuid()); - Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid()); - Map <String, Object> nestedTemplatesChecked = new HashMap <> (); + LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplatesChecked = new HashMap<>(); if (nestedTemplates != null) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:"); + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) { String providerResourceFile = entry.getKey(); Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); String childTemplateBody = (String) value; - LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); - nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); + LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody); + nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody); } } else { - LOGGER.debug ("No nested templates found - nothing to do here"); + LOGGER.debug("No nested templates found - nothing to do here"); nestedTemplatesChecked = null; // just to make sure } @@ -1114,25 +1139,29 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + + " - default to false", e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { if (oldWay) { - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); + LOGGER.debug( + "In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); //heatFiles = db.getHeatFiles(vnfResource.getId()); } else { // 1607 - now use VF_MODULE_TO_HEAT_FILES table - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + LOGGER.debug( + "In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + vf.getModelUUID()); heatFiles = db - .getHeatFilesForVfModule(vf.getModelUUID()); + .getHeatFilesForVfModule(vf.getModelUUID()); } if (heatFiles != null) { // add these to stack - to be done in createStack @@ -1146,19 +1175,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + + " at HEAT_FILES index=" + heatFileId; LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER + .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, + vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, + "HEAT_FILES entry not found"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.DataNotFound, error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } String heatFileBody = value.getFileBody(); String heatFileNameChecked = heatFileName; LOGGER.debug(heatFileNameChecked + " -> " - + heatFileBody); + + heatFileBody); heatFilesObjects.put(heatFileNameChecked, heatFileBody); } } else { @@ -1166,12 +1200,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatFilesObjects = null; } } else { - LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); + LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); } // Check that required parameters have been supplied - String missingParams = null; - List <String> paramList = new ArrayList <> (); + StringBuilder missingParams = null; + List<String> paramList = new ArrayList<>(); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. @@ -1180,23 +1214,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // shouldn't boolean checkRequiredParameters = true; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) - .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); - if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null); + if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); } // 1604 - Add enhanced environment & parameter checking // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep // Part 2: only submit to openstack the parameters in the envt that are in the heat template // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; - if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) { + if (heatEnvironmentString != null && heatEnvironmentString.contains("parameters:")) { //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases"); LOGGER.debug("Enhanced environment checking enabled - 1604"); mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString); @@ -1224,7 +1258,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { int cntr = 0; try { for (HeatTemplateParam htp : heatTemplate.getParameters()) { - sb.append("param[" + cntr++ + "]=" + htp.getParamName()); + sb.append("param[").append(cntr++).append("]=").append(htp.getParamName()); parameterNames.add(htp.getParamName()); if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { aliasToParam.put(htp.getParamAlias(), htp.getParamName()); @@ -1234,7 +1268,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.debug(sb.toString()); } catch (Exception e) { - LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e); + LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(), e); } // Step 1 - convert what we got as inputs (Map<String, String>) to a // Map<String, Object> - where the object matches the param type identified in the template @@ -1248,42 +1282,45 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam); this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack"); - for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () - + "', isRequired=" - + parm.isRequired () - + ", alias=" - + parm.getParamAlias ()); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + LOGGER.debug("Parameter:'" + parm.getParamName() + + "', isRequired=" + + parm.isRequired() + + ", alias=" + + parm.getParamAlias()); - if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) { + if (parm.isRequired() && (goldenInputs == null || !goldenInputs.containsKey(parm.getParamName()))) { // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object> - LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment"); + LOGGER.debug("**Parameter " + parm.getParamName() + + " is required and not in the inputs...check environment"); if (mhee != null && mhee.containsParameter(parm.getParamName())) { - LOGGER.debug ("Required parameter " + parm.getParamName () - + " appears to be in environment - do not count as missing"); + LOGGER.debug("Required parameter " + parm.getParamName() + + " appears to be in environment - do not count as missing"); } else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + LOGGER.debug("adding to missing parameters list: " + parm.getParamName()); if (missingParams == null) { - missingParams = parm.getParamName (); + missingParams = new StringBuilder(parm.getParamName()); } else { - missingParams += "," + parm.getParamName (); + missingParams.append("," + parm.getParamName()); } } } - paramList.add (parm.getParamName ()); + paramList.add(parm.getParamName()); } if (missingParams != null) { if (checkRequiredParameters) { // Problem - missing one or more required parameters String error = "Create VFModule: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block"); } } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); + LOGGER.debug("No missing parameters found - ok to proceed"); } // We can now remove the recreating of the ENV with only legit params - that check is done for us, // and it causes problems with json that has arrays @@ -1293,13 +1330,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate (); - template = template.replaceAll ("\r\n", "\n"); + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); // Have the tenant. Now deploy the stack itself // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long createStackStarttime = System.currentTimeMillis (); + long createStackStarttime = System.currentTimeMillis(); try { // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true, // heatTemplate.getTimeoutMinutes()); @@ -1309,47 +1346,59 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heat != null) { LOGGER.debug("heat is not null!!"); } - heatStack = heat.createStack (cloudSiteId, - tenantId, - vfModuleName, - template, - goldenInputs, - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects, - backout.booleanValue()); - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); + heatStack = heat.createStack(cloudSiteId, + tenantId, + vfModuleName, + template, + goldenInputs, + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects, + backout.booleanValue()); + LOGGER + .recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); } catch (MsoException me) { - me.addContext ("CreateVFModule"); + me.addContext("CreateVFModule"); String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "MsoException - createStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "MsoException - createStack", me); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); + throw new VnfException(me); } catch (NullPointerException npe) { String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack"); //npe.addContext ("CreateVNF"); - throw new VnfException ("NullPointerException during heat.createStack"); + throw new VnfException("NullPointerException during heat.createStack"); } catch (Exception e) { - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName); - LOGGER.debug("unhandled exception at heat.createStack",e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack"); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", + "OpenStack", "CreateStack", vfModuleName); + LOGGER.debug("unhandled exception at heat.createStack", e); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Exception while creating stack with OpenStack"); throw new VnfException("Exception during heat.createStack! " + e.getMessage()); } } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF",e); + LOGGER.debug("unhandled exception in create VF", e); throw new VnfException("Exception during create VF " + e.getMessage()); - } finally { - // Make sure DB session is closed - db.close (); } + // Make sure DB session is closed // Reach this point if createStack is successful. // Populate remaining rollback info and response parameters. @@ -1441,19 +1490,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; MsoLogger.setServiceName (serviceName); - StringBuilder sbInit = new StringBuilder(); - sbInit.append("updateVfModule: \n"); - sbInit.append("cloudSiteId=" + cloudSiteId + "\n"); - sbInit.append("tenantId=" + tenantId + "\n"); - sbInit.append("vnfType=" + vnfType + "\n"); - sbInit.append("vnfVersion=" + vnfVersion + "\n"); - sbInit.append("vnfName=" + vnfName + "\n"); - sbInit.append("requestType=" + requestType + "\n"); - sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n"); - sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); - sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); - sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); - LOGGER.debug(sbInit.toString()); + String strInit = "updateVfModule: cloudSiteId=" + cloudSiteId + + ",tenantId=" + tenantId + + ",vnfType=" + vnfType + + ",vnfVersion=" + vnfVersion + + ",vnfName=" + vnfName + + ",requestType=" + requestType + + ",volumeGroupHeatStackId=" + volumeGroupHeatStackId + + ",baseVfHeatStackId=" + baseVfHeatStackId + + ",vfModuleStackId=" + vfModuleStackId + + ",modelCustomizationUuid=" + modelCustomizationUuid; + LOGGER.debug(strInit); String mcu = modelCustomizationUuid; boolean useMCUuid = false; @@ -1634,10 +1681,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Ready to deploy the new VNF // Get a handle to the Catalog Database - CatalogDatabase db = CatalogDatabase.getInstance(); // Make sure DB session is closed - try { + try (CatalogDatabase db = CatalogDatabase.getInstance()) { // Retrieve the VF definition VnfResource vnfResource = null; VfModule vf = null; @@ -1652,20 +1698,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); } - if (vf == null) { + if (vf == null) { String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } - LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ()); + LOGGER.debug("Got VF module definition from Catalog: " + vf.toString()); if (vf.isBase()) { isBaseRequest = true; LOGGER.debug("This a BASE update request"); } else { LOGGER.debug("This is *not* a BASE VF update request"); if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + LOGGER.debug( + "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } @@ -1677,7 +1725,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vnfResource = db.getVnfResourceById(vnfResourceId); vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + LOGGER + .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); } } String minVersionVnf = null; @@ -1687,35 +1736,42 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e); minVersionVnf = null; maxVersionVnf = null; - } + } if (minVersionVnf != null && "".equals(minVersionVnf)) { minVersionVnf = null; } if (maxVersionVnf != null && "".equals(maxVersionVnf)) { maxVersionVnf = null; - } } + } if (minVersionVnf != null && maxVersionVnf != null) { MavenLikeVersioning aicV = new MavenLikeVersioning(); //String aicVersion = ""; if (this.cloudConfig == null) { this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); - } + } // double check if (this.cloudConfig != null) { Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId); if (cloudSiteOpt.isPresent()) { aicV.setVersion(cloudSiteOpt.get().getAic_version()); if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min - && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); + && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV + .isMoreRecentThan(maxVersionVnf)))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + String error = + "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get() + .getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -1741,11 +1797,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); } if (heatTemplateArtifactUuid == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = + "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); @@ -1753,90 +1813,97 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == null) { String error = "Update VNF: undefined Heat Template. VF=" - + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; + + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString()); // Add check for any Environment variable HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; if (heatEnvironmentArtifactUuid != null) { - LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); + LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid); if (heatEnvironment == null) { String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType - + ", Environment ID=" - + heatEnvironmentArtifactUuid; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + + ", Environment ID=" + + heatEnvironmentArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", + String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, + error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); - heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); - LOGGER.debug ("After parsing: " + heatEnvironmentString); + LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString()); + heatEnvironmentString = heatEnvironment + .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug("After parsing: " + heatEnvironmentString); } } else { - LOGGER.debug ("no environment parameter for this VFModuleType " + vfModuleType); + LOGGER.debug("no environment parameter for this VFModuleType " + vfModuleType); } - - LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" - + heatTemplate.getArtifactUuid ()); - Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ()); - Map <String, Object> nestedTemplatesChecked = new HashMap <> (); + LOGGER.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplatesChecked = new HashMap<>(); if (nestedTemplates != null) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:"); + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) { String providerResourceFile = entry.getKey(); Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); String childTemplateBody = (String) value; - nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); - LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); + nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody); + LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody); } } else { - LOGGER.debug ("No nested templates found - nothing to do here"); + LOGGER.debug("No nested templates found - nothing to do here"); nestedTemplatesChecked = null; } // Also add the files: for any get_files associated with this VfModule // *if* there are any - LOGGER.debug ("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId=" - + vf.getModelUUID()); + LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId=" + + vf.getModelUUID()); - Map <String, HeatFiles> heatFiles = null; + Map<String, HeatFiles> heatFiles = null; // Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ()); - Map <String, Object> heatFilesObjects = new HashMap <> (); + Map<String, Object> heatFilesObjects = new HashMap<>(); // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + + " - default to false", e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { - LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + LOGGER.debug( + "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + vf.getModelUUID()); heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID()); @@ -1844,35 +1911,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // add these to stack - to be done in createStack // here, we will map them to Map<String, Object> from Map<String, HeatFiles> // this will match the nested templates format - LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); + LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); - for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) { + for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) { String heatFileName = entry.getKey(); HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + + " at HEAT_FILES index=" + heatFileId; LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER + .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, + vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.DataNotFound, error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } - String heatFileBody = value.getFileBody (); - LOGGER.debug (heatFileName + " -> " + heatFileBody); - heatFilesObjects.put (heatFileName, heatFileBody); + String heatFileBody = value.getFileBody(); + LOGGER.debug(heatFileName + " -> " + heatFileBody); + heatFilesObjects.put(heatFileName, heatFileBody); } } else { - LOGGER.debug ("No heat files found -nothing to do here"); + LOGGER.debug("No heat files found -nothing to do here"); heatFilesObjects = null; } } // Check that required parameters have been supplied - String missingParams = null; - List <String> paramList = new ArrayList <> (); + StringBuilder missingParams = null; + List<String> paramList = new ArrayList<>(); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. @@ -1882,23 +1953,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean haveEnvironmentParameters = false; boolean checkRequiredParameters = true; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) - .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); - if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null); + if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); } // 1604 - Add enhanced environment & parameter checking // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep // Part 2: only submit to openstack the parameters in the envt that are in the heat template // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; - if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) { + if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) { LOGGER.debug("Enhanced environment checking enabled - 1604"); mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString); StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); @@ -1920,12 +1991,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HashMap<String, JsonNode> jsonParams = new HashMap<>(); boolean hasJson = false; - for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () - + "', isRequired=" - + parm.isRequired () - + ", alias=" - + parm.getParamAlias ()); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + LOGGER.debug("Parameter:'" + parm.getParamName() + + "', isRequired=" + + parm.isRequired() + + ", alias=" + + parm.getParamAlias()); // handle json String parameterType = parm.getParamType(); if (parameterType == null || "".equals(parameterType.trim())) { @@ -1933,7 +2004,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } JsonNode jsonNode = null; if ("json".equalsIgnoreCase(parameterType) && inputs != null) { - if (inputs.containsKey(parm.getParamName()) ) { + if (inputs.containsKey(parm.getParamName())) { hasJson = true; String jsonString = null; try { @@ -1943,12 +2014,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); hasJson = false; jsonNode = null; } @@ -1958,77 +2029,78 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else if (inputs.containsKey(parm.getParamAlias())) { hasJson = true; String jsonString = null; - try { + try { jsonString = inputs.get(parm.getParamAlias()); jsonNode = new ObjectMapper().readTree(jsonString); } catch (JsonParseException jpe) { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); hasJson = false; jsonNode = null; } - if (jsonNode != null) { - // Notice here - we add it to the jsonParams hashMap with the actual name - - // then manipulate the inputs so when we check for aliases below - it will not - // get flagged. - jsonParams.put(parm.getParamName(), jsonNode); - inputs.remove(parm.getParamAlias()); - inputs.put(parm.getParamName(), jsonString); - } + if (jsonNode != null) { + // Notice here - we add it to the jsonParams hashMap with the actual name - + // then manipulate the inputs so when we check for aliases below - it will not + // get flagged. + jsonParams.put(parm.getParamName(), jsonNode); + inputs.remove(parm.getParamAlias()); + inputs.put(parm.getParamName(), jsonString); + } } //TODO add a check for the parameter in the env file } - if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { - if (inputs.containsKey (parm.getParamAlias ())) { + if (parm.isRequired() && (inputs == null || !inputs.containsKey(parm.getParamName()))) { + if (inputs.containsKey(parm.getParamAlias())) { // They've submitted using an alias name. Remove that from inputs, and add back using real name. - String realParamName = parm.getParamName (); - String alias = parm.getParamAlias (); - String value = inputs.get (alias); - LOGGER.debug ("*Found an Alias: paramName=" + realParamName - + ",alias=" - + alias - + ",value=" - + value); - inputs.remove (alias); - inputs.put (realParamName, value); - LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); + String realParamName = parm.getParamName(); + String alias = parm.getParamAlias(); + String value = inputs.get(alias); + LOGGER.debug("*Found an Alias: paramName=" + realParamName + + ",alias=" + + alias + + ",value=" + + value); + inputs.remove(alias); + inputs.put(realParamName, value); + LOGGER.debug(alias + " entry removed from inputs, added back using " + realParamName); } // enhanced - check if it's in the Environment (note: that method else if (mhee != null && mhee.containsParameter(parm.getParamName())) { - LOGGER.debug ("Required parameter " + parm.getParamName () - + " appears to be in environment - do not count as missing"); - } - else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + LOGGER.debug("Required parameter " + parm.getParamName() + + " appears to be in environment - do not count as missing"); + } else { + LOGGER.debug("adding to missing parameters list: " + parm.getParamName()); if (missingParams == null) { - missingParams = parm.getParamName (); + missingParams = new StringBuilder(parm.getParamName()); } else { - missingParams += "," + parm.getParamName (); + missingParams.append("," + parm.getParamName()); } } } - paramList.add (parm.getParamName ()); + paramList.add(parm.getParamName()); } if (missingParams != null) { // Problem - missing one or more required parameters if (checkRequiredParameters) { - String error = "Update VNF: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + String error = "Update VNF: Missing Required inputs: " + missingParams; + LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block"); } } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); + LOGGER.debug("No missing parameters found - ok to proceed"); } // Just submit the envt entry as received from the database @@ -2039,13 +2111,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Remove any extraneous parameters (don't throw an error) if (inputs != null) { - List <String> extraParams = new ArrayList <> (); - extraParams.addAll (inputs.keySet ()); + List<String> extraParams = new ArrayList<>(); + extraParams.addAll(inputs.keySet()); // This is not a valid parameter for this template - extraParams.removeAll (paramList); - if (!extraParams.isEmpty ()) { - LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); - inputs.keySet ().removeAll (extraParams); + extraParams.removeAll(paramList); + if (!extraParams.isEmpty()) { + LOGGER.warn(MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Extra params"); + inputs.keySet().removeAll(extraParams); } } // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json @@ -2064,54 +2137,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate (); - template = template.replaceAll ("\r\n", "\n"); + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); // Have the tenant. Now deploy the stack itself // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long updateStackStarttime = System.currentTimeMillis (); + long updateStackStarttime = System.currentTimeMillis(); try { if (!hasJson) { - heatStack = heatU.updateStack (cloudSiteId, - tenantId, - vfModuleName, - template, - copyStringInputs (inputs), - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - //heatEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + heatStack = heatU.updateStack(cloudSiteId, + tenantId, + vfModuleName, + template, + copyStringInputs(inputs), + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", + "UpdateStack", null); } else { - heatStack = heatU.updateStack (cloudSiteId, - tenantId, - vfModuleName, - template, - inputsTwo, - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - //heatEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + heatStack = heatU.updateStack(cloudSiteId, + tenantId, + vfModuleName, + template, + inputsTwo, + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", + "UpdateStack", null); } } catch (MsoException me) { - me.addContext ("UpdateVFModule"); + me.addContext("UpdateVFModule"); String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); + LOGGER.error(MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); + throw new VnfException(me); } - } finally { - // Make sure DB session is closed - db.close (); } + // Make sure DB session is closed // Reach this point if updateStack is successful. // Populate remaining rollback info and response parameters. diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java new file mode 100755 index 0000000000..6e06eed702 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.vdu.utils; + +import java.util.Map; + +/* + * This Java bean class describes the template model of a VDU as distributed + * by SDC to SO. It is composed of one or more templates, one of which must be + * the main template, + * + * The structure of this class corresponds to the format in which the templates + * and associated artifacts are represented in the SO Catalog. + * + * The map keys will be the "path" that is used to reference these artifacts within + * the other templates. This may be relevant to how different VDU plugins package + * the files for delivery to the sub-orchestrator. + * + * In the future, it is possible that pre-packaged blueprints (e.g. complete TOSCA CSARs) + * could be stored in the catalog (and added to this structure). + * + * This bean is passed as an input to instantiateVdu and updateVdu. + */ + +public class VduBlueprint { + String vduModelId; + String mainTemplateName; + Map<String,byte[]> templateFiles; + Map<String,byte[]> attachedFiles; + + public String getVduModelId() { + return vduModelId; + } + + public void setVduModelId(String vduModelId) { + this.vduModelId = vduModelId; + } + + public String getMainTemplateName() { + return mainTemplateName; + } + + public void setMainTemplateName(String mainTemplateName) { + this.mainTemplateName = mainTemplateName; + } + + public Map<String, byte[]> getTemplateFiles() { + return templateFiles; + } + + public void setTemplateFiles(Map<String, byte[]> templateFiles) { + this.templateFiles = templateFiles; + } + + public Map<String, byte[]> getAttachedFiles() { + return attachedFiles; + } + + public void setAttachedFiles(Map<String, byte[]> attachedFiles) { + this.attachedFiles = attachedFiles; + } + + @Override + public String toString() { + return "VduInfo {" + + "id='" + vduModelId + '\'' + + "mainTemplateName='" + mainTemplateName + '\'' + + '}'; + } + +} + diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java new file mode 100755 index 0000000000..3646b292c5 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.vdu.utils; + +import java.util.Map; +import java.util.HashMap; + +/* + * This Java bean class relays VDU status information in a cloud-agnostic format. + * + * This bean is returned by all implementors of the MsoVduUtils interface operations + * (instantiate, query, delete). + */ + +public class VduInfo { + // Set defaults for everything + private String vduInstanceId = ""; + private String vduInstanceName = ""; + private VduStatus status = VduStatus.NOTFOUND; + private Map<String,Object> outputs = new HashMap<>(); + private Map<String,Object> inputs = new HashMap<>(); + private String lastAction; + private String actionStatus; + private String errorMessage; + + public VduInfo () { + } + + // Add more constructors as appropriate + // + + public VduInfo (String id, Map<String,Object> outputs) { + this.vduInstanceId = id; + if (outputs != null) this.outputs = outputs; + } + + public VduInfo (String id) { + this.vduInstanceId = id; + } + + public VduInfo (String id, VduStatus status) { + this.vduInstanceId = id; + this.status = status; + } + + public String getVnfInstanceId() { + return vduInstanceId; + } + + public void setVnfInstanceId (String id) { + this.vduInstanceId = id; + } + + public String getVnfInstanceName() { + return vduInstanceName; + } + + public void setVnfInstanceName (String name) { + this.vduInstanceName = name; + } + + public VduStatus getStatus() { + return status; + } + + public void setStatus (VduStatus status) { + this.status = status; + } + + public Map<String,Object> getOutputs () { + return outputs; + } + + public void setOutputs (Map<String,Object> outputs) { + this.outputs = outputs; + } + + public Map<String,Object> getInputs () { + return inputs; + } + + public void setInputs (Map<String,Object> inputs) { + this.inputs = inputs; + } + + public String getLastAction() { + return lastAction; + } + + public String getActionStatus() { + return actionStatus; + } + + public String getErrorMessage() { + return errorMessage; + } + + @Override + public String toString() { + return "VduInfo {" + + "id='" + vduInstanceId + '\'' + + "name='" + vduInstanceName + '\'' + + ", inputs='" + inputs + '\'' + + ", outputs='" + outputs + '\'' + + ", lastAction='" + lastAction + '\'' + + ", status='" + status + '\'' + + ", errorMessage='" + errorMessage + '\'' + + '}'; + } + +} + diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java new file mode 100755 index 0000000000..2118eec0a5 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java @@ -0,0 +1,248 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.vdu.utils; + +/** + * This interface defines a common API for template-based cloud deployments. + * The methods here should be adaptable for Openstack (Heat), Cloudify (TOSCA), + * Aria (TOSCA), Multi-VIM (TBD), and others (e.g. Azure Resource Manager). + * + * The deployed instances are referred to here as Virtual Deployment Units (VDUs). + * The package of templates that define a give VDU is referred to as its blueprint. + * + * Template-based orchestrators all follow a similar template/blueprint model. + * - One main template that is the top level definition + * - Optional nested templates referenced/included by the main template + * - Optional files attached to the template package, typically containing + * configuration files, install scripts, orchestration scripts, etc. + * + * The main template also defines the required inputs for creating a new instance, + * and output values exposed by successfully deployed instances. Inputs and outputs + * may include simple or complex (JSON) data types. + * + * Each implementation of this interface is expected to understand the MSO CloudConfig + * to obtain the credentials for its sub-orchestrator and the targeted cloud. + * The sub-orchestrator may have different credentials from the cloud (e.g. an Aria + * instance in front of an Openstack cloud) or they may be the same (e.g. Heat) + */ +import java.util.Map; + +import org.openecomp.mso.openstack.exceptions.MsoException; + +public interface VduPlugin { + + /** + * The instantiateVdu interface deploys a new VDU instance from a blueprint package. + * The templates and files in the blueprint may be pre-installed where supported + * (e.g. in Cloudify or Aria), or may be passed in directly (e.g. for Heat). These + * files are expressed as byte arrays, though only text files are expected from ASDC. + * + * For some VIMs, this may be a single command (e.g. Heat -> create stack) or may + * require a series of API calls (e.g. Cloudify -> upload blueprint, create deployment, + * execute install workflow). These details are hidden within the implementation. + * The instantiation should be fully completed before returning. On failures, this + * method is expected to back out the attempt, leaving the cloud in its previous state. + * + * It is expected that parameters have been validated and contain at minimum the + * required parameters for the given template with no extra parameters. + * + * The VDU name supplied by the caller will be globally unique, and identify the artifact + * in A&AI. Inventory is managed by the higher levels invoking this function. + * + * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry. + * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by + * cloud provider, but every cloud supports some sort of tenant partitioning. + * @param vduInstanceName A unique name for the VDU instance to create + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects. + * @param environmentFile A file containing default parameter name/value pairs. This is + * primarily for Heat, though ASDC may create a similar file for other orchestrators. + * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled + * @param suppressBackout Flag to preserve the deployment on install Failure. Should normally + * be False except in troubleshooting/debug cases + * + * @return A VduInfo object + * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo instantiateVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceName, + VduBlueprint vduBlueprint, + Map <String, ?> inputs, + String environmentFile, + int timeoutMinutes, + boolean suppressBackout) + throws MsoException; + + + /** + * Query a deployed VDU instance. This call will return a VduInfo object, or null + * if the deployment does not exist. + * + * Some VIM orchestrators identify deployment instances by string UUIDs, and others + * by integers. In the latter case, the ID will be passed in as a numeric string. + * + * The returned VduInfo object contains the input and output parameter maps, + * as well as other properties of the deployment (name, status, last action, etc.). + * + * @param cloudSiteId The target cloud to query for the VDU. + * @param tenantId The cloud tenant in which to query + * @param vduInstanceId The ID of the deployment to query + * + * @return A VduInfo object + * @throws MsoException Thrown if the VIM/sub-orchestrator API calls fail. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo queryVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId) + throws MsoException; + + + /** + * Delete a VDU instance by ID. If the VIM sub-orchestrator supports pre-installation + * of blueprints, the blueprint itself may remain installed. This is recommended, since + * other VDU instances may be using it. + * + * Some VIM orchestrators identify deployment instances by string UUIDs, and others + * by integers. In the latter case, the ID will be passed in as a numeric string. + * + * For some VIMs, deletion may be a single command (e.g. Heat -> delete stack) or a + * series of API calls (e.g. Cloudify -> execute uninstall workflow, delete deployment). + * These details are hidden within the implementation. The deletion should be fully + * completed before returning. + * + * The successful return is a VduInfo object which contains the state of the object just prior + * to deletion, with a status of DELETED. If the deployment was not found, the VduInfo object + * should be empty (with a status of NOTFOUND). There is no rollback from a successful deletion. + * + * A deletion failure will result in an undefined deployment state - the components may + * or may not have been all or partially uninstalled, so the resulting deployment must + * be considered invalid. + * + * @param cloudSiteId The target cloud from which to delete the VDU. + * @param tenantId The cloud tenant in which to delete the VDU. + * @param vduInstanceId The unique id of the deployment to delete. + * @param timeoutMinutes Timeout after which the delete action will be cancelled + * @param keepBlueprintLoaded Flag to also delete the blueprint + * + * @return A VduInfo object, representing the state of the instance just prior to deletion. + * + * @throws MsoException Thrown if the API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo deleteVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId, + int timeoutMinutes, + boolean keepBlueprintLoaded) + throws MsoException; + + + /** + * The updateVdu interface attempts to update a VDU in-place, using either new inputs or + * a new model definition (i.e. updated templates/blueprints). This depends on the + * capabilities of the targeted sub-orchestrator, as not all implementations are expected + * to support this ability. It is primary included initially only for Heat. + * + * It is expected that parameters have been validated and contain at minimum the required + * parameters for the given template with no extra parameters. The VDU instance name cannot + * be updated. + * + * The update should be fully completed before returning. The successful return is a + * VduInfo object containing the updated VDU state. + * + * An update failure will result in an undefined deployment state - the components may + * or may not have been all or partially modified, deleted, recreated, etc. So the resulting + * VDU must be considered invalid. + * + * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry. + * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by + * cloud provider, but every cloud supports some sort of tenant partitioning. + * @param vduInstanceId The unique ID for the VDU instance to update. + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects. + * @param environmentFile A file containing default parameter name/value pairs. This is + * primarily for Heat, though ASDC may create a similar file for other orchestrators. + * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled + * + * @return A VduInfo object + * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo updateVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId, + VduBlueprint vduBlueprint, + Map <String, ?> inputs, + String environmentFile, + int timeoutMinutes) + throws MsoException; + + + /** + * Check if a blueprint package has been installed in the sub-orchestrator and available + * for use at a targeted cloud site. If the specific sub-orchestrator does not support + * pre-installation, then those implementations should always return False. + * + * @param cloudSiteId The cloud site where the blueprint is needed + * @param vduModelId Unique ID of the VDU model to query + * + * @throws MsoException Thrown if the API call fails. + */ + public boolean isBlueprintLoaded (String cloudSiteId, String vduModelId) + throws MsoException; + + + /** + * Install a blueprint package to the target sub-orchestrator for a cloud site. + * The blueprints currently must be structured as a single directory with all of the + * required files. One of those files is designated the "main file" for the blueprint. + * Files are provided as byte arrays, though expect only text files will be distributed + * from ASDC and stored by MSO. + * + * @param cloudSiteId The cloud site where the blueprint is needed + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param failIfExists Flag to return an error if blueprint already exists + * + * @throws MsoException Thrown if the API call fails. + */ + public void uploadBlueprint (String cloudSiteId, + VduBlueprint vduBlueprint, + boolean failIfExists) + throws MsoException; + + /** + * Indicator that this VIM sub-orchestrator implementation supports independent upload + * of blueprint packages. Each implementation should return a constant value. + * + * @returns True if the sub-orchestrator supports blueprint pre-installation (upload). + */ + public boolean blueprintUploadSupported (); + +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java new file mode 100755 index 0000000000..0f4611a2de --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.vdu.utils; + + +/* + * Enum status values to capture the state of a generic (cloud-agnostic) VDU. + */ +public enum VduStatus { + NOTFOUND, + INSTANTIATING, + INSTANTIATED, + DELETING, + DELETED, // Note - only returned in success response to deleteVdu call. + UPDATING, + FAILED, + UNKNOWN +} + diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java index a045b00699..acde3153ab 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java @@ -44,7 +44,7 @@ public class MsoVnfAdapterAsyncImplTest { try {
instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, "messageId",
+ "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId",
null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
} catch (Exception e) {
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java index 6f01954db3..eec2257c7f 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java @@ -48,8 +48,8 @@ public class MsoVnfAdapterImplTest { try {
instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -67,8 +67,8 @@ public class MsoVnfAdapterImplTest { try {
instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -82,7 +82,7 @@ public class MsoVnfAdapterImplTest { msoRequest.setServiceInstanceId("12345");
try {
instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<Map<String, String>>());
+ new Holder<>());
} catch (Exception e) {
}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java index f6e79e12a0..d898a6547e 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java @@ -55,10 +55,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); @@ -82,10 +82,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); @@ -101,10 +101,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java index 52e1797531..000ed8aef3 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java @@ -42,16 +42,16 @@ public class VnfCreateTest { String tenantName = "John_Test"; String vnfType = "ApacheDemo"; String vnfName = "AdapterTest"; - Map<String,String> inputs = new HashMap<String,String>(); + Map<String,String> inputs = new HashMap<>(); inputs.put("vnf_id", "abc"); inputs.put("extra", "whocares"); inputs.put("private_subnet_gateway", "10.4.1.1"); inputs.put("private_subnet_cidr", "10.4.1.0/29"); // Web Service Outputs - Holder<String> vnfId = new Holder<String>(); - Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); - Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>(); + Holder<String> vnfId = new Holder<>(); + Holder<Map<String,String>> outputs = new Holder<>(); + Holder<VnfRollback> vnfRollback = new Holder<>(); try { vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null, diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java index 84f2f2ff57..bbffddfd15 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java @@ -39,10 +39,10 @@ public class VnfQueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String,String>> outputs = new Holder<>(); try { vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java new file mode 100644 index 0000000000..019ae1e3f9 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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.vdu.utils; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.vdu.utils.VduBlueprint; + +import org.junit.Assert; + +public class VduBlueprintTest { + + private VduBlueprint vduBlueprint; + + private Map<String, byte[]> templateFiles; + private Map<String, byte[]> attachedFiles; + + @Before + public void setUp() { + vduBlueprint = new VduBlueprint(); + } + + @Test + public void testGetVduModelId() { + vduBlueprint.setVduModelId("vduModelId"); + Assert.assertNotNull(vduBlueprint.getVduModelId()); + Assert.assertEquals(vduBlueprint.getVduModelId(), "vduModelId"); + } + + @Test + public void testGetMainTemplateName() { + vduBlueprint.setMainTemplateName("MainTemplateName"); + Assert.assertNotNull(vduBlueprint.getMainTemplateName()); + Assert.assertEquals(vduBlueprint.getMainTemplateName(), "MainTemplateName"); + } + + @Test + public void testGetTemplateFiles() { + byte[] templateFileData = "some template file data".getBytes(); + templateFiles = new HashMap<>(); + templateFiles.put("templateKey1", templateFileData); + vduBlueprint.setTemplateFiles(templateFiles); + Assert.assertNotNull(vduBlueprint.getTemplateFiles()); + Assert.assertTrue(vduBlueprint.getTemplateFiles().containsKey("templateKey1")); + Assert.assertTrue(vduBlueprint.getTemplateFiles().containsValue(templateFileData)); + } + + @Test + public void testGetAttachedFiles() { + byte[] attachedFileData = "some file data".getBytes(); + attachedFiles = new HashMap<>(); + attachedFiles.put("attachedKey1", attachedFileData); + vduBlueprint.setAttachedFiles(attachedFiles); + Assert.assertNotNull(vduBlueprint.getAttachedFiles()); + Assert.assertTrue(vduBlueprint.getAttachedFiles().containsKey("attachedKey1")); + Assert.assertTrue(vduBlueprint.getAttachedFiles().containsValue(attachedFileData)); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java new file mode 100644 index 0000000000..98a00033f7 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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.vdu.utils; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class VduInfoTest { + + private VduInfo vduInfo; + private VduStatus status = VduStatus.NOTFOUND; + private Map<String, Object> outputs; + private Map<String, Object> inputs; + + @Before + public void setUp() { + vduInfo = new VduInfo(); + } + + @Test + public void testGetVnfInstanceId() { + String vnfInstanceId = "vnfInstanceId"; + vduInfo.setVnfInstanceId(vnfInstanceId); + Assert.assertNotNull(vduInfo.getVnfInstanceId()); + Assert.assertEquals(vduInfo.getVnfInstanceId(), "vnfInstanceId"); + } + + @Test + public void testGetVnfInstanceName() { + String vnfInstanceName = "vnfInstanceName"; + vduInfo.setVnfInstanceName(vnfInstanceName); + Assert.assertNotNull(vduInfo.getVnfInstanceName()); + Assert.assertEquals(vduInfo.getVnfInstanceName(), "vnfInstanceName"); + } + + @Test + public void testGetStatus() { + vduInfo.setStatus(status); + Assert.assertNotNull(vduInfo.getStatus()); + Assert.assertEquals(status, vduInfo.getStatus()); + } + + @Test + public void testGetOutputs() { + Object obj = new Object(); + String str = "some text"; + outputs = new HashMap<>(); + outputs.put(str, obj); + vduInfo.setOutputs(outputs); + Assert.assertNotNull(vduInfo.getOutputs()); + Assert.assertTrue(vduInfo.getOutputs().containsKey(str)); + Assert.assertTrue(vduInfo.getOutputs().containsValue(obj)); + } + + @Test + public void testGetInputs() { + Object obj = new Object(); + String str = "some text"; + inputs = new HashMap<>(); + inputs.put(str, obj); + vduInfo.setInputs(inputs); + Assert.assertNotNull(vduInfo.getInputs()); + Assert.assertTrue(vduInfo.getInputs().containsKey(str)); + Assert.assertTrue(vduInfo.getInputs().containsValue(obj)); + } + +} diff --git a/adapters/mso-workflow-message-adapter/pom.xml b/adapters/mso-workflow-message-adapter/pom.xml index 3501dd5571..46e4a2bc13 100644 --- a/adapters/mso-workflow-message-adapter/pom.xml +++ b/adapters/mso-workflow-message-adapter/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-workflow-message-adapter</artifactId> <packaging>war</packaging> <name>mso-workflow-message-adapter</name> @@ -30,7 +30,7 @@ <dependencies> <dependency> - <groupId>org.openecomp.so.adapters</groupId> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> </dependency> @@ -58,7 +58,7 @@ <version>4.5.2</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/adapters/pom.xml b/adapters/pom.xml index 97c2506bcc..6877d76ae3 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> <name>MSO Adapters</name> <description>Adapters for MSO</description> diff --git a/aria/aria-rest-java-client/pom.xml b/aria/aria-rest-java-client/pom.xml index 402d3c1268..f35403cf81 100755 --- a/aria/aria-rest-java-client/pom.xml +++ b/aria/aria-rest-java-client/pom.xml @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- /* * ============LICENSE_START=================================================== @@ -17,7 +18,6 @@ * ============LICENSE_END==================================================== */ --> -<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClient.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClient.java index d6e9f2434d..d6e9f2434d 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClient.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClient.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClientFactory.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClientFactory.java index a97384e084..7241b2ac65 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClientFactory.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaClientFactory.java @@ -25,7 +25,7 @@ import java.net.URL; */
public class AriaClientFactory {
- AriaClient createRestClient(String protocol, String address, int port, String version){
+ public AriaClient createRestClient(String protocol, String address, int port, String version){
return new AriaRestClient(protocol, address, port, version);
}
}
diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaRestClient.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaRestClient.java index a4e453395d..5de2203b2f 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaRestClient.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/AriaRestClient.java @@ -1,336 +1,377 @@ -/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2017 Cloudify.co. 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 com.gigaspaces.aria.rest.client;
-
-import com.gigaspaces.aria.rest.client.exceptions.StorageException;
-import com.gigaspaces.aria.rest.client.exceptions.ValidationException;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
-import org.codehaus.jackson.map.ObjectMapper;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import static javax.ws.rs.client.Entity.entity;
-
-/**
- * Created by DeWayne on 7/12/2017.
- */
-public class AriaRestClient implements AriaClient {
- private Client client=null;
- private WebTarget base_target=null;
-
- /**
- * Construct an Aria REST client
- *
- * @param protocol either http or https
- * @param address the IP address or host name
- * @param port the port of the service
- * @param version the api version
- */
- public AriaRestClient(String protocol, String address, int port, String version){
- this.client = ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build();
- base_target = client.target(protocol+"://"+address+":"+port+"/api/"+version);
- }
-
- /**
- * Installs a service template
- *
- * @param template the template object
- * @throws ValidationException
- * @throws StorageException
- */
- public void install_service_template(ServiceTemplate template) throws ValidationException, StorageException, Exception {
-
- Response response = base_target.path("templates/"+template.getName()).request(MediaType.APPLICATION_JSON).put(Entity.entity(
- "{\"service-template-path\":\""+template.getURI().toString()+"\""+
- ",\"service-template-filename\":\""+template.getFilename()+"\"", MediaType.APPLICATION_JSON));
-
- if(response.getStatus() == 500){
- throw new StorageException(response.readEntity(String.class));
- }
- else if(response.getStatus() == 400){
- throw new ValidationException(response.readEntity(String.class));
- }
- else if(response.getStatus()>199 && response.getStatus() <300){
- return;
- }
- else{
- throw new Exception("Error installing template: "+response.getStatus()+" "+ response.readEntity(String.class));
- }
- }
-
- public ValidationResult validate_service_template(ServiceTemplate template)throws Exception{
- Response response = base_target.path("templates").request(MediaType.APPLICATION_JSON).post(Entity.entity(
- "{\"service-template-path\":\""+template.getURI().toString()+"\""+
- ",\"service-template-filename\":\""+template.getFilename()+"\"}", MediaType.APPLICATION_JSON));
-
- ValidationResultImpl result = new ValidationResultImpl();
- if(response.getStatus() >= 200 && response.getStatus() < 300){
- result.setFailed(false);
- }
- else if(response.getStatus()==400){
- result.setFailed(true);
- }
- else{
- throw new Exception("received error response '"+ response.getStatus()+"':"+response.readEntity(String.class));
- }
- return result;
-
- }
-
- /**
- *
- * @return a list of service templates
- */
- public List<? extends ServiceTemplate> list_service_templates(){
- List<? extends ServiceTemplate> templates = base_target.path("templates").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ServiceTemplateImpl>>(){});
-
- return templates;
- }
-
-
- /**
- * Deletes the specified template.
- *
- * TODO: Error handling is a little blunt. Need to describe failures better
- *
- * @param template_id the template id to delete
- * @throws IllegalArgumentException thrown when the template can't be deleted
- * @throws Exception other server side errors
- */
- public void delete_service_template(int template_id) throws IllegalArgumentException, Exception{
- Response response = base_target.path("templates/"+template_id).request(MediaType.APPLICATION_JSON).delete();
-
- if(response.getStatus()>=200 && response.getStatus()<300){
- return;
- }
- else if(response.getStatus()==400){
- throw new IllegalArgumentException("Error deleting template '"+template_id+"'");
- }
- else{
- throw new Exception("Error processing request. Return code = "+response.getStatus());
- }
- }
-
- /**
- * List the node templates for a given template id
- *
- * @param template_id
- * @return
- */
- public List<? extends NodeTemplate> list_nodes(int template_id) {
- List<? extends NodeTemplate> nodes = base_target.path("templates/"+template_id+"/nodes").request(MediaType.APPLICATION_JSON).get(new GenericType<List<NodeTemplateImpl>>(){});
- return nodes;
- }
-
- /**
- * Get a specific node by id
- *
- * @param node_id the node id
- * @return
- * @throws IllegalArgumentException
- */
- public NodeTemplate get_node(int node_id) throws IllegalArgumentException {
- NodeTemplate node = base_target.path("nodes/"+node_id).request(MediaType.APPLICATION_JSON).get(NodeTemplateImpl.class);
- return node;
- }
-
- public List<? extends Service> list_services() {
- List<? extends Service> services = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ServiceImpl>>(){});
- return services;
- }
-
- public Service get_service(int service_id) throws IllegalArgumentException {
- throw new NotImplementedException();
- }
-
- public List<? extends Output> list_service_outputs(int service_id) throws IllegalArgumentException {
- List<? extends Output> outputs = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<OutputImpl>>(){});
- return outputs;
- }
-
- public List<? extends Input> list_service_inputs(int service_id) throws IllegalArgumentException {
- List<? extends Input> inputs = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<InputImpl>>(){});
- return inputs;
- }
-
- /**
- * Create a service based on the supplied template
- *
- * @param template_id the template to create the service for
- * @param service_name a name for the service
- * @param inputs an optional list of inputs for the service (can be null)
- * @throws Exception
- */
- public void create_service(int template_id, String service_name, List<Input> inputs) throws Exception {
-
- String json="{"+inputsToJson(inputs)+"}";
-
- Response response = base_target.path("templates/"+template_id+"/services/"+service_name).
- request(MediaType.APPLICATION_JSON).post(
- Entity.entity(json, MediaType.APPLICATION_JSON)
- );
-
- if( response.getStatus()< 200 || response.getStatus()>299){
- throw new Exception("create service failed:"+response.getStatus()+" "+ response.readEntity(String.class));
- }
- }
-
- public void delete_service(int service_id) throws Exception {
- Response response = base_target.path("services/"+service_id).request(MediaType.APPLICATION_JSON).delete();
- if(!responseOK(response)){
- throw new Exception("delete service failed: "+response.getStatus()+" "+ response.readEntity(String.class));
- }
- }
-
- /**
- * List user workflows for supplied service
- *
- * @param service_id
- * @return
- * @throws IllegalArgumentException
- */
- public List<? extends Workflow> list_workflows(int service_id) throws IllegalArgumentException {
- List<? extends Workflow> workflows = base_target.path("services/"+service_id+"/workflows").request(MediaType.APPLICATION_JSON).get(new GenericType<List<WorkflowImpl>>(){});
- return workflows;
- }
-
- public Workflow get_workflow(int workflow_id) throws IllegalArgumentException {
- throw new NotImplementedException();
- }
-
- /**
- * List all executions
- *
- * @return
- * @throws Exception
- */
- public List<? extends Execution> list_executions() throws Exception {
- List<? extends Execution> executions = base_target.path("executions").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ExecutionImpl>>(){});
- return executions;
- }
-
- /**
- * List executions for specified service
- *
- * @param service_id
- * @return
- * @throws Exception
- */
- public List<? extends Execution> list_executions(int service_id) throws Exception {
- List<? extends Execution> executions = base_target.path("services/"+service_id+"/executions").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ExecutionImpl>>(){});
- return executions;
- }
-
- /**
- * Get details about a specified execution
- *
- * @param execution_id
- * @return
- * @throws IllegalArgumentException
- */
- public Execution get_execution(int execution_id) throws IllegalArgumentException {
- Execution execution = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).get(ExecutionImpl.class);
- return execution;
- }
-
- /**
- * Start an execution for the specified service
- *
- * @param service_id the service to run the execution for
- * @param workflow_name the name of the workflow to execute
- * @param details details controlling execution operation
- * @return the execution id
- * @throws Exception
- */
- public int start_execution(int service_id, String workflow_name, ExecutionDetails details) throws Exception {
- StringBuilder json=new StringBuilder("{");
- if(details.getExecutor().length()>0){
- json.append("\"executor\":\"").append(details.getExecutor()).append("\",");
- }
- if(details.getInputs()!=null){
- json.append(inputsToJson(details.getInputs()));
- }
- json.append("\"task_max_attempts\":").append(details.getTaskMaxAttempts()).append(",");
- json.append("\"task_retry_interval\":").append(details.getTaskRetryInterval()).append("}");
-
- System.out.println("JSON="+json.toString());
-
- Response response = base_target.path("services/"+service_id+"/executions/"+workflow_name).request(MediaType.APPLICATION_JSON).
- post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON));
-
- if(!responseOK(response)){
- throw new Exception("start execution failed: "+response.getStatus()+" "+response.readEntity(String.class));
- }
-
- ObjectMapper mapper = new ObjectMapper(new JsonFactory());
- JsonNode rootNode = mapper.readTree(response.readEntity(String.class));
- int id=rootNode.get("id").asInt(-1);
- return id;
- }
-
- public void resume_execution(int execution_id, ExecutionDetails details) throws IllegalArgumentException {
- StringBuilder json=new StringBuilder("{");
- if(details.getExecutor().length()>0){
- json.append("\"executor\":\"").append(details.getExecutor()).append("\",");
- }
- json.append("\"retry_failed_tasks\":").append(details.isRetry_failed_tasks()).append("}");
- Response response = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).
- post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON));
- }
-
- public void cancel_execution(int execution_id) throws Exception {
- Response response = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).delete();
- if(!responseOK(response)){
- throw new Exception("delete service failed: "+response.getStatus()+" "+ response.readEntity(String.class));
- }
- }
-
- /**
- * -----
- * ----- PRIVATE METHODS
- * -----
- */
-
- private boolean responseOK(Response response){
- return response.getStatus()>199 && response.getStatus()<300;
- }
-
- private String inputsToJson(List<Input> inputs){
- if(inputs==null)return null;
-
- StringBuilder sb=new StringBuilder("\"inputs\":{");
- for(Input input:inputs){
- sb.append("\"").append(input.getName()).append("\":\"").append(input.getValue()).append("\",");
- }
- if(inputs.size()>0)sb.deleteCharAt(sb.length()-1); //trim comma
-
- return sb.toString();
- }
-}
+/* + * ============LICENSE_START=================================================== + * Copyright (c) 2017 Cloudify.co. 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 com.gigaspaces.aria.rest.client; + +import java.util.List; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.jaxrs.JacksonJsonProvider; +import org.codehaus.jackson.map.ObjectMapper; +import com.gigaspaces.aria.rest.client.exceptions.StorageException; +import com.gigaspaces.aria.rest.client.exceptions.ValidationException; + +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +/** + * Created by DeWayne on 7/12/2017. + */ +public class AriaRestClient implements AriaClient { + private Client client = null; + private WebTarget base_target = null; + + /** + * Construct an Aria REST client + * + * @param protocol + * either http or https + * @param address + * the IP address or host name + * @param port + * the port of the service + * @param version + * the api version + */ + public AriaRestClient(String protocol, String address, int port, String version) { + this.client = ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build(); + base_target = client.target(protocol + "://" + address + ":" + port + "/api/" + version); + } + + /** + * Installs a service template + * + * @param template + * the template object + * @throws ValidationException + * @throws StorageException + */ + public void install_service_template(ServiceTemplate template) + throws ValidationException, StorageException, Exception { + + byte[] csarBytes = template.getCSARBytes(); + Response response = null; + if (csarBytes == null) { + response = base_target.path("templates/" + template.getName()).request(MediaType.APPLICATION_JSON) + .put(Entity.entity( + "{\"service-template-path\":\"" + template.getURI().toString() + "\"" + + ",\"service-template-filename\":\"" + template.getFilename() + "\"", + MediaType.APPLICATION_JSON)); + } + else { + + response = base_target.path("templates/" + template.getName()).request("application/zip") + .put(Entity.entity(csarBytes, "application/zip")); + } + + if (response.getStatus() == 500) { + throw new StorageException(response.readEntity(String.class)); + } else if (response.getStatus() == 400) { + throw new ValidationException(response.readEntity(String.class)); + } else if (response.getStatus() > 199 && response.getStatus() < 300) { + return; + } else { + throw new Exception( + "Error installing template: " + response.getStatus() + " " + response.readEntity(String.class)); + } + } + + public ValidationResult validate_service_template(ServiceTemplate template) throws Exception { + Response response = base_target.path("templates").request(MediaType.APPLICATION_JSON) + .post(Entity.entity( + "{\"service-template-path\":\"" + template.getURI().toString() + "\"" + + ",\"service-template-filename\":\"" + template.getFilename() + "\"}", + MediaType.APPLICATION_JSON)); + + ValidationResultImpl result = new ValidationResultImpl(); + if (response.getStatus() >= 200 && response.getStatus() < 300) { + result.setFailed(false); + } else if (response.getStatus() == 400) { + result.setFailed(true); + } else { + throw new Exception( + "received error response '" + response.getStatus() + "':" + response.readEntity(String.class)); + } + return result; + + } + + /** + * + * @return a list of service templates + */ + public List<? extends ServiceTemplate> list_service_templates() { + List<? extends ServiceTemplate> templates = base_target.path("templates").request(MediaType.APPLICATION_JSON) + .get(new GenericType<List<ServiceTemplateImpl>>() { + }); + + return templates; + } + + /** + * Deletes the specified template. + * + * TODO: Error handling is a little blunt. Need to describe failures better + * + * @param template_id + * the template id to delete + * @throws IllegalArgumentException + * thrown when the template can't be deleted + * @throws Exception + * other server side errors + */ + public void delete_service_template(int template_id) throws IllegalArgumentException, Exception { + Response response = base_target.path("templates/" + template_id).request(MediaType.APPLICATION_JSON).delete(); + + if (response.getStatus() >= 200 && response.getStatus() < 300) { + return; + } else if (response.getStatus() == 400) { + throw new IllegalArgumentException("Error deleting template '" + template_id + "'"); + } else { + throw new Exception("Error processing request. Return code = " + response.getStatus()); + } + } + + /** + * List the node templates for a given template id + * + * @param template_id + * @return + */ + public List<? extends NodeTemplate> list_nodes(int template_id) { + List<? extends NodeTemplate> nodes = base_target.path("templates/" + template_id + "/nodes") + .request(MediaType.APPLICATION_JSON).get(new GenericType<List<NodeTemplateImpl>>() { + }); + return nodes; + } + + /** + * Get a specific node by id + * + * @param node_id + * the node id + * @return + * @throws IllegalArgumentException + */ + public NodeTemplate get_node(int node_id) throws IllegalArgumentException { + NodeTemplate node = base_target.path("nodes/" + node_id).request(MediaType.APPLICATION_JSON) + .get(NodeTemplateImpl.class); + return node; + } + + public List<? extends Service> list_services() { + List<? extends Service> services = base_target.path("services").request(MediaType.APPLICATION_JSON) + .get(new GenericType<List<ServiceImpl>>() { + }); + return services; + } + + public Service get_service(int service_id) throws IllegalArgumentException { + throw new NotImplementedException(); + } + + public List<? extends Output> list_service_outputs(int service_id) throws IllegalArgumentException { + List<? extends Output> outputs = base_target.path("services").request(MediaType.APPLICATION_JSON) + .get(new GenericType<List<OutputImpl>>() { + }); + return outputs; + } + + public List<? extends Input> list_service_inputs(int service_id) throws IllegalArgumentException { + List<? extends Input> inputs = base_target.path("services").request(MediaType.APPLICATION_JSON) + .get(new GenericType<List<InputImpl>>() { + }); + return inputs; + } + + /** + * Create a service based on the supplied template + * + * @param template_id + * the template to create the service for + * @param service_name + * a name for the service + * @param inputs + * an optional list of inputs for the service (can be null) + * @throws Exception + */ + public void create_service(int template_id, String service_name, List<Input> inputs) throws Exception { + + String json = "{" + inputsToJson(inputs) + "}"; + + Response response = base_target.path("templates/" + template_id + "/services/" + service_name) + .request(MediaType.APPLICATION_JSON).post(Entity.entity(json, MediaType.APPLICATION_JSON)); + + if (response.getStatus() < 200 || response.getStatus() > 299) { + throw new Exception( + "create service failed:" + response.getStatus() + " " + response.readEntity(String.class)); + } + } + + public void delete_service(int service_id) throws Exception { + Response response = base_target.path("services/" + service_id).request(MediaType.APPLICATION_JSON).delete(); + if (!responseOK(response)) { + throw new Exception( + "delete service failed: " + response.getStatus() + " " + response.readEntity(String.class)); + } + } + + /** + * List user workflows for supplied service + * + * @param service_id + * @return + * @throws IllegalArgumentException + */ + public List<? extends Workflow> list_workflows(int service_id) throws IllegalArgumentException { + List<? extends Workflow> workflows = base_target.path("services/" + service_id + "/workflows") + .request(MediaType.APPLICATION_JSON).get(new GenericType<List<WorkflowImpl>>() { + }); + return workflows; + } + + public Workflow get_workflow(int workflow_id) throws IllegalArgumentException { + throw new NotImplementedException(); + } + + /** + * List all executions + * + * @return + * @throws Exception + */ + public List<? extends Execution> list_executions() throws Exception { + List<? extends Execution> executions = base_target.path("executions").request(MediaType.APPLICATION_JSON) + .get(new GenericType<List<ExecutionImpl>>() { + }); + return executions; + } + + /** + * List executions for specified service + * + * @param service_id + * @return + * @throws Exception + */ + public List<? extends Execution> list_executions(int service_id) throws Exception { + List<? extends Execution> executions = base_target.path("services/" + service_id + "/executions") + .request(MediaType.APPLICATION_JSON).get(new GenericType<List<ExecutionImpl>>() { + }); + return executions; + } + + /** + * Get details about a specified execution + * + * @param execution_id + * @return + * @throws IllegalArgumentException + */ + public Execution get_execution(int execution_id) throws IllegalArgumentException { + Execution execution = base_target.path("executions/" + execution_id).request(MediaType.APPLICATION_JSON) + .get(ExecutionImpl.class); + return execution; + } + + /** + * Start an execution for the specified service + * + * @param service_id + * the service to run the execution for + * @param workflow_name + * the name of the workflow to execute + * @param details + * details controlling execution operation + * @return the execution id + * @throws Exception + */ + public int start_execution(int service_id, String workflow_name, ExecutionDetails details) throws Exception { + StringBuilder json = new StringBuilder("{"); + if (details.getExecutor().length() > 0) { + json.append("\"executor\":\"").append(details.getExecutor()).append("\","); + } + if (details.getInputs() != null) { + json.append(inputsToJson(details.getInputs())); + } + json.append("\"task_max_attempts\":").append(details.getTaskMaxAttempts()).append(","); + json.append("\"task_retry_interval\":").append(details.getTaskRetryInterval()).append("}"); + + System.out.println("JSON=" + json.toString()); + + Response response = base_target.path("services/" + service_id + "/executions/" + workflow_name) + .request(MediaType.APPLICATION_JSON).post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON)); + + if (!responseOK(response)) { + throw new Exception( + "start execution failed: " + response.getStatus() + " " + response.readEntity(String.class)); + } + + ObjectMapper mapper = new ObjectMapper(new JsonFactory()); + JsonNode rootNode = mapper.readTree(response.readEntity(String.class)); + int id = rootNode.get("id").asInt(-1); + return id; + } + + public void resume_execution(int execution_id, ExecutionDetails details) throws IllegalArgumentException { + StringBuilder json = new StringBuilder("{"); + if (details.getExecutor().length() > 0) { + json.append("\"executor\":\"").append(details.getExecutor()).append("\","); + } + json.append("\"retry_failed_tasks\":").append(details.isRetry_failed_tasks()).append("}"); + Response response = base_target.path("executions/" + execution_id).request(MediaType.APPLICATION_JSON) + .post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON)); + } + + public void cancel_execution(int execution_id) throws Exception { + Response response = base_target.path("executions/" + execution_id).request(MediaType.APPLICATION_JSON).delete(); + if (!responseOK(response)) { + throw new Exception( + "delete service failed: " + response.getStatus() + " " + response.readEntity(String.class)); + } + } + + /** + * ----- ----- PRIVATE METHODS ----- + */ + + private boolean responseOK(Response response) { + return response.getStatus() > 199 && response.getStatus() < 300; + } + + private String inputsToJson(List<Input> inputs) { + if (inputs == null) + return null; + + StringBuilder sb = new StringBuilder("\"inputs\":{"); + for (Input input : inputs) { + sb.append("\"").append(input.getName()).append("\":\"").append(input.getValue()).append("\","); + } + if (inputs.size() > 0) + sb.deleteCharAt(sb.length() - 1); // trim comma + + return sb.toString(); + } +} diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Execution.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Execution.java index ab742833e6..ab742833e6 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Execution.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Execution.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionDetails.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionDetails.java index e7685a259c..e7685a259c 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionDetails.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionDetails.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionImpl.java index 8e420cc16c..8e420cc16c 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ExecutionImpl.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Input.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Input.java index 595dfb1245..595dfb1245 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Input.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Input.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/InputImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/InputImpl.java index 3002b7b54e..3002b7b54e 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/InputImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/InputImpl.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplate.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplate.java index bc46d7f5b2..bc46d7f5b2 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplate.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplate.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplateImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplateImpl.java index 43338c952d..43338c952d 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplateImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/NodeTemplateImpl.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Output.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Output.java index 83363bad6c..83363bad6c 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Output.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Output.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/OutputImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/OutputImpl.java index 0a6cecc9c1..0a6cecc9c1 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/OutputImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/OutputImpl.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Service.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Service.java index 9cf86ec73f..9cf86ec73f 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Service.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Service.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceImpl.java new file mode 100644 index 0000000000..456335cedc --- /dev/null +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceImpl.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2017 Cloudify.co. 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 com.gigaspaces.aria.rest.client; + +import java.net.URI; +import java.util.Date; + +/** + * + * + * Created by DeWayne on 7/17/2017. + */ +public class ServiceImpl implements Service { + private int id; + private String description, name, template; + private Date created, updated; + + public int getId(){ + return id; + } + + public String getDescription(){ + return description; + } + + public String getName(){ + return name; + } + + public String getServiceTemplate(){ + return template; + } + + public Date getCreated(){ + return created; + } + + public Date getUpdated(){ + return updated; + } + + +} diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplate.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplate.java index 0df6d60905..a2ca8cf662 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplate.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplate.java @@ -1,31 +1,32 @@ -/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2017 Cloudify.co. 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 com.gigaspaces.aria.rest.client;
-
-import java.net.URI;
-
-/**
- * Created by DeWayne on 7/12/2017.
- */
-public interface ServiceTemplate {
- String getName();
- URI getURI();
- int getId();
- String getFilename();
- String getDescription();
-}
+/* + * ============LICENSE_START=================================================== + * Copyright (c) 2017 Cloudify.co. 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 com.gigaspaces.aria.rest.client; + +import java.net.URI; + +/** + * Created by DeWayne on 7/12/2017. + */ +public interface ServiceTemplate { + String getName(); + URI getURI(); + int getId(); + String getFilename(); + String getDescription(); + byte[] getCSARBytes(); +} diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplateImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplateImpl.java index 9e158a27fd..562fcb232e 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplateImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ServiceTemplateImpl.java @@ -31,6 +31,7 @@ public class ServiceTemplateImpl implements ServiceTemplate { private URI uri; private String filename = DEFAULT_TEMPLATE_NAME; private String description; + private byte[] csar_blob; // for opaque binary public ServiceTemplateImpl(){} @@ -40,7 +41,15 @@ public class ServiceTemplateImpl implements ServiceTemplate { } /** - * Construct an instance + * Construct service template from CSAR byte array + */ + public ServiceTemplateImpl(String name, byte[] csar){ + this.csar_blob = csar; + this.name = name; + } + + /** + * Construct an instance based on CSAR * @param name a textual name for the template * @param uri a URI to a CSAR * @param filename the filename in the CSAR representing main yaml template @@ -51,7 +60,7 @@ public class ServiceTemplateImpl implements ServiceTemplate { this.filename=filename; this.description=description; } - + public int getId(){ return id; } @@ -76,6 +85,9 @@ public class ServiceTemplateImpl implements ServiceTemplate { public void setFilename(String filename){ this.filename=filename; } + public byte[] getCSARBytes() { + return csar_blob; + } public String getDescription(){ return description;} } diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResult.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResult.java index 3d40dfa1ec..3d40dfa1ec 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResult.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResult.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResultImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResultImpl.java index 22e34eb7b3..22e34eb7b3 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResultImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/ValidationResultImpl.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Workflow.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Workflow.java index 7dbab18943..7dbab18943 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Workflow.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/Workflow.java diff --git a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/WorkflowImpl.java b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/WorkflowImpl.java index 41105df26a..41105df26a 100755..100644 --- a/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/WorkflowImpl.java +++ b/aria/aria-rest-java-client/src/main/java/com/gigaspaces/aria/rest/client/WorkflowImpl.java diff --git a/aria/pom.xml b/aria/pom.xml new file mode 100644 index 0000000000..a754d78ed1 --- /dev/null +++ b/aria/pom.xml @@ -0,0 +1,21 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>so</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + + <groupId>org.onap.so</groupId> + <artifactId>aria</artifactId> + <name>ARIA related artifacts</name> + <description>ARIA related artifacts</description> + <packaging>pom</packaging> + + <modules> + <module>aria-rest-java-client</module> + <module>aria-rest-server</module> + <!-- <module>multivim-plugin</module> --> + </modules> +</project> diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index 5836e4cf7e..c3add03408 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>asdc-controller</artifactId> <name>asdc-controller</name> <description>ASDC CLient and Controller</description> @@ -47,7 +47,7 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> @@ -124,7 +124,7 @@ </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> @@ -142,7 +142,7 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java index 6cfe90b92c..e069989aeb 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java @@ -399,7 +399,7 @@ public class ASDCConfiguration implements IConfiguration { MsoJsonProperties msoProp; try { - List <String> result = new ArrayList <String> (); + List <String> result = new ArrayList<>(); msoProp = new MsoPropertiesFactory ().getMsoJsonProperties (MSO_PROP_ASDC); if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java index c0056e0573..430bd10892 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java @@ -41,7 +41,7 @@ import org.openecomp.mso.properties.MsoPropertiesFactory; public class ASDCGlobalController { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); - private Map <String,ASDCController> controllers = new HashMap <String,ASDCController> (); + private Map <String,ASDCController> controllers = new HashMap<>(); private MsoJsonProperties msoProp= null; @@ -49,7 +49,7 @@ public class ASDCGlobalController { List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); - StringBuffer controllerListLog = new StringBuffer("List of controllers loaded:"); + StringBuilder controllerListLog = new StringBuilder("List of controllers loaded:"); for (String controllerName : controllerNames) { controllers.put(controllerName, new ASDCController(controllerName)); controllerListLog.append(controllerName); @@ -78,7 +78,7 @@ public class ASDCGlobalController { /** * Check that controllers list needs to be updated or not. - * @param return true if the list has been updated + * return true if the list has been updated */ private boolean updateControllersListIfNeeded () { boolean updateNeeded=false; @@ -149,7 +149,7 @@ public class ASDCGlobalController { } public void closeASDC () { - List<String> controllerToRemove = new LinkedList<String>(); + List<String> controllerToRemove = new LinkedList<>(); for (ASDCController controller : controllers.values()) { try { diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java index 3c262c6c90..29144a9884 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java @@ -109,7 +109,7 @@ public class ASDCElementInfo { */ @Override public final String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); List<String> aggregatedElements = new ArrayList<>(); for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) { aggregatedElements.add(entry.getKey() + ": " + entry.getValue()); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java index 5547bb1189..c2faf1c0e8 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java @@ -34,7 +34,7 @@ public class BigDecimalVersion { public static BigDecimal castAndCheckNotificationVersion(String version) { // Truncate the version if bad type String[] splitVersion = version.split("\\."); - StringBuffer newVersion = new StringBuffer(); + StringBuilder newVersion = new StringBuilder(); if (splitVersion.length > 1) { newVersion.append(splitVersion[0]); newVersion.append("."); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java index f6ac480c93..c9bde98da8 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java @@ -47,7 +47,7 @@ public final class VfModuleStructure { vfModuleMetadata = vfmoduleMetadata; parentVfResource = vfParentResource; - artifactsMap = new HashMap<String, List<VfModuleArtifact>>(); + artifactsMap = new HashMap<>(); for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) { if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) { @@ -64,7 +64,7 @@ public final class VfModuleStructure { artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact); } else { - List<VfModuleArtifact> nestedList = new LinkedList<VfModuleArtifact>(); + List<VfModuleArtifact> nestedList = new LinkedList<>(); nestedList.add(vfModuleArtifact); artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList); @@ -73,19 +73,15 @@ public final class VfModuleStructure { public List<VfModuleArtifact> getOrderedArtifactList() { - List <VfModuleArtifact> artifactsList = new LinkedList <VfModuleArtifact>(); + List <VfModuleArtifact> artifactsList = new LinkedList<>(); artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT)); artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV)); artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_NESTED))) { - artifactsList.add(artifact); - } + artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED))); - for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))) { - artifactsList.add(artifact); - } + artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))); artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java index c2879a4df2..e9e39d7660 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java @@ -101,8 +101,8 @@ public final class VfResourceStructure { resourceInstance=resourceinstance; - vfModulesStructureList = new LinkedList<VfModuleStructure>(); - artifactsMapByUUID = new HashMap<String, VfModuleArtifact>(); + vfModulesStructureList = new LinkedList<>(); + artifactsMapByUUID = new HashMap<>(); } //@Override diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java index b998be9a69..8c08d3eb26 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java @@ -419,39 +419,34 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller { toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
logger.debug("vfGroups:" + vfGroups.toString());
- Collections.sort(vfGroups, new Comparator<org.openecomp.sdc.toscaparser.api.Group>() {
-
- @Override
- public int compare(org.openecomp.sdc.toscaparser.api.Group group1,
- org.openecomp.sdc.toscaparser.api.Group group2) {
-
- // Field name1Field = group1.class.getDeclaredField("name");
- // name1Field.setAccessible(true);
- String thisName = group1.getName(); // (String)
- // name1Field.get(group1);
- String thatName = group2.getName(); // (String)
- // name1Field.get(group2);
-
- Matcher m = lastDigit.matcher(thisName);
- Matcher m2 = lastDigit.matcher(thatName);
-
- String thisDigit = "0";
- String thatDigit = "0";
- if(m.find()) {
- thisDigit = m.group();
- } else {
- return -1;
- }
- if(m2.find()) {
- thatDigit = m2.group();
- } else {
- return 1;
- }
+ vfGroups.sort((group1, group2) -> {
+
+ // Field name1Field = group1.class.getDeclaredField("name");
+ // name1Field.setAccessible(true);
+ String thisName = group1.getName(); // (String)
+ // name1Field.get(group1);
+ String thatName = group2.getName(); // (String)
+ // name1Field.get(group2);
+
+ Matcher m = lastDigit.matcher(thisName);
+ Matcher m2 = lastDigit.matcher(thatName);
+
+ String thisDigit = "0";
+ String thatDigit = "0";
+ if (m.find()) {
+ thisDigit = m.group();
+ } else {
+ return -1;
+ }
+ if (m2.find()) {
+ thatDigit = m2.group();
+ } else {
+ return 1;
+ }
- return new Integer(thisDigit).compareTo(new Integer(thatDigit));
+ return new Integer(thisDigit).compareTo(new Integer(thatDigit));
- }
- });
+ });
logger.debug("vfGroupsAfter:" + vfGroups.toString());
@@ -636,7 +631,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller { return body;
}
- StringBuffer sb = new StringBuffer(body.length());
+ StringBuilder sb = new StringBuilder(body.length());
int currentIndex = 0;
int startIndex = 0;
@@ -878,7 +873,7 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller { String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
- if(vfModuleModelUUID != null && vfModuleModelUUID.indexOf(".") > -1){
+ if(vfModuleModelUUID != null && vfModuleModelUUID.contains(".")){
vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf("."));
}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java index bd20eb0bf1..0ae58dad41 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java @@ -631,7 +631,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { return body; } - StringBuffer sb = new StringBuffer(body.length()); + StringBuilder sb = new StringBuilder(body.length()); int currentIndex = 0; int startIndex = 0; diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java index 28f5dbdee5..396784add4 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java @@ -42,51 +42,15 @@ public class ASDCNotificationLogging { if (asdcNotification == null) { return "NULL"; } - StringBuffer buffer = new StringBuffer("ASDC Notification:"); - buffer.append(System.lineSeparator()); - - buffer.append("DistributionID:"); - buffer.append(testNull(asdcNotification.getDistributionID())); - buffer.append(System.lineSeparator()); - - - buffer.append("ServiceName:"); - buffer.append(testNull(asdcNotification.getServiceName())); - buffer.append(System.lineSeparator()); - - - buffer.append("ServiceVersion:"); - buffer.append(testNull(asdcNotification.getServiceVersion())); - buffer.append(System.lineSeparator()); - - - buffer.append("ServiceUUID:"); - buffer.append(testNull(asdcNotification.getServiceUUID())); - buffer.append(System.lineSeparator()); - - - buffer.append("ServiceInvariantUUID:"); - buffer.append(testNull(asdcNotification.getServiceInvariantUUID())); - buffer.append(System.lineSeparator()); - - - buffer.append("ServiceDescription:"); - buffer.append(testNull(asdcNotification.getServiceDescription())); - buffer.append(System.lineSeparator()); - - - buffer.append("Service Artifacts List:"); - buffer.append(System.lineSeparator()); - buffer.append(testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts()))); - buffer.append(System.lineSeparator()); - - buffer.append("Resource Instances List:"); - buffer.append(System.lineSeparator()); - buffer.append(testNull(dumpASDCResourcesList(asdcNotification))); - buffer.append(System.lineSeparator()); - - - return buffer.toString(); + return "ASDC Notification:" + System.lineSeparator() + + "DistributionID:" + testNull(asdcNotification.getDistributionID()) + System.lineSeparator() + + "ServiceName:" + testNull(asdcNotification.getServiceName()) + System.lineSeparator() + + "ServiceVersion:" + testNull(asdcNotification.getServiceVersion()) + System.lineSeparator() + + "ServiceUUID:" + testNull(asdcNotification.getServiceUUID()) + System.lineSeparator() + + "ServiceInvariantUUID:" + testNull(asdcNotification.getServiceInvariantUUID()) + System.lineSeparator() + + "ServiceDescription:" + testNull(asdcNotification.getServiceDescription()) + System.lineSeparator() + + "Service Artifacts List:" + System.lineSeparator() + testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts())) + System.lineSeparator() + + "Resource Instances List:" + System.lineSeparator() + testNull(dumpASDCResourcesList(asdcNotification)) + System.lineSeparator(); } public static String dumpCSARNotification(INotificationData asdcNotification, ToscaResourceStructure toscaResourceStructure) { @@ -96,7 +60,7 @@ public class ASDCNotificationLogging { } - StringBuffer buffer = new StringBuffer("CSAR Notification:"); + StringBuilder buffer = new StringBuilder("CSAR Notification:"); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); @@ -286,7 +250,7 @@ public class ASDCNotificationLogging { return null; } - StringBuffer buffer = new StringBuffer("VfModuleMetaData List:"); + StringBuilder buffer = new StringBuilder("VfModuleMetaData List:"); buffer.append(System.lineSeparator()); buffer.append("{"); @@ -311,71 +275,71 @@ public class ASDCNotificationLogging { return "NULL"; } - StringBuffer buffer = new StringBuffer("VfModuleMetaData:"); - buffer.append(System.lineSeparator()); + StringBuilder stringBuilder = new StringBuilder("VfModuleMetaData:"); + stringBuilder.append(System.lineSeparator()); - buffer.append("VfModuleModelName:"); - buffer.append(testNull(moduleMetaData.getVfModuleModelName())); - buffer.append(System.lineSeparator()); + stringBuilder.append("VfModuleModelName:"); + stringBuilder.append(testNull(moduleMetaData.getVfModuleModelName())); + stringBuilder.append(System.lineSeparator()); - buffer.append("VfModuleModelVersion:"); - buffer.append(testNull(moduleMetaData.getVfModuleModelVersion())); - buffer.append(System.lineSeparator()); + stringBuilder.append("VfModuleModelVersion:"); + stringBuilder.append(testNull(moduleMetaData.getVfModuleModelVersion())); + stringBuilder.append(System.lineSeparator()); - buffer.append("VfModuleModelUUID:"); - buffer.append(testNull(moduleMetaData.getVfModuleModelUUID())); - buffer.append(System.lineSeparator()); + stringBuilder.append("VfModuleModelUUID:"); + stringBuilder.append(testNull(moduleMetaData.getVfModuleModelUUID())); + stringBuilder.append(System.lineSeparator()); - buffer.append("VfModuleModelInvariantUUID:"); - buffer.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID())); - buffer.append(System.lineSeparator()); + stringBuilder.append("VfModuleModelInvariantUUID:"); + stringBuilder.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID())); + stringBuilder.append(System.lineSeparator()); - buffer.append("VfModuleModelDescription:"); - buffer.append(testNull(moduleMetaData.getVfModuleModelDescription())); - buffer.append(System.lineSeparator()); + stringBuilder.append("VfModuleModelDescription:"); + stringBuilder.append(testNull(moduleMetaData.getVfModuleModelDescription())); + stringBuilder.append(System.lineSeparator()); - buffer.append("Artifacts UUID List:"); + stringBuilder.append("Artifacts UUID List:"); if (moduleMetaData.getArtifacts() != null) { - buffer.append("{"); + stringBuilder.append("{"); for (String artifactUUID:moduleMetaData.getArtifacts()) { - buffer.append(System.lineSeparator()); - buffer.append(testNull(artifactUUID)); - buffer.append(System.lineSeparator()); - buffer.append(","); + stringBuilder.append(System.lineSeparator()); + stringBuilder.append(testNull(artifactUUID)); + stringBuilder.append(System.lineSeparator()); + stringBuilder.append(","); } - buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator()); - buffer.append("}"); - buffer.append(System.lineSeparator()); + stringBuilder.replace(stringBuilder.length()-1,stringBuilder.length(), System.lineSeparator()); + stringBuilder.append("}"); + stringBuilder.append(System.lineSeparator()); } else { - buffer.append("NULL"); + stringBuilder.append("NULL"); } if (moduleMetaData.getProperties() != null) { Map<String, String> vfModuleMap = moduleMetaData.getProperties(); - buffer.append("Properties List:"); - buffer.append("{"); + stringBuilder.append("Properties List:"); + stringBuilder.append("{"); for (Map.Entry<String, String> entry : vfModuleMap.entrySet()) { - buffer.append(System.lineSeparator()); - buffer.append(" " + entry.getKey() + " : " + entry.getValue()); + stringBuilder.append(System.lineSeparator()); + stringBuilder.append(" ").append(entry.getKey()).append(" : ").append(entry.getValue()); } - buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator()); - buffer.append("}"); - buffer.append(System.lineSeparator()); + stringBuilder.replace(stringBuilder.length()-1,stringBuilder.length(), System.lineSeparator()); + stringBuilder.append("}"); + stringBuilder.append(System.lineSeparator()); } else { - buffer.append("NULL"); + stringBuilder.append("NULL"); } - buffer.append(System.lineSeparator()); + stringBuilder.append(System.lineSeparator()); - buffer.append("isBase:"); - buffer.append(moduleMetaData.isBase()); - buffer.append(System.lineSeparator()); + stringBuilder.append("isBase:"); + stringBuilder.append(moduleMetaData.isBase()); + stringBuilder.append(System.lineSeparator()); - return buffer.toString(); + return stringBuilder.toString(); } private static String testNull(Object object) { @@ -395,7 +359,7 @@ public class ASDCNotificationLogging { return null; } - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); buffer.append("{"); for (IResourceInstance resourceInstanceElem:asdcNotification.getResources()) { @@ -418,52 +382,17 @@ public class ASDCNotificationLogging { return null; } - StringBuffer buffer = new StringBuffer("Resource Instance Info:"); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceInstanceName:"); - buffer.append(testNull(resourceInstance.getResourceInstanceName())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceCustomizationUUID:"); - buffer.append(testNull(resourceInstance.getResourceCustomizationUUID())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceInvariantUUID:"); - buffer.append(testNull(resourceInstance.getResourceInvariantUUID())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceName:"); - buffer.append(testNull(resourceInstance.getResourceName())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceType:"); - buffer.append(testNull(resourceInstance.getResourceType())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceUUID:"); - buffer.append(testNull(resourceInstance.getResourceUUID())); - buffer.append(System.lineSeparator()); - - buffer.append("ResourceVersion:"); - buffer.append(testNull(resourceInstance.getResourceVersion())); - buffer.append(System.lineSeparator()); - - buffer.append("Category:"); - buffer.append(testNull(resourceInstance.getCategory())); - buffer.append(System.lineSeparator()); - - buffer.append("SubCategory:"); - buffer.append(testNull(resourceInstance.getSubcategory())); - buffer.append(System.lineSeparator()); - - buffer.append("Resource Artifacts List:"); - buffer.append(System.lineSeparator()); - buffer.append(testNull(dumpArtifactInfoList(resourceInstance.getArtifacts()))); - buffer.append(System.lineSeparator()); - - return buffer.toString(); - + return "Resource Instance Info:" + System.lineSeparator() + + "ResourceInstanceName:" + testNull(resourceInstance.getResourceInstanceName()) + System.lineSeparator() + + "ResourceCustomizationUUID:" + testNull(resourceInstance.getResourceCustomizationUUID()) + System.lineSeparator() + + "ResourceInvariantUUID:" + testNull(resourceInstance.getResourceInvariantUUID()) + System.lineSeparator() + + "ResourceName:" + testNull(resourceInstance.getResourceName()) + System.lineSeparator() + + "ResourceType:" + testNull(resourceInstance.getResourceType()) + System.lineSeparator() + + "ResourceUUID:" + testNull(resourceInstance.getResourceUUID()) + System.lineSeparator() + + "ResourceVersion:" + testNull(resourceInstance.getResourceVersion()) + System.lineSeparator() + + "Category:" + testNull(resourceInstance.getCategory()) + System.lineSeparator() + + "SubCategory:" + testNull(resourceInstance.getSubcategory()) + System.lineSeparator() + + "Resource Artifacts List:" + System.lineSeparator() + testNull(dumpArtifactInfoList(resourceInstance.getArtifacts())) + System.lineSeparator(); } @@ -473,7 +402,7 @@ public class ASDCNotificationLogging { return null; } - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); buffer.append("{"); for (IArtifactInfo artifactInfoElem:artifactsList) { buffer.append(System.lineSeparator()); @@ -495,7 +424,7 @@ public class ASDCNotificationLogging { return null; } - StringBuffer buffer = new StringBuffer("Service Artifacts Info:"); + StringBuilder buffer = new StringBuilder("Service Artifacts Info:"); buffer.append(System.lineSeparator()); buffer.append("ArtifactName:"); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java index 9b38a50daf..f9871b745a 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java @@ -43,19 +43,15 @@ public class NotificationLogging implements InvocationHandler { private static Map<Object, List<Method>> objectMethodsToLog = new HashMap<>(); protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); - - private static InvocationHandler handler = new InvocationHandler() { - @Override - public Object invoke(Object arg0, Method arg1, Object[] arg2) - throws Throwable { - List<Method> methods = objectMethodsToLog.get(arg0); - if ((methods == null) || (methods.isEmpty())) { - // Do nothing for now... - return null; - } - methods.add(arg1); - return arg1.invoke(arg0, arg2); + + private static InvocationHandler handler = (arg0, arg1, arg2) -> { + List<Method> methods = objectMethodsToLog.get(arg0); + if ((methods == null) || (methods.isEmpty())) { + // Do nothing for now... + return null; } + methods.add(arg1); + return arg1.invoke(arg0, arg2); }; public static InvocationHandler getHandler() { @@ -82,7 +78,7 @@ public class NotificationLogging implements InvocationHandler { return "EMPTY"; // No declared methods in this class !!! } - StringBuffer buffer = new StringBuffer("ASDC Notification:"); + StringBuilder buffer = new StringBuilder("ASDC Notification:"); buffer.append(System.lineSeparator()); for (Method m : declaredMethods) { @@ -107,7 +103,7 @@ public class NotificationLogging implements InvocationHandler { return buffer.toString(); } - private static final boolean isGetter(Method method) { + private static boolean isGetter(Method method) { // Must start with a valid (and known) prefix boolean prefixFound = false; @@ -156,7 +152,7 @@ public class NotificationLogging implements InvocationHandler { INotificationData.class.getClassLoader(), new Class[] { INotificationData.class }, NotificationLogging.getHandler()); - objectMethodsToLog.put(proxy, new ArrayList<Method>()); + objectMethodsToLog.put(proxy, new ArrayList<>()); } private static <T> void methodToLog(T methodCall) { diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java index f94e0a153b..f6f1af5da6 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java @@ -58,7 +58,7 @@ public class YamlEditor { } public synchronized List <String> getYamlNestedFileResourceTypeList () { - List <String> typeList = new ArrayList <String> (); + List <String> typeList = new ArrayList<>(); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("resources"); @@ -78,16 +78,14 @@ public class YamlEditor { } public synchronized List <String> getYamlResourceTypeList () { - List <String> typeList = new ArrayList <String> (); + List <String> typeList = new ArrayList<>(); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("resources"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> pair : resourceMap.entrySet()) { @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); - typeList.add (resourceEntry.get ("type")); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); + typeList.add(resourceEntry.get("type")); } return typeList; } @@ -97,31 +95,30 @@ public class YamlEditor { // Within Heat Template, under parameters catalog, it might indicate the default value of the parameter // If default value exist, the parameter is not mandatory, otherwise its value should be set public synchronized Set <HeatTemplateParam> getParameterList (String artifactUUID) { - Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> (); + Set <HeatTemplateParam> paramSet = new HashSet<>(); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - HeatTemplateParam param = new HeatTemplateParam (); - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + HeatTemplateParam param = new HeatTemplateParam(); + Entry<String, Object> pair = stringObjectEntry; @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); - - param.setParamName (pair.getKey ()); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); + + param.setParamName(pair.getKey()); // System.out.println(pair.getKey()+":"+type); if (resourceEntry.containsKey("default")) { - param.setRequired (false); + param.setRequired(false); } else { - param.setRequired (true); + param.setRequired(true); } // Now set the type - String value = resourceEntry.get ("type"); - param.setParamType (value); - + String value = resourceEntry.get("type"); + param.setParamType(value); + param.setHeatTemplateArtifactUuid(artifactUUID); - paramSet.add (param); + paramSet.add(param); } return paramSet; @@ -133,11 +130,11 @@ public class YamlEditor { @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); if (resourceMap == null) { - resourceMap = new LinkedHashMap <String, Object> (); + resourceMap = new LinkedHashMap<>(); this.yml.put ("parameters", resourceMap); } for (HeatTemplateParam heatParam : heatSet) { - Map <String, Object> paramInfo = new HashMap <String, Object> (); + Map <String, Object> paramInfo = new HashMap<>(); paramInfo.put ("type", heatParam.getParamType ()); resourceMap.put (heatParam.getParamName (), paramInfo); diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java index 45bd7cff8b..5026b51bd1 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java @@ -117,7 +117,7 @@ public class ASDCControllerTest { Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); // Now provision the NotificationData mock - List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>(); + List<IArtifactInfo> listArtifact = new ArrayList<>(); listArtifact.add(artifactInfo1); // Create fake resource Instance diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java index b752cfbb45..73c5456d29 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java @@ -109,7 +109,7 @@ public class ASDCGlobalControllerTest { Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); // Now provision the NotificationData mock - List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>(); + List<IArtifactInfo> listArtifact = new ArrayList<>(); listArtifact.add(artifactInfo1); // Create fake resource Instance diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java index d7c8315d3a..589968ece4 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java @@ -76,7 +76,7 @@ public class YamlTest { InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml")); YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input)); - Set <HeatTemplateParam> newParamSet = new HashSet <HeatTemplateParam> (); + Set <HeatTemplateParam> newParamSet = new HashSet<>(); HeatTemplateParam heatParam1 = new HeatTemplateParam(); heatParam1.setHeatTemplateArtifactUuid("1"); @@ -108,7 +108,7 @@ public class YamlTest { InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml")); YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input)); - Set <HeatTemplateParam> newParamSet = new HashSet <HeatTemplateParam> (); + Set <HeatTemplateParam> newParamSet = new HashSet<>(); HeatTemplateParam heatParam1 = new HeatTemplateParam(); heatParam1.setHeatTemplateArtifactUuid("1"); diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java index a4563c66ac..9c20a084c3 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java @@ -143,7 +143,7 @@ public class ToscaResourceInstallerTest { distributionClient = Mockito.mock(IDistributionClient.class);
// Now provision the NotificationData mock
- List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> listArtifact = new ArrayList<>();
listArtifact.add(artifactInfo1);
// Create fake resource Instance
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java index c4ada7437e..e2239dc952 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java @@ -121,7 +121,7 @@ public class VfResourceInstallerTest { distributionClient = Mockito.mock(IDistributionClient.class);
// Now provision the NotificationData mock
- List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> listArtifact = new ArrayList<>();
listArtifact.add(artifactInfo1);
// Create fake resource Instance
diff --git a/bpmn/MSOCockpit/pom.xml b/bpmn/MSOCockpit/pom.xml index 7557f5e8ce..e64f68bad0 100644 --- a/bpmn/MSOCockpit/pom.xml +++ b/bpmn/MSOCockpit/pom.xml @@ -1,13 +1,13 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>bpmn</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCockpit</artifactId>
<packaging>pom</packaging>
<name>MSOCockpit</name>
@@ -47,17 +47,17 @@ </dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>cockpit-urnmap-plugin</artifactId>
<version>${project.version}</version>
</dependency> -->
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCoreBPMN</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 4a7cb5900a..71626f52b3 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -4,7 +4,7 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> @@ -264,20 +264,20 @@ <version>3.4</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>MSOCoreBPMN</artifactId> <version>${project.version}</version> </dependency> <dependency> <!-- unit test utilities --> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>MSOCoreBPMN</artifactId> <version>${project.version}</version> <classifier>tests</classifier> <scope>test</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> @@ -287,7 +287,7 @@ <version>2.0</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>MSORESTClient</artifactId> <version>${project.version}</version> </dependency> @@ -501,5 +501,16 @@ <artifactId>guava</artifactId> <version>22.0</version> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.9.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>pl.pragmatists</groupId> + <artifactId>JUnitParams</artifactId> + <version>1.1.1</version> + </dependency> </dependencies> </project> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy index 50e761eb77..921e0ee00d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy @@ -694,6 +694,49 @@ class CatalogDbUtils { return vnfsList
}
+ public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) {
+ JSONObject resources = null
+ String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ try {
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
+
+ if (catalogDbResponse != null) {
+
+ resources = parseServiceResourcesJson(catalogDbResponse, "v1")
+ }
+
+ }
+ catch (Exception e) {
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+
+ return resources
+ }
+
+ public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
+ JSONObject resources = null
+ String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ try {
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
+
+ if (catalogDbResponse != null) {
+ if (!catalogUtilsVersion.equals("v1")) {
+ resources = new JSONObject(catalogDbResponse)
+ }
+ else {
+ resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
+ }
+ }
+
+ }
+ catch (Exception e) {
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+
+ return resources
+ }
+
+
public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
JSONObject resources = null
String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
@@ -1160,4 +1203,25 @@ class CatalogDbUtils { }
}
+
+ /**
+ * get resource recipe by resource model uuid and action
+ */
+ public JSONObject getResourceRecipe(Execution execution, String resourceModelUuid, String action) {
+ String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8")
+ JSONObject responseJson = null
+ try {
+ msoLogger.debug("ENDPOINT: " + endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
+
+ if (catalogDbResponse != null) {
+ responseJson = new JSONObject(catalogDbResponse)
+ }
+ }
+ catch (Exception e) {
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+
+ return responseJson
+ }
}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy index 2645ea3c02..8d855e9311 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy @@ -77,6 +77,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") String serviceModelInfo = execution.getVariable("serviceModelInfo") execution.setVariable("DDS_serviceModelInvariantId", jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")) + execution.setVariable("DDS_serviceModelUuid", jsonUtils.getJsonValue(serviceModelInfo, "modelUuid")) execution.setVariable("DDS_modelVersion", jsonUtils.getJsonValue(serviceModelInfo, "modelVersion")) } catch (BpmnError e) { throw e; @@ -97,14 +98,16 @@ public class DecomposeService extends AbstractServiceTaskProcessor { // check for input String serviceModelInvariantId = execution.getVariable("DDS_serviceModelInvariantId") + String serviceModelUuid = execution.getVariable("DDS_serviceModelUuid") String modelVersion = execution.getVariable("DDS_modelVersion") utils.log("DEBUG", "serviceModelInvariantId: " + serviceModelInvariantId, isDebugEnabled) utils.log("DEBUG", "modelVersion: " + modelVersion, isDebugEnabled) JSONObject catalogDbResponse = null - - if (modelVersion != null && modelVersion.length() > 0) + if(serviceModelUuid != null && serviceModelUuid.length() > 0) + catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, serviceModelUuid, "v2") + else if (modelVersion != null && modelVersion.length() > 0) catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(execution, serviceModelInvariantId, modelVersion, "v2") else catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuid(execution, serviceModelInvariantId, "v2") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy index d97a304e16..121e0c8ccb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy @@ -1,398 +1,396 @@ -/*-
- * ============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.bpmn.common.scripts
-
-import static org.apache.commons.lang3.StringUtils.*
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
-import org.openecomp.mso.bpmn.core.WorkflowException
-
-/**
- * @version 1.0
- */
-class ExceptionUtil extends AbstractServiceTaskProcessor {
-
-
- /**
- * This error handling method maps an AAI Exception response to a
- * WorkflowException Object. It then sets the WorkflowException Object
- * on the execution as "WorkflowException".
- *
- * This method formats the exception from AAI into the WorkflowException's
- * errorMessage that CCD expects.
- *
- * @param execution the execution
- * @param response the aai exception
- */
- WorkflowException MapAAIExceptionToWorkflowException(String response, Execution execution)
- {
- def utils=new MsoUtils()
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- def prefix=execution.getVariable("prefix")
- def errorMsg = execution.getVariable(prefix+"ErrorResponse")
- utils.log("DEBUG","=========== Begin MapAAIExceptionToWorkflowException ===========",isDebugEnabled)
- String text = null
- def variables
- String errorCode = '5000'
- WorkflowException wfex
- utils.log("DEBUG","response: " + response, isDebugEnabled)
- try{
- try {
- //String msg = utils.getNodeXml(response, "Fault")
- variables = utils.getMultNodes(response, "variable")
- text = utils.getNodeText1(response, "text")
- } catch (Exception ex) {
- //Ignore the exception - cases include non xml payload
- utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugEnabled)
- }
-
- if(text != null) {
- if(variables.size()>=4){
- text = text.replaceFirst("%1", variables[0])
- text = text.replaceFirst("%2", variables[1])
- text = text.replaceFirst("%3", variables[2])
- text = text.replaceFirst("%4", variables[3])
- }
- String modifiedErrorMessage = 'Received error from A&AI (' + text +')'
- utils.log("DEBUG", "ModifiedErrorMessage " + modifiedErrorMessage, isDebugEnabled)
- // let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')')
- buildWorkflowException(execution, 5000, modifiedErrorMessage)
-
- wfex = execution.getVariable("WorkflowException")
- utils.log("ERROR","Fault:"+ wfex)
- return wfex
- } else {
- try {
- errorCode = MapErrorCode(errorMsg)
- String mappedErrorMessage = MapErrorMessage(errorMsg, errorCode)
-
- int errorCodeInt = Integer.parseInt(errorCode)
- buildWorkflowException(execution, errorCodeInt, mappedErrorMessage)
-
- utils.log("DEBUG", "mappedErrorMessage " + mappedErrorMessage, isDebugEnabled)
- wfex = execution.getVariable("WorkflowException")
- utils.log("ERROR","Fault:"+ wfex, isDebugEnabled)
- return wfex
- } catch(Exception ex) {
- utils.log("DEBUG","error mapping error, return null: " + ex, isDebugEnabled)
- return null
-
- }
- }
- }catch(Exception e){
- utils.log("DEBUG", "Exception occured during MapAAIExceptionToWorkflowException: " + e, isDebugEnabled)
- buildWorkflowException(execution, 5000, "Error mapping AAI Response to WorkflowException")
- }
- }
-
- /**
- * This error handling method maps an AAI Exception response to a
- * WorkflowException Object. It then sets the WorkflowException Object
- * on the execution as "WorkflowException".
- *
- * This method takes the exact exception inside the <Fault> tags from AAI Response
- * and puts it into the WorkflowException's errorMessage.
- *
- * @param execution the execution
- * @param response the aai exception
- */
- WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(Execution execution, String response, int resCode){
- def utils=new MsoUtils()
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", "Start MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled)
-
- WorkflowException wfex
- try {
- if(utils.nodeExists(response, "Fault")){
- String fault = utils.getNodeXml(response, "Fault")
- fault = utils.removeXmlPreamble(fault)
- fault = fault.replace("<Fault>", "").replace("</Fault>", "")
- fault = fault.replaceAll("\\s+\\s+", "") // Removes extra white spaces
- buildWorkflowException(execution, resCode, fault)
- }else if(utils.nodeExists(response, "RESTFault")){
- String rFault = utils.getNodeXml(response, "RESTFault")
- buildWorkflowException(execution, resCode, rFault)
- }else{
- buildWorkflowException(execution, resCode, "Received a bad response from AAI")
- }
- } catch (Exception ex) {
- utils.log("DEBUG", "Exception Occured during MapAAIExceptionToWorkflowExceptionGeneric: " + ex, isDebugLogEnabled)
- buildWorkflowException(execution, resCode, "Internal Error - Occured in MapAAIExceptionToWorkflowExceptionGeneric")
-
- }
- utils.log("DEBUG", "Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugLogEnabled)
- utils.log("DEBUG", "Completed MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled)
- }
-
- /**
- * This method takes a WorkflowException Object and builds
- * WorkflowException Xml. This method should only be used
- * for the purpose of sending a sync error response or for
- * creating a FalloutHandler request.
- *
- *@param - WorkflowException Object
- *
- *@return - String WorkflowException Xml
- *
- *
- */
- String buildErrorResponseXml(WorkflowException wfex) {
- String xml
- if(wfex != null){
- String mes = wfex.getErrorMessage()
- int code = wfex.getErrorCode()
- xml =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${mes}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${code}</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- }else{
- xml =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>Internal Error</aetgt:ErrorMessage>
- <aetgt:ErrorCode>2500</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
- }
- return xml
- }
-
- /*
- 5000 Received error from A&AI ($A&AI_ERROR) Asynchronous During orchestration of the recipe, A&AI returned an error. The error returned by A&AI is passed through in $A&AI_ERROR.
- 5010 Could not communicate with A&AI Asynchronous During orchestration of the recipe, a connection with A&AI could not be established.
- 5020 No response from A&AI Asynchronous During orchestration of the recipe, communication was established with A&AI, but no response was received within the configured timeout.
- */
- /**
- *
- * Utility Method for MapAAIExceptionToWorkflowException
- *
- *@param - String ErrorMessage
- *
- *@return - String ErrorCode
- *
- */
- private String MapErrorCode(String errorMessage)
- {
- if(errorMessage==null){
- return '5000'
- }
- errorMessage = errorMessage.toLowerCase();
- if(errorMessage.contains('timed out') || errorMessage.contains('timeout'))
- return '5020'
- else if (errorMessage.contains('connection'))
- return '5010'
- else
- return '5000'
- }
-
- /**
- *
- * Utility Method for MapAAIExceptionToWorkflowException
- *
- *@param - String ErrorMessage
- *@param - String ErrorCode
- *
- *@return - String ErrorMessage
- *
- */
- private String MapErrorMessage(String errorMessage, String errorCode)
- {
- if(errorMessage == null){
- errorMessage=""
- }
- if( errorCode.equals('5010')){
- return 'Could not communicate with A&AI'
- }else if (errorCode.equals('5020')){
- return 'No response from A&AI'
- }else{
- errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">")
- return 'Received error from A&AI (' +errorMessage +')'
- }
- }
-
- /**
- *
- * Utility Method for Mapping SDNC
- * Adapter Response Codes
- *
- *@param - String sdncResponseCode
- *
- *@return - String code
- *
- */
- String MapSDNCResponseCodeToErrorCode(String sdncResponseCode)
- {
- if (sdncResponseCode == '500') {
- return '5310'
- } else if ( sdncResponseCode == '408') {
- return '5320'
- } else if ( sdncResponseCode == '60010') {
- return '5350'
- } else {
- return '5300'
- }
- }
-
- /**
- * This error handling method builds a WorkflowException Object. It sets it on
- * the execution as "WorkflowException".
- *
- * @param execution the execution
- * @param errorCode the error code
- * @param errorMessage the error message
- */
- public void buildWorkflowException(Execution execution, int errorCode, String errorMessage) {
- MsoUtils utils = new MsoUtils()
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- String processKey = getProcessKey(execution);
- utils.log("DEBUG", "Building a WorkflowException for " + processKey, isDebugLogEnabled)
-
- WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage);
- execution.setVariable("WorkflowException", exception);
- utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled)
- }
-
- /**
- * This error handling method builds a WorkflowException Object and throws a
- * MSOWorkflowException. It throws a "MSOWorkflowException" BpmnError after
- * setting the WorkflowException Object on the execution as "WorkflowException".
- *
- * @param execution the execution
- * @param errorCode the error code
- * @param errorMessage the error message
- */
- public void buildAndThrowWorkflowException(Execution execution, int errorCode, String errorMessage) {
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- String processKey = getProcessKey(execution);
- utils.log("Building a WorkflowException for Subflow " + processKey, isDebugLogEnabled)
-
- WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage);
- execution.setVariable("WorkflowException", exception);
- utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled)
- utils.log("DEBUG", "Throwing MSOWorkflowException", isDebugLogEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
-
- /**
- * This method is executed after an MSOWorkflowException is caught by a
- * subflow (during subflows "Error Handling Sub Process").
- * It ensures the WorkflowException variable is populated before ending the
- * subflow and also logs the subflows outgoing WorkflowException Variable.
- *
- * @param - execution
- *
- */
- public void processSubflowsBPMNException(Execution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String processKey = getProcessKey(execution)
- try{
- utils.log("DEBUG", "Started ProcessSubflowsBPMNException Method", isDebugEnabled)
- if(execution.getVariable("WorkflowException") == null){
- buildWorkflowException(execution, 2500, "Internal Error - Occured During " + processKey)
- }
-
- utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during ProcessSubflowsBPMNException Method: " + e, isDebugEnabled)
- }
- utils.log("DEBUG", "Completed ProcessSubflowsBPMNException Method", isDebugEnabled)
- }
-
- /**
- * This method is executed after an MSOWorkflowException is caught by a
- * Mainflow. It builds and returns a FalloutHandler Request. It also
- * verifies the WorkflowException variable is populated.
- *
- * @param - execution
- * @param - requestInfo
- *
- * @return - falloutHandlerRequest
- *
- */
- public String processMainflowsBPMNException(Execution execution, String requestInfo){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String processKey = getProcessKey(execution)
- try{
- utils.log("DEBUG", "Started ProcessMainflowBPMNException Method", isDebugEnabled)
- if(execution.getVariable("WorkflowException") == null || isBlank(requestInfo)){
- buildWorkflowException(execution, 2500, "Internal Error - WorkflowException Object and/or RequestInfo is null! " + processKey)
- }
- requestInfo = utils.removeXmlPreamble(requestInfo)
- WorkflowException wfex = execution.getVariable("WorkflowException")
- String errorMessage = wfex.getErrorMessage()
- int errorCode = wfex.getErrorCode()
-
- String falloutHandlerRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- ${requestInfo}
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)
- utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled)
-
- return falloutHandlerRequest
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled)
- return null
- }
- utils.log("DEBUG", "Completed ProcessMainflowBPMNException Method", isDebugEnabled)
- }
-
- /**
- *
- * This method is executed after an Java Exception is caught
- * It sets the WorkflowException variable. The method can be used in either mainflow or subflows.
- *
- * @param - execution
- *
- */
- public void processJavaException(Execution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String processKey = getProcessKey(execution)
- try{
- utils.log("DEBUG", "Caught a Java Exception in " + processKey, isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- buildWorkflowException(execution, 2500, "Catch a Java Lang Exception in " + processKey)
-
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- buildWorkflowException(execution, 2500, "Internal Error - During Process Java Exception")
- }
- utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
- }
-
-
- public void preProcessRequest(Execution execution) {
- // TODO Auto-generated method stub
-
- }
-}
+/*- + * ============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.bpmn.common.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.core.WorkflowException + +/** + * @version 1.0 + */ +class ExceptionUtil extends AbstractServiceTaskProcessor { + + + /** + * This error handling method maps an AAI Exception response to a + * WorkflowException Object. It then sets the WorkflowException Object + * on the execution as "WorkflowException". + * + * This method formats the exception from AAI into the WorkflowException's + * errorMessage that CCD expects. + * + * @param execution the execution + * @param response the aai exception + */ + WorkflowException MapAAIExceptionToWorkflowException(String response, Execution execution) + { + def utils=new MsoUtils() + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def prefix=execution.getVariable("prefix") + def errorMsg = execution.getVariable(prefix+"ErrorResponse") + utils.log("DEBUG","=========== Begin MapAAIExceptionToWorkflowException ===========",isDebugEnabled) + String text = null + def variables + String errorCode = '5000' + WorkflowException wfex + utils.log("DEBUG","response: " + response, isDebugEnabled) + try{ + try { + //String msg = utils.getNodeXml(response, "Fault") + variables = utils.getMultNodes(response, "variable") + text = utils.getNodeText1(response, "text") + } catch (Exception ex) { + //Ignore the exception - cases include non xml payload + utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugEnabled) + } + + if(text != null) { + if(variables.size()>=4){ + text = text.replaceFirst("%1", variables[0]) + text = text.replaceFirst("%2", variables[1]) + text = text.replaceFirst("%3", variables[2]) + text = text.replaceFirst("%4", variables[3]) + } + String modifiedErrorMessage = 'Received error from A&AI (' + text +')' + utils.log("DEBUG", "ModifiedErrorMessage " + modifiedErrorMessage, isDebugEnabled) + // let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')') + buildWorkflowException(execution, 5000, modifiedErrorMessage) + + wfex = execution.getVariable("WorkflowException") + utils.log("ERROR","Fault:"+ wfex) + return wfex + } else { + try { + errorCode = MapErrorCode(errorMsg) + String mappedErrorMessage = MapErrorMessage(errorMsg, errorCode) + + int errorCodeInt = Integer.parseInt(errorCode) + buildWorkflowException(execution, errorCodeInt, mappedErrorMessage) + + utils.log("DEBUG", "mappedErrorMessage " + mappedErrorMessage, isDebugEnabled) + wfex = execution.getVariable("WorkflowException") + utils.log("ERROR","Fault:"+ wfex, isDebugEnabled) + return wfex + } catch(Exception ex) { + utils.log("DEBUG","error mapping error, return null: " + ex, isDebugEnabled) + return null + + } + } + }catch(Exception e){ + utils.log("DEBUG", "Exception occured during MapAAIExceptionToWorkflowException: " + e, isDebugEnabled) + buildWorkflowException(execution, 5000, "Error mapping AAI Response to WorkflowException") + } + } + + /** + * This error handling method maps an AAI Exception response to a + * WorkflowException Object. It then sets the WorkflowException Object + * on the execution as "WorkflowException". + * + * This method takes the exact exception inside the <Fault> tags from AAI Response + * and puts it into the WorkflowException's errorMessage. + * + * @param execution the execution + * @param response the aai exception + */ + WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(Execution execution, String response, int resCode){ + def utils=new MsoUtils() + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", "Start MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled) + + WorkflowException wfex + try { + if(utils.nodeExists(response, "Fault")){ + String fault = utils.getNodeXml(response, "Fault") + fault = utils.removeXmlPreamble(fault) + fault = fault.replace("<Fault>", "").replace("</Fault>", "") + fault = fault.replaceAll("\\s+\\s+", "") // Removes extra white spaces + buildWorkflowException(execution, resCode, fault) + }else if(utils.nodeExists(response, "RESTFault")){ + String rFault = utils.getNodeXml(response, "RESTFault") + buildWorkflowException(execution, resCode, rFault) + }else{ + buildWorkflowException(execution, resCode, "Received a bad response from AAI") + } + } catch (Exception ex) { + utils.log("DEBUG", "Exception Occured during MapAAIExceptionToWorkflowExceptionGeneric: " + ex, isDebugLogEnabled) + buildWorkflowException(execution, resCode, "Internal Error - Occured in MapAAIExceptionToWorkflowExceptionGeneric") + + } + utils.log("DEBUG", "Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugLogEnabled) + utils.log("DEBUG", "Completed MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled) + } + + /** + * This method takes a WorkflowException Object and builds + * WorkflowException Xml. This method should only be used + * for the purpose of sending a sync error response or for + * creating a FalloutHandler request. + * + *@param - WorkflowException Object + * + *@return - String WorkflowException Xml + * + * + */ + String buildErrorResponseXml(WorkflowException wfex) { + String xml + if(wfex != null){ + String mes = wfex.getErrorMessage() + int code = wfex.getErrorCode() + xml = + """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${mes}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${code}</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + + }else{ + xml = + """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>Internal Error</aetgt:ErrorMessage> + <aetgt:ErrorCode>2500</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + } + return xml + } + + /* + 5000 Received error from A&AI ($A&AI_ERROR) Asynchronous During orchestration of the recipe, A&AI returned an error. The error returned by A&AI is passed through in $A&AI_ERROR. + 5010 Could not communicate with A&AI Asynchronous During orchestration of the recipe, a connection with A&AI could not be established. + 5020 No response from A&AI Asynchronous During orchestration of the recipe, communication was established with A&AI, but no response was received within the configured timeout. + */ + /** + * + * Utility Method for MapAAIExceptionToWorkflowException + * + *@param - String ErrorMessage + * + *@return - String ErrorCode + * + */ + private String MapErrorCode(String errorMessage) + { + if(errorMessage==null){ + return '5000' + } + errorMessage = errorMessage.toLowerCase(); + if(errorMessage.contains('timed out') || errorMessage.contains('timeout')) + return '5020' + else if (errorMessage.contains('connection')) + return '5010' + else + return '5000' + } + + /** + * + * Utility Method for MapAAIExceptionToWorkflowException + * + *@param - String ErrorMessage + *@param - String ErrorCode + * + *@return - String ErrorMessage + * + */ + private String MapErrorMessage(String errorMessage, String errorCode) + { + if(errorMessage == null){ + errorMessage="" + } + if( errorCode.equals('5010')){ + return 'Could not communicate with A&AI' + }else if (errorCode.equals('5020')){ + return 'No response from A&AI' + }else{ + errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">") + return 'Received error from A&AI (' +errorMessage +')' + } + } + + /** + * + * Utility Method for Mapping SDNC + * Adapter Response Codes + * + *@param - String sdncResponseCode + * + *@return - String code + * + */ + String MapSDNCResponseCodeToErrorCode(String sdncResponseCode) + { + if (sdncResponseCode == '500') { + return '5310' + } else if ( sdncResponseCode == '408') { + return '5320' + } else if ( sdncResponseCode == '60010') { + return '5350' + } else { + return '5300' + } + } + + /** + * This error handling method builds a WorkflowException Object. It sets it on + * the execution as "WorkflowException". + * + * @param execution the execution + * @param errorCode the error code + * @param errorMessage the error message + */ + public void buildWorkflowException(Execution execution, int errorCode, String errorMessage) { + MsoUtils utils = new MsoUtils() + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + utils.log("DEBUG", "Building a WorkflowException for " + processKey, isDebugLogEnabled) + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled) + } + + /** + * This error handling method builds a WorkflowException Object and throws a + * MSOWorkflowException. It throws a "MSOWorkflowException" BpmnError after + * setting the WorkflowException Object on the execution as "WorkflowException". + * + * @param execution the execution + * @param errorCode the error code + * @param errorMessage the error message + */ + public void buildAndThrowWorkflowException(Execution execution, int errorCode, String errorMessage) { + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + String processKey = getProcessKey(execution); + utils.log("Building a WorkflowException for Subflow " + processKey, isDebugLogEnabled) + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + utils.log("DEBUG", "Outgoing WorkflowException is " + exception, isDebugLogEnabled) + utils.log("DEBUG", "Throwing MSOWorkflowException", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + + /** + * This method is executed after an MSOWorkflowException is caught by a + * subflow (during subflows "Error Handling Sub Process"). + * It ensures the WorkflowException variable is populated before ending the + * subflow and also logs the subflows outgoing WorkflowException Variable. + * + * @param - execution + * + */ + public void processSubflowsBPMNException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Started ProcessSubflowsBPMNException Method", isDebugEnabled) + if(execution.getVariable("WorkflowException") == null){ + buildWorkflowException(execution, 2500, "Internal Error - Occured During " + processKey) + } + + utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during ProcessSubflowsBPMNException Method: " + e, isDebugEnabled) + } + utils.log("DEBUG", "Completed ProcessSubflowsBPMNException Method", isDebugEnabled) + } + + /** + * This method is executed after an MSOWorkflowException is caught by a + * Mainflow. It builds and returns a FalloutHandler Request. It also + * verifies the WorkflowException variable is populated. + * + * @param - execution + * @param - requestInfo + * + * @return - falloutHandlerRequest + * + */ + public String processMainflowsBPMNException(Execution execution, String requestInfo){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Started ProcessMainflowBPMNException Method", isDebugEnabled) + if(execution.getVariable("WorkflowException") == null || isBlank(requestInfo)){ + buildWorkflowException(execution, 2500, "Internal Error - WorkflowException Object and/or RequestInfo is null! " + processKey) + } + requestInfo = utils.removeXmlPreamble(requestInfo) + WorkflowException wfex = execution.getVariable("WorkflowException") + String errorMessage = wfex.getErrorMessage() + int errorCode = wfex.getErrorCode() + + String falloutHandlerRequest = + """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" + xmlns:ns="http://org.openecomp/mso/request/types/v1" + xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> + ${requestInfo} + <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> + <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> + </aetgt:WorkflowException> + </aetgt:FalloutHandlerRequest>""" + + utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) + utils.log("DEBUG", processKey + "Completed ProcessMainflowBPMNException Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled) + return falloutHandlerRequest + + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled) + return null + } + } + + /** + * + * This method is executed after an Java Exception is caught + * It sets the WorkflowException variable. The method can be used in either mainflow or subflows. + * + * @param - execution + * + */ + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String processKey = getProcessKey(execution) + try{ + utils.log("DEBUG", "Caught a Java Exception in " + processKey, isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + buildWorkflowException(execution, 2500, "Catch a Java Lang Exception in " + processKey) + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + buildWorkflowException(execution, 2500, "Internal Error - During Process Java Exception") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } + + + public void preProcessRequest(Execution execution) { + // TODO Auto-generated method stub + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java index c3912b48bc..eabd465934 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequest.java @@ -105,11 +105,8 @@ public class MsoRequest { @Override public String toString() { - StringBuilder request = new StringBuilder(); - request.append("<requestId>"+requestId+"</requestId>"); - request.append('\n'); - request.append("<serviceInstanceId>"+serviceInstanceId+"</serviceInstanceId>"); - return request.toString(); + return "<requestId>" + requestId + "</requestId>" + '\n' + "<serviceInstanceId>" + serviceInstanceId + + "</serviceInstanceId>"; } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java index 952e3e2f95..c22fd286cf 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactory.java @@ -166,7 +166,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "rollbackVnfNotification") public JAXBElement<RollbackVnfNotification> createRollbackVnfNotification(RollbackVnfNotification value) { - return new JAXBElement<RollbackVnfNotification>(_RollbackVnfNotification_QNAME, RollbackVnfNotification.class, null, value); + return new JAXBElement<>(_RollbackVnfNotification_QNAME, RollbackVnfNotification.class, null, value); } /** @@ -175,7 +175,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "deleteVnfNotification") public JAXBElement<DeleteVnfNotification> createDeleteVnfNotification(DeleteVnfNotification value) { - return new JAXBElement<DeleteVnfNotification>(_DeleteVnfNotification_QNAME, DeleteVnfNotification.class, null, value); + return new JAXBElement<>(_DeleteVnfNotification_QNAME, DeleteVnfNotification.class, null, value); } /** @@ -184,7 +184,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "createVnfNotification") public JAXBElement<CreateVnfNotification> createCreateVnfNotification(CreateVnfNotification value) { - return new JAXBElement<CreateVnfNotification>(_CreateVnfNotification_QNAME, CreateVnfNotification.class, null, value); + return new JAXBElement<>(_CreateVnfNotification_QNAME, CreateVnfNotification.class, null, value); } /** @@ -193,7 +193,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "updateVnfNotification") public JAXBElement<UpdateVnfNotification> createUpdateVnfNotification(UpdateVnfNotification value) { - return new JAXBElement<UpdateVnfNotification>(_UpdateVnfNotification_QNAME, UpdateVnfNotification.class, null, value); + return new JAXBElement<>(_UpdateVnfNotification_QNAME, UpdateVnfNotification.class, null, value); } /** @@ -202,7 +202,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp.mso/vnfNotify", name = "queryVnfNotification") public JAXBElement<QueryVnfNotification> createQueryVnfNotification(QueryVnfNotification value) { - return new JAXBElement<QueryVnfNotification>(_QueryVnfNotification_QNAME, QueryVnfNotification.class, null, value); + return new JAXBElement<>(_QueryVnfNotification_QNAME, QueryVnfNotification.class, null, value); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java new file mode 100644 index 0000000000..f4ebd0615a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.bpmn.common.recipe; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The bpmn workflow input param object + */ +public class BpmnParam { + + @JsonProperty("value") + private String value; + @JsonProperty("type") + private String type = "String"; + + + public BpmnParam() { + /* Empty constructor */ + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("type") + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java new file mode 100644 index 0000000000..e43af18ceb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java @@ -0,0 +1,219 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.bpmn.common.recipe;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import javax.xml.bind.DatatypeConverter;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.openecomp.mso.utils.CryptoUtils;
+
+/**
+ * Support to call resource recipes from the BPMN workflow.
+ * Such as call resource recipe in service workflow.
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-27
+ */
+public class BpmnRestClient {
+
+ public static final String DEFAULT_BPEL_AUTH = "admin:admin";
+
+ public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
+
+ public static final String CONTENT_TYPE_JSON = "application/json";
+
+ public static final String CAMUNDA_AUTH = "camundaAuth";
+
+ private final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private static boolean noProperties = true;
+
+ public synchronized static MsoJavaProperties loadMsoProperties() {
+ MsoJavaProperties msoProperties;
+ try {
+ msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_APIHANDLER_INFRA);
+ } catch(Exception e) {
+ msoLogger.error(MessageEnum.APIH_LOAD_PROPERTIES_FAIL, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError,
+ "Exception when loading MSO Properties", e);
+ return null;
+ }
+
+ if(msoProperties != null && msoProperties.size() > 0) {
+ noProperties = false;
+ msoLogger.info(MessageEnum.APIH_PROPERTY_LOAD_SUC, "", "");
+ return msoProperties;
+ } else {
+ msoLogger.error(MessageEnum.APIH_NO_PROPERTIES, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError,
+ "No MSO APIH_INFRA Properties found");
+ return null;
+ }
+ }
+
+ public synchronized static final boolean getNoPropertiesState() {
+ return noProperties;
+ }
+
+ /**
+ * post the recipe Uri
+ * <br>
+ *
+ * @param recipeUri The request recipe uri
+ * @param requestId the request id
+ * @param recipeTimeout The recipe time out
+ * @param requestAction The request action
+ * @param serviceInstanceId The service instance id
+ * @param serviceType The service Type
+ * @param requestDetails The request Details, these information is from runtime
+ * @param recipeParamXsd The recipe params, its from recipe design
+ * @return The response of the recipe.
+ * @throws ClientProtocolException
+ * @throws IOException
+ * @since ONAP Beijing Release
+ */
+ public static HttpResponse post(String recipeUri, String requestId, int recipeTimeout, String requestAction, String serviceInstanceId, String serviceType,
+ String requestDetails, String recipeParamXsd) throws ClientProtocolException, IOException {
+
+ HttpClient client = HttpClientBuilder.create().build();
+
+ HttpPost post = new HttpPost(recipeUri);
+ MsoJavaProperties props = loadMsoProperties();
+ RequestConfig requestConfig =
+ RequestConfig.custom().setSocketTimeout(recipeTimeout).setConnectTimeout(recipeTimeout).setConnectionRequestTimeout(recipeTimeout).build();
+ post.setConfig(requestConfig);
+ msoLogger.debug("call the bpmn, url:" + recipeUri);
+ String jsonReq = wrapResourceRequest(requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, requestDetails, recipeParamXsd);
+
+ StringEntity input = new StringEntity(jsonReq);
+ input.setContentType(CONTENT_TYPE_JSON);
+ String encryptedCredentials;
+ if(props != null) {
+ encryptedCredentials = props.getProperty(CAMUNDA_AUTH, null);
+ if(encryptedCredentials != null) {
+ String userCredentials = getEncryptedPropValue(encryptedCredentials, DEFAULT_BPEL_AUTH, ENCRYPTION_KEY);
+ if(userCredentials != null) {
+ post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
+ }
+ }
+ }
+ post.setEntity(input);
+ return client.execute(post);
+ }
+
+ /**
+ * prepare the resource recipe bpmn request.
+ * <br>
+ *
+ * @param requestId
+ * @param recipeTimeout
+ * @param requestAction
+ * @param serviceInstanceId
+ * @param serviceType
+ * @param requestDetails
+ * @param recipeParams
+ * @return
+ * @since ONAP Beijing Release
+ */
+ private static String wrapResourceRequest(String requestId, int recipeTimeout, String requestAction, String serviceInstanceId, String serviceType,
+ String requestDetails, String recipeParams) {
+ String jsonReq = null;
+ if(requestId == null) {
+ requestId = "";
+ }
+ if(requestAction == null) {
+ requestAction = "";
+ }
+ if(serviceInstanceId == null) {
+ serviceInstanceId = "";
+ }
+
+ if(requestDetails == null) {
+ requestDetails = "";
+ }
+
+ try {
+ ResourceRecipeRequest recipeRequest = new ResourceRecipeRequest();
+ BpmnParam resourceInput = new BpmnParam();
+ BpmnParam host = new BpmnParam();
+ BpmnParam requestIdInput = new BpmnParam();
+ BpmnParam requestActionInput = new BpmnParam();
+ BpmnParam serviceInstanceIdInput = new BpmnParam();
+ BpmnParam serviceTypeInput = new BpmnParam();
+ BpmnParam recipeParamsInput = new BpmnParam();
+ // host.setValue(parseURL());
+ requestIdInput.setValue(requestId);
+ requestActionInput.setValue(requestAction);
+ serviceInstanceIdInput.setValue(serviceInstanceId);
+ recipeParamsInput.setValue(recipeParams);
+ resourceInput.setValue(requestDetails);
+ recipeRequest.setHost(host);
+ recipeRequest.setRequestId(requestIdInput);
+ recipeRequest.setRequestAction(requestActionInput);
+ recipeRequest.setServiceInstanceId(serviceInstanceIdInput);
+ recipeRequest.setServiceType(serviceTypeInput);
+ recipeRequest.setRecipeParams(recipeParamsInput);
+ jsonReq = recipeRequest.toString();
+ msoLogger.debug("request body is " + jsonReq);
+ } catch(Exception e) {
+ msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapVIDRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request",
+ e);
+ }
+ return jsonReq;
+ }
+
+ /**
+ * <br>
+ *
+ * @param prop
+ * @param defaultValue
+ * @param encryptionKey
+ * @return
+ * @since ONAP Beijing Release
+ */
+ protected static String getEncryptedPropValue(String prop, String defaultValue, String encryptionKey) {
+ try {
+ return CryptoUtils.decrypt(prop, encryptionKey);
+ } catch(GeneralSecurityException e) {
+ msoLogger.debug("Security exception", e);
+ }
+ return defaultValue;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequest.java new file mode 100644 index 0000000000..5bf5a02a38 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequest.java @@ -0,0 +1,143 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.bpmn.common.recipe; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * java object of the resource recipe , it + * will be passed to the Camunda process + */ +@JsonPropertyOrder({"resourceInput", "host", "requestId", "requestAction", "serviceInstanceId", "serviceType", "recipeParams"}) +@JsonRootName("variables") +public class ResourceRecipeRequest { + + @JsonProperty("resourceInput") + private BpmnParam resourceInput; + + @JsonProperty("host") + private BpmnParam host; + + @JsonProperty("requestId") + private BpmnParam requestId; + + @JsonProperty("requestAction") + private BpmnParam requestAction; + + @JsonProperty("serviceInstanceId") + private BpmnParam serviceInstanceId; + + @JsonProperty("serviceType") + private BpmnParam serviceType; + + @JsonProperty("recipeParams") + private BpmnParam recipeParams; + + @JsonProperty("resourceInput") + public BpmnParam getResourceInput() { + return resourceInput; + } + + @JsonProperty("resourceInput") + public void setResourceInput(BpmnParam resourceInput) { + this.resourceInput = resourceInput; + } + + @JsonProperty("host") + public BpmnParam getHost() { + return host; + } + + @JsonProperty("host") + public void setHost(BpmnParam host) { + this.host = host; + } + + @JsonProperty("requestId") + public BpmnParam getRequestId() { + return requestId; + } + + @JsonProperty("requestId") + public void setRequestId(BpmnParam requestId) { + this.requestId = requestId; + } + + @JsonProperty("requestAction") + public BpmnParam getRequestAction() { + return requestAction; + } + + @JsonProperty("requestAction") + public void setRequestAction(BpmnParam requestAction) { + this.requestAction = requestAction; + } + + @JsonProperty("serviceInstanceId") + public BpmnParam getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(BpmnParam serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty("serviceType") + public BpmnParam getServiceType() { + return serviceType; + } + + @JsonProperty("serviceType") + public void setServiceType(BpmnParam serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("recipeParams") + public BpmnParam getRecipeParams() { + return recipeParams; + } + + @JsonProperty("recipeParams") + public void setRecipeParams(BpmnParam recipeParams) { + this.recipeParams = recipeParams; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + String jsonStr = "ResourceRecipeRequest"; + try { + jsonStr = mapper.writeValueAsString(this); + } catch(JsonProcessingException e) { + + e.printStackTrace(); + } + return jsonStr; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java index 6cc34f7464..846b87aba8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/util/CryptoUtils.java @@ -38,11 +38,10 @@ public class CryptoUtils { public static final String AES = "AES";
/**
- * encrypt a value and generate a keyfile
+ * encrypt a value and generate a keyfile
* if the keyfile is not found then a new one is created
- * @throws GeneralSecurityException
- * @throws IOException
- */
+ * @throws GeneralSecurityException
+ * */
public static String encrypt(String value, String keyString) throws GeneralSecurityException
{
SecretKeySpec sks = getSecretKeySpec(keyString);
@@ -53,9 +52,8 @@ public class CryptoUtils { }
/**
- * decrypt a value
+ * decrypt a value
* @throws GeneralSecurityException
- * @throws IOException
*/
public static String decrypt(String message, String keyString) throws GeneralSecurityException
{
@@ -75,14 +73,14 @@ public class CryptoUtils { private static String byteArrayToHexString(byte[] b){
- StringBuffer sb = new StringBuffer(b.length * 2);
- for (int i = 0; i < b.length; i++){
- int v = b[i] & 0xff;
+ StringBuilder sb = new StringBuilder(b.length * 2);
+ for (byte aB : b) {
+ int v = aB & 0xff;
if (v < 16) {
- sb.append('0');
+ sb.append('0');
}
sb.append(Integer.toHexString(v));
- }
+ }
return sb.toString().toUpperCase();
}
@@ -96,23 +94,5 @@ public class CryptoUtils { return b;
}
- /**
- * Not Used...
- *
- * Call Rttp utility jar to encrypt pwd
- * @param clearPassword
- * @return
- * @throws GeneralSecurityException
- * @throws Exception
- *
- public static String encryptRttpPwd(String clearPassword) throws GeneralSecurityException {
- try {
- return RttpBasicAuth.encrypt(clearPassword);
- } catch (Exception e) {
- // wrap generic exception
- throw new GeneralSecurityException(e);
- }
- }
- */
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java index d65311dfe8..daca9fcf3f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java @@ -70,7 +70,7 @@ public abstract class AbstractCallbackService extends ProcessEngineAwareService + (message == null ? "" : System.lineSeparator()) + message);
try {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
if (injectedVariables != null) {
variables.putAll(injectedVariables);
@@ -192,7 +192,7 @@ public abstract class AbstractCallbackService extends ProcessEngineAwareService int count = waitingProcesses.size();
- List<ExecInfo> execInfoList = new ArrayList<ExecInfo>(count);
+ List<ExecInfo> execInfoList = new ArrayList<>(count);
for (Execution execution : waitingProcesses) {
execInfoList.add(new ExecInfo(execution));
}
@@ -364,4 +364,4 @@ public abstract class AbstractCallbackService extends ProcessEngineAwareService + ":" + execution.getId() + "]";
}
}
-} +}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java index d9aed816c9..4ba35907b9 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -90,7 +90,7 @@ public class WorkflowMessageResource extends AbstractCallbackService { String correlationValue = correlator;
String contentTypeVariable = messageType + "_CONTENT_TYPE";
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
if (contentType != null) {
variables.put(contentTypeVariable, contentType);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java index 76ff221018..dd100a3824 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java @@ -450,7 +450,7 @@ public class WorkflowResource extends ProcessEngineAwareService { Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject);
msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
- responseMap = new HashMap<String, Object>();
+ responseMap = new HashMap<>();
responseMap.put("WorkflowResponse", workflowResponse);
responseMap.put("ResponseCode", responseCode);
responseMap.put("Status", "Success");
@@ -467,7 +467,7 @@ public class WorkflowResource extends ProcessEngineAwareService { if(workflowExceptionObject instanceof WorkflowException) {
workflowException = (WorkflowException) workflowExceptionObject;
workflowExceptionText = workflowException.toString();
- responseMap = new HashMap<String, Object>();
+ responseMap = new HashMap<>();
responseMap.put("WorkflowException", workflowExceptionText);
responseMap.put("ResponseCode", workflowException.getErrorCode());
responseMap.put("Status", "Fail");
@@ -477,7 +477,7 @@ public class WorkflowResource extends ProcessEngineAwareService { Object object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
String responseCode = object == null ? null : String.valueOf(object);
workflowExceptionText = (String) workflowExceptionObject;
- responseMap = new HashMap<String, Object>();
+ responseMap = new HashMap<>();
responseMap.put("WorkflowException", workflowExceptionText);
responseMap.put("ResponseCode", responseCode);
responseMap.put("Status", "Fail");
@@ -496,7 +496,7 @@ public class WorkflowResource extends ProcessEngineAwareService { object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
String responseCode = object == null ? null : String.valueOf(object);
msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
- responseMap = new HashMap<String, Object>();
+ responseMap = new HashMap<>();
responseMap.put("Response", response);
responseMap.put("ResponseCode", responseCode);
responseMap.put("Status", "Success");
@@ -511,7 +511,7 @@ public class WorkflowResource extends ProcessEngineAwareService { object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode");
String responseCode = object == null ? null : String.valueOf(object);
msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode);
- responseMap = new HashMap<String, Object>();
+ responseMap = new HashMap<>();
responseMap.put("Response", errorResponse);
responseMap.put("ResponseCode", responseCode);
responseMap.put("Status", "Fail");
@@ -569,7 +569,7 @@ public class WorkflowResource extends ProcessEngineAwareService { try {
ProcessEngineServices engine = getProcessEngineServices();
List<HistoricVariableInstance> variables = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
- Map<String,String> variablesMap = new HashMap<String,String>();
+ Map<String,String> variablesMap = new HashMap<>();
for (HistoricVariableInstance variableInstance: variables) {
variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString());
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java index 193b8fe903..64e5adc091 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java @@ -28,8 +28,8 @@ import javax.ws.rs.core.Application; @ApplicationPath("/")
public class WorkflowResourceApplication extends Application {
- private Set<Object> singletons = new HashSet<Object>();
- private Set<Class<?>> classes = new HashSet<Class<?>>();
+ private Set<Object> singletons = new HashSet<>();
+ private Set<Class<?>> classes = new HashSet<>();
public WorkflowResourceApplication() {
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java index aa6e1954a1..f7db52b1c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java @@ -56,9 +56,9 @@ public class ApplicationControllerSupport { private static final int ERROR_SERIES = 200; private static final int REJECT_SERIES = 300; private static final int SUCCESS_SERIES = 400; - private static final int SUCCESS_STATUS = SUCCESS_SERIES + 0; + private static final int SUCCESS_STATUS = SUCCESS_SERIES; private static final int PARTIAL_SERIES = 500; - private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES + 0; + private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; @Value("${lcm.model.package:org.openecomp.appc.client.lcm.model}") @@ -71,7 +71,7 @@ public class ApplicationControllerSupport { } /** - * @param inputClass + * @param action * @return * @throws ClassNotFoundException * @throws InstantiationException diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java index a21dbe8477..1bdecbf2a7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java @@ -39,9 +39,8 @@ public class DmaapPropertiesLoader { } public DmaapProperties getImpl() { - Iterator<DmaapProperties> propertyImpls = services.iterator(); - while (propertyImpls.hasNext()) { - return propertyImpls.next(); + for (DmaapProperties service : services) { + return service; } return null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java index 124e2c3a28..f54eba406e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java @@ -42,7 +42,7 @@ public class DMaaPRestClient extends RestClient { @Override protected void initializeHeaderMap(Map<String, String> headerMap) { - headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(new String(username + ":" + password).getBytes())); + headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes())); } @Override diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java index c746c0d448..df30e43822 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java @@ -27,8 +27,8 @@ public interface SDNOValidator { /** * Issues a health diagnostic request for a given vnf to SDN-O * - * @param vnfName - * @param uuid + * @param vnfId + * @param requestingUserId * @throws IOException * @throws Exception */ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java index cc8ce81dec..26c74b0615 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java @@ -41,7 +41,7 @@ public class Body implements Serializable @JsonProperty("input") private Input input; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 9101706044452851559L; @JsonProperty("input") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java index 7b9bf6f2c7..579f481ba8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java @@ -43,7 +43,7 @@ public class Input implements Serializable private RequestHealthDiagnostic RequestHealthDiagnostic; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 7155546785389227528L; @JsonProperty("request-healthdiagnostic") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java index 104dbb7ee6..2cddd0331e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java @@ -59,7 +59,7 @@ public class RequestHealthDiagnostic implements Serializable @JsonProperty("health-diagnostic-code") private String healthDiagnosticCode; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 1166788526178388021L; @JsonProperty("request-client-name") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java index 4d029cb8cb..976f5b9a33 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java @@ -51,7 +51,7 @@ private String requestId; @JsonProperty("status") private String status; @JsonIgnore -private Map<String, Object> additionalProperties = new HashMap<String, Object>(); +private Map<String, Object> additionalProperties = new HashMap<>(); @JsonProperty("client-name") public String getClientName() { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java index 4edd54ca09..8505ec9a74 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java @@ -50,7 +50,7 @@ public class SDNO implements Serializable @JsonProperty("body") private Body body; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = -5303297382564282650L; @JsonProperty("operation") diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy index ab7ee7a689..5949c3af53 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcessTest.groovy @@ -16,23 +16,24 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ + */ package org.openecomp.mso.bpmn.common.scripts -import org.junit.runner.RunWith; -import static org.junit.Assert.* -import static org.mockito.Mockito.* - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor import org.mockito.MockitoAnnotations import org.mockito.runners.MockitoJUnitRunner import org.openecomp.mso.bpmn.core.WorkflowException +import static org.assertj.core.api.Assertions.assertThat +import static org.assertj.core.api.Assertions.assertThatThrownBy +import static org.mockito.Matchers.eq +import static org.mockito.Mockito.* @RunWith(MockitoJUnitRunner.class) class CompleteMsoProcessTest { @@ -128,7 +129,7 @@ class CompleteMsoProcessTest { when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL") when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); - + CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution) @@ -145,29 +146,25 @@ class CompleteMsoProcessTest { </sdncadapterworkflow:MsoCompletionResponse>""" */ @Test - public void testbuildDataError(){ - - boolean thrown = false; - String msg = "Some-Message"; - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL-NAME") - when(mockExecution.getVariable("testProcessKey")).thenReturn("CompleteMsoProcess") - - WorkflowException exception = new WorkflowException("CompleteMsoProcess", 500, msg); - - try{ - CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() - completeMsoProcess.buildDataError(mockExecution, msg) - } - catch (BpmnError e){ - thrown = true; - } - - - verify(mockExecution).setVariable("CompleteMsoProcessResponse",msoCompletionResponse) - // Can't seem to figure out how to verify the exception and have spent way too much time on fixing this test case! - //verify(mockExecution).setVariable("WorkflowException",exception) - assertTrue(thrown); - } + void testBuildDataError() { + // given + def message = "Some-Message" + + def mockExecution = mock ExecutionEntity.class + when mockExecution.getVariable("CMSO_mso-bpel-name") thenReturn "BPEL-NAME" + when mockExecution.getVariable("testProcessKey") thenReturn "CompleteMsoProcess" + + def completeMsoProcess = new CompleteMsoProcess() + // when + assertThatThrownBy { completeMsoProcess.buildDataError(mockExecution, message) } isInstanceOf BpmnError + // then + verify mockExecution setVariable("CompleteMsoProcessResponse", msoCompletionResponse) + def argumentCaptor = ArgumentCaptor.forClass WorkflowException.class + verify mockExecution setVariable(eq("WorkflowException"), argumentCaptor.capture()) + def capturedException = argumentCaptor.value + + assertThat capturedException.processKey isEqualTo "CompleteMsoProcess" + assertThat capturedException.errorCode isEqualTo 500 + assertThat capturedException.errorMessage isEqualTo message + } }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java index eef9ed8ee0..0bb5186a17 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java @@ -68,7 +68,7 @@ public class BPMNUtil { }
@SuppressWarnings("unchecked")
- public static <T extends Object> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
+ public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
String pID = getProcessInstanceId(processEngineServices,
processDefinitionID);
assertProcessInstanceFinished(processEngineServices, pID);
@@ -121,7 +121,7 @@ public class BPMNUtil { private static void buildVariable(String key, String value, Map<String,Object> variableValueType) {
- Map<String, Object> host = new HashMap<String, Object>();
+ Map<String, Object> host = new HashMap<>();
host.put("value", value);
host.put("type", "String");
variableValueType.put(key, host);
@@ -131,7 +131,7 @@ public class BPMNUtil { WorkflowResource workflowResource = new WorkflowResource();
VariableMapImpl variableMap = new VariableMapImpl();
- Map<String, Object> variableValueType = new HashMap<String, Object>();
+ Map<String, Object> variableValueType = new HashMap<>();
for (String key : variables.keySet()) {
buildVariable(key, variables.get(key), variableValueType);
}
@@ -203,7 +203,7 @@ public class BPMNUtil { WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
VariableMapImpl variableMap = new VariableMapImpl();
- Map<String, Object> variableValueType = new HashMap<String, Object>();
+ Map<String, Object> variableValueType = new HashMap<>();
for (String key : variables.keySet()) {
buildVariable(key, variables.get(key), variableValueType);
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java index b050a81f18..9d4dac2333 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java @@ -42,7 +42,7 @@ public class CompleteMsoProcessTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
//String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("CompleteMsoProcessRequest",inputRequestFile);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CompleteMsoProcess", variables);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java index 1925c0a1b9..845f06045a 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java @@ -51,7 +51,7 @@ public class ConfirmVolumeGroupNameTest extends WorkflowTest { System.out.println("Before starting process"); RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("isDebugLogEnabled","true"); variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME"); @@ -83,7 +83,7 @@ public class ConfirmVolumeGroupNameTest extends WorkflowTest { System.out.println("Before starting process"); RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("isDebugLogEnabled","true"); variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST"); variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); @@ -116,7 +116,7 @@ public class ConfirmVolumeGroupNameTest extends WorkflowTest { System.out.println("Before starting process"); RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("isDebugLogEnabled","true"); variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java index 3856f7b5e1..457128f104 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java @@ -46,7 +46,7 @@ public class ConfirmVolumeGroupTenantTest extends WorkflowTest { public void testRemoveLayer3Service_success() throws Exception{ MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); @@ -66,7 +66,7 @@ public class ConfirmVolumeGroupTenantTest extends WorkflowTest { public void testRemoveLayer3Service_idsNotMatch() throws Exception{ MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java index 045bd6f9c7..b2b7760327 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java @@ -51,7 +51,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfName", "STMTN5MMSC22");
@@ -78,7 +78,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -103,7 +103,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfName", "STMTN5MMSC23");
@@ -128,7 +128,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfName", "STMTN5MMSC21");
@@ -153,7 +153,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfId", "2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4");
@@ -178,7 +178,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfName", "STMTN5MMSC22");
@@ -203,7 +203,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfId", "768073c7-f41f-4822-9323-b75962763d74");
@@ -228,7 +228,7 @@ public class CreateAAIVfModuleTest extends WorkflowTest { MockAAICreateGenericVnf();
MockAAIVfModulePUT(true);
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("isVidRequest", "false");
variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java index 5845ec1a56..5cc26459e8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java @@ -55,7 +55,7 @@ public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
@@ -86,7 +86,7 @@ public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
@@ -117,7 +117,7 @@ public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java index bda6dd953c..7295cd8e10 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java @@ -49,7 +49,7 @@ public class DecomposeServiceTest extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); invokeSubProcess("DecomposeService", businessKey, variables); @@ -66,7 +66,7 @@ public class DecomposeServiceTest extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); invokeSubProcess("DecomposeService", businessKey, variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java index bb2fc03163..564927a854 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java @@ -52,7 +52,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -88,7 +88,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -123,7 +123,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -158,7 +158,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -193,7 +193,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -228,7 +228,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -263,7 +263,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest",request);
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
@@ -284,7 +284,7 @@ public class DeleteAAIVfModuleTest extends WorkflowTest { MockAAIDeleteGenericVnf();
MockAAIDeleteVfModule();
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java index 8281687dec..257cec9b11 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java @@ -58,7 +58,7 @@ public class FalloutHandlerTest extends WorkflowTest { System.out.println("STARTED TEST: " + method);
//String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("FalloutHandlerRequest",inputRequestFile);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "FalloutHandler", variables);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java index cced8c1860..125a9ad916 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java @@ -51,7 +51,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) public void testGenericDeleteService_success_serviceInstance() throws Exception{ MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); @@ -70,7 +70,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -94,7 +94,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceSubscription.xml"); MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -118,7 +118,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesSubscription(variables, null, "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -142,7 +142,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockGetServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -164,7 +164,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { public void testGenericDeleteService_success_subscriptionGetEmpty200() throws Exception{ MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 200); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", ""); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -189,7 +189,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GENDSI_getServiceInstanceResponse.xml"); MockDeleteServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -210,7 +210,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) public void testGenericDeleteService_error_invalidVariables() throws Exception{ - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "1234"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); @@ -236,7 +236,7 @@ public class GenericDeleteServiceTest extends WorkflowTest { MockGetServiceInstance_500("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "aaiFault.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java index 473f6c8195..add9a32d61 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java @@ -51,7 +51,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_success_genericVnf() throws Exception{ MockDeleteGenericVnf("testVnfId123", "testReVer123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -66,7 +66,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_success_vce() throws Exception{ MockDeleteVce("testVnfId123", "testReVer123", 204); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "vce", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -83,7 +83,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { MockGetGenericVnfById("/testVnfId123", "GenericFlows/getGenericVnfByNameResponse.xml", 200); MockDeleteGenericVnf("testVnfId123", "testReVer123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", ""); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -99,7 +99,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { MockDeleteVce("testVnfId123", "testReVer123", 204); MockGetVceById("testVnfId123", "GenericFlows/getVceResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "vce", null); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -114,7 +114,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_success_genericVnf404() throws Exception{ MockDeleteGenericVnf("testVnfId123", "testReVer123", 404); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -129,7 +129,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_success_vce404() throws Exception{ MockDeleteVce("testVnfId123", "testReVer123", 404); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "vce", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -144,7 +144,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_success_genericVnfNoResourceVersion404() throws Exception{ MockGetGenericVnfById_404("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", ""); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -158,7 +158,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) public void testGenericDeleteVnf_error_missingVariables() throws Exception{ - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -173,7 +173,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_error_genericVnf500() throws Exception{ MockDeleteGenericVnf_500("testVnfId123", "testReVer123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); @@ -188,7 +188,7 @@ public class GenericDeleteVnfTest extends WorkflowTest { public void testGenericDeleteVnf_error_genericVnf412() throws Exception{ MockDeleteGenericVnf("testVnfId123", "testReVer123", 412); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java index 82cceb0b70..0198395750 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java @@ -56,7 +56,7 @@ public class GenericGetServiceTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
public void testGenericGetService_success_serviceInstance() throws Exception{
MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
@@ -81,7 +81,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -109,7 +109,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml");
MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, null, "1604-MVM-26", null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -139,7 +139,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -168,7 +168,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -192,7 +192,7 @@ public class GenericGetServiceTest extends WorkflowTest { public void testGenericGetService_success_serviceSubscription404() throws Exception{
MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404);
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -219,7 +219,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceByName_404("1604-MVM-26");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "", "1604-MVM-26", null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -246,7 +246,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -273,7 +273,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " ");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -297,7 +297,7 @@ public class GenericGetServiceTest extends WorkflowTest { public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{
MockNodeQueryServiceInstanceByName("1604-MVM-26", "");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "", "1604-MVM-26", null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -324,7 +324,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", "");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -350,7 +350,7 @@ public class GenericGetServiceTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -375,7 +375,7 @@ public class GenericGetServiceTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -403,7 +403,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789");
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -430,7 +430,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -459,7 +459,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceByName_500("1604-MVM-26");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, null, "1604-MVM-26", null, null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -489,7 +489,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
MockGetServiceInstance("XyCorporation", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, null, "1604-MVM-26", "XyCorporation", null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
@@ -517,7 +517,7 @@ public class GenericGetServiceTest extends WorkflowTest { MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
MockGetServiceInstance("CorporationNotPresent", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
setVariablesInstance(variables, null, "1604-MVM-26", "CorporationNotPresent", null);
WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java index 126a5fda62..4922263744 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java @@ -52,7 +52,7 @@ public class GenericGetVnfTest extends WorkflowTest { public void testGenericGetVnf_success_genericVnf() throws Exception{ MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); @@ -79,7 +79,7 @@ public class GenericGetVnfTest extends WorkflowTest { public void testGenericGetVnf_success_vce() throws Exception{ MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "testVnfName123", "vce"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); @@ -106,7 +106,7 @@ public class GenericGetVnfTest extends WorkflowTest { public void testGenericGetVnf_success_genericVnfByName() throws Exception{ MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "", "testVnfName123", "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); @@ -133,7 +133,7 @@ public class GenericGetVnfTest extends WorkflowTest { public void testGenericGetVnf_success_vceByName() throws Exception{ MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, null, "testVnfName123", "vce"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); @@ -162,7 +162,7 @@ public class GenericGetVnfTest extends WorkflowTest { MockGetGenericVnfById_500("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java index 149f8aead2..0e0a237090 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java @@ -51,7 +51,7 @@ public class GenericPutVnfTest extends WorkflowTest { MockPutGenericVnf("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); @@ -71,7 +71,7 @@ public class GenericPutVnfTest extends WorkflowTest { MockPutVce("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", vcePayload, "vce"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); @@ -91,7 +91,7 @@ public class GenericPutVnfTest extends WorkflowTest { MockPutGenericVnf("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", genericVnfPayload, ""); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); @@ -113,7 +113,7 @@ public class GenericPutVnfTest extends WorkflowTest { MockPutGenericVnf("testVnfId123"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", genericVnfPayload, ""); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); @@ -133,7 +133,7 @@ public class GenericPutVnfTest extends WorkflowTest { @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) public void testGenericPutVnf_error_404() throws Exception{ - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); @@ -154,7 +154,7 @@ public class GenericPutVnfTest extends WorkflowTest { MockPutGenericVnf("/testVnfId123", 400); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java index e49ef0032e..3210fe8fc7 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java @@ -23,7 +23,7 @@ */ package org.openecomp.mso.bpmn.common; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*; import static org.junit.Assert.*; @@ -140,7 +140,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("Homing", businessKey, variables); @@ -183,7 +183,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables2(variables); invokeSubProcess("Homing", businessKey, variables); @@ -235,9 +235,10 @@ public class HomingTest extends WorkflowTest { // Create a Service Decomposition //System.out.println("At start of testHoming_success_vnfResourceList"); - MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json"); + MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); + //MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json"); String busKey = UUID.randomUUID().toString(); - Map<String, Object> vars = new HashMap<String, Object>(); + Map<String, Object> vars = new HashMap<>(); setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); invokeSubProcess("DecomposeService", busKey, vars); @@ -252,7 +253,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("isDebugLogEnabled", "true"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "testServiceInstanceId"); @@ -288,7 +289,7 @@ public class HomingTest extends WorkflowTest { public void testHoming_error_inputVariable() throws Exception { String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables3(variables); invokeSubProcess("Homing", businessKey, variables); @@ -307,7 +308,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO_500(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("Homing", businessKey, variables); @@ -326,7 +327,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("Homing", businessKey, variables); @@ -347,7 +348,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("Homing", businessKey, variables); @@ -368,7 +369,7 @@ public class HomingTest extends WorkflowTest { mockSNIRO(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("Homing", businessKey, variables); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java index 6141ee021f..a7c2d19aa0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java @@ -67,7 +67,7 @@ public class ManualHandlingTest extends WorkflowTest { public void TestManualHandlingSuccess() { RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("isDebugLogEnabled","true"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceType", "X"); @@ -103,7 +103,7 @@ public class ManualHandlingTest extends WorkflowTest { System.out.println("TASK NAME: " + task.getName()); try { System.out.println("Completing the task"); - Map<String,Object> completeVariables = new HashMap<String,Object>(); + Map<String,Object> completeVariables = new HashMap<>(); completeVariables.put("responseValue", "skip"); taskService.complete(task.getId(), completeVariables); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java index 441cefdb41..be74770e98 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java @@ -60,7 +60,7 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { MockPatchVfModuleId("skask", "supercool");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
@@ -94,7 +94,7 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { MockGetGenericVnfById_404("skask[?]depth=1");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
@@ -129,7 +129,7 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
@@ -159,7 +159,7 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
@@ -190,7 +190,7 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java index 8a78f3206c..65575ba861 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java @@ -57,7 +57,7 @@ public class RainyDayHandlerTest extends WorkflowTest { public void TestRainyDayHandlingSuccess() {
RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("msoRequestId", "testRequestId");
variables.put("serviceType", "X");
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java index 4669192249..a806515974 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java @@ -85,7 +85,7 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { logStart(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); variables.put("isDebugLogEnabled", "true"); variables.put("RCVWFMSG_timeout", "PT1M"); @@ -115,7 +115,7 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { logStart(); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); variables.put("isDebugLogEnabled", "true"); variables.put("RCVWFMSG_timeout", "PT0.1S"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java index 778eec190e..0349b178cb 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java @@ -75,12 +75,12 @@ public class SDNCAdapterV1Test extends WorkflowTest { private WorkflowResponse invokeFlow(String workflowRequest) {
- Map<String, Object>valueMap = new HashMap<String, Object>();
+ Map<String, Object>valueMap = new HashMap<>();
valueMap.put("value", workflowRequest);
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("sdncAdapterWorkflowRequest", valueMap);
- Map<String, Object> valueMap2 = new HashMap<String, Object>();
+ Map<String, Object> valueMap2 = new HashMap<>();
valueMap2.put("value", "true");
variables.put("isDebugLogEnabled", valueMap2);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java index 20f6f6d264..7c557ffe63 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java @@ -59,7 +59,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockPatchGenericVnf("skask");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
@@ -92,7 +92,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
@@ -122,7 +122,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockGetGenericVnfById_404("skask[?]depth=1");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
@@ -156,7 +156,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java index 0e523cbfa3..30d7e6d8c6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java @@ -58,7 +58,7 @@ public class UpdateAAIVfModuleTest extends WorkflowTest { MockPatchVfModuleId("skask", "supercool");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
@@ -89,7 +89,7 @@ public class UpdateAAIVfModuleTest extends WorkflowTest { MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
@@ -122,7 +122,7 @@ public class UpdateAAIVfModuleTest extends WorkflowTest { MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "999-99-9999");
variables.put("isDebugLogEnabled","true");
variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java index 707fe46cc1..fb029fa740 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java @@ -241,7 +241,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", requestId); variables.put("isDebugLogEnabled", "true"); variables.put("vnfAdapterRestV1Request", request); @@ -272,7 +272,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String request = UPDATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", requestId); variables.put("isDebugLogEnabled", "true"); variables.put("vnfAdapterRestV1Request", request); @@ -303,7 +303,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String request = DELETE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", requestId); variables.put("isDebugLogEnabled", "true"); variables.put("vnfAdapterRestV1Request", request); @@ -334,7 +334,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String request = ROLLBACK_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", requestId); variables.put("isDebugLogEnabled", "true"); variables.put("vnfAdapterRestV1Request", request); @@ -365,7 +365,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("mso-request-id", requestId); variables.put("isDebugLogEnabled", "true"); variables.put("vnfAdapterRestV1Request", request); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java index 426bceef4b..5f91298958 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java @@ -42,7 +42,7 @@ public class WorkflowAsyncResourceTest extends WorkflowTest { //it can be any request which asynchronously processed by the workflow String request = "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>"; - Map<String,String> variables = new HashMap<String,String>(); + Map<String,String> variables = new HashMap<>(); variables.put("testAsyncRequestMsg", request); variables.put("mso-request-id", UUID.randomUUID().toString()); variables.put("mso-service-request-timeout", "5"); @@ -56,17 +56,17 @@ public class WorkflowAsyncResourceTest extends WorkflowTest { WorkflowAsyncResource workflowResource = new WorkflowAsyncResource(); VariableMapImpl variableMap = new VariableMapImpl(); - Map<String, Object> variableValueType = new HashMap<String, Object>(); + Map<String, Object> variableValueType = new HashMap<>(); - Map<String, Object> requestMsg = new HashMap<String, Object>(); + Map<String, Object> requestMsg = new HashMap<>(); requestMsg.put("value", request); requestMsg.put("type", "String"); - Map<String, Object> msorequestId = new HashMap<String, Object>(); + Map<String, Object> msorequestId = new HashMap<>(); msorequestId.put("type", "String"); msorequestId.put("value",requestId); - Map<String, Object> timeout = new HashMap<String, Object>(); + Map<String, Object> timeout = new HashMap<>(); timeout.put("type", "String"); timeout.put("value","5"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java index ce8eb7afec..6f0095fb02 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java @@ -327,7 +327,7 @@ public class WorkflowTest { String businessKey, String request, Map<String, Object> injectedVariables,
boolean serviceInstantiationModel) {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
// These variables may be overridded by injected variables.
variables.put("mso-service-request-timeout", "180");
@@ -422,7 +422,7 @@ public class WorkflowTest { * @return a VariableMap
*/
private VariableMapImpl createVariableMapImpl(Map<String, Object> variables) {
- Map<String, Object> wrappedVariables = new HashMap<String, Object>();
+ Map<String, Object> wrappedVariables = new HashMap<>();
for (String key : variables.keySet()) {
Object value = variables.get(key);
@@ -441,7 +441,7 @@ public class WorkflowTest { * @return the wrapped variable
*/
private Map<String, Object> wrapVariableValue(Object value) {
- HashMap<String, Object> valueMap = new HashMap<String, Object>();
+ HashMap<String, Object> valueMap = new HashMap<>();
valueMap.put("value", value);
return valueMap;
}
@@ -1634,11 +1634,7 @@ public class WorkflowTest { return null;
}
- Collections.sort(processInstanceList, new Comparator<HistoricProcessInstance>() {
- public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) {
- return m1.getStartTime().compareTo(m2.getStartTime());
- }
- });
+ processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
HistoricProcessInstance processInstance = processInstanceList.get(0);
@@ -1672,11 +1668,7 @@ public class WorkflowTest { return null;
}
- Collections.sort(processInstanceList, new Comparator<HistoricProcessInstance>() {
- public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) {
- return m1.getStartTime().compareTo(m2.getStartTime());
- }
- });
+ processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
@@ -1784,7 +1776,7 @@ public class WorkflowTest { * An object that contains callback data for a "program".
*/
public class CallbackSet {
- private final Map<String, CallbackData> map = new HashMap<String, CallbackData>();
+ private final Map<String, CallbackData> map = new HashMap<>();
/**
* Add untyped callback data to the set.
@@ -1837,7 +1829,7 @@ public class WorkflowTest { /**
* Constructor
* @param contentType the HTTP content type (optional)
- * @param type the callback message type (optional)
+ * @param messageType the callback message type (optional)
* @param content the content
*/
public CallbackData(String contentType, String messageType, String content) {
@@ -1983,8 +1975,8 @@ public class WorkflowTest { * A NamespaceContext class based on a Map.
*/
private class SimpleNamespaceContext implements NamespaceContext {
- private Map<String, String> prefixMap = new HashMap<String, String>();
- private Map<String, String> uriMap = new HashMap<String, String>();
+ private Map<String, String> prefixMap = new HashMap<>();
+ private Map<String, String> uriMap = new HashMap<>();
public synchronized void add(String prefix, String uri) {
prefixMap.put(prefix, uri);
@@ -1998,7 +1990,7 @@ public class WorkflowTest { @Override
public Iterator<String> getPrefixes(String uri) {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
String prefix = uriMap.get(uri);
if (prefix != null) {
list.add(prefix);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java index 2ebb44a644..38d0584d0d 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java @@ -35,11 +35,6 @@ public class FileUtil { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - private FileUtil() { - /** - * Constructor. - */ - } /** * Read the specified resource file and return the contents as a String. * diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java index fc97e69c5c..74f50ba438 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java @@ -45,7 +45,7 @@ public class MockResource { private boolean started = false; private final Integer defaultPort = 28090; private WireMockServer wireMockServer = null; - private static Map<String,String> mockProperties = new HashMap<String,String>(); + private static Map<String,String> mockProperties = new HashMap<>(); public static String getMockProperties(String key) { return mockProperties.get(key); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java index ebbfea5cd1..ba48bffca0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java @@ -31,8 +31,8 @@ import javax.ws.rs.core.Application; @ApplicationPath("/console") public class MockResourceApplication extends Application { - private Set<Object> singletons = new HashSet<Object>(); - private Set<Class<?>> classes = new HashSet<Class<?>>(); + private Set<Object> singletons = new HashSet<>(); + private Set<Class<?>> classes = new HashSet<>(); public MockResourceApplication() { singletons.add(new MockResource()); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java index c9f64d9b26..ffa6701a89 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java @@ -98,5 +98,13 @@ public class StubResponseDatabase { .withBodyFile(responseFile))); } + public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){ + stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBodyFile(responseFile))); + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java new file mode 100644 index 0000000000..8943014ad0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java @@ -0,0 +1,111 @@ +/*- + * ============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.client; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.google.common.base.Charsets; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.ForbiddenException; +import javax.ws.rs.InternalServerErrorException; +import javax.ws.rs.NotAcceptableException; +import javax.ws.rs.NotAllowedException; +import javax.ws.rs.NotAuthorizedException; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.NotSupportedException; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.core.Response.Status; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(JUnitParamsRunner.class) +public class ResponseExceptionMapperImplTest { + + private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl(); + + public static Object[][] statusesAndCorrespondingExceptions() { + return new Object[][]{ + {Status.BAD_REQUEST, BadRequestException.class}, + {Status.UNAUTHORIZED, NotAuthorizedException.class}, + {Status.FORBIDDEN, ForbiddenException.class}, + {Status.NOT_FOUND, NotFoundException.class}, + {Status.METHOD_NOT_ALLOWED, NotAllowedException.class}, + {Status.NOT_ACCEPTABLE, NotAcceptableException.class}, + {Status.PRECONDITION_FAILED, PreconditionFailedException.class}, + {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class}, + {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class}, + {Status.SERVICE_UNAVAILABLE, WebApplicationException.class}, + {Status.BAD_GATEWAY, WebApplicationException.class}, + }; + } + + @Test + @Parameters(method = "statusesAndCorrespondingExceptions") + public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) { + // given + ClientResponseContext responseContext = createMockResponseContext(status); + // when, then + assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(expectedException); + } + + @Test + public void shouldNotThrowExceptionWhenStatusIsOk() { + // given + ClientResponseContext responseContext = createMockResponseContext(Status.OK); + // when, then + assertThatCode(() -> mapper.filter(null, responseContext)).doesNotThrowAnyException(); + } + + @Test + public void shouldThrowExceptionWithCustomMessageWhenResponseHasEntity() { + // given + ClientResponseContext responseContext = createMockResponseContext(Status.BAD_REQUEST); + when(responseContext.hasEntity()).thenReturn(true); + when(responseContext.getEntityStream()).thenReturn(IOUtils.toInputStream("test message", Charsets.UTF_8)); + // when, then + assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(BadRequestException.class) + .hasMessage("test message"); + } + + @Test + public void shouldThrowExceptionWithDefaultMessageWhenResponseHasNoEntity() { + // given + ClientResponseContext responseContext = createMockResponseContext(Status.BAD_REQUEST); + when(responseContext.hasEntity()).thenReturn(false); + // when, then + assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(BadRequestException.class) + .hasMessage("empty message"); + } + + private static ClientResponseContext createMockResponseContext(Status status) { + ClientResponseContext responseContext = mock(ClientResponseContext.class); + when(responseContext.getStatusInfo()).thenReturn(status); + when(responseContext.getStatus()).thenReturn(status.getStatusCode()); + return responseContext; + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java new file mode 100644 index 0000000000..0a323e43d8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java @@ -0,0 +1,83 @@ +/*- + * ============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.client.appc; + +import static org.assertj.core.api.Assertions.assertThat; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openecomp.appc.client.lcm.model.Status; +import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; + +@RunWith(JUnitParamsRunner.class) +public class ApplicationControllerSupportTest { + + public static Object[][] statusesAndCategories() { + return new Object[][]{ + {100, StatusCategory.NORMAL}, + {200, StatusCategory.ERROR}, + {300, StatusCategory.ERROR}, + {400, StatusCategory.NORMAL}, + {401, StatusCategory.ERROR}, + {500, StatusCategory.NORMAL}, + {501, StatusCategory.ERROR}, + {502, StatusCategory.WARNING}, + {800, StatusCategory.WARNING}, + }; + } + + public static Object[][] statusesAndFinalities() { + return new Object[][]{ + {100, false}, + {200, true}, + {300, true}, + {400, true}, + {500, false}, + {800, true}, + }; + } + + @Test + @Parameters(method = "statusesAndCategories") + public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception { + // when + StatusCategory detectedCategory = ApplicationControllerSupport.getCategoryOf(createStatus(code)); + // then + assertThat(detectedCategory).isEqualTo(category); + } + + @Test + @Parameters(method = "statusesAndFinalities") + public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception { + // when + boolean finality = ApplicationControllerSupport.getFinalityOf(createStatus(code)); + // then + assertThat(finality).isEqualTo(expectedFinality); + } + + private Status createStatus(int code) { + Status status = new Status(); + status.setCode(code); + return status; + } +}
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml index 267f175533..960a553757 100644 --- a/bpmn/MSOCoreBPMN/pom.xml +++ b/bpmn/MSOCoreBPMN/pom.xml @@ -2,12 +2,12 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>MSOCoreBPMN</artifactId> <packaging>jar</packaging> @@ -128,7 +128,7 @@ <artifactId>Saxon-HE</artifactId> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> @@ -164,7 +164,7 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java index 204d9e4e5e..9c79df85ff 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java @@ -238,9 +238,10 @@ public class HealthCheckHandler { BPMNLogger.debug(healthcheckDebugEnabled, "Post url is: " + url); //now create a soap request message as follows: - final StringBuffer payload = new StringBuffer(); + final StringBuilder payload = new StringBuilder(); payload.append("\n"); - payload.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:req=\"" + adapterNamespace + "/requestsdb\">\n"); + payload.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:req=\"") + .append(adapterNamespace).append("/requestsdb\">\n"); payload.append("<soapenv:Header/>\n"); payload.append("<soapenv:Body>\n"); payload.append("<req:getSiteStatus>\n"); @@ -270,7 +271,7 @@ public class HealthCheckHandler { BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java index 6059a357b6..b6272057a5 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java @@ -238,7 +238,6 @@ public class PropertyConfiguration { * Reads properties from the specified file, updates the property file cache, and * returns the properties in a map. * @param file the file to read - * @param reload true if this is a reload event * @return a map of properties */ private Map<String, String> readProperties(File file) throws IOException { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java index ce171b56e4..a1719a90ef 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfigurationSetup.java @@ -156,7 +156,7 @@ public class PropertyConfigurationSetup { * Create a map to hold properties to be added to mso.bpmn.properties. */ public static Map<String, String> createBpmnProperties() { - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_PROPERTIES); return properties; } @@ -165,7 +165,7 @@ public class PropertyConfigurationSetup { * Create a map to hold properties to be added to mso.bpmn.urn.properties. */ public static Map<String, String> createBpmnUrnProperties() { - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_URN_PROPERTIES); return properties; } @@ -176,7 +176,7 @@ public class PropertyConfigurationSetup { * PropertyConfiguration, just like they do when a property file is updated on * a real MSO system. This method will optionally wait for the new properties * to be loaded. Timeout results in an IOException. - * @param values new properties + * @param properties new properties * @param wait maximum amount of time to wait for new properties to be loaded, * in milliseconds. A value of zero means, "Do not wait." * @throws IOException diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java index 64068d2b90..f49712ee8b 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java @@ -35,7 +35,7 @@ public class RollbackData implements Serializable { private static final long serialVersionUID = 1L; private Map<String, Map<String, Serializable>> dictionary = - new HashMap<String, Map<String, Serializable>>(); + new HashMap<>(); /** * Returns true if the specified type is stored in this object. @@ -54,12 +54,8 @@ public class RollbackData implements Serializable { * @param value the value */ public void put(String type, String key, String value) { - Map<String, Serializable> mapForType = dictionary.get(type); - - if (mapForType == null) { - mapForType = new HashMap<String, Serializable>(); - dictionary.put(type, mapForType); - } + Map<String, Serializable> mapForType = dictionary + .computeIfAbsent(type, k -> new HashMap<>()); mapForType.put(key, value); } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java index 21653e26c3..b555563936 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java @@ -31,7 +31,7 @@ public class WorkflowException implements Serializable { private final String processKey; private final int errorCode; private final String errorMessage; - + /** * Constructor * @param processKey the process key for the process that generated the exception @@ -44,42 +44,34 @@ public class WorkflowException implements Serializable { this.errorCode = errorCode; this.errorMessage = errorMessage; } - + /** * Returns the process key. */ public String getProcessKey() { return processKey; } - + /** * Returns the error code. */ public int getErrorCode() { return errorCode; } - + /** * Returns the error message. */ public String getErrorMessage() { return errorMessage; } - + /** * Returns a string representation of this object. */ @Override public String toString() { - StringBuilder out = new StringBuilder(); - out.append(getClass().getSimpleName()); - out.append("[processKey="); - out.append(getProcessKey()); - out.append(",errorCode="); - out.append(getErrorCode()); - out.append(",errorMessage="); - out.append(getErrorMessage()); - out.append("]"); - return out.toString(); + return getClass().getSimpleName() + "[processKey=" + getProcessKey() + ",errorCode=" + getErrorCode() + + ",errorMessage=" + getErrorMessage() + "]"; } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java index 4d895f3279..fbed36548e 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/JsonWrapper.java @@ -92,10 +92,6 @@ public abstract class JsonWrapper implements Serializable { JSONObject json = new JSONObject();
try {
json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JsonGenerationException e) {
- LOGGER.debug("Exception :",e);
- } catch (JsonMappingException e) {
- LOGGER.debug("Exception :",e);
} catch (JSONException e) {
LOGGER.debug("Exception :",e);
} catch (IOException e) {
@@ -113,8 +109,6 @@ public abstract class JsonWrapper implements Serializable { jsonString = mapper.writeValueAsString(list);
} catch (JsonGenerationException e) {
LOGGER.debug("Exception :",e);
- } catch (JsonMappingException e) {
- LOGGER.debug("Exception :",e);
} catch (IOException e) {
LOGGER.debug("Exception :",e);
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java index 0e985cc8f1..8581eee25a 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java @@ -146,15 +146,12 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { /**
* This method returns String representation of one combined list of Resources of All Types
- * @return
*/
@JsonIgnore
- public String getServiceResourcesJsonString(){
- StringBuffer serviceResourcesJsonStringBuffer = new StringBuffer();
- serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceNetworks())));
- serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceVnfs())));
- serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceAllottedResources())));
- return serviceResourcesJsonStringBuffer.toString();
+ public String getServiceResourcesJsonString() {
+ return listToJson((this.getServiceNetworks())) +
+ listToJson((this.getServiceVnfs())) +
+ listToJson((this.getServiceAllottedResources()));
}
/**
@@ -186,15 +183,13 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { @JsonIgnore
public String getVnfResource(String resourceObjectId) {
- Iterator<Resource> iter = getServiceResources().iterator();
- while (iter.hasNext()) {
- Resource resource = iter.next();
- //resource.getModelInfo().getModelInvariantId();
+ for (Resource resource : getServiceResources()) {
+ //resource.getModelInfo().getModelInvariantId();
- if ("extracted information".equals(resourceObjectId)){
- return resource.toJsonString();
- }
- }
+ if ("extracted information".equals(resourceObjectId)) {
+ return resource.toJsonString();
+ }
+ }
return "";
}
@@ -205,7 +200,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */
public void addVnfResource(Resource vnfResource) {
if (vnfResources == null){
- vnfResources = new ArrayList<VnfResource>();
+ vnfResources = new ArrayList<>();
}
this.vnfResources.add((VnfResource)vnfResource);
}
@@ -215,7 +210,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */
public void addNetworkResource(Resource networkResource) {
if (networkResources == null){
- networkResources = new ArrayList<NetworkResource>();
+ networkResources = new ArrayList<>();
}
this.networkResources.add((NetworkResource)networkResource);
}
@@ -225,7 +220,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */
public void addAllottedResource(Resource allottedResource) {
if (allottedResources == null){
- allottedResources = new ArrayList<AllottedResource>();
+ allottedResources = new ArrayList<>();
}
this.allottedResources.add((AllottedResource)allottedResource);
}
@@ -290,13 +285,11 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { public boolean replaceResource(Resource newResource){
boolean result = false;
List serviceResources = getServiceResources();
- Iterator<Resource> iter = serviceResources.iterator();
- while (iter.hasNext()) {
- Resource resource = iter.next();
+ for (Resource resource : (Iterable<Resource>) serviceResources) {
System.out.println("resource found");
- if (resource.resourceType == newResource.resourceType){
+ if (resource.resourceType == newResource.resourceType) {
System.out.println("resource type matches");
- if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())){
+ if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())) {
System.out.println("resource id matches");
//returns TRUE if replacement is a success
result = Collections.replaceAll(serviceResources, resource, newResource);
@@ -326,12 +319,9 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */
public boolean deleteResource(Resource resource){
List serviceResources = getServiceResources();
- Iterator<Resource> iter = serviceResources.iterator();
- while (iter.hasNext()) {
- Resource item = iter.next();
-
- if (item.resourceType == resource.resourceType){
- if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())){
+ for (Resource item : (Iterable<Resource>) serviceResources) {
+ if (item.resourceType == resource.resourceType) {
+ if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())) {
//returns TRUE if replacement is a success
return serviceResources.remove(resource);
}
@@ -377,10 +367,8 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { @JsonIgnore
public Resource getServiceResource(String resourceId){
List<Resource> resources = getServiceResources();
- Iterator<Resource> iter = resources.iterator();
- while (iter.hasNext()){
- Resource resource = iter.next();
- if (resource.getResourceId().equalsIgnoreCase(resourceId)){
+ for (Resource resource : resources) {
+ if (resource.getResourceId().equalsIgnoreCase(resourceId)) {
//match
return resource;
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java index 0d8721b4d1..20903c0717 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/VnfResource.java @@ -134,7 +134,7 @@ public class VnfResource extends Resource { // methods to add to the list
public void addVfModule(ModuleResource moduleResource) {
if (vfModules == null){
- vfModules = new ArrayList<ModuleResource>();
+ vfModules = new ArrayList<>();
}
this.vfModules.add(moduleResource);
}
@@ -146,7 +146,6 @@ public class VnfResource extends Resource { *
* default setter for this field deprecated
* @param modelName << serviceResources.modelInfo.modelName
- * @param modelInstanceName
*/
public void constructVnfType(String modelName) {
this.vnfType = modelName.concat("/").concat(this.modelInfo.getModelInstanceName());
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java index 640dc697a2..b0152a1296 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java @@ -117,12 +117,12 @@ public class JsonUtils { * to convert a JSONObject to an XML Doc. The intent of this is to
* correctly generate XML from JSON including TAGs for JSONArrays
*
- * @param jsonObj org.json.JSON object to be converted to XML
+ * @param obj object to be converted to XML
* @param tagName optional XML tagname supplied primarily during recursive calls
* @return String containing the XML translation
*/
public static String toXMLString(Object obj, String tagName) throws JSONException {
- StringBuffer strBuf = new StringBuffer();
+ StringBuilder strBuf = new StringBuilder();
int i;
JSONArray jsonArr;
JSONObject jsonObj;
@@ -388,7 +388,7 @@ public class JsonUtils { return 0;
} else {
if (rawValue instanceof Integer) {
- msoLogger.debug("getJsonValue(): the raw value is an Integer Object=" + ((String) rawValue).toString());
+ msoLogger.debug("getJsonValue(): the raw value is an Integer Object=" + ((String) rawValue));
return (Integer) rawValue;
} else {
msoLogger.debug("getJsonValue(): the raw value is NOT an Integer Object=" + rawValue.toString());
@@ -913,7 +913,7 @@ public class JsonUtils { * and puts it in a Java List<String>.
*
* @param execution
- * @param stringArray - the getJsonValue of a json array of strings
+ * @param jsonArrayOfStrings - the getJsonValue of a json array of strings
*
* @return List - a java list containing the strings
*
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java index 967b1dfe1c..cfa5c853a3 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonWrapper.java @@ -85,10 +85,6 @@ public abstract class JsonWrapper implements Serializable { JSONObject json = new JSONObject();
try {
json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JsonGenerationException e) {
- LOGGER.debug("Exception :",e);
- } catch (JsonMappingException e) {
- LOGGER.debug("Exception :",e);
} catch (JSONException e) {
LOGGER.debug("Exception :",e);
} catch (IOException e) {
@@ -106,8 +102,6 @@ public abstract class JsonWrapper implements Serializable { jsonString = mapper.writeValueAsString(list);
} catch (JsonGenerationException e) {
LOGGER.debug("Exception :",e);
- } catch (JsonMappingException e) {
- LOGGER.debug("Exception :",e);
} catch (IOException e) {
LOGGER.debug("Exception :",e);
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java index ad4a1a52c8..4dde5ae595 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java @@ -88,7 +88,7 @@ public class CustomMyBatisSessionFactory extends @Override protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() { List<CommandInterceptor> defaultCommandInterceptorsTxRequired = - new ArrayList<CommandInterceptor>(); + new ArrayList<>(); defaultCommandInterceptorsTxRequired.add(new LogInterceptor()); defaultCommandInterceptorsTxRequired.add(new CommandContextInterceptor( commandContextFactory, this, true)); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java index 177fafcd4b..c48b671b72 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java @@ -93,7 +93,7 @@ public class URNMapping { * aai:endpoint becomes URN_aai_endpoint <br/> * ae:internal-reporting becomes URN_ae_internal_reporting <br/> * - * @param name the URN + * @param urn the URN * @return a normalized identifier */ public static String createIdentifierFromURN(String urn) { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index c346308e2b..730c1451d5 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -321,14 +321,8 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - Command<List<URNMapping>> command = new Command<List<URNMapping>>() { - @SuppressWarnings("unchecked") - @Override - public List<URNMapping> execute(CommandContext commandContext) { - return (List<URNMapping>) commandContext.getDbSqlSession().selectList( - "mso.urnMapping.selectAll", null); - } - }; + Command<List<URNMapping>> command = commandContext -> (List<URNMapping>) commandContext.getDbSqlSession() + .selectList("mso.urnMapping.selectAll", null); CustomMyBatisSessionFactory sessionFactory = new CustomMyBatisSessionFactory(); sessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration, diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java index 18113fabcd..d25dcb6f3c 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java @@ -65,7 +65,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { processEngineConfiguration.getCustomPreBPMNParseListeners(); if (preParseListeners == null) { - preParseListeners = new ArrayList<BpmnParseListener>(); + preParseListeners = new ArrayList<>(); processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); } @@ -76,7 +76,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { @Override public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { AtomicInteger triggerTaskIndex = new AtomicInteger(1); - List<ActivityImpl> activities = new ArrayList<ActivityImpl>(processDefinition.getActivities()); + List<ActivityImpl> activities = new ArrayList<>(processDefinition.getActivities()); recurse(activities, triggerTaskIndex); } @@ -103,7 +103,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { // cause the process to die. List<PvmTransition> outTransitions = - new ArrayList<PvmTransition>(activity.getOutgoingTransitions()); + new ArrayList<>(activity.getOutgoingTransitions()); for (PvmTransition transition : outTransitions) { String triggerTaskId = "WorkflowExceptionTriggerTask_" + triggerTaskIndex; @@ -112,7 +112,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { ClassDelegateActivityBehavior behavior = new ClassDelegateActivityBehavior( WorkflowExceptionTriggerTask.class.getName(), - new ArrayList<FieldDeclaration>(0)); + new ArrayList<>(0)); triggerTask.setActivityBehavior(behavior); triggerTask.setName("Workflow Exception Trigger Task " + triggerTaskIndex); @@ -124,7 +124,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { transitionImpl.setDestination(triggerTask); } } else if ("subProcess".equals(type)) { - recurse(new ArrayList<ActivityImpl>(activity.getActivities()), triggerTaskIndex); + recurse(new ArrayList<>(activity.getActivities()), triggerTaskIndex); } } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java index c2b832812e..1fc43baef8 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java @@ -64,10 +64,10 @@ public final class XmlTool { private static final Map<String, Integer> ENTITIES = new HashMap<>(); private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL); static { - ENTITIES.put("amp", new Integer(38)); - ENTITIES.put("quot", new Integer(34)); - ENTITIES.put("lt", new Integer(60)); - ENTITIES.put("gt", new Integer(62)); + ENTITIES.put("amp", 38); + ENTITIES.put("quot", 34); + ENTITIES.put("lt", 60); + ENTITIES.put("gt", 62); } /** @@ -130,7 +130,7 @@ public final class XmlTool { /** * Encodes a value so it can be used inside an XML text element. - * @param s the string to encode + * @param value the string to encode * @return the encoded string */ public static String encode(Object value) { @@ -155,7 +155,7 @@ public final class XmlTool { out.append("&"); modified = true; } else if (c < 32 || c > 126) { - out.append("&#" + (int)c + ";"); + out.append("&#").append((int) c).append(";"); modified = true; } else { out.append(c); @@ -171,7 +171,7 @@ public final class XmlTool { /** * Encodes a value so it can be used inside an XML attribute. - * @param s the string to encode + * @param value the string to encode * @return the encoded string */ public static String encodeAttr(Object value) { @@ -199,7 +199,7 @@ public final class XmlTool { out.append("&"); modified = true; } else if (c < 32 || c > 126) { - out.append("&#" + (int)c + ";"); + out.append("&#").append((int) c).append(";"); modified = true; } else { out.append(c); diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java index 9730b129be..2d204c338a 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java @@ -55,7 +55,7 @@ public class TestBaseTask { @Test @Deployment(resources={"BaseTaskTest.bpmn"}) public void shouldInvokeService() { - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); variables.put("firstName", "Jane"); variables.put("lastName", "Doe"); variables.put("age", (Integer)25); diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index 908fcce276..a72240955a 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -1,7 +1,7 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>bpmn</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
@@ -281,17 +281,17 @@ <version>3.4</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCoreBPMN</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCommonBPMN</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCommonBPMN</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
@@ -299,7 +299,7 @@ </dependency>
<dependency>
<!-- unit test utilities -->
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSOCoreBPMN</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
@@ -317,7 +317,7 @@ <version>4.3.2.RELEASE</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSORESTClient</artifactId>
<version>${project.version}</version>
</dependency>
@@ -420,7 +420,7 @@ <!--for yang tools-->
<!-- <dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index d15be38042..cfdc0e9bfa 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -32,17 +32,20 @@ import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils; import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig +import java.util.List; import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.json.JSONObject; +import org.json.JSONArray; import org.apache.commons.lang3.* import org.apache.commons.codec.binary.Base64; import org.springframework.web.util.UriUtils; @@ -77,6 +80,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String Prefix="DCRESI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() public void preProcessRequest (Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -172,7 +176,47 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) } + + public void prepareDecomposeService(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + utils.log("DEBUG", " ***** Completed prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside processDecomposition() of create generic e2e service flow ***** ", isDebugEnabled) + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doServiceHoming(Execution execution) { + //Now Homing is not clear. So to be implemented. + } + public void postProcessAAIGET(Execution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) @@ -402,7 +446,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceName = execution.getVariable("serviceInstanceName") String nsServiceName = resourceType + "_" + serviceInstanceName execution.setVariable("nsServiceName", nsServiceName) - utils.log("INFO", "Prepare VFC Request nsServiceName:" + nsServiceName, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request nsServiceName:" + nsServiceName, isDebugEnabled) String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") String serviceId = execution.getVariable("serviceInstanceId") @@ -412,7 +456,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") String nsServiceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description") execution.setVariable("nsServiceDescription", nsServiceDescription) - utils.log("INFO", "Prepare VFC Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled) List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) //reset the variables execution.setVariable("resourceUUID", "") @@ -427,18 +471,102 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("resourceUUID", resourceUUID) execution.setVariable("resourceInvariantUUID", resourceInvariantUUID) execution.setVariable("resourceParameters", resourceParameters) - utils.log("INFO", "Prepare VFC Request resourceType:" + resourceType, isDebugEnabled) - utils.log("INFO", "Prepare VFC Request resourceUUID:" + resourceUUID, isDebugEnabled) - utils.log("INFO", "Prepare VFC Request resourceParameters:" + resourceParameters, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceType:" + resourceType, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceUUID:" + resourceUUID, isDebugEnabled) + utils.log("INFO", "Prepare Resource Request resourceParameters:" + resourceParameters, isDebugEnabled) } } - utils.log("INFO", "Prepare VFC Request finished", isDebugEnabled) + utils.log("INFO", "Prepare Controller Request finished", isDebugEnabled) + } + /** + * sequence resource. we should analyze resource sequence from service template + * Here we make VF first, and then network for E2E service. + */ + public void sequenceResoure(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled) + String serviceModelUUID = execution.getVariable("modelUuid") + JSONArray networks = cutils.getAllNetworksByServiceModelUuid(execution, serviceModelUUID) + utils.log("DEBUG", "obtained Network list: " + networks, isDebugEnabled) + if (networks == null) { + utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled) + } + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + // Only one match herenetwork + List<String> nsResources = new ArrayList<String>() + List<String> wanResources = new ArrayList<String>() + List<String> resourceSequence = new ArrayList<String>() + for(String resource : resourceList){ + String resourceName = jsonUtil.getJsonValue(resource, "resourceName") + String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId") + //check is network. + boolean isNetwork = false; + if(networks != null){ + for(int i = 0; i < networks.size(); i++){ + String networkUUID = jsonUtil.getJsonValueForKey(networks.get(i), "modelVersionId") + if(StringUtils.equals(resourceUUID, networkUUID)){ + isNetwork = true + break + } + } + } + if(isNetwork){ + wanResources.add(resourceName) + }else{ + nsResources.add(resourceName) + } + } + resourceSequence.addAll(nsResources) + resourceSequence.addAll(wanResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) + execution.setVariable("wanResources", wanResources) + utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled) } + public void getCurrentResoure(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + List<String> resourceSequence = execution.getVariable("resourceSequence") + List<String> wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) + } + /** - * post config request. + * sequence resource */ - public void postConfigRequest(execution){ - //now do noting - } + public void parseNextResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List<String> resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) + } + + /** + * post config request. + */ + public void postConfigRequest(execution){ + //now do noting + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index ecc1488cbc..bf61013c76 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -35,6 +35,7 @@ import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig +import java.util.List; import java.util.UUID; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -589,5 +590,72 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess } utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) } + + public void sequenceResource(execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) + List<String> nsResources = new ArrayList<String>() + List<String> wanResources = new ArrayList<String>() + List<String> resourceSequence = new ArrayList<String>() + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + + + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){ + wanResources.add(it.resourceType) + }else{ + nsResources.add(it.resourceType) + } + } + } + resourceSequence.addAll(wanResources) + resourceSequence.addAll(nsResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) + execution.setVariable("wanResources", wanResources) + utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) + } + + public void getCurrentResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + List<String> resourceSequence = execution.getVariable("resourceSequence") + List<String> wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) + } + + public void parseNextResource(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List<String> resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) + } + }
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index dd6d4514bc..e1cae802e7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -1,753 +1,835 @@ -/*
- * ============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.bpmn.vcpe.scripts;
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.domain.*
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-
-/**
- * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process.
- *
- * @author ek1439
- *
- */
-public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
-
- private static final String DebugFlag = "isDebugLogEnabled"
-
- String Prefix="CVRCS_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils()
- CatalogDbUtils catalogDbUtils = new CatalogDbUtils()
-
- /**
- * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(Execution execution){
- /* Initialize all the process variables in this block */
-
- execution.setVariable("createVcpeServiceRequest", "")
- execution.setVariable("globalSubscriberId", "")
- execution.setVariable("serviceInstanceName", "")
- execution.setVariable("msoRequestId", "")
- execution.setVariable(Prefix+"VnfsCreatedCount", 0)
- execution.setVariable("productFamilyId", "")
- execution.setVariable("brgWanMacAddress", "")
-
- //TODO
- execution.setVariable("sdncVersion", "1707")
- }
-
- // **************************************************
- // Pre or Prepare Request Section
- // **************************************************
- /**
- * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
-
- try {
- // initialize flow variables
- InitializeProcessVariables(execution)
-
- //Config Inputs
- String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay')
- if (isBlank(aaiDistDelay)) {
- msg = "URN_mso_workflow_aai_distribution_delay is null"
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
- execution.setVariable("aaiDistDelay", aaiDistDelay)
- utils.log("DEBUG","AAI distribution delay: " + aaiDistDelay, isDebugEnabled)
-
- // check for incoming json message/input
- String createVcpeServiceRequest = execution.getVariable("bpmnRequest")
- utils.logAudit(createVcpeServiceRequest)
- execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest);
- println 'createVcpeServiceRequest - ' + createVcpeServiceRequest
-
- // extract requestId
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {
- serviceInstanceId = UUID.randomUUID().toString()
- utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled)
- } else {
- utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled)
- }
-
- serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceInstanceId)
-
- String requestAction = execution.getVariable("requestAction")
- execution.setVariable("requestAction", requestAction)
-
- setBasicDBAuthHeader(execution, isDebugEnabled)
-
- String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source")
- if ((source == null) || (source.isEmpty())) {
- source = "VID"
- }
- execution.setVariable("source", source)
-
- // extract globalSubscriberId
- String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")
-
- // verify element global-customer-id is sent from JSON input, throw exception if missing
- if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) {
- String dataErrorMessage = " Element 'globalSubscriberId' is missing. "
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- execution.setVariable("globalCustomerId", globalSubscriberId)
- }
-
- // extract subscriptionServiceType
- String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)
-
- String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback")
- execution.setVariable("disableRollback", suppressRollback)
- utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)
-
- String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")
- execution.setVariable("productFamilyId", productFamilyId)
- utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)
-
- String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo")
- execution.setVariable("subscriberInfo", subscriberInfo)
- utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)
-
- /*
- * Extracting User Parameters from incoming Request and converting into a Map
- */
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
-
- Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)
-
- //InputParams
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
+/* + * ============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.bpmn.vcpe.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.domain.* + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.json.JSONArray; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* + +/** + * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process. + * + * @author ek1439 + * + */ +public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { + + private static final String DebugFlag = "isDebugLogEnabled" + + String Prefix="CVRCS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + CatalogDbUtils catalogDbUtils = new CatalogDbUtils() + + /** + * This method is executed during the preProcessRequest task of the + * <class>CreateServiceInstance.bpmn</class> process. + * @param execution + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("createVcpeServiceRequest", "") + execution.setVariable("globalSubscriberId", "") + execution.setVariable("serviceInstanceName", "") + execution.setVariable("msoRequestId", "") + execution.setVariable(Prefix+"VnfsCreatedCount", 0) + execution.setVariable("productFamilyId", "") + execution.setVariable("brgWanMacAddress", "") + execution.setVariable("customerLocation", "") + + //TODO + execution.setVariable("sdncVersion", "1707") + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the + * <class>CreateServiceInstance.bpmn</class> process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + //Config Inputs + String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay') + if (isBlank(aaiDistDelay)) { + msg = "URN_mso_workflow_aai_distribution_delay is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("aaiDistDelay", aaiDistDelay) + utils.log("DEBUG","AAI distribution delay: " + aaiDistDelay, isDebugEnabled) + + // check for incoming json message/input + String createVcpeServiceRequest = execution.getVariable("bpmnRequest") + utils.logAudit(createVcpeServiceRequest) + execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest); + println 'createVcpeServiceRequest - ' + createVcpeServiceRequest + + // extract requestId + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { + serviceInstanceId = UUID.randomUUID().toString() + utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled) + } else { + utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled) + } + + serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + String requestAction = execution.getVariable("requestAction") + execution.setVariable("requestAction", requestAction) + + setBasicDBAuthHeader(execution, isDebugEnabled) + + String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + source = "VID" + } + execution.setVariable("source", source) + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.subscriberInfo.globalSubscriberId") + + // verify element global-customer-id is sent from JSON input, throw exception if missing + if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) { + String dataErrorMessage = " Element 'globalSubscriberId' is missing. " + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + execution.setVariable("globalCustomerId", globalSubscriberId) + } + + // extract subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) + + String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) + + String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) + + String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.subscriberInfo") + execution.setVariable("subscriberInfo", subscriberInfo) + utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled) + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + + Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest) + - Map<String, String> inputMap = [:]
-
-
- if (userParams) {
- userParams.each {
- userParam ->
- if("BRG_WAN_MAC_Address".equals(userParam?.name)) {
- execution.setVariable("brgWanMacAddress", userParam.value)
- inputMap.put("BRG_WAN_MAC_Address", userParam.value)
- }
- }
- }
-
- utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
- execution.setVariable("serviceInputParams", inputMap)
-
- utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable(Prefix+"requestInfo", requestInfo)
-
- utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex){
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void sendSyncResponse(Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- String requestId = execution.getVariable("mso-request-id")
-
- // RESTResponse (for API Handler (APIH) Reply Task)
- String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()
-
- utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
- sendWorkflowResponse(execution, 202, syncResponse)
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- // *******************************
- //
- // *******************************
- public void prepareDecomposeService(Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
-
- //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB
- String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo")
- execution.setVariable("serviceModelInfo", serviceModelInfo)
-
- utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- // *******************************
- //
- // *******************************
- public void prepareCreateServiceInstance(Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- /*
- * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
- * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- *
- */
- String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
-// String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters")
-// execution.setVariable("serviceInputParams", serviceInputParams)
-
- - String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName")
- execution.setVariable("serviceInstanceName", serviceInstanceName)
-
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName())
-
- utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void postProcessServiceInstanceCreate (Execution execution){
- def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable(DebugFlag)
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- String requestId = execution.getVariable("mso-request-id")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- String serviceInstanceName = execution.getVariable("serviceInstanceName")
-
- try {
-
- String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
- execution.setVariable(Prefix+"setUpdateDbInstancePayload", payload)
- utils.logAudit(Prefix+"setUpdateDbInstancePayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
- }
-
-
- public void processDecomposition (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- try {
-
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
-
- // VNFs
- List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()
- filterVnfs(vnfList)
- serviceDecomposition.setServiceVnfs(vnfList)
-
- execution.setVariable("vnfList", vnfList)
- execution.setVariable("vnfListString", vnfList.toString())
-
- String vnfModelInfoString = ""
- if (vnfList != null && vnfList.size() > 0) {
- execution.setVariable(Prefix+"VNFsCount", vnfList.size())
- utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled)
- ModelInfo vnfModelInfo = vnfList[0].getModelInfo()
-
- vnfModelInfoString = vnfModelInfo.toString()
- String vnfModelInfoWithRoot = vnfModelInfo.toString()
- vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo")
- } else {
- execution.setVariable(Prefix+"VNFsCount", 0)
- utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled)
- }
-
- execution.setVariable("vnfModelInfo", vnfModelInfoString)
- execution.setVariable("vnfModelInfoString", vnfModelInfoString)
- utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
-
- utils.log("DEBUG", " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- sendSyncError(execution)
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. processDecomposition() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- private void filterVnfs(List<VnfResource> vnfList) {
- if(vnfList == null) {
- return
- }
-
- // remove BRG & TXC from VNF list
-
- Iterator<VnfResource> it = vnfList.iterator()
- while(it.hasNext()) {
- VnfResource vr = it.next()
-
- String role = vr.getNfRole()
- if(role == "BRG" || role == "TunnelXConn") {
- it.remove()
- }
- }
- }
-
-
- public void prepareCreateAllottedResourceTXC(Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- /*
- * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
- * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- *
- */
- String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
-
- //allottedResourceModelInfo
- //allottedResourceRole
- //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
- //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.
- List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
- if (allottedResources != null) {
- Iterator iter = allottedResources.iterator();
- while (iter.hasNext()){
- AllottedResource allottedResource = (AllottedResource)iter.next();
-
- utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled)
- utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)
- if("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())){
- //set create flag to true
- execution.setVariable("createTXCAR", true)
- ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
- execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonStringNoRootName())
- execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole())
- execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType())
- //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the TXC,
- //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing BB would have populated).
- execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId())
- } - }
- }
-
- //unit test only
- String allottedResourceId = execution.getVariable("allottedResourceId")
- execution.setVariable("allottedResourceIdTXC", allottedResourceId)
- utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)
-
- utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
- public void prepareCreateAllottedResourceBRG(Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- /*
- * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
- * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
- *
- */
- String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
-
- //allottedResourceModelInfo
- //allottedResourceRole
- //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
- //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.
- List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
- if (allottedResources != null) {
- Iterator iter = allottedResources.iterator();
- while (iter.hasNext()){
- AllottedResource allottedResource = (AllottedResource)iter.next();
-
- utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled)
- utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)
- if("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())){
- //set create flag to true
- execution.setVariable("createBRGAR", true)
- ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
- execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonStringNoRootName())
- execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole())
- execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType())
- //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG,
- //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated).
- execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId())
- }
- }
- }
-
- //unit test only
- String allottedResourceId = execution.getVariable("allottedResourceId")
- execution.setVariable("allottedResourceIdBRG", allottedResourceId)
- utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)
-
- utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- - - // *******************************
- // Generate Network request Section
- // *******************************
- public void prepareVnfAndModulesCreate (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- // String disableRollback = execution.getVariable("disableRollback")
- // def backoutOnFailure = ""
- // if(disableRollback != null){
- // if ( disableRollback == true) {
- // backoutOnFailure = "false"
- // } else if ( disableRollback == false) {
- // backoutOnFailure = "true"
- // }
- // }
- //failIfExists - optional
-
- String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
- String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")
- execution.setVariable("productFamilyId", productFamilyId)
- utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled)
-
- List<VnfResource> vnfList = execution.getVariable("vnfList")
-
- Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")
- String vnfModelInfoString = null;
-
- if (vnfList != null && vnfList.size() > 0 ) {
- utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled)
- ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo()
- utils.log("DEBUG", "got 0 ", isDebugEnabled)
- ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo()
- vnfModelInfoString = vnfModelInfo.toString()
- } else {
- //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored
- vnfModelInfoString = execution.getVariable("vnfModelInfo")
- }
-
- utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
-
- // extract cloud configuration
- String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")
- execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)
- utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)
- String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")
- execution.setVariable("tenantId", tenantId)
- utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)
-
- String sdncVersion = execution.getVariable("sdncVersion")
- utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)
-
- utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- // *******************************
- // Validate Vnf request Section -> increment count
- // *******************************
- public void validateVnfCreate (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- try {
- utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")
- vnfsCreatedCount++
-
- execution.setVariable(Prefix+"VnfsCreatedCount", vnfsCreatedCount)
-
- utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- // *****************************************
- // Prepare Completion request Section
- // *****************************************
- public void postProcessResponse (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String source = execution.getVariable("source")
- String requestId = execution.getVariable("mso-request-id")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- String msoCompletionRequest =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <status-message>Service Instance has been created successfully via macro orchestration</status-message>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <mso-bpel-name>BPMN macro create</mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- utils.logAudit(xmlMsoCompletionRequest)
- execution.setVariable(Prefix+"Success", true)
- execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void preProcessRollback (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
- try {
-
- Object workflowException = execution.getVariable("WorkflowException");
-
- if (workflowException instanceof WorkflowException) {
- utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
- execution.setVariable("prevWorkflowException", workflowException);
- //execution.setVariable("WorkflowException", null);
- }
- } catch (BpmnError e) {
- utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
- } catch(Exception ex) {
- String msg = "Exception in preProcessRollback. " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- }
- utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
- }
-
- public void postProcessRollback (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
- String msg = ""
- try {
- Object workflowException = execution.getVariable("prevWorkflowException");
- if (workflowException instanceof WorkflowException) {
- utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
- execution.setVariable("WorkflowException", workflowException);
- }
- } catch (BpmnError b) {
- utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
- throw b;
- } catch(Exception ex) {
- msg = "Exception in postProcessRollback. " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- }
- utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
- }
-
- public void prepareFalloutRequest(Execution execution){
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)
-
- try {
- WorkflowException wfex = execution.getVariable("WorkflowException")
- utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)
- String requestInfo = execution.getVariable(Prefix+"requestInfo")
- utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)
-
- //TODO. hmmm. there is no way to UPDATE error message.
-// String errorMessage = wfex.getErrorMessage()
-// boolean successIndicator = execution.getVariable("DCRESI_rolledBack")
-// if (successIndicator){
-// errorMessage = errorMessage + ". Rollback successful."
-// } else {
-// errorMessage = errorMessage + ". Rollback not completed."
-// }
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
-
- execution.setVariable(Prefix+"falloutRequest", falloutRequest)
-
- } catch (Exception ex) {
- utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process")
- }
- utils.log("DEBUG", "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)
- }
-
-
- public void sendSyncError (Execution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- execution.setVariable("prefix", Prefix)
-
- utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String errorMessage = ""
- def wfe = execution.getVariable("WorkflowException")
- if (wfe instanceof WorkflowException) {
- errorMessage = wfe.getErrorMessage()
- } else {
- errorMessage = "Sending Sync Error."
- }
-
- String buildworkflowException =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
- }
-
- public void processJavaException(Execution execution){
- def isDebugEnabled=execution.getVariable(DebugFlag)
- execution.setVariable("prefix",Prefix)
- try{
- utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
- execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")
- }catch(BpmnError b){
- utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)
- throw b
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")
- }
- utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
- }
-}
+ //InputParams + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map<String, String> inputMap = [:] + + + if (userParams) { + userParams.each { + userParam -> + if("BRG_WAN_MAC_Address".equals(userParam?.name)) { + execution.setVariable("brgWanMacAddress", userParam.value) + inputMap.put("BRG_WAN_MAC_Address", userParam.value) + } + if("Customer_Location".equals(userParam?.name)) { + execution.setVariable("customerLocation", userParam.value) + userParam.value.each { + customerLocParam -> + inputMap.put(customerLocParam.key, customerLocParam.value) + } + } + } + } + + utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) + execution.setVariable("serviceInputParams", inputMap) + + utils.log("DEBUG", "Incoming brgWanMacAddress is: " + + execution.getVariable('brgWanMacAddress'), isDebugEnabled) + utils.log("DEBUG", "Incoming customerLocation is: " + + execution.getVariable('customerLocation'), isDebugEnabled) + + //For Completion Handler & Fallout Handler + String requestInfo = + """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> + <request-id>${requestId}</request-id> + <action>CREATE</action> + <source>${source}</source> + </request-info>""" + + execution.setVariable(Prefix+"requestInfo", requestInfo) + + utils.log("DEBUG", + " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow." + + " Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String requestId = execution.getVariable("mso-request-id") + + // RESTResponse (for API Handler (APIH) Reply Task) + String syncResponse ="""{"requestReferences":{ + "instanceId":"${serviceInstanceId}", + "requestId":"${requestId}" + }}""".trim() + + utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareDecomposeService(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", + " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled) + + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + + //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB + String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.modelInfo") + execution.setVariable("serviceModelInfo", serviceModelInfo) + + utils.log("DEBUG", + " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareCreateServiceInstance(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", + " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled) + + /* + * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from + * DecompositionObject + * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + * ModelInfo modelInfo = serviceDecomposition.getModelInfo() + * + */ + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") +// String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, +// "requestDetails.requestParameters") +// execution.setVariable("serviceInputParams", serviceInputParams) + + + String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.requestInfo.instanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName()) + + utils.log("DEBUG", + " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void postProcessServiceInstanceCreate (Execution execution){ + def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' + + 'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable(DebugFlag) + logDebug('Entered ' + method, isDebugLogEnabled) + + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + + try { + + String payload = """ + <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:req="http://org.openecomp.mso/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <req:updateInfraRequest> + <requestId>${requestId}</requestId> + <lastModifiedBy>BPEL</lastModifiedBy> + <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> + <serviceInstanceName>${serviceInstanceName}</serviceInstanceName> + </req:updateInfraRequest> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable(Prefix+"setUpdateDbInstancePayload", payload) + utils.logAudit(Prefix+"setUpdateDbInstancePayload: " + payload) + logDebug('Exited ' + method, isDebugLogEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + } + + + public void processDecomposition (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) + + try { + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + // VNFs + List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs() + filterVnfs(vnfList) + serviceDecomposition.setServiceVnfs(vnfList) + + execution.setVariable("vnfList", vnfList) + execution.setVariable("vnfListString", vnfList.toString()) + + String vnfModelInfoString = "" + if (vnfList != null && vnfList.size() > 0) { + execution.setVariable(Prefix+"VNFsCount", vnfList.size()) + utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled) + ModelInfo vnfModelInfo = vnfList[0].getModelInfo() + + vnfModelInfoString = vnfModelInfo.toString() + String vnfModelInfoWithRoot = vnfModelInfo.toString() + vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") + } else { + execution.setVariable(Prefix+"VNFsCount", 0) + utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled) + } + + execution.setVariable("vnfModelInfo", vnfModelInfoString) + execution.setVariable("vnfModelInfoString", vnfModelInfoString) + utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + utils.log("DEBUG", + " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "processDecomposition() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + private void filterVnfs(List<VnfResource> vnfList) { + if(vnfList == null) { + return + } + + // remove BRG & TXC from VNF list + + Iterator<VnfResource> it = vnfList.iterator() + while(it.hasNext()) { + VnfResource vr = it.next() + + String role = vr.getNfRole() + if(role == "BRG" || role == "TunnelXConn") { + it.remove() + } + } + } + + + public void prepareCreateAllottedResourceTXC(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", + " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled) + + /* + * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from + * DecompositionObject + * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + * ModelInfo modelInfo = serviceDecomposition.getModelInfo() + * + */ + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //allottedResourceModelInfo + //allottedResourceRole + //The model Info parameters are a JSON structure as defined in the Service Instantiation API. + //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this + //BB will query the full model from the Catalog DB. + List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources() + if (allottedResources != null) { + Iterator iter = allottedResources.iterator(); + while (iter.hasNext()){ + AllottedResource allottedResource = (AllottedResource)iter.next(); + + utils.log("DEBUG", " getting model info for AllottedResource # :" + + allottedResource.toJsonStringNoRootName(), isDebugEnabled) + utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + + allottedResource.getAllottedResourceType(), isDebugEnabled) + if("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())){ + //set create flag to true + execution.setVariable("createTXCAR", true) + ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() + execution.setVariable("allottedResourceModelInfoTXC", + allottedResourceModelInfo.toJsonStringNoRootName()) + execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole()) + execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType()) + //After decomposition and homing BBs, there should be an allotted resource object in the + // decomposition that represents the TXC, + //and in its homingSolution section should be found the infraServiceInstanceId + // (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing + // BB would have populated). + execution.setVariable("parentServiceInstanceIdTXC", + allottedResource.getHomingSolution().getServiceInstanceId()) + } + } + } + + //unit test only + String allottedResourceId = execution.getVariable("allottedResourceId") + execution.setVariable("allottedResourceIdTXC", allottedResourceId) + utils.log("DEBUG", + "setting allottedResourceId CreateVcpeResCustService "+ allottedResourceId, isDebugEnabled) + + utils.log("DEBUG", + " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", + isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. " + + "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + public void prepareCreateAllottedResourceBRG(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", + " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled) + + /* + * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from + * DecompositionObject + * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + * ModelInfo modelInfo = serviceDecomposition.getModelInfo() + * + */ + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //allottedResourceModelInfo + //allottedResourceRole + //The model Info parameters are a JSON structure as defined in the Service Instantiation API. + //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this + // BB will query the full model from the Catalog DB. + List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources() + if (allottedResources != null) { + Iterator iter = allottedResources.iterator(); + while (iter.hasNext()){ + AllottedResource allottedResource = (AllottedResource)iter.next(); + + utils.log("DEBUG", " getting model info for AllottedResource # :" + + allottedResource.toJsonStringNoRootName(), isDebugEnabled) + utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + + allottedResource.getAllottedResourceType(), isDebugEnabled) + if("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())){ + //set create flag to true + execution.setVariable("createBRGAR", true) + ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() + execution.setVariable("allottedResourceModelInfoBRG", + allottedResourceModelInfo.toJsonStringNoRootName()) + execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole()) + execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType()) + //After decomposition and homing BBs, there should be an allotted resource object in the + // decomposition that represents the BRG, + //and in its homingSolution section should be found the infraServiceInstanceId + // (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing + // BB would have populated). + execution.setVariable("parentServiceInstanceIdBRG", + allottedResource.getHomingSolution().getServiceInstanceId()) + } + } + } + + //unit test only + String allottedResourceId = execution.getVariable("allottedResourceId") + execution.setVariable("allottedResourceIdBRG", allottedResourceId) + utils.log("DEBUG", + "setting allottedResourceId CreateVcpeResCustService " + allottedResourceId, isDebugEnabled) + + utils.log("DEBUG", + " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", + isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. " + + "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareVnfAndModulesCreate (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", + " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled) + + // String disableRollback = execution.getVariable("disableRollback") + // def backoutOnFailure = "" + // if(disableRollback != null){ + // if ( disableRollback == true) { + // backoutOnFailure = "false" + // } else if ( disableRollback == false) { + // backoutOnFailure = "true" + // } + // } + //failIfExists - optional + + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) + + List<VnfResource> vnfList = execution.getVariable("vnfList") + + Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount") + String vnfModelInfoString = null; + + if (vnfList != null && vnfList.size() > 0 ) { + utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) + ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo() + utils.log("DEBUG", "got 0 ", isDebugEnabled) + ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo() + vnfModelInfoString = vnfModelInfo.toString() + } else { + //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored + vnfModelInfoString = execution.getVariable("vnfModelInfo") + } + + utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) + + utils.log("DEBUG", + " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfCreate (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + try { + utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled) + + Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount") + vnfsCreatedCount++ + + execution.setVariable(Prefix+"VnfsCreatedCount", vnfsCreatedCount) + + utils.log("DEBUG", + " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected Error from method validateVnfCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled) + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String msoCompletionRequest = + """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" + xmlns:ns="http://org.openecomp/mso/request/types/v1"> + <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> + <request-id>${requestId}</request-id> + <action>CREATE</action> + <source>${source}</source> + </request-info> + <status-message>Service Instance has been created successfully via macro orchestration</status-message> + <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> + <mso-bpel-name>BPMN macro create</mso-bpel-name> + </aetgt:MsoCompletionRequest>""" + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable(Prefix+"Success", true) + execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest) + utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " + + "Unexpected Error from method postProcessResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void preProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled) + } + + public void postProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + } catch (BpmnError b) { + utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled) + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable(DebugFlag) + + utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestInfo = execution.getVariable(Prefix+"requestInfo") + utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) + + //TODO. hmmm. there is no way to UPDATE error message. +// String errorMessage = wfex.getErrorMessage() +// boolean successIndicator = execution.getVariable("DCRESI_rolledBack") +// if (successIndicator){ +// errorMessage = errorMessage + ". Rollback successful." +// } else { +// errorMessage = errorMessage + ". Rollback not completed." +// } + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable(Prefix+"falloutRequest", falloutRequest) + + } catch (Exception ex) { + utils.log("DEBUG", + "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), + isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process") + } + utils.log("DEBUG", + "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled) + + try { + String errorMessage = "" + def wfe = execution.getVariable("WorkflowException") + if (wfe instanceof WorkflowException) { + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> + <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> + <aetgt:ErrorCode>7000</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + } + + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable(DebugFlag) + execution.setVariable("prefix",Prefix) + try{ + utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) + // Adding below line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") + }catch(BpmnError b){ + utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + // Adding below line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java index 80b11bbdf5..dbf5a57f33 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java @@ -32,8 +32,8 @@ import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; @ApplicationPath("/")
public class WorkflowResourceApplication extends Application {
- private Set<Object> singletons = new HashSet<Object>();
- private Set<Class<?>> classes = new HashSet<Class<?>>();
+ private Set<Object> singletons = new HashSet<>();
+ private Set<Class<?>> classes = new HashSet<>();
public WorkflowResourceApplication() {
singletons.add(new WorkflowResource());
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index dfa390c296..38a44ab1f6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -150,7 +150,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getPostStringBody(ResourceOperationStatus resourceOperationStatus) { logger.info("AbstractSdncOperationTask.getPostStringBody begin!"); - String postBody = new String(postBodyTemplate); + String postBody = postBodyTemplate; postBody = postBody.replace("$errorCode", resourceOperationStatus.getErrorCode()); postBody = postBody.replace("$jobId", resourceOperationStatus.getJobId()); postBody = postBody.replace("$operType", resourceOperationStatus.getOperType()); @@ -166,7 +166,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getGetStringBody(String serviceId, String operationId, String resourceTemplateUUID) { logger.info("AbstractSdncOperationTask.getGetStringBody begin!"); - String getBody = new String(getBodyTemplate); + String getBody = getBodyTemplate; getBody = getBody.replace("$operationId", operationId); getBody = getBody.replace("$resourceTemplateUUID", resourceTemplateUUID); getBody = getBody.replace("$serviceId", serviceId); @@ -319,7 +319,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { updateResOperStatus(resourceOperationStatus); logger.info("AbstractSdncOperationTask.updateProgress end!"); } catch (Exception exception) { - System.out.println(exception); logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString()); @@ -403,7 +402,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return vlaue; } } catch (Exception e) { - System.out.println(e); LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); } return defaultValue; @@ -416,7 +414,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return vlaue; } } catch (Exception e) { - System.out.println(e); LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); } return defaultValue; diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java index 698f0c54dc..60bc83b0ea 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java @@ -77,7 +77,7 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody.toString(), "SDNC", ""); + LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly end!"); diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index 89d0958c75..602894475c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -77,7 +77,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody.toString(), "SDNC", ""); + LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly end!"); diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index 2fbb898f7b..ddc87c7d55 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -1,20 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="DoCreateE2EServiceInstance" name="DoCreateE2EServiceInstance" isExecutable="true"> + <bpmn2:process id="DoCreateE2EServiceInstanceV3" name="DoCreateE2EServiceInstanceV3" isExecutable="true"> <bpmn2:startEvent id="createSI_startEvent" name="Start Flow"> - <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1qiiycn</bpmn2:outgoing> </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="createSI_startEvent" targetRef="preProcessRequest_ScriptTask" /> <bpmn2:scriptTask id="preProcessRequest_ScriptTask" name="PreProcess Incoming Request" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> + <bpmn2:incoming>SequenceFlow_1qiiycn</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0w9t6tc</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* def dcsi = new DoCreateE2EServiceInstance() dcsi.preProcessRequest(execution) ]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="CustomE2EGetService" targetRef="ScriptTask_0i8cqdy" /> - <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="preProcessRequest_ScriptTask" targetRef="CustomE2EGetService" /> <bpmn2:callActivity id="CustomE2EGetService" name="Call Custom E2E Get Service" calledElement="CustomE2EGetService"> <bpmn2:extensionElements> <camunda:in source="serviceInstanceName" target="GENGS_serviceInstanceName" /> @@ -25,7 +23,7 @@ dcsi.preProcessRequest(execution) <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="serviceType" target="GENGS_serviceType" /> </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1i7t9hq</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> </bpmn2:callActivity> <bpmn2:callActivity id="CustomE2EPutService" name="Call Custom E2E Put Service" calledElement="CustomE2EPutService"> @@ -93,67 +91,29 @@ dcsi.postProcessAAIGET(execution)]]></bpmn2:script> <bpmn2:sequenceFlow id="SequenceFlow_1w01tqs" sourceRef="ScriptTask_0i8cqdy" targetRef="CustomE2EPutService" /> <bpmn2:scriptTask id="ScriptTask_0q37vn9" name="Post Process AAI PUT" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_129ih1g</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_03fabby</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1tkgqu3</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstance() ddsi.postProcessAAIPUT(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_0081lne" name="Prepare Resource Requst For overlay" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1pjr82f</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0ofqw6v</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -execution.setVariable("resourceType", "overlay") -def csi = new DoCreateE2EServiceInstance() -csi.preResourceRequest(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_0wvq4t8" name="Prepare Resource Request for vEPC" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_05gdjox</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_15zgrcq</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -execution.setVariable("resourceType", "vEPC") -def csi = new DoCreateE2EServiceInstance() -csi.preResourceRequest(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:callActivity id="CallActivity_0uwm4l1" name="Call DoCreateVFCNetworkServiceInstance For vEPC" calledElement="DoCreateVFCNetworkServiceInstance"> - <bpmn2:extensionElements> - <camunda:in source="nsServiceName" target="nsServiceName" /> - <camunda:in source="nsServiceDescription" target="nsServiceDescription" /> - <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> - <camunda:in source="serviceType" target="serviceType" /> - <camunda:in source="serviceId" target="serviceId" /> - <camunda:in source="operationId" target="operationId" /> - <camunda:in source="resourceType" target="resourceType" /> - <camunda:in source="resourceUUID" target="resourceUUID" /> - <camunda:in source="resourceParameters" target="resourceParameters" /> - <camunda:in source="operationType" target="operationType" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_15zgrcq</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0k4q7jm</bpmn2:outgoing> - </bpmn2:callActivity> <bpmn2:scriptTask id="ScriptTask_1xdjlzm" name="Post Config Service Instance Creation" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1vvdkcs</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_092ghvu</bpmn2:outgoing> + <bpmn2:incoming>SequenceFlow_16nxl6h</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0vbznai</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* def csi = new DoCreateE2EServiceInstance() csi.postConfigRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_0ofqw6v" sourceRef="ScriptTask_0081lne" targetRef="CallActivity_09c3ajg" /> - <bpmn2:sequenceFlow id="SequenceFlow_15zgrcq" sourceRef="ScriptTask_0wvq4t8" targetRef="CallActivity_0uwm4l1" /> - <bpmn2:sequenceFlow id="SequenceFlow_1vvdkcs" sourceRef="CallActivity_09c3ajg" targetRef="ScriptTask_1xdjlzm" /> - <bpmn2:sequenceFlow id="SequenceFlow_092ghvu" sourceRef="ScriptTask_1xdjlzm" targetRef="EndEvent_0kbbt94" /> <bpmn2:endEvent id="EndEvent_0kbbt94"> - <bpmn2:incoming>SequenceFlow_092ghvu</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0vbznai</bpmn2:incoming> </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_0k4q7jm" sourceRef="CallActivity_0uwm4l1" targetRef="Task_0aidjmp" /> <bpmn2:sequenceFlow id="SequenceFlow_1qctzm0" sourceRef="Task_0uiekmn" targetRef="Task_0raqlqc" /> <bpmn2:scriptTask id="Task_0uiekmn" name="Prepare Resource Oper Status" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_03fabby</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1hbesp9</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1qctzm0</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstance() ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_05gdjox" sourceRef="Task_0raqlqc" targetRef="ScriptTask_0wvq4t8" /> <bpmn2:serviceTask id="Task_0raqlqc" name="Init Resource Oper Status"> <bpmn2:extensionElements> <camunda:connector> @@ -174,307 +134,544 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script> </camunda:connector> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_1qctzm0</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_05gdjox</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_10reo7r</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="Task_0io5qby" name="Call Sync SDNC service Create " camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncServiceTopologyOperationTask"> + <bpmn2:incoming>SequenceFlow_1vprtt9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_11f2zuu</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_0ua1bbk" sourceRef="Task_0aidjmp" targetRef="Task_03n6y9h" /> - <bpmn2:scriptTask id="Task_0aidjmp" name="Prepare Resource Request For vIMS" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0k4q7jm</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0ua1bbk</bpmn2:outgoing> + <bpmn2:sequenceFlow id="SequenceFlow_10reo7r" sourceRef="Task_0raqlqc" targetRef="ScriptTask_1y0los4" /> + <bpmn2:sequenceFlow id="SequenceFlow_11f2zuu" sourceRef="Task_0io5qby" targetRef="IntermediateThrowEvent_0f2w7aj" /> + <bpmn2:scriptTask id="ScriptTask_1y0los4" name="Sequence Resource" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_10reo7r</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13d9g1n</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -execution.setVariable("resourceType", "vIMS") -def csi = new DoCreateE2EServiceInstance() -csi.preResourceRequest(execution)]]></bpmn2:script> +def ddsi = new DoCreateE2EServiceInstance() +ddsi.sequenceResoure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_13d9g1n" sourceRef="ScriptTask_1y0los4" targetRef="ExclusiveGateway_07rr3wp" /> + <bpmn2:exclusiveGateway id="ExclusiveGateway_0n9y4du" name="All ResourceFinished?"> + <bpmn2:incoming>SequenceFlow_1jenxlp</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0q6uy30</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_16nxl6h</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_0q6uy30" name="no" sourceRef="ExclusiveGateway_0n9y4du" targetRef="ScriptTask_0l4nkqr"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("allResourceFinished" ) == "false" )}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="ScriptTask_0y4u2ty" name="Parse Next Resource" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_13c7bhn</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1jenxlp</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateE2EServiceInstance() +ddsi.parseNextResource(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1hgiln0" sourceRef="Task_03n6y9h" targetRef="Task_0io5qby" /> - <bpmn2:callActivity id="Task_03n6y9h" name="Call DoCreateVFCNetworkServiceInstance For vIMS" calledElement="DoCreateVFCNetworkServiceInstance"> + <bpmn2:sequenceFlow id="SequenceFlow_1jenxlp" sourceRef="ScriptTask_0y4u2ty" targetRef="ExclusiveGateway_0n9y4du" /> + <bpmn2:scriptTask id="ScriptTask_0l4nkqr" name="Get Current Resource" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0q6uy30</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1qozd66</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0uiygod</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateE2EServiceInstance() +ddsi.getCurrentResoure(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:exclusiveGateway id="ExclusiveGateway_07rr3wp" name="Is SDN-C Service Needed"> + <bpmn2:incoming>SequenceFlow_13d9g1n</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18wj44x</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1vprtt9</bpmn2:outgoing> + </bpmn2:exclusiveGateway> + <bpmn2:sequenceFlow id="SequenceFlow_18wj44x" name="no" sourceRef="ExclusiveGateway_07rr3wp" targetRef="IntermediateThrowEvent_0f2w7aj"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" ) == "false" )}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:scriptTask id="Task_0qlkmvt" name="Prepare resource recipe Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0uiygod</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1u9k0dm</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateE2EServiceInstance() +ddsi.prepareResourceRecipeRequest(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:scriptTask id="Task_12ghoph" name="Execute Resource Recipe"> + <bpmn2:incoming>SequenceFlow_1u9k0dm</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_13c7bhn</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateE2EServiceInstance() +ddsi.executeResourceRecipe(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0bq4fxs" name="Go to Decompose_Service"> + <bpmn2:incoming>SequenceFlow_0w9t6tc</bpmn2:incoming> + <bpmn2:linkEventDefinition name="Decompose_Service" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_1mlbhmt" name="GoTo StartService"> + <bpmn2:incoming>SequenceFlow_1gusrvp</bpmn2:incoming> + <bpmn2:linkEventDefinition name="StartService" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:scriptTask id="ScriptTask_1o01d7d" name="PostProcess Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0xjwb45</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_027owbf</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def dcsi= new DoCreateE2EServiceInstance() +dcsi.processDecomposition(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:callActivity id="CallActivity_0biblpc" name="Call Decompose Service" calledElement="DecomposeService"> <bpmn2:extensionElements> - <camunda:in source="nsServiceName" target="nsServiceName" /> - <camunda:in source="nsServiceDescription" target="nsServiceDescription" /> - <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> - <camunda:in source="serviceType" target="serviceType" /> - <camunda:in source="serviceId" target="serviceId" /> - <camunda:in source="operationId" target="operationId" /> - <camunda:in source="resourceType" target="resourceType" /> - <camunda:in source="resourceUUID" target="resourceUUID" /> - <camunda:in source="resourceParameters" target="resourceParameters" /> - <camunda:in source="operationType" target="operationType" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_0ua1bbk</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1hgiln0</bpmn2:outgoing> + <bpmn2:incoming>SequenceFlow_0qxzgvq</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0xjwb45</bpmn2:outgoing> </bpmn2:callActivity> - <bpmn2:sequenceFlow id="SequenceFlow_1vo0235" sourceRef="Task_0io5qby" targetRef="Task_0pkhzoj" /> - <bpmn2:serviceTask id="Task_0io5qby" name="Call Sync SDNC service Create " camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncServiceTopologyOperationTask"> - <bpmn2:incoming>SequenceFlow_1hgiln0</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1vo0235</bpmn2:outgoing> - </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_17i1ors" sourceRef="Task_0pkhzoj" targetRef="Task_0gs55f1" /> - <bpmn2:sequenceFlow id="SequenceFlow_1pjr82f" sourceRef="Task_0gs55f1" targetRef="ScriptTask_0081lne" /> - <bpmn2:scriptTask id="Task_0pkhzoj" name="Prepare Resource Request For underlay" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1vo0235</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_17i1ors</bpmn2:outgoing> + <bpmn2:scriptTask id="ScriptTask_1cllqk3" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_166w91p</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0qxzgvq</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -execution.setVariable("resourceType", "underlay") -def csi = new DoCreateE2EServiceInstance() -csi.preResourceRequest(execution)]]></bpmn2:script> +def dcsi= new DoCreateE2EServiceInstance() +dcsi.prepareDecomposeService(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0tv85pg" name="Decompose_Service"> + <bpmn2:outgoing>SequenceFlow_166w91p</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="Decompose_Service" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_027owbf" sourceRef="ScriptTask_1o01d7d" targetRef="Task_0ush1g4" /> + <bpmn2:sequenceFlow id="SequenceFlow_0xjwb45" sourceRef="CallActivity_0biblpc" targetRef="ScriptTask_1o01d7d" /> + <bpmn2:sequenceFlow id="SequenceFlow_0qxzgvq" sourceRef="ScriptTask_1cllqk3" targetRef="CallActivity_0biblpc" /> + <bpmn2:sequenceFlow id="SequenceFlow_1qiiycn" sourceRef="createSI_startEvent" targetRef="preProcessRequest_ScriptTask" /> + <bpmn2:sequenceFlow id="SequenceFlow_166w91p" sourceRef="IntermediateCatchEvent_0tv85pg" targetRef="ScriptTask_1cllqk3" /> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_16okck2" name="GoTo StartPrepareResource"> + <bpmn2:incoming>SequenceFlow_1tkgqu3</bpmn2:incoming> + <bpmn2:linkEventDefinition name="StartPrepareResource" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1tkgqu3" sourceRef="ScriptTask_0q37vn9" targetRef="IntermediateThrowEvent_16okck2" /> + <bpmn2:sequenceFlow id="SequenceFlow_0w9t6tc" sourceRef="preProcessRequest_ScriptTask" targetRef="IntermediateThrowEvent_0bq4fxs" /> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0jrb3xu" name="StartService"> + <bpmn2:outgoing>SequenceFlow_1i7t9hq</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="StartService" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1i7t9hq" sourceRef="IntermediateCatchEvent_0jrb3xu" targetRef="CustomE2EGetService" /> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0f2w7aj" name="GoTo ResourceLoop"> + <bpmn2:incoming>SequenceFlow_18wj44x</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_11f2zuu</bpmn2:incoming> + <bpmn2:linkEventDefinition name="ResourceLoop" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1vprtt9" name="yes" sourceRef="ExclusiveGateway_07rr3wp" targetRef="Task_0io5qby"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" ) == "true" )}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_05dus9b" name="StartPrepareResource"> + <bpmn2:outgoing>SequenceFlow_1hbesp9</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="StartPrepareResource" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1hbesp9" sourceRef="IntermediateCatchEvent_05dus9b" targetRef="Task_0uiekmn" /> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_02bah5m" name="ResourceLoop"> + <bpmn2:outgoing>SequenceFlow_1qozd66</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="ResourceLoop" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_16nxl6h" name="yes" sourceRef="ExclusiveGateway_0n9y4du" targetRef="ScriptTask_1xdjlzm"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("allResourceFinished" ) == "true" )}]]></bpmn2:conditionExpression> + </bpmn2:sequenceFlow> + <bpmn2:sequenceFlow id="SequenceFlow_0uiygod" sourceRef="ScriptTask_0l4nkqr" targetRef="Task_0qlkmvt" /> + <bpmn2:sequenceFlow id="SequenceFlow_1u9k0dm" sourceRef="Task_0qlkmvt" targetRef="Task_12ghoph" /> + <bpmn2:sequenceFlow id="SequenceFlow_13c7bhn" sourceRef="Task_12ghoph" targetRef="ScriptTask_0y4u2ty" /> + <bpmn2:sequenceFlow id="SequenceFlow_0vbznai" sourceRef="ScriptTask_1xdjlzm" targetRef="EndEvent_0kbbt94" /> + <bpmn2:sequenceFlow id="SequenceFlow_1qozd66" sourceRef="IntermediateCatchEvent_02bah5m" targetRef="ScriptTask_0l4nkqr" /> + <bpmn2:sequenceFlow id="SequenceFlow_1gusrvp" sourceRef="Task_0ush1g4" targetRef="IntermediateThrowEvent_1mlbhmt" /> + <bpmn2:scriptTask id="Task_0ush1g4" name="Call Homing(To be Done)" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_027owbf</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1gusrvp</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def dcsi= new DoCreateE2EServiceInstance() +dcsi.doServiceHoming(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:serviceTask id="Task_0gs55f1" name="Call Underlay Create" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncNetworkTopologyOperationTask"> - <bpmn2:incoming>SequenceFlow_17i1ors</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1pjr82f</bpmn2:outgoing> - </bpmn2:serviceTask> - <bpmn2:serviceTask id="CallActivity_09c3ajg" name="Call Overlay Create" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncNetworkTopologyOperationTask"> - <bpmn2:incoming>SequenceFlow_0ofqw6v</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1vvdkcs</bpmn2:outgoing> - </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_03fabby" sourceRef="ScriptTask_0q37vn9" targetRef="Task_0uiekmn" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateE2EServiceInstance"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateE2EServiceInstanceV3"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="createSI_startEvent"> - <dc:Bounds x="34" y="79" width="36" height="36" /> + <dc:Bounds x="18" y="-207" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="28" y="120" width="50" height="12" /> + <dc:Bounds x="12" y="-166" width="50" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_61" bpmnElement="preProcessRequest_ScriptTask"> - <dc:Bounds x="245" y="57" width="100" height="80" /> + <dc:Bounds x="126" y="-229" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_47" targetElement="_BPMNShape_ScriptTask_61"> - <di:waypoint xsi:type="dc:Point" x="70" y="97" /> - <di:waypoint xsi:type="dc:Point" x="245" y="97" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="112.5" y="82" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_4"> - <di:waypoint xsi:type="dc:Point" x="626" y="94" /> - <di:waypoint xsi:type="dc:Point" x="971" y="94" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="753.5" y="79" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_61" targetElement="CallActivity_1md4kyb_di"> - <di:waypoint xsi:type="dc:Point" x="345" y="97" /> - <di:waypoint xsi:type="dc:Point" x="526" y="97" /> + <di:waypoint xsi:type="dc:Point" x="296" y="94" /> + <di:waypoint xsi:type="dc:Point" x="387" y="94" /> + <di:waypoint xsi:type="dc:Point" x="387" y="94" /> + <di:waypoint xsi:type="dc:Point" x="478" y="94" /> <bpmndi:BPMNLabel> - <dc:Bounds x="390.5" y="82" width="90" height="0" /> + <dc:Bounds x="357" y="94" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1md4kyb_di" bpmnElement="CustomE2EGetService"> - <dc:Bounds x="526" y="57" width="100" height="80" /> + <dc:Bounds x="196" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0khp0qc_di" bpmnElement="CustomE2EPutService"> - <dc:Bounds x="972" y="206" width="100" height="80" /> + <dc:Bounds x="713" y="54" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_129ih1g_di" bpmnElement="SequenceFlow_129ih1g"> - <di:waypoint xsi:type="dc:Point" x="1023" y="286" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="336" /> + <di:waypoint xsi:type="dc:Point" x="813" y="94" /> + <di:waypoint xsi:type="dc:Point" x="941" y="94" /> + <di:waypoint xsi:type="dc:Point" x="941" y="94" /> + <di:waypoint xsi:type="dc:Point" x="1068" y="94" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1023" y="296" width="0" height="0" /> + <dc:Bounds x="911" y="94" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_06d8lk8_di" bpmnElement="SubProcess_06d8lk8" isExpanded="true"> - <dc:Bounds x="-155" y="387" width="783" height="195" /> + <dc:Bounds x="15" y="865" width="783" height="195" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_0yljq9y_di" bpmnElement="StartEvent_0yljq9y"> - <dc:Bounds x="-59" y="464" width="36" height="36" /> + <dc:Bounds x="111" y="942" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-86" y="505" width="90" height="0" /> + <dc:Bounds x="84" y="983" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_117lkk3_di" bpmnElement="EndEvent_117lkk3"> - <dc:Bounds x="574" y="464" width="36" height="36" /> + <dc:Bounds x="744" y="942" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="547" y="505" width="90" height="0" /> + <dc:Bounds x="717" y="983" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_1srx6p6_di" bpmnElement="CallActivity_1srx6p6"> - <dc:Bounds x="239" y="442" width="100" height="80" /> + <dc:Bounds x="409" y="920" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0eumzpf_di" bpmnElement="SequenceFlow_0eumzpf"> - <di:waypoint xsi:type="dc:Point" x="339" y="482" /> - <di:waypoint xsi:type="dc:Point" x="407" y="482" /> + <di:waypoint xsi:type="dc:Point" x="509" y="960" /> + <di:waypoint xsi:type="dc:Point" x="577" y="960" /> <bpmndi:BPMNLabel> - <dc:Bounds x="328" y="467" width="90" height="0" /> + <dc:Bounds x="498" y="945" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0tgrn11_di" bpmnElement="SequenceFlow_0tgrn11"> - <di:waypoint xsi:type="dc:Point" x="-23" y="482" /> - <di:waypoint xsi:type="dc:Point" x="76" y="482" /> + <di:waypoint xsi:type="dc:Point" x="147" y="960" /> + <di:waypoint xsi:type="dc:Point" x="246" y="960" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-18" y="467" width="90" height="0" /> + <dc:Bounds x="152" y="945" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0i8cqdy_di" bpmnElement="ScriptTask_0i8cqdy"> - <dc:Bounds x="971" y="57" width="100" height="80" /> + <dc:Bounds x="478" y="54" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1w01tqs_di" bpmnElement="SequenceFlow_1w01tqs"> - <di:waypoint xsi:type="dc:Point" x="1021" y="137" /> - <di:waypoint xsi:type="dc:Point" x="1021" y="206" /> + <di:waypoint xsi:type="dc:Point" x="578" y="94" /> + <di:waypoint xsi:type="dc:Point" x="646" y="94" /> + <di:waypoint xsi:type="dc:Point" x="646" y="94" /> + <di:waypoint xsi:type="dc:Point" x="713" y="94" /> <bpmndi:BPMNLabel> - <dc:Bounds x="991" y="171.5" width="90" height="0" /> + <dc:Bounds x="616" y="94" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0q37vn9_di" bpmnElement="ScriptTask_0q37vn9"> - <dc:Bounds x="972" y="336" width="100" height="80" /> + <dc:Bounds x="1068" y="54" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0ocetux_di" bpmnElement="ScriptTask_0ocetux"> - <dc:Bounds x="76" y="442" width="100" height="80" /> + <dc:Bounds x="246" y="920" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1lqktwf_di" bpmnElement="SequenceFlow_1lqktwf"> - <di:waypoint xsi:type="dc:Point" x="176" y="482" /> - <di:waypoint xsi:type="dc:Point" x="239" y="482" /> + <di:waypoint xsi:type="dc:Point" x="346" y="960" /> + <di:waypoint xsi:type="dc:Point" x="409" y="960" /> <bpmndi:BPMNLabel> - <dc:Bounds x="163" y="467" width="90" height="0" /> + <dc:Bounds x="333" y="945" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1p0vyip_di" bpmnElement="ScriptTask_1p0vyip"> - <dc:Bounds x="407" y="442" width="100" height="80" /> + <dc:Bounds x="577" y="920" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xzgv5k_di" bpmnElement="SequenceFlow_1xzgv5k"> - <di:waypoint xsi:type="dc:Point" x="507" y="482" /> - <di:waypoint xsi:type="dc:Point" x="539" y="482" /> - <di:waypoint xsi:type="dc:Point" x="539" y="482" /> - <di:waypoint xsi:type="dc:Point" x="574" y="482" /> + <di:waypoint xsi:type="dc:Point" x="677" y="960" /> + <di:waypoint xsi:type="dc:Point" x="709" y="960" /> + <di:waypoint xsi:type="dc:Point" x="709" y="960" /> + <di:waypoint xsi:type="dc:Point" x="744" y="960" /> <bpmndi:BPMNLabel> - <dc:Bounds x="509" y="482" width="90" height="0" /> + <dc:Bounds x="679" y="960" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0081lne_di" bpmnElement="ScriptTask_0081lne"> - <dc:Bounds x="-410" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_1xdjlzm_di" bpmnElement="ScriptTask_1xdjlzm"> + <dc:Bounds x="1119" y="485" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0wvq4t8_di" bpmnElement="ScriptTask_0wvq4t8"> - <dc:Bounds x="789" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="EndEvent_01p249c_di" bpmnElement="EndEvent_0kbbt94"> + <dc:Bounds x="1315" y="507" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1197" y="547" width="90" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_0uwm4l1_di" bpmnElement="CallActivity_0uwm4l1"> - <dc:Bounds x="632" y="819" width="100" height="80" /> + <bpmndi:BPMNEdge id="SequenceFlow_1qctzm0_di" bpmnElement="SequenceFlow_1qctzm0"> + <di:waypoint xsi:type="dc:Point" x="296" y="300" /> + <di:waypoint xsi:type="dc:Point" x="402" y="300" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="304" y="279" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0v81r5h_di" bpmnElement="Task_0uiekmn"> + <dc:Bounds x="196" y="260" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1xdjlzm_di" bpmnElement="ScriptTask_1xdjlzm"> - <dc:Bounds x="-741" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="ServiceTask_14tnuxf_di" bpmnElement="Task_0raqlqc"> + <dc:Bounds x="402" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0qi8cgg_di" bpmnElement="Task_0io5qby"> + <dc:Bounds x="944" y="353" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ofqw6v_di" bpmnElement="SequenceFlow_0ofqw6v"> - <di:waypoint xsi:type="dc:Point" x="-410" y="859" /> - <di:waypoint xsi:type="dc:Point" x="-478" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_10reo7r_di" bpmnElement="SequenceFlow_10reo7r"> + <di:waypoint xsi:type="dc:Point" x="502" y="300" /> + <di:waypoint xsi:type="dc:Point" x="583" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-489" y="838" width="90" height="12" /> + <dc:Bounds x="497.5" y="279" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_15zgrcq_di" bpmnElement="SequenceFlow_15zgrcq"> - <di:waypoint xsi:type="dc:Point" x="789" y="859" /> - <di:waypoint xsi:type="dc:Point" x="732" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_11f2zuu_di" bpmnElement="SequenceFlow_11f2zuu"> + <di:waypoint xsi:type="dc:Point" x="1044" y="393" /> + <di:waypoint xsi:type="dc:Point" x="1090" y="393" /> + <di:waypoint xsi:type="dc:Point" x="1090" y="300" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="715.5" y="838" width="90" height="12" /> + <dc:Bounds x="1060" y="340.5" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1vvdkcs_di" bpmnElement="SequenceFlow_1vvdkcs"> - <di:waypoint xsi:type="dc:Point" x="-578" y="859" /> - <di:waypoint xsi:type="dc:Point" x="-641" y="859" /> + <bpmndi:BPMNShape id="ScriptTask_1y0los4_di" bpmnElement="ScriptTask_1y0los4"> + <dc:Bounds x="583" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_13d9g1n_di" bpmnElement="SequenceFlow_13d9g1n"> + <di:waypoint xsi:type="dc:Point" x="683" y="300" /> + <di:waypoint xsi:type="dc:Point" x="753" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-654.5" y="838" width="90" height="12" /> + <dc:Bounds x="673" y="279" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_092ghvu_di" bpmnElement="SequenceFlow_092ghvu"> - <di:waypoint xsi:type="dc:Point" x="-741" y="859" /> - <di:waypoint xsi:type="dc:Point" x="-787" y="859" /> + <bpmndi:BPMNShape id="ExclusiveGateway_0n9y4du_di" bpmnElement="ExclusiveGateway_0n9y4du" isMarkerVisible="true"> + <dc:Bounds x="929" y="500" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-809" y="838" width="90" height="12" /> + <dc:Bounds x="912" y="554" width="83" height="36" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0q6uy30_di" bpmnElement="SequenceFlow_0q6uy30"> + <di:waypoint xsi:type="dc:Point" x="954" y="550" /> + <di:waypoint xsi:type="dc:Point" x="954" y="691" /> + <di:waypoint xsi:type="dc:Point" x="246" y="691" /> + <di:waypoint xsi:type="dc:Point" x="246" y="565" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="594" y="670" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_01p249c_di" bpmnElement="EndEvent_0kbbt94"> - <dc:Bounds x="-823" y="841" width="36" height="36" /> + <bpmndi:BPMNShape id="ScriptTask_0y4u2ty_di" bpmnElement="ScriptTask_0y4u2ty"> + <dc:Bounds x="728" y="485" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1jenxlp_di" bpmnElement="SequenceFlow_1jenxlp"> + <di:waypoint xsi:type="dc:Point" x="828" y="525" /> + <di:waypoint xsi:type="dc:Point" x="929" y="525" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-941" y="881" width="90" height="12" /> + <dc:Bounds x="833.5" y="504" width="90" height="12" /> </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0l4nkqr_di" bpmnElement="ScriptTask_0l4nkqr"> + <dc:Bounds x="196" y="485" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0k4q7jm_di" bpmnElement="SequenceFlow_0k4q7jm"> - <di:waypoint xsi:type="dc:Point" x="632" y="859" /> - <di:waypoint xsi:type="dc:Point" x="596" y="859" /> + <bpmndi:BPMNShape id="ExclusiveGateway_07rr3wp_di" bpmnElement="ExclusiveGateway_07rr3wp" isMarkerVisible="true"> + <dc:Bounds x="753" y="275" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="569" y="838" width="90" height="12" /> + <dc:Bounds x="736" y="329" width="87" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_18wj44x_di" bpmnElement="SequenceFlow_18wj44x"> + <di:waypoint xsi:type="dc:Point" x="803" y="300" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="300" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="832.3633633633633" y="294" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qctzm0_di" bpmnElement="SequenceFlow_1qctzm0"> - <di:waypoint xsi:type="dc:Point" x="1022" y="668" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="704" /> + <bpmndi:BPMNShape id="ScriptTask_0u88n0f_di" bpmnElement="Task_0qlkmvt"> + <dc:Bounds x="357" y="485" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1y17r20_di" bpmnElement="Task_12ghoph"> + <dc:Bounds x="551" y="485" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_11saqvj_di" bpmnElement="IntermediateThrowEvent_0bq4fxs"> + <dc:Bounds x="1315" y="-207" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1290" y="-167" width="88" height="36" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_1mlbhmt_di" bpmnElement="IntermediateThrowEvent_1mlbhmt"> + <dc:Bounds x="1315" y="-57" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="680" width="0" height="12" /> + <dc:Bounds x="1288" y="-16" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1o01d7d_di" bpmnElement="ScriptTask_1o01d7d"> + <dc:Bounds x="713" y="-79" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0biblpc_di" bpmnElement="CallActivity_0biblpc"> + <dc:Bounds x="478" y="-79" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1cllqk3_di" bpmnElement="ScriptTask_1cllqk3"> + <dc:Bounds x="196" y="-79" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0tv85pg_di" bpmnElement="IntermediateCatchEvent_0tv85pg"> + <dc:Bounds x="26" y="-57" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2" y="-21" width="88" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_027owbf_di" bpmnElement="SequenceFlow_027owbf"> + <di:waypoint xsi:type="dc:Point" x="813" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="1057" y="-39" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="890" y="-60" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0v81r5h_di" bpmnElement="Task_0uiekmn"> - <dc:Bounds x="972" y="588" width="100" height="80" /> + <bpmndi:BPMNEdge id="SequenceFlow_0xjwb45_di" bpmnElement="SequenceFlow_0xjwb45"> + <di:waypoint xsi:type="dc:Point" x="578" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="713" y="-39" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="645.5" y="-60" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qxzgvq_di" bpmnElement="SequenceFlow_0qxzgvq"> + <di:waypoint xsi:type="dc:Point" x="296" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="478" y="-39" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="387" y="-60" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qiiycn_di" bpmnElement="SequenceFlow_1qiiycn"> + <di:waypoint xsi:type="dc:Point" x="54" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="126" y="-189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="90" y="-210" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_166w91p_di" bpmnElement="SequenceFlow_166w91p"> + <di:waypoint xsi:type="dc:Point" x="62" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="196" y="-39" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="129" y="-60" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_16okck2_di" bpmnElement="IntermediateThrowEvent_16okck2"> + <dc:Bounds x="1315" y="76" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1299" y="117" width="71" height="24" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_05gdjox_di" bpmnElement="SequenceFlow_05gdjox"> - <di:waypoint xsi:type="dc:Point" x="1022" y="784" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="859" /> - <di:waypoint xsi:type="dc:Point" x="889" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_1tkgqu3_di" bpmnElement="SequenceFlow_1tkgqu3"> + <di:waypoint xsi:type="dc:Point" x="1168" y="94" /> + <di:waypoint xsi:type="dc:Point" x="1242" y="94" /> + <di:waypoint xsi:type="dc:Point" x="1242" y="94" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="94" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="815.5" width="0" height="12" /> + <dc:Bounds x="1257" y="88" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_14tnuxf_di" bpmnElement="Task_0raqlqc"> - <dc:Bounds x="972" y="704" width="100" height="80" /> + <bpmndi:BPMNEdge id="SequenceFlow_0w9t6tc_di" bpmnElement="SequenceFlow_0w9t6tc"> + <di:waypoint xsi:type="dc:Point" x="226" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="-189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="786" y="-195" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0jrb3xu_di" bpmnElement="IntermediateCatchEvent_0jrb3xu"> + <dc:Bounds x="18" y="79" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="8" y="115" width="60" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ua1bbk_di" bpmnElement="SequenceFlow_0ua1bbk"> - <di:waypoint xsi:type="dc:Point" x="496" y="859" /> - <di:waypoint xsi:type="dc:Point" x="446" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_1i7t9hq_di" bpmnElement="SequenceFlow_1i7t9hq"> + <di:waypoint xsi:type="dc:Point" x="54" y="97" /> + <di:waypoint xsi:type="dc:Point" x="196" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="471" y="838" width="0" height="12" /> + <dc:Bounds x="125" y="76" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0ue196s_di" bpmnElement="Task_0aidjmp"> - <dc:Bounds x="496" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0f2w7aj_di" bpmnElement="IntermediateThrowEvent_0f2w7aj"> + <dc:Bounds x="1315" y="282" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1299" y="323" width="73" height="24" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1hgiln0_di" bpmnElement="SequenceFlow_1hgiln0"> - <di:waypoint xsi:type="dc:Point" x="346" y="859" /> - <di:waypoint xsi:type="dc:Point" x="191" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_1vprtt9_di" bpmnElement="SequenceFlow_1vprtt9"> + <di:waypoint xsi:type="dc:Point" x="778" y="325" /> + <di:waypoint xsi:type="dc:Point" x="778" y="393" /> + <di:waypoint xsi:type="dc:Point" x="944" y="393" /> <bpmndi:BPMNLabel> - <dc:Bounds x="268.5" y="838" width="0" height="12" /> + <dc:Bounds x="784" y="353" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_1hcdpgq_di" bpmnElement="Task_03n6y9h"> - <dc:Bounds x="346" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="IntermediateCatchEvent_05dus9b_di" bpmnElement="IntermediateCatchEvent_05dus9b"> + <dc:Bounds x="18" y="282" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-3" y="318" width="82" height="24" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1vo0235_di" bpmnElement="SequenceFlow_1vo0235"> - <di:waypoint xsi:type="dc:Point" x="91" y="859" /> - <di:waypoint xsi:type="dc:Point" x="46" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_1hbesp9_di" bpmnElement="SequenceFlow_1hbesp9"> + <di:waypoint xsi:type="dc:Point" x="54" y="300" /> + <di:waypoint xsi:type="dc:Point" x="196" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="68.5" y="838" width="0" height="12" /> + <dc:Bounds x="125" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0qi8cgg_di" bpmnElement="Task_0io5qby"> - <dc:Bounds x="91" y="819" width="100" height="80" /> + <bpmndi:BPMNShape id="IntermediateCatchEvent_02bah5m_di" bpmnElement="IntermediateCatchEvent_02bah5m"> + <dc:Bounds x="18" y="507" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2" y="543" width="73" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_17i1ors_di" bpmnElement="SequenceFlow_17i1ors"> - <di:waypoint xsi:type="dc:Point" x="-54" y="859" /> - <di:waypoint xsi:type="dc:Point" x="-125" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_16nxl6h_di" bpmnElement="SequenceFlow_16nxl6h"> + <di:waypoint xsi:type="dc:Point" x="979" y="525" /> + <di:waypoint xsi:type="dc:Point" x="1119" y="525" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-134.5" y="838" width="90" height="12" /> + <dc:Bounds x="1040" y="504" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1pjr82f_di" bpmnElement="SequenceFlow_1pjr82f"> - <di:waypoint xsi:type="dc:Point" x="-225" y="859" /> - <di:waypoint xsi:type="dc:Point" x="-310" y="859" /> + <bpmndi:BPMNEdge id="SequenceFlow_0uiygod_di" bpmnElement="SequenceFlow_0uiygod"> + <di:waypoint xsi:type="dc:Point" x="296" y="525" /> + <di:waypoint xsi:type="dc:Point" x="357" y="525" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-312.5" y="838" width="90" height="12" /> + <dc:Bounds x="326.5" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0ue4dzp_di" bpmnElement="Task_0pkhzoj"> - <dc:Bounds x="-54" y="819" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1q727pm_di" bpmnElement="Task_0gs55f1"> - <dc:Bounds x="-225" y="819" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1cnnn5b_di" bpmnElement="CallActivity_09c3ajg"> - <dc:Bounds x="-578" y="819" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03fabby_di" bpmnElement="SequenceFlow_03fabby"> - <di:waypoint xsi:type="dc:Point" x="1022" y="416" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="588" /> + <bpmndi:BPMNEdge id="SequenceFlow_1u9k0dm_di" bpmnElement="SequenceFlow_1u9k0dm"> + <di:waypoint xsi:type="dc:Point" x="457" y="525" /> + <di:waypoint xsi:type="dc:Point" x="551" y="525" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="504" y="504" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_13c7bhn_di" bpmnElement="SequenceFlow_13c7bhn"> + <di:waypoint xsi:type="dc:Point" x="651" y="525" /> + <di:waypoint xsi:type="dc:Point" x="728" y="525" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="689.5" y="504" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0vbznai_di" bpmnElement="SequenceFlow_0vbznai"> + <di:waypoint xsi:type="dc:Point" x="1219" y="525" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="525" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="496" width="0" height="12" /> + <dc:Bounds x="1267" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qozd66_di" bpmnElement="SequenceFlow_1qozd66"> + <di:waypoint xsi:type="dc:Point" x="54" y="525" /> + <di:waypoint xsi:type="dc:Point" x="196" y="525" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="125" y="504" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gusrvp_di" bpmnElement="SequenceFlow_1gusrvp"> + <di:waypoint xsi:type="dc:Point" x="1157" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="1315" y="-39" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1236" y="-60" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0wr11dt_di" bpmnElement="Task_0ush1g4"> + <dc:Bounds x="1057" y="-79" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn index 10e49a198b..095948a87c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> - <bpmn:process id="DoCustomDeleteE2EServiceInstance" isExecutable="true"> + <bpmn:process id="DoCustomDeleteE2EServiceInstanceV3" name="All Resources Deleted" isExecutable="true"> <bpmn:startEvent id="StartEvent_0212h2r" name="Start Flow"> <bpmn:outgoing>SequenceFlow_0vz7cd9</bpmn:outgoing> </bpmn:startEvent> @@ -26,7 +26,8 @@ ddsi.preProcessRequest(execution) <camunda:out source="GENDS_SuccessIndicator" target="GENDS_SuccessIndicator" /> <camunda:out source="WorkflowException" target="WorkflowExcpeton" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_0vg4q7x</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ev7z6q</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0oj2anh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0g6bxqw</bpmn:outgoing> </bpmn:callActivity> <bpmn:scriptTask id="ScriptTask_1rtnsh8" name="Post Process AAI GET" scriptFormat="groovy"> @@ -66,70 +67,25 @@ ex.processJavaException(execution)]]></bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0e7inkl" sourceRef="ScriptTask_01erufg" targetRef="EndEvent_1uqzt26" /> <bpmn:sequenceFlow id="SequenceFlow_0g6bxqw" sourceRef="CallActivity_06izbke" targetRef="ScriptTask_01erufg" /> <bpmn:sequenceFlow id="SequenceFlow_0vi0sv6" sourceRef="ScriptTask_1rtnsh8" targetRef="ScriptTask_146jt8v" /> - <bpmn:callActivity id="CallActivity_Del_VFC" name="Call Network Service Delete for vEPC" calledElement="DoDeleteVFCNetworkServiceInstance"> - <bpmn:extensionElements> - <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> - <camunda:in source="serviceType" target="serviceType" /> - <camunda:in source="serviceInstanceId" target="serviceId" /> - <camunda:in source="operationId" target="operationId" /> - <camunda:in source="resourceTemplateId" target="resourceTemplateId" /> - <camunda:in source="resourceInstanceId" target="resourceInstanceId" /> - <camunda:in source="resourceType" target="resourceType" /> - <camunda:in source="operationType" target="operationType" /> - </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_1wmjau1</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0qquvgc</bpmn:outgoing> - </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_0qquvgc" sourceRef="CallActivity_Del_VFC" targetRef="ScriptTask_0mdub03" /> - <bpmn:scriptTask id="ScriptTask_0vcz9mj" name="Prepare Resource Delele For vEPC" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1931m8u</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1wmjau1</bpmn:outgoing> - <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -String resourceName = "vEPC" -def ddsi = new DoCustomDeleteE2EServiceInstance() -ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1wmjau1" sourceRef="ScriptTask_0vcz9mj" targetRef="CallActivity_Del_VFC" /> - <bpmn:scriptTask id="ScriptTask_0mdub03" name="Post Process VFC Delete" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0qquvgc</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0vg4q7x</bpmn:outgoing> - <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* - -String response = execution.getVariable("vfcDeleteResponse") -def ddsi = new DoCustomDeleteE2EServiceInstance() -ddsi.postProcessVFCDelete(execution, response, "delete")]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_1g0tsto" name="Post Process SDNC Delete" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0uc2beq</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1m7tont</bpmn:outgoing> - <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* - -String response = execution.getVariable("sdncDeleteResponse") -def ddsi = new DoCustomDeleteE2EServiceInstance() -ddsi.postProcessSDNCDelete(execution, response, "delete")]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_0z30dax" name="Prepare Resource Delele For Overlay" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0l4w9nr</bpmn:incoming> + <bpmn:scriptTask id="ScriptTask_0z30dax" name="Prepare Resource Delele For WAN" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ubor5z</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1dza4q4</bpmn:outgoing> <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -String resourceName = "overlay" +String resourceName = execution.getVariable("resourceType") def ddsi = new DoCustomDeleteE2EServiceInstance() ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_1dza4q4" sourceRef="ScriptTask_0z30dax" targetRef="CallActivity_Del_SDNC_cust" /> - <bpmn:sequenceFlow id="SequenceFlow_0rpu756" sourceRef="CallActivity_Del_SDNC_cust" targetRef="Task_14erap6" /> <bpmn:sequenceFlow id="SequenceFlow_1wnkgpx" sourceRef="Task_0z1x3sg" targetRef="Task_0963dho" /> - <bpmn:sequenceFlow id="SequenceFlow_1931m8u" sourceRef="Task_0963dho" targetRef="ScriptTask_0vcz9mj" /> - <bpmn:scriptTask id="Task_0z1x3sg" name="Prepare Resource Delele For vIMS" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1m7tont</bpmn:incoming> + <bpmn:scriptTask id="Task_0z1x3sg" name="Prepare Resource Delele For NS" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1x3lehs</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1wnkgpx</bpmn:outgoing> <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -String resourceName = "vIMS" +String resourceName = execution.getVariable("resourceType") def ddsi = new DoCustomDeleteE2EServiceInstance() ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1m7tont" sourceRef="ScriptTask_1g0tsto" targetRef="Task_0z1x3sg" /> - <bpmn:callActivity id="Task_0963dho" name="Call Network Service Delete for vIMS" calledElement="DoDeleteVFCNetworkServiceInstance"> + <bpmn:callActivity id="Task_0963dho" name="Call Network Service Delete for NS" calledElement="DoDeleteVFCNetworkServiceInstance"> <bpmn:extensionElements> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="serviceType" target="serviceType" /> @@ -141,31 +97,15 @@ ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script> <camunda:in source="operationType" target="operationType" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1wnkgpx</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1931m8u</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0phwem2</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_0vg4q7x" sourceRef="ScriptTask_0mdub03" targetRef="CallActivity_06izbke" /> <bpmn:serviceTask id="CallActivity_Del_SDNC_cust" name="Call Custom Delete SDNC Overlay" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncNetworkTopologyOperationTask"> <bpmn:incoming>SequenceFlow_1dza4q4</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0rpu756</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0d9lmlv" sourceRef="Task_14erap6" targetRef="Task_1j1u666" /> - <bpmn:sequenceFlow id="SequenceFlow_1g4djgh" sourceRef="Task_1j1u666" targetRef="Task_0edkv0m" /> - <bpmn:sequenceFlow id="SequenceFlow_0uc2beq" sourceRef="Task_0edkv0m" targetRef="ScriptTask_1g0tsto" /> - <bpmn:scriptTask id="Task_14erap6" name="Prepare Resource Delele For Underlay" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0rpu756</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0d9lmlv</bpmn:outgoing> - <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* -String resourceName = "underlay" -def ddsi = new DoCustomDeleteE2EServiceInstance() -ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script> - </bpmn:scriptTask> - <bpmn:serviceTask id="Task_1j1u666" name="Call Custom Delete SDNC Underlay" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncNetworkTopologyOperationTask"> - <bpmn:incoming>SequenceFlow_0d9lmlv</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1g4djgh</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1lxqjmp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="Task_0edkv0m" name="Call Delete SDNC Service Topology" camunda:class="org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncServiceTopologyOperationTask"> - <bpmn:incoming>SequenceFlow_1g4djgh</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0uc2beq</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_1icwpye</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ev7z6q</bpmn:outgoing> </bpmn:serviceTask> <bpmn:scriptTask id="ScriptTask_146jt8v" name="Prepare Resource Oper Status" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0vi0sv6</bpmn:incoming> @@ -194,10 +134,9 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script> </camunda:connector> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1ym9otf</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0l4w9nr</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1j08ko3</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1ym9otf" sourceRef="ScriptTask_146jt8v" targetRef="ServiceTask_00tg69u" /> - <bpmn:sequenceFlow id="SequenceFlow_0l4w9nr" sourceRef="ServiceTask_00tg69u" targetRef="ScriptTask_0z30dax" /> <bpmn:callActivity id="CallActivity_076pc2z" name="Call AAI Generic GetService" calledElement="GenericGetService"> <bpmn:extensionElements> <camunda:in source="serviceInstanceId" target="GENGS_serviceInstanceId" /> @@ -214,9 +153,72 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script> <bpmn:outgoing>SequenceFlow_188ejvu</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_188ejvu" sourceRef="CallActivity_076pc2z" targetRef="ScriptTask_1rtnsh8" /> + <bpmn:scriptTask id="ScriptTask_0o5bglz" name="Sequense Resources" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1j08ko3</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_03c0zlq</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCustomDeleteE2EServiceInstance() +ddsi.sequenceResource(execution)]]></bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1j08ko3" sourceRef="ServiceTask_00tg69u" targetRef="ScriptTask_0o5bglz" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_07toixi" name="Check Current Resource"> + <bpmn:incoming>SequenceFlow_1htjmkv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ubor5z</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1x3lehs</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="ScriptTask_12q6a51" name="Get Current Resource" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03c0zlq</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0s1lswk</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1htjmkv</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCustomDeleteE2EServiceInstance() +ddsi.getCurrentResource(execution)]]></bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03c0zlq" sourceRef="ScriptTask_0o5bglz" targetRef="ScriptTask_12q6a51" /> + <bpmn:sequenceFlow id="SequenceFlow_1htjmkv" sourceRef="ScriptTask_12q6a51" targetRef="ExclusiveGateway_07toixi" /> + <bpmn:sequenceFlow id="SequenceFlow_1ubor5z" name="SDN-C" sourceRef="ExclusiveGateway_07toixi" targetRef="ScriptTask_0z30dax"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("controllerInfo" ) == "SDN-C" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1x3lehs" name="VF-C" sourceRef="ExclusiveGateway_07toixi" targetRef="Task_0z1x3sg"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("controllerInfo" ) == "VF-C" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_0w46sge" name="Parse Next Resource" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1lxqjmp</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0phwem2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0l5r96s</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +def ddsi = new DoCustomDeleteE2EServiceInstance() +ddsi.parseNextResource(execution)]]></bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1lxqjmp" sourceRef="CallActivity_Del_SDNC_cust" targetRef="ScriptTask_0w46sge" /> + <bpmn:sequenceFlow id="SequenceFlow_0phwem2" sourceRef="Task_0963dho" targetRef="ScriptTask_0w46sge" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1hgjg3u" name="Is All Resource Deleted"> + <bpmn:incoming>SequenceFlow_0l5r96s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0talboa</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0s1lswk</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0l5r96s" sourceRef="ScriptTask_0w46sge" targetRef="ExclusiveGateway_1hgjg3u" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_16046vb" name="Is SDNC Service Contained"> + <bpmn:incoming>SequenceFlow_0talboa</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1icwpye</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0oj2anh</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1icwpye" name="yes" sourceRef="ExclusiveGateway_16046vb" targetRef="Task_0edkv0m"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" ) == "true" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1ev7z6q" sourceRef="Task_0edkv0m" targetRef="CallActivity_06izbke" /> + <bpmn:sequenceFlow id="SequenceFlow_0oj2anh" name="no" sourceRef="ExclusiveGateway_16046vb" targetRef="CallActivity_06izbke"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" ) == "false" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0talboa" name="yes" sourceRef="ExclusiveGateway_1hgjg3u" targetRef="ExclusiveGateway_16046vb"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("allResourceFinished" ) == "true" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0s1lswk" name="no" sourceRef="ExclusiveGateway_1hgjg3u" targetRef="ScriptTask_12q6a51"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("allResourceFinished" ) == "false" )}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCustomDeleteE2EServiceInstance"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCustomDeleteE2EServiceInstanceV3"> <bpmndi:BPMNShape id="StartEvent_0212h2r_di" bpmnElement="StartEvent_0212h2r"> <dc:Bounds x="-612" y="-35" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -227,22 +229,22 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script> <dc:Bounds x="-519" y="-57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1uqzt26_di" bpmnElement="EndEvent_1uqzt26"> - <dc:Bounds x="1220" y="1109" width="36" height="36" /> + <dc:Bounds x="1388" y="855" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1148" y="1150" width="90" height="12" /> + <dc:Bounds x="1316" y="896" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_06izbke_di" bpmnElement="CallActivity_06izbke"> - <dc:Bounds x="1188" y="779" width="100" height="80" /> + <dc:Bounds x="1356" y="578" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1rtnsh8_di" bpmnElement="ScriptTask_1rtnsh8"> <dc:Bounds x="-193" y="-57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_01erufg_di" bpmnElement="ScriptTask_01erufg"> - <dc:Bounds x="1188" y="915" width="100" height="80" /> + <dc:Bounds x="1356" y="711" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1u8zt9i_di" bpmnElement="SubProcess_1u8zt9i" isExpanded="true"> - <dc:Bounds x="445" y="320" width="467" height="193" /> + <dc:Bounds x="292" y="675" width="467" height="193" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0vz7cd9_di" bpmnElement="SequenceFlow_0vz7cd9"> <di:waypoint xsi:type="dc:Point" x="-576" y="-17" /> @@ -259,17 +261,17 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0e7inkl_di" bpmnElement="SequenceFlow_0e7inkl"> - <di:waypoint xsi:type="dc:Point" x="1238" y="995" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="1109" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="791" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="855" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1208" y="1046" width="90" height="12" /> + <dc:Bounds x="1376" y="817" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0g6bxqw_di" bpmnElement="SequenceFlow_0g6bxqw"> - <di:waypoint xsi:type="dc:Point" x="1238" y="859" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="915" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="658" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="711" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1208" y="881" width="90" height="12" /> + <dc:Bounds x="1376" y="678.5" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0vi0sv6_di" bpmnElement="SequenceFlow_0vi0sv6"> @@ -280,172 +282,214 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_0sf5lpt_di" bpmnElement="StartEvent_0sf5lpt"> - <dc:Bounds x="513" y="387" width="36" height="36" /> + <dc:Bounds x="360" y="742" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="441" y="428" width="90" height="12" /> + <dc:Bounds x="288" y="783" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_06utmg4_di" bpmnElement="EndEvent_06utmg4"> - <dc:Bounds x="806" y="387" width="36" height="36" /> + <dc:Bounds x="653" y="742" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="734" y="428" width="90" height="12" /> + <dc:Bounds x="581" y="783" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0nha3pr_di" bpmnElement="ScriptTask_0nha3pr"> - <dc:Bounds x="617" y="365" width="100" height="80" /> + <dc:Bounds x="464" y="720" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1921mo3_di" bpmnElement="SequenceFlow_1921mo3"> - <di:waypoint xsi:type="dc:Point" x="549" y="405" /> - <di:waypoint xsi:type="dc:Point" x="617" y="405" /> + <di:waypoint xsi:type="dc:Point" x="396" y="760" /> + <di:waypoint xsi:type="dc:Point" x="464" y="760" /> <bpmndi:BPMNLabel> - <dc:Bounds x="493" y="390" width="90" height="12" /> + <dc:Bounds x="340" y="745" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_18vlzfo_di" bpmnElement="SequenceFlow_18vlzfo"> - <di:waypoint xsi:type="dc:Point" x="717" y="405" /> - <di:waypoint xsi:type="dc:Point" x="806" y="405" /> + <di:waypoint xsi:type="dc:Point" x="564" y="760" /> + <di:waypoint xsi:type="dc:Point" x="653" y="760" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="520" y="745" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0z30dax_di" bpmnElement="ScriptTask_0z30dax"> + <dc:Bounds x="470" y="111" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1dza4q4_di" bpmnElement="SequenceFlow_1dza4q4"> + <di:waypoint xsi:type="dc:Point" x="570" y="151" /> + <di:waypoint xsi:type="dc:Point" x="688" y="152" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="584" y="130.5" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1wnkgpx_di" bpmnElement="SequenceFlow_1wnkgpx"> + <di:waypoint xsi:type="dc:Point" x="576" y="378" /> + <di:waypoint xsi:type="dc:Point" x="688" y="378" /> <bpmndi:BPMNLabel> - <dc:Bounds x="673" y="390" width="90" height="12" /> + <dc:Bounds x="587" y="357" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_1x56smn_di" bpmnElement="CallActivity_Del_VFC"> - <dc:Bounds x="1188" y="483" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_00301ai_di" bpmnElement="Task_0z1x3sg"> + <dc:Bounds x="476" y="338" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1mwacgl_di" bpmnElement="Task_0963dho"> + <dc:Bounds x="688" y="338" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0v9q75y_di" bpmnElement="CallActivity_Del_SDNC_cust"> + <dc:Bounds x="688" y="112" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0p4b7e1_di" bpmnElement="Task_0edkv0m"> + <dc:Bounds x="1356" y="233" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0qquvgc_di" bpmnElement="SequenceFlow_0qquvgc"> - <di:waypoint xsi:type="dc:Point" x="1238" y="563" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="642" /> + <bpmndi:BPMNShape id="ScriptTask_146jt8v_di" bpmnElement="ScriptTask_146jt8v"> + <dc:Bounds x="-26" y="-57" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_00tg69u_di" bpmnElement="ServiceTask_00tg69u"> + <dc:Bounds x="-26" y="67" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ym9otf_di" bpmnElement="SequenceFlow_1ym9otf"> + <di:waypoint xsi:type="dc:Point" x="24" y="23" /> + <di:waypoint xsi:type="dc:Point" x="24" y="67" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1208" y="596.5" width="90" height="12" /> + <dc:Bounds x="-6" y="39" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0vcz9mj_di" bpmnElement="ScriptTask_0vcz9mj"> - <dc:Bounds x="1188" y="338" width="100" height="80" /> + <bpmndi:BPMNShape id="CallActivity_076pc2z_di" bpmnElement="CallActivity_076pc2z"> + <dc:Bounds x="-357" y="-57" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1wmjau1_di" bpmnElement="SequenceFlow_1wmjau1"> - <di:waypoint xsi:type="dc:Point" x="1238" y="418" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="483" /> + <bpmndi:BPMNEdge id="SequenceFlow_188ejvu_di" bpmnElement="SequenceFlow_188ejvu"> + <di:waypoint xsi:type="dc:Point" x="-257" y="-17" /> + <di:waypoint xsi:type="dc:Point" x="-193" y="-17" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1208" y="444.5" width="90" height="12" /> + <dc:Bounds x="-225" y="-38" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0mdub03_di" bpmnElement="ScriptTask_0mdub03"> - <dc:Bounds x="1188" y="642" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_0o5bglz_di" bpmnElement="ScriptTask_0o5bglz"> + <dc:Bounds x="-26" y="233" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1g0tsto_di" bpmnElement="ScriptTask_1g0tsto"> - <dc:Bounds x="1188" y="-57" width="100" height="80" /> + <bpmndi:BPMNEdge id="SequenceFlow_1j08ko3_di" bpmnElement="SequenceFlow_1j08ko3"> + <di:waypoint xsi:type="dc:Point" x="24" y="147" /> + <di:waypoint xsi:type="dc:Point" x="24" y="233" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="39" y="184" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_07toixi_di" bpmnElement="ExclusiveGateway_07toixi" isMarkerVisible="true"> + <dc:Bounds x="342.56962025316454" y="248" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="332" y="302" width="73" height="24" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0z30dax_di" bpmnElement="ScriptTask_0z30dax"> - <dc:Bounds x="316" y="-57" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_12q6a51_di" bpmnElement="ScriptTask_12q6a51"> + <dc:Bounds x="159" y="450" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1dza4q4_di" bpmnElement="SequenceFlow_1dza4q4"> - <di:waypoint xsi:type="dc:Point" x="416" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="499" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_03c0zlq_di" bpmnElement="SequenceFlow_03c0zlq"> + <di:waypoint xsi:type="dc:Point" x="24" y="313" /> + <di:waypoint xsi:type="dc:Point" x="24" y="494" /> + <di:waypoint xsi:type="dc:Point" x="159" y="490" /> <bpmndi:BPMNLabel> - <dc:Bounds x="412.5" y="-38" width="90" height="12" /> + <dc:Bounds x="39" y="397.5" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0rpu756_di" bpmnElement="SequenceFlow_0rpu756"> - <di:waypoint xsi:type="dc:Point" x="599" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="679" y="-16" /> + <bpmndi:BPMNEdge id="SequenceFlow_1htjmkv_di" bpmnElement="SequenceFlow_1htjmkv"> + <di:waypoint xsi:type="dc:Point" x="209" y="450" /> + <di:waypoint xsi:type="dc:Point" x="209" y="273" /> + <di:waypoint xsi:type="dc:Point" x="343" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="594" y="-37.5" width="90" height="12" /> + <dc:Bounds x="224" y="355.5" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1wnkgpx_di" bpmnElement="SequenceFlow_1wnkgpx"> - <di:waypoint xsi:type="dc:Point" x="1237" y="134" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="192" /> + <bpmndi:BPMNEdge id="SequenceFlow_1ubor5z_di" bpmnElement="SequenceFlow_1ubor5z"> + <di:waypoint xsi:type="dc:Point" x="368" y="248" /> + <di:waypoint xsi:type="dc:Point" x="368" y="151" /> + <di:waypoint xsi:type="dc:Point" x="470" y="151" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1237.5" y="142" width="0" height="12" /> + <dc:Bounds x="366" y="193.5" width="35" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1931m8u_di" bpmnElement="SequenceFlow_1931m8u"> - <di:waypoint xsi:type="dc:Point" x="1237" y="272" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="338" /> + <bpmndi:BPMNEdge id="SequenceFlow_1x3lehs_di" bpmnElement="SequenceFlow_1x3lehs"> + <di:waypoint xsi:type="dc:Point" x="368" y="298" /> + <di:waypoint xsi:type="dc:Point" x="368" y="378" /> + <di:waypoint xsi:type="dc:Point" x="476" y="378" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1237.5" y="284" width="0" height="12" /> + <dc:Bounds x="379" y="353" width="27" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_00301ai_di" bpmnElement="Task_0z1x3sg"> - <dc:Bounds x="1188" y="54" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_0w46sge_di" bpmnElement="ScriptTask_0w46sge"> + <dc:Bounds x="865" y="233" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1m7tont_di" bpmnElement="SequenceFlow_1m7tont"> - <di:waypoint xsi:type="dc:Point" x="1238" y="23" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="54" /> + <bpmndi:BPMNEdge id="SequenceFlow_1lxqjmp_di" bpmnElement="SequenceFlow_1lxqjmp"> + <di:waypoint xsi:type="dc:Point" x="788" y="152" /> + <di:waypoint xsi:type="dc:Point" x="827" y="152" /> + <di:waypoint xsi:type="dc:Point" x="827" y="273" /> + <di:waypoint xsi:type="dc:Point" x="865" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1253" y="32.5" width="0" height="12" /> + <dc:Bounds x="842" y="206.5" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_1mwacgl_di" bpmnElement="Task_0963dho"> - <dc:Bounds x="1188" y="192" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0vg4q7x_di" bpmnElement="SequenceFlow_0vg4q7x"> - <di:waypoint xsi:type="dc:Point" x="1238" y="722" /> - <di:waypoint xsi:type="dc:Point" x="1238" y="779" /> + <bpmndi:BPMNEdge id="SequenceFlow_0phwem2_di" bpmnElement="SequenceFlow_0phwem2"> + <di:waypoint xsi:type="dc:Point" x="788" y="378" /> + <di:waypoint xsi:type="dc:Point" x="827" y="378" /> + <di:waypoint xsi:type="dc:Point" x="827" y="273" /> + <di:waypoint xsi:type="dc:Point" x="865" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1253" y="744.5" width="0" height="12" /> + <dc:Bounds x="842" y="319.5" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0v9q75y_di" bpmnElement="CallActivity_Del_SDNC_cust"> - <dc:Bounds x="499" y="-57" width="100" height="80" /> + <bpmndi:BPMNShape id="ExclusiveGateway_1hgjg3u_di" bpmnElement="ExclusiveGateway_1hgjg3u" isMarkerVisible="true"> + <dc:Bounds x="1040.9252217997464" y="248" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1029" y="302" width="74" height="24" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0d9lmlv_di" bpmnElement="SequenceFlow_0d9lmlv"> - <di:waypoint xsi:type="dc:Point" x="779" y="-16" /> - <di:waypoint xsi:type="dc:Point" x="855" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_0l5r96s_di" bpmnElement="SequenceFlow_0l5r96s"> + <di:waypoint xsi:type="dc:Point" x="965" y="273" /> + <di:waypoint xsi:type="dc:Point" x="1041" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="772" y="-37.5" width="90" height="12" /> + <dc:Bounds x="1003" y="252" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1g4djgh_di" bpmnElement="SequenceFlow_1g4djgh"> - <di:waypoint xsi:type="dc:Point" x="955" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="1021" y="-17" /> + <bpmndi:BPMNShape id="ExclusiveGateway_16046vb_di" bpmnElement="ExclusiveGateway_16046vb" isMarkerVisible="true"> + <dc:Bounds x="1203.8174904942966" y="248.28010139416983" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1187" y="302" width="83" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1icwpye_di" bpmnElement="SequenceFlow_1icwpye"> + <di:waypoint xsi:type="dc:Point" x="1254" y="273" /> + <di:waypoint xsi:type="dc:Point" x="1356" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="943" y="-38" width="90" height="12" /> + <dc:Bounds x="1297" y="252" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0uc2beq_di" bpmnElement="SequenceFlow_0uc2beq"> - <di:waypoint xsi:type="dc:Point" x="1121" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="1188" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_1ev7z6q_di" bpmnElement="SequenceFlow_1ev7z6q"> + <di:waypoint xsi:type="dc:Point" x="1406" y="313" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="448" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="448" /> + <di:waypoint xsi:type="dc:Point" x="1406" y="578" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1109.5" y="-38" width="90" height="12" /> + <dc:Bounds x="1421" y="442" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1e5z0wu_di" bpmnElement="Task_14erap6"> - <dc:Bounds x="679" y="-56" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0f0965f_di" bpmnElement="Task_1j1u666"> - <dc:Bounds x="855" y="-57" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0p4b7e1_di" bpmnElement="Task_0edkv0m"> - <dc:Bounds x="1021" y="-57" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_146jt8v_di" bpmnElement="ScriptTask_146jt8v"> - <dc:Bounds x="-26" y="-57" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_00tg69u_di" bpmnElement="ServiceTask_00tg69u"> - <dc:Bounds x="144" y="-57" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ym9otf_di" bpmnElement="SequenceFlow_1ym9otf"> - <di:waypoint xsi:type="dc:Point" x="74" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="144" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_0oj2anh_di" bpmnElement="SequenceFlow_0oj2anh"> + <di:waypoint xsi:type="dc:Point" x="1229" y="298" /> + <di:waypoint xsi:type="dc:Point" x="1229" y="618" /> + <di:waypoint xsi:type="dc:Point" x="1356" y="618" /> <bpmndi:BPMNLabel> - <dc:Bounds x="64" y="-38" width="90" height="12" /> + <dc:Bounds x="1238" y="452.30710172744716" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0l4w9nr_di" bpmnElement="SequenceFlow_0l4w9nr"> - <di:waypoint xsi:type="dc:Point" x="244" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="316" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_0talboa_di" bpmnElement="SequenceFlow_0talboa"> + <di:waypoint xsi:type="dc:Point" x="1091" y="273" /> + <di:waypoint xsi:type="dc:Point" x="1204" y="273" /> <bpmndi:BPMNLabel> - <dc:Bounds x="235" y="-38" width="90" height="12" /> + <dc:Bounds x="1138" y="252" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_076pc2z_di" bpmnElement="CallActivity_076pc2z"> - <dc:Bounds x="-357" y="-57" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_188ejvu_di" bpmnElement="SequenceFlow_188ejvu"> - <di:waypoint xsi:type="dc:Point" x="-257" y="-17" /> - <di:waypoint xsi:type="dc:Point" x="-193" y="-17" /> + <bpmndi:BPMNEdge id="SequenceFlow_0s1lswk_di" bpmnElement="SequenceFlow_0s1lswk"> + <di:waypoint xsi:type="dc:Point" x="1066" y="298" /> + <di:waypoint xsi:type="dc:Point" x="1066" y="490" /> + <di:waypoint xsi:type="dc:Point" x="259" y="490" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-225" y="-38" width="0" height="12" /> + <dc:Bounds x="1075" y="388" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index 3b97cad585..7a494db998 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -109,6 +109,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { assertTrue(map.containsKey("subscriberInfo")) verify(mex).setVariable("brgWanMacAddress", "brgmac") + verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"]) assertTrue(map.containsKey("serviceInputParams")) assertTrue(map.containsKey(Prefix+"requestInfo")) @@ -141,6 +142,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { def req = request .replace('"source"', '"sourceXXX"') .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"') + .replace('"Customer_Location"', '"Customer_LocationXXX"') when(mex.getVariable("bpmnRequest")).thenReturn(req) when(mex.getVariable("serviceInstanceId")).thenReturn(null) @@ -164,6 +166,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { assertTrue(map.containsKey("subscriberInfo")) assertEquals("", map.get("brgWanMacAddress")) + assertEquals("", map.get("customerLocation")) assertTrue(map.containsKey("serviceInputParams")) assertTrue(map.containsKey(Prefix+"requestInfo")) diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java index 571db76399..549664588e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java @@ -113,7 +113,7 @@ public class CreateGenericALaCarteServiceInstanceTest extends WorkflowTest { // Success Scenario private Map<String, String> setupVariables() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("isDebugLogEnabled", "true"); variables.put("bpmnRequest", getRequest()); variables.put("mso-request-id", "RaaCSIRequestId-1"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java index c259310717..b95ebb5fc7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java @@ -430,7 +430,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // Success Scenario private Map<String, String> setupVariables1() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); variables.put("requestId", "testRequestId"); @@ -455,7 +455,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // Success Scenario 2 private Map<String, String> setupVariables2() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); @@ -479,7 +479,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // Active Scenario private Map<String, String> setupVariablesActive() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); @@ -503,7 +503,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // Missing Name Scenario private Map<String, String> setupVariablesMissingName() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); //variables.put("bpmnRequest", getCreateNetworkRequestMissingName()); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); @@ -524,7 +524,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // SDNC Rollback Scenario private Map<String, String> setupVariablesSDNCRollback() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); @@ -609,7 +609,7 @@ public class CreateNetworkInstanceTest extends WorkflowTest { // VID json input private Map<String, String> setupVariablesVID1() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("bpmnRequest", getCreateNetworkRequestVID1()); variables.put("mso-request-id", "testRequestId"); //variables.put("msoRequestId", "testRequestId"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java index 75858996bc..a28e95ad0d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java @@ -175,7 +175,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
//variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
@@ -263,7 +263,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVIDWVolumeAttach() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java index 4496ab0731..23999c99ad 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java @@ -88,7 +88,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -138,7 +138,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -182,7 +182,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -229,7 +229,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -271,7 +271,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -311,7 +311,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); //testVariables.put("vnfId", "TEST-VNF-ID-0123"); @@ -349,7 +349,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString(); String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("serviceInstanceId", "test-service-instance-id"); //testVariables.put("vnfId", "TEST-VNF-ID-0123"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java index 803977bbb3..d5f94965fe 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java @@ -87,7 +87,7 @@ public class CreateVnfInfraTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariablesSuccess(variables, createVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVnfInfra", "v1", businessKey, createVnfInfraRequest, variables); @@ -124,7 +124,7 @@ public class CreateVnfInfraTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, null, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVnfInfra", variables); @@ -142,7 +142,7 @@ public class CreateVnfInfraTest extends WorkflowTest { MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, createVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVnfInfra", variables); @@ -174,7 +174,7 @@ public class CreateVnfInfraTest extends WorkflowTest { MockPutGenericVnf(); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, createVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVnfInfra", variables); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java index 02e236c914..aa05953493 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java @@ -95,7 +95,7 @@ public class DeleteGenericALaCarteServiceInstanceTest extends WorkflowTest { // Success Scenario
private Map<String, String> setupVariables() {
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("isDebugLogEnabled", "true");
variables.put("bpmnRequest", getRequest());
variables.put("mso-request-id", "RaaTestRequestId-1");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java index ca04d6fe46..4317a57405 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java @@ -87,7 +87,7 @@ public class DeleteNetworkInstanceTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
MockGetCloudRegion("RDM2WAGPLCP", 200, "DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml");
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("mso-request-id", "testRequestId");
variables.put("requestId", "testRequestId");
variables.put("isBaseVfModule", "true");
@@ -160,7 +160,7 @@ public class DeleteNetworkInstanceTest extends WorkflowTest { String networkModelInfo = " {\"modelName\": \"modelName\", " + '\n' +
" \"networkType\": \"modelName\" }";
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56");
variables.put("msoRequestId", "testRequestId");
variables.put("requestId", "testRequestId");
@@ -236,7 +236,7 @@ public class DeleteNetworkInstanceTest extends WorkflowTest { String networkModelInfo = " {\"modelCustomizationId\": \"uuid-nrc-001-1234\", " + '\n' +
" \"modelInvariantId\": \"was-ist-das-001-1234\" }";
- Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> variables = new HashMap<>();
variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56");
variables.put("msoRequestId", "testRequestId");
variables.put("requestId", "testRequestId");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleInfraTest.java index e89c64e6df..4c478e6143 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleInfraTest.java @@ -552,7 +552,7 @@ public class DeleteVfModuleInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
@@ -576,4 +576,4 @@ public class DeleteVfModuleInfraTest extends WorkflowTest { }
-} +}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleVolumeInfraV1Test.java index c343c9791e..84050c40e5 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVfModuleVolumeInfraV1Test.java @@ -65,7 +65,7 @@ public class DeleteVfModuleVolumeInfraV1Test extends WorkflowTest { String deleteVfModuleVolRequest = FileUtil.readResourceFile("__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("volumeGroupId", "78987"); testVariables.put("serviceInstanceId", "test-service-instance-id-0123"); @@ -105,7 +105,7 @@ public class DeleteVfModuleVolumeInfraV1Test extends WorkflowTest { String deleteVfModuleVolRequest = FileUtil.readResourceFile("__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("volumeGroupId", "78987"); @@ -145,7 +145,7 @@ public class DeleteVfModuleVolumeInfraV1Test extends WorkflowTest { String deleteVfModuleVolRequest = FileUtil.readResourceFile("__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json"); - Map<String, Object> testVariables = new HashMap<String, Object>(); + Map<String, Object> testVariables = new HashMap<>(); testVariables.put("requestId", "TEST-REQUEST-ID-0123"); testVariables.put("volumeGroupId", "78987"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVnfInfraTest.java index 29e278cd39..89bf141247 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVnfInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteVnfInfraTest.java @@ -79,7 +79,7 @@ public class DeleteVnfInfraTest extends WorkflowTest { MockDeleteGenericVnf(); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, deleteVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "DeleteVnfInfra", variables); waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); @@ -109,7 +109,7 @@ public class DeleteVnfInfraTest extends WorkflowTest { MockDeleteGenericVnf(); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, deleteVnfInfraRequestCascadeDelete, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "DeleteVnfInfra", variables); waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); @@ -139,7 +139,7 @@ public class DeleteVnfInfraTest extends WorkflowTest { MockDeleteGenericVnf_404(); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, deleteVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "DeleteVnfInfra", variables); @@ -173,7 +173,7 @@ public class DeleteVnfInfraTest extends WorkflowTest { MockDeleteGenericVnf(); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); setVariables(variables, deleteVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "DeleteVnfInfra", variables); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java index 852c8f922f..16433caa4c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java @@ -84,7 +84,7 @@ public class DoCreateSIRollbackTest extends WorkflowTest { mockUpdateRequestDB(200, "DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setupVariables(variables);
invokeSubProcess("DoCreateServiceInstanceRollback", businessKey, variables);
injectSDNCCallbacks(callbacks, "deactivate");
@@ -196,4 +196,4 @@ public class DoCreateSIRollbackTest extends WorkflowTest { variables.put("rollbackData",rollbackData);
}
-} +}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java index 5f05364289..f6c5d904bd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java @@ -90,7 +90,7 @@ public class DoCreateServiceInstanceTest extends WorkflowTest { mockUpdateRequestDB(200, "DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setupVariables(variables); invokeSubProcess("DoCreateServiceInstance", businessKey, variables); injectSDNCCallbacks(callbacks, "assign"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java index 1d0cb0cd10..25787c79b6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java @@ -105,7 +105,7 @@ public class DoCreateVfModuleRollbackTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
RollbackData rollbackData = new RollbackData();
rollbackData.put("VFMODULE", "source", "PORTAL");
rollbackData.put("VFMODULE", "vnfid", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java index 84e9ad14ed..d62c7598cb 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java @@ -230,7 +230,7 @@ public class DoCreateVfModuleTest extends WorkflowTest { private Map<String, Object> setupVariablesSunnyDayBuildingBlocks() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java index f5c8ab6ee8..e9082d9d65 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java @@ -67,7 +67,7 @@ public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString();
String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123");
testVariables.put("vnfId", "TEST-VNF-ID-0123");
testVariables.put("lcpCloudRegionId", "AAIAIC25");
@@ -100,7 +100,7 @@ public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString();
String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123");
testVariables.put("vnf-id", "TEST-VNF-ID-0123");
testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123");
@@ -139,7 +139,7 @@ public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString();
String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123");
testVariables.put("vnf-id", "TEST-VNF-ID-0123");
testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123");
@@ -176,7 +176,7 @@ public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString();
String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123");
testVariables.put("vnf-id", "TEST-VNF-ID-0123");
testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123");
@@ -217,7 +217,7 @@ public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { String businessKey = UUID.randomUUID().toString();
String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123");
testVariables.put("vnf-id", "TEST-VNF-ID-0123");
testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java index 6c36f12c82..fb2160d970 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java @@ -145,7 +145,7 @@ public class DoCreateVnfAndModulesRollbackTest extends WorkflowTest { MockDeleteGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721", "0000021");
MockDeleteVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73", "0000073", 200);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
RollbackData rollbackData = new RollbackData();
rollbackData.put("VFMODULE_BASE", "source", "PORTAL");
@@ -240,7 +240,7 @@ public class DoCreateVnfAndModulesRollbackTest extends WorkflowTest { MockDoDeleteVfModule_SDNCSuccess();
mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
RollbackData rollbackData = new RollbackData();
rollbackData.put("VNF", "vnfId", "testVnfId123");
@@ -327,7 +327,7 @@ public class DoCreateVnfAndModulesRollbackTest extends WorkflowTest { MockDeleteGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721", "0000021");
MockDeleteVfModuleId("", "", "", 200);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
RollbackData rollbackData = new RollbackData();
rollbackData.put("VFMODULE_BASE", "source", "PORTAL");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java index b2afc875b9..c8f97cac04 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java @@ -114,7 +114,7 @@ public class DoCreateVnfAndModulesTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET");
invokeSubProcess("DoCreateVnfAndModules", businessKey, variables);
@@ -168,7 +168,7 @@ public class DoCreateVnfAndModulesTest extends WorkflowTest { mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setVariablesAddonSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET");
invokeSubProcess("DoCreateVnfAndModules", businessKey, variables);
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java index bbdc285498..90d562e101 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java @@ -74,7 +74,7 @@ public class DoCreateVnfTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariablesSuccess(variables, createVnfInfraRequest, "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); invokeSubProcess("DoCreateVnf", businessKey, variables); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java index e2850b6b4f..37814999ba 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java @@ -84,7 +84,7 @@ public class DoDeleteServiceInstanceTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setupVariables(variables); invokeSubProcess("DoDeleteServiceInstance", businessKey, variables); injectSDNCCallbacks(callbacks, "deactivate"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java index c0d5539a21..13b2f5432d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java @@ -113,7 +113,7 @@ public class DoDeleteVfModuleFromVnfTest extends WorkflowTest { MockAAIDeleteVfModule();
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("msoRequestId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java index c741dfd2ed..578fda3910 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java @@ -128,7 +128,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -173,7 +173,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("requestId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -263,7 +263,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -334,7 +334,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -405,7 +405,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
@@ -475,7 +475,7 @@ public class DoDeleteVfModuleTest extends WorkflowTest { MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java index 454c5302fc..165debe7f1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java @@ -64,7 +64,7 @@ public class DoDeleteVfModuleVolumeV2Test extends WorkflowTest { MockGetVolumeGroupById("AAIAIC25", "78987", "VfModularity/VolumeGroup.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123");
testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123");
testVariables.put("isDebugLogEnabled", "true");
@@ -102,7 +102,7 @@ public class DoDeleteVfModuleVolumeV2Test extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123");
testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123");
testVariables.put("isDebugLogEnabled", "true");
@@ -138,7 +138,7 @@ public class DoDeleteVfModuleVolumeV2Test extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123");
testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123");
testVariables.put("isDebugLogEnabled", "true");
@@ -174,7 +174,7 @@ public class DoDeleteVfModuleVolumeV2Test extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123");
testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123");
testVariables.put("isDebugLogEnabled", "true");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java index de2fc86dbc..a9dde90327 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java @@ -77,7 +77,7 @@ public class DoDeleteVnfAndModulesTest extends WorkflowTest { mockSDNCAdapter(200);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setVariablesVnfOnly(variables);
invokeSubProcess("DoDeleteVnfAndModules", businessKey, variables);
@@ -142,7 +142,7 @@ public class DoDeleteVnfAndModulesTest extends WorkflowTest { MockAAIDeleteVfModule();
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setVariablesVnfAndModules(variables);
invokeSubProcess("DoDeleteVnfAndModules", businessKey, variables);
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfTest.java index 086ac099e8..8caa9f22a2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfTest.java @@ -54,7 +54,7 @@ public class DoDeleteVnfTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("DoDeleteVnf", businessKey, variables); // Disabled until SDNC support is there @@ -81,7 +81,7 @@ public class DoDeleteVnfTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("DoDeleteVnf", businessKey, variables); @@ -110,7 +110,7 @@ public class DoDeleteVnfTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> variables = new HashMap<>(); setVariables(variables); invokeSubProcess("DoDeleteVnf", businessKey, variables); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java index a626fde481..9fa93235b7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java @@ -100,7 +100,7 @@ public class DoUpdateVfModuleTest extends WorkflowTest { MockGetGenericVnfByIdWithPriority("skask", "supercool", 200, "VfModularity/VfModule-supercool.xml", 1);
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "DEV-VF-0011");
variables.put("isDebugLogEnabled","true");
variables.put("DoUpdateVfModuleRequest", doUpdateVfModuleRequest);
@@ -146,7 +146,7 @@ public class DoUpdateVfModuleTest extends WorkflowTest { MockVNFAdapterRestVfModule();
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", "DEV-VF-0011");
variables.put("isDebugLogEnabled","true");
variables.put("msoRequestId", "DEV-VF-0011");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java index 9f19b355ae..4def56cf6a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java @@ -104,7 +104,7 @@ public class DoUpdateVnfAndModulesTest extends WorkflowTest { mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET");
invokeSubProcess("DoUpdateVnfAndModules", businessKey, variables);
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java index d3d1b5b7f4..64852dfb5f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java @@ -210,7 +210,7 @@ public class ReplaceVnfInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java index 7aca55d502..5b5e4e59d3 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java @@ -291,7 +291,7 @@ public class UpdateNetworkInstanceTest extends WorkflowTest { // Success Scenario private Map<String, String> setupVariablesVID1() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("bpmnRequest", getCreateNetworkRequest1()); variables.put("mso-request-id", "testRequestId"); variables.put("requestId", "testRequestId"); @@ -378,7 +378,7 @@ public class UpdateNetworkInstanceTest extends WorkflowTest { // Success Scenario private Map<String, String> setupVariablesVIPER1() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("msoRequestId", "testRequestId"); variables.put("requestId", "testRequestId"); @@ -402,7 +402,7 @@ public class UpdateNetworkInstanceTest extends WorkflowTest { // Missing Name Scenario private Map<String, String> setupVariablesMissingNetworkId() { - Map<String, String> variables = new HashMap<String, String>(); + Map<String, String> variables = new HashMap<>(); variables.put("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); variables.put("bpmnRequest", getCreateNetworkRequestNetworkId()); variables.put("requestId", "testRequestId"); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraTest.java index 04189a30b2..37c548abf7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraTest.java @@ -118,7 +118,7 @@ public class UpdateVfModuleInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java index 6f3ce69a07..65a514c804 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java @@ -98,7 +98,7 @@ public class UpdateVfModuleInfraV2Test extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("requestId", "testRequestId");
variables.put("isBaseVfModule", false);
variables.put("isDebugLogEnabled", "true");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java index ab72118e36..b24eb56058 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java @@ -76,7 +76,7 @@ public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { String updaetVfModuleVolRequest =
FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("requestId", "TEST-REQUEST-ID-0123");
testVariables.put("serviceInstanceId", "test-service-instance-id");
testVariables.put("volumeGroupId", "78987");
@@ -122,7 +122,7 @@ public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { String updaetVfModuleVolRequest =
FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json");
- Map<String, Object> testVariables = new HashMap<String, Object>();
+ Map<String, Object> testVariables = new HashMap<>();
testVariables.put("requestId", "TEST-REQUEST-ID-0123");
testVariables.put("serviceInstanceId", "test-service-instance-id");
testVariables.put("volumeGroupId", "78987");
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java index 597628590e..391fc2308b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java @@ -152,7 +152,7 @@ public class UpdateVnfInfraTest extends WorkflowTest { // Active Scenario
private Map<String, Object> setupVariablesSunnyDayVID() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
//try {
// variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
//}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java index 0af43a2c42..1b3bfa8c76 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java @@ -134,9 +134,9 @@ public class CreateVcpeResCustServiceTest extends AbstractTestBase { assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); assertEquals(null, workflowException); - assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0); - assertTrue(completionReq.indexOf("action>CREATE<") >= 0); - assertTrue(completionReq.indexOf("source>VID<") >= 0); + assertTrue(completionReq.contains("request-id>testRequestId<")); + assertTrue(completionReq.contains("action>CREATE<")); + assertTrue(completionReq.contains("source>VID<")); assertEquals("1", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); } @@ -200,9 +200,9 @@ public class CreateVcpeResCustServiceTest extends AbstractTestBase { assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); assertEquals(null, workflowException); - assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0); - assertTrue(completionReq.indexOf("action>CREATE<") >= 0); - assertTrue(completionReq.indexOf("source>VID<") >= 0); + assertTrue(completionReq.contains("request-id>testRequestId<")); + assertTrue(completionReq.contains("action>CREATE<")); + assertTrue(completionReq.contains("source>VID<")); assertEquals("0", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java index 88b6464de0..d026b7a949 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java @@ -162,9 +162,9 @@ public class DeleteVcpeResCustServiceTest extends AbstractTestBase { assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); assertEquals(null, workflowException); - assertTrue(completionReq.indexOf("<request-id>testRequestId<") >= 0); - assertTrue(completionReq.indexOf("<action>DELETE<") >= 0); - assertTrue(completionReq.indexOf("<source>VID<") >= 0); + assertTrue(completionReq.contains("<request-id>testRequestId<")); + assertTrue(completionReq.contains("<action>DELETE<")); + assertTrue(completionReq.contains("<source>VID<")); assertEquals("2", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"vnfsDeletedCount")); @@ -223,9 +223,9 @@ public class DeleteVcpeResCustServiceTest extends AbstractTestBase { assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); assertEquals(null, workflowException); - assertTrue(completionReq.indexOf("<request-id>testRequestId<") >= 0); - assertTrue(completionReq.indexOf("<action>DELETE<") >= 0); - assertTrue(completionReq.indexOf("<source>VID<") >= 0); + assertTrue(completionReq.contains("<request-id>testRequestId<")); + assertTrue(completionReq.contains("<action>DELETE<")); + assertTrue(completionReq.contains("<source>VID<")); assertEquals("0", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"vnfsDeletedCount")); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json index a0168bd96a..3e05ba0f9d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json @@ -32,12 +32,19 @@ "aLaCarte":"false", "userParams": [ - { - "name":"BRG_WAN_MAC_Address", - "value":"brgmac" - } - ] + { + "name":"BRG_WAN_MAC_Address", + "value":"brgmac" + }, + { + "name": "Customer_Location", + "value": { + "customerLatitude": "32.897480", + "customerLongitude": "-97.040443", + "customerName": "some_company" + } + } + ] } - } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json index 17c6d15fe7..cf02444705 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json @@ -29,14 +29,21 @@ { "subscriptionServiceType":"123456789", "aLaCarte":"false", - "userParams": - [ - { - "name":"BRG_WAN_MAC_Address", - "value":"brgmac" - } - ] + "userParams": + [ + { + "name":"BRG_WAN_MAC_Address", + "value":"brgmac" + }, + { + "name": "Customer_Location", + "value": { + "customerLatitude": "32.897480", + "customerLongitude": "-97.040443", + "customerName": "some_company" + } + } + ] } - } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json index 8583e66d33..39be40aedd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json @@ -29,14 +29,21 @@ { "subscriptionServiceType":"123456789", "aLaCarte":"false", - "userParams": - [ - { - "name":"BRG_WAN_MAC_Address", - "value":"brgmac" - } - ] + "userParams": + [ + { + "name":"BRG_WAN_MAC_Address", + "value":"brgmac" + }, + { + "name": "Customer_Location", + "value": { + "customerLatitude": "32.897480", + "customerLongitude": "-97.040443", + "customerName": "some_company" + } + } + ] } - } } diff --git a/bpmn/MSORESTClient/pom.xml b/bpmn/MSORESTClient/pom.xml index c17015c003..5d89e29025 100644 --- a/bpmn/MSORESTClient/pom.xml +++ b/bpmn/MSORESTClient/pom.xml @@ -4,12 +4,12 @@ <modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>bpmn</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>MSORESTClient</artifactId>
<packaging>jar</packaging>
@@ -31,7 +31,7 @@ </dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/RESTClient.java b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/RESTClient.java index 6504615f7a..3170e49371 100644 --- a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/RESTClient.java +++ b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/RESTClient.java @@ -242,16 +242,16 @@ public class RESTClient { /** * Creates a RESTClient with the RESTConfig object. * - * @param RESTConfig config to use for sending request + * @param restConfig config to use for sending request * * @throws RESTException if unable to create a RESTClient */ - public RESTClient(RESTConfig cfg) throws RESTException { - this.headers = new LinkedHashMap<String, List<String>>(); - this.parameters = new LinkedHashMap<String, List<String>>(); - this.URL = cfg.getURL(); - this.proxyHost = cfg.getProxyHost(); - this.proxyPort = cfg.getProxyPort(); + public RESTClient(RESTConfig restConfig) throws RESTException { + this.headers = new LinkedHashMap<>(); + this.parameters = new LinkedHashMap<>(); + this.URL = restConfig.getURL(); + this.proxyHost = restConfig.getProxyHost(); + this.proxyPort = restConfig.getProxyPort(); } /** @@ -266,7 +266,7 @@ public class RESTClient { */ public RESTClient addParameter(String name, String value) { if (!parameters.containsKey(name)) { - parameters.put(name, new ArrayList<String>()); + parameters.put(name, new ArrayList<>()); } List<String> values = parameters.get(name); @@ -306,7 +306,7 @@ public class RESTClient { */ public RESTClient addHeader(String name, String value) { if (!headers.containsKey(name)) { - headers.put(name, new ArrayList<String>()); + headers.put(name, new ArrayList<>()); } List<String> values = headers.get(name); diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 79acccb04d..d36d4c785d 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -4,12 +4,12 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>bpmn</artifactId> <name>BPMN Subsystem</name> <description>BPMN Subsystem for MSO</description> diff --git a/common/pom.xml b/common/pom.xml index 6a304c272c..48518aea31 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <name>MSO Common classes</name> <description>MSO Common classes:- Logger</description> @@ -241,7 +241,7 @@ </executions> <dependencies> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java index 7b9c6a5166..b2b8d0aa33 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java +++ b/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java @@ -162,8 +162,8 @@ public class MsoAlarmLogger implements ServletContextListener { encoder.setPattern(logPattern); encoder.setContext(context); encoder.start(); - RollingFileAppender<ILoggingEvent> fileAppender=new RollingFileAppender<ILoggingEvent>(); - TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy=new TimeBasedRollingPolicy<ILoggingEvent>(); + RollingFileAppender<ILoggingEvent> fileAppender= new RollingFileAppender<>(); + TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy= new TimeBasedRollingPolicy<>(); rollingPolicy.setContext(context); rollingPolicy.setFileNamePattern(msoAlarmFile + ".%d"); rollingPolicy.setParent(fileAppender); diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java index 86aedc1a43..b8c4aed8fa 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java +++ b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java @@ -144,15 +144,16 @@ public class MsoLogger { // For internal logging of the initialization of MSO logs private static final Logger LOGGER = Logger.getLogger(MsoLogger.class.getName()); - private MsoLogger(MsoLogger.Catalog cat) { - this.logger = EELFManager.getInstance().getErrorLogger(); - this.auditLogger = EELFManager.getInstance().getAuditLogger(); - this.metricsLogger = EELFManager.getInstance().getMetricsLogger(); - MsoLogger.initialization(); - setDefaultLogCatalog(cat); - } - private static synchronized void initialization() { + // Since four adaptors are using the instance of MsoLogger which will be referenced everywhere + // hence limiting the number of MsoLogger instances to five. + private static final MsoLogger generalMsoLogger = new MsoLogger(Catalog.GENERAL); + private static final MsoLogger apihLogger = new MsoLogger(Catalog.APIH); + private static final MsoLogger asdcLogger = new MsoLogger(Catalog.ASDC); + private static final MsoLogger raLogger = new MsoLogger(Catalog.RA); + private static final MsoLogger bpelLogger = new MsoLogger(Catalog.BPEL); + + static { if (instanceUUID == null || ("").equals(instanceUUID)) { instanceUUID = getInstanceUUID(); } @@ -170,15 +171,40 @@ public class MsoLogger { } } + // Singleton instances of the EELFLogger of all types are referenced by MsoLogger + private MsoLogger(Catalog cat) { + this.logger = EELFManager.getInstance().getErrorLogger(); + this.auditLogger = EELFManager.getInstance().getAuditLogger(); + this.metricsLogger = EELFManager.getInstance().getMetricsLogger(); + this.setDefaultLogCatalog(cat); + } + + + /** * Get the MsoLogger based on the catalog - * + * This method is fixed now to resolve the total number of objects that are getting created + * everytime this function gets called. Its supposed to have fixed number of instance per java process. + * * @param cat * Catalog of the logger * @return the MsoLogger */ public static synchronized MsoLogger getMsoLogger(MsoLogger.Catalog cat) { - return new MsoLogger(cat); + switch (cat) { + case GENERAL: + return generalMsoLogger; + case APIH: + return apihLogger; + case RA: + return raLogger; + case BPEL: + return bpelLogger; + case ASDC: + return asdcLogger; + default: + return generalMsoLogger; + } } /** diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java b/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java index 5687775048..dd42efbfda 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java +++ b/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java @@ -95,7 +95,8 @@ public class MsoLoggingServlet { List <Logger> loggerList = context.getLoggerList(); for (Logger logger:loggerList) { //if (logger.getLevel() != null) { - response.append (logger.getName () + ":" + logger.getLevel () + " (" + logger.getEffectiveLevel () + ")\n"); + response.append(logger.getName()).append(":").append(logger.getLevel()).append(" (") + .append(logger.getEffectiveLevel()).append(")\n"); //} } return Response.status (200).entity (response).build (); diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java b/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java index c0997f31d9..ec0b54a14f 100644 --- a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java +++ b/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java @@ -159,15 +159,9 @@ public class MsoJsonProperties extends AbstractMsoProperties { @Override public String toString() { - StringBuffer response = new StringBuffer(); - response.append("Config file " + propertiesFileName + "(Timer:" + automaticRefreshInMinutes + "mins):" - + System.getProperty("line.separator")); - response.append(this.jsonRootNode.toString()); - response.append(System.getProperty("line.separator")); - response.append(System.getProperty("line.separator")); - return response.toString(); - + return "Config file " + propertiesFileName + "(Timer:" + automaticRefreshInMinutes + "mins):" + System + .getProperty("line.separator") + this.jsonRootNode.toString() + System.getProperty("line.separator") + + System.getProperty("line.separator"); } - } diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java b/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java index cf69cf92c8..3f81734796 100644 --- a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java +++ b/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java @@ -78,7 +78,7 @@ public class MsoPropertiesFactory implements Serializable { // Hardcode if nothing is received prefixMsoPropertiesPath = ""; } - msoPropertiesCache = new ConcurrentHashMap <String, MsoPropertiesParameters> (); + msoPropertiesCache = new ConcurrentHashMap<>(); } private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock (); @@ -268,7 +268,7 @@ public class MsoPropertiesFactory implements Serializable { */ public List <AbstractMsoProperties> getAllMsoProperties () { - List <AbstractMsoProperties> resultList = new LinkedList <AbstractMsoProperties> (); + List <AbstractMsoProperties> resultList = new LinkedList<>(); rwl.readLock ().lock (); try { diff --git a/common/src/main/java/org/openecomp/mso/utils/CheckResults.java b/common/src/main/java/org/openecomp/mso/utils/CheckResults.java index 75337f0cf1..ad0344d028 100644 --- a/common/src/main/java/org/openecomp/mso/utils/CheckResults.java +++ b/common/src/main/java/org/openecomp/mso/utils/CheckResults.java @@ -36,7 +36,7 @@ public class CheckResults { private List <CheckResult> results; public CheckResults () { - results = new ArrayList <CheckResult> (); + results = new ArrayList<>(); } public List <CheckResult> getResults () { diff --git a/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java b/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java index 42cd190e95..5d0ff5b79e 100644 --- a/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java +++ b/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java @@ -72,13 +72,13 @@ public final class CryptoUtils { } public static String byteArrayToHexString (byte[] b) { - StringBuffer sb = new StringBuffer (b.length * 2); - for (int i = 0; i < b.length; i++) { - int v = b[i] & 0xff; + StringBuilder sb = new StringBuilder(b.length * 2); + for (byte aB : b) { + int v = aB & 0xff; if (v < 16) { - sb.append ('0'); + sb.append('0'); } - sb.append (Integer.toHexString (v)); + sb.append(Integer.toHexString(v)); } return sb.toString ().toUpperCase (); } diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java index f038cbc851..a814c4ea9c 100644 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java +++ b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java @@ -146,7 +146,7 @@ public class MsoPropertiesFactoryConcurrencyTest { public final void testGetMsoProperties() throws MsoPropertiesException, InterruptedException, ExecutionException, FileNotFoundException { - List<Future<Integer>> list = new ArrayList<Future<Integer>>(); + List<Future<Integer>> list = new ArrayList<>(); ExecutorService executor = Executors.newFixedThreadPool(20); for (int i = 0; i <= 100000; i++) { diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java index 54b01a5410..db58c5a49e 100644 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java +++ b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java @@ -153,7 +153,7 @@ public class MsoPropertiesFactoryTest { assertFalse(msoPropChanged.equals(null)); assertFalse(msoPropChanged.equals(msoPropCache)); - assertFalse(msoPropChanged.equals(new Boolean(true))); + assertFalse(msoPropChanged.equals(Boolean.TRUE)); assertTrue(msoPropChanged.equals(msoPropChanged)); } @@ -598,8 +598,8 @@ public class MsoPropertiesFactoryTest { assertFalse(msoProperties.equals(msoProperties2)); assertTrue(msoProperties.equals(msoProperties)); assertFalse(msoProperties.equals(null)); - assertFalse(msoProperties.equals(new String())); - + assertFalse(msoProperties.toString().isEmpty()); + // Test a reload with timer set to 1 in PATH_MSO_JSON_PROP2 msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JSON_PROP_ID, PATH_MSO_JSON_PROP); diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml index eaab61c756..8eab5d6a47 100644 --- a/mso-api-handlers/mso-api-handler-common/pom.xml +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -3,13 +3,13 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handler-common</artifactId> <name>ECOMP MSO API Handler common</name> @@ -73,13 +73,13 @@ </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-requests-db</artifactId> <version>${project.version}</version> </dependency> diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java index fd1227ec13..3ef6d4974c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java @@ -38,7 +38,7 @@ import org.openecomp.mso.apihandler.common.CommonConstants; CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, CommonConstants.VF_MODULE_TYPE_VARIABLE, CommonConstants.NETWORK_TYPE_VARIABLE, - CommonConstants.CAMUNDA_SERVICE_INPUT}) + CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.RECIPE_PARAMS}) @JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) public class CamundaVIDRequest { @@ -91,6 +91,9 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) private CamundaInput networkType; + @JsonProperty(CommonConstants.RECIPE_PARAMS) + private CamundaInput recipeParams; + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) public CamundaInput getServiceInput() { return serviceInput; @@ -250,8 +253,17 @@ public class CamundaVIDRequest { this.networkType = networkType; } + @JsonProperty(CommonConstants.RECIPE_PARAMS) + public CamundaInput getRecipeParams() { + return recipeParams; + } - @Override + @JsonProperty(CommonConstants.RECIPE_PARAMS) + public void setRecipeParams(CamundaInput recipeParams) { + this.recipeParams = recipeParams; + } + + @Override public String toString() { //return "CamundaRequest [requestId=" + + ", host=" // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java index ddeb359071..cc68a45d19 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java @@ -89,7 +89,7 @@ public class BPELRestClient extends RequestClient { int recipeTimeout, String requestAction, String serviceInstanceId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails) { + String requestDetails, String recipeParamXsd) { return null; } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java index b9c0725766..9258cabe5b 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java @@ -60,7 +60,8 @@ public class CamundaClient extends RequestClient{ if(encryptedCredentials != null){ String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + post.addHeader("Authorization", "Basic " + DatatypeConverter + .printBase64Binary(userCredentials.getBytes())); } } } @@ -83,7 +84,8 @@ public class CamundaClient extends RequestClient{ if(encryptedCredentials != null){ String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + post.addHeader("Authorization", "Basic " + DatatypeConverter + .printBase64Binary(userCredentials.getBytes())); } } } @@ -98,13 +100,13 @@ public class CamundaClient extends RequestClient{ int recipeTimeout, String requestAction, String serviceInstanceId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails) + String requestDetails, String recipeParamXsd) throws ClientProtocolException, IOException{ HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE + url); String jsonReq = wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, - serviceType, vnfType, vfModuleType, networkType, requestDetails); + serviceType, vnfType, vfModuleType, networkType, requestDetails, recipeParamXsd); StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); @@ -115,7 +117,8 @@ public class CamundaClient extends RequestClient{ if(encryptedCredentials != null){ String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + post.addHeader("Authorization", "Basic " + DatatypeConverter + .printBase64Binary(userCredentials.getBytes())); } } } @@ -178,7 +181,7 @@ public class CamundaClient extends RequestClient{ int recipeTimeout, String requestAction, String serviceInstanceId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails){ + String requestDetails, String recipeParams){ String jsonReq = null; if(requestId == null){ requestId =""; @@ -236,7 +239,7 @@ public class CamundaClient extends RequestClient{ CamundaInput vnfTypeInput = new CamundaInput(); CamundaInput vfModuleTypeInput = new CamundaInput(); CamundaInput networkTypeInput = new CamundaInput(); - + CamundaInput recipeParamsInput = new CamundaInput(); host.setValue(parseURL()); requestIdInput.setValue(requestId); isBaseVfModuleInput.setValue(isBaseVfModule); @@ -251,7 +254,7 @@ public class CamundaClient extends RequestClient{ vnfTypeInput.setValue(vnfType); vfModuleTypeInput.setValue(vfModuleType); networkTypeInput.setValue(networkType); - + recipeParamsInput.setValue(recipeParams); serviceInput.setValue(requestDetails); camundaRequest.setServiceInput(serviceInput); camundaRequest.setHost(host); @@ -269,7 +272,7 @@ public class CamundaClient extends RequestClient{ camundaRequest.setVnfType(vnfTypeInput); camundaRequest.setVfModuleType(vfModuleTypeInput); camundaRequest.setNetworkType(networkTypeInput); - + camundaRequest.setRecipeParams(recipeParamsInput); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java index 64193cf6c4..4b179daa7c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java @@ -52,7 +52,8 @@ public class CamundaTaskClient extends RequestClient{ if(encryptedCredentials != null){
String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY);
if(userCredentials != null){
- post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes())));
+ post.addHeader("Authorization", "Basic " + DatatypeConverter
+ .printBase64Binary(userCredentials.getBytes()));
}
}
}
@@ -74,7 +75,7 @@ public class CamundaTaskClient extends RequestClient{ int recipeTimeout, String requestAction, String serviceInstanceId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails)
+ String requestDetails, String recipeParamXsd)
throws ClientProtocolException, IOException{
msoLogger.debug("Method not supported");
return null;
@@ -90,7 +91,8 @@ public class CamundaTaskClient extends RequestClient{ if(encryptedCredentials != null){
String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY);
if(userCredentials != null){
- get.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes())));
+ get.addHeader("Authorization", "Basic " + DatatypeConverter
+ .printBase64Binary(userCredentials.getBytes()));
}
}
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java index 91bd226c30..cfbe892e68 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java @@ -63,6 +63,7 @@ public final class CommonConstants { public static final String VF_MODULE_TYPE_VARIABLE = "vfModuleType"; public static final String NETWORK_TYPE_VARIABLE = "networkType"; public static final String REQUEST_DETAILS_VARIABLE = "requestDetails"; + public static final String RECIPE_PARAMS = "recipeParams"; private CommonConstants () { // prevent creating an instance of this class diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java index addf4e11a5..eaf8be76a3 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java @@ -74,7 +74,7 @@ public abstract class RequestClient { int recipeTimeout, String requestAction, String serviceInstanceId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails) + String requestDetails, String recipeParamXsd) throws ClientProtocolException, IOException; public abstract HttpResponse get() diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index f152116421..08ff9fedd0 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -3,7 +3,7 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> @@ -220,22 +220,22 @@ <version>${spring-version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-requests-db</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handler-common</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java index f6b30e8772..c51c61e3dd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java @@ -1,926 +1,1155 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.apihandlerinfra; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.codehaus.jackson.map.ObjectMapper; -import org.hibernate.Session; -import org.json.JSONObject; -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandlerinfra.Messages; -import org.openecomp.mso.apihandlerinfra.MsoException; -import org.openecomp.mso.apihandlerinfra.MsoRequest; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.DelE2ESvcResp; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoDatabaseException; -import org.openecomp.mso.requestsdb.OperationStatus; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; -import org.openecomp.mso.utils.UUIDChecker; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path("/e2eServiceInstances") -@Api(value = "/e2eServiceInstances", description = "API Requests for E2E Service Instances") -public class E2EServiceInstances { - - private HashMap<String, String> instanceIdMap = new HashMap<>(); - private static MsoLogger msoLogger = MsoLogger - .getMsoLogger(MsoLogger.Catalog.APIH); - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); - public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - private ServiceInstancesRequest sir = null; - - public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; - public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB"; - public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine"; - - /** - * POST Requests for E2E Service create Instance on a version provided - */ - - @POST - @Path("/{version:[vV][3-5]}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Create a E2E Service Instance on a version provided", response = Response.class) - public Response createE2EServiceInstance(String request, - @PathParam("version") String version) { - - return processE2EserviceInstances(request, Action.createInstance, null, - version); - } - - /** - * DELETE Requests for E2E Service delete Instance on a specified version - * and serviceId - */ - - @DELETE - @Path("/{version:[vV][3-5]}/{serviceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class) - public Response deleteE2EServiceInstance(String request, - @PathParam("version") String version, - @PathParam("serviceId") String serviceId) { - - instanceIdMap.put("serviceId", serviceId); - - return deleteE2EserviceInstances(request, Action.deleteInstance, - instanceIdMap, version); - } - - @GET - @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}") - @ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", response = Response.class) - @Produces(MediaType.APPLICATION_JSON) - public Response getE2EServiceInstances( - @PathParam("serviceId") String serviceId, - @PathParam("version") String version, - @PathParam("operationId") String operationId) { - return getE2EServiceInstances(serviceId, operationId); - } - - private Response getE2EServiceInstances(String serviceId, String operationId) { - RequestsDatabase requestsDB = RequestsDatabase.getInstance(); - - GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse(); - - MsoRequest msoRequest = new MsoRequest(serviceId); - - long startTime = System.currentTimeMillis(); - - OperationStatus operationStatus = null; - - try { - operationStatus = requestsDB.getOperationStatus(serviceId, - operationId); - - } catch (Exception e) { - msoLogger - .error(MessageEnum.APIH_DB_ACCESS_EXC, - MSO_PROP_APIHANDLER_INFRA, - "", - "", - MsoLogger.ErrorCode.AvailabilityError, - "Exception while communciate with Request DB - Infra Request Lookup", - e); - msoRequest - .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - e.getMessage(), - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null); - alarmLogger.sendAlarm("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, Messages.errors - .get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.DBAccessError, - "Exception while communciate with Request DB"); - msoLogger.debug("End of the transaction, the final response is: " - + (String) response.getEntity()); - return response; - - } - - if (operationStatus == null) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NO_CONTENT, MsoException.ServiceException, - "E2E serviceId " + serviceId + " is not found in DB", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Null response from RequestDB when searching by serviceId"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.DataNotFound, - "Null response from RequestDB when searching by serviceId"); - msoLogger.debug("End of the transaction, the final response is: " - + (String) resp.getEntity()); - return resp; - - } - - e2eServiceResponse.setOperationStatus(operationStatus); - - return Response.status(200).entity(e2eServiceResponse).build(); - } - - private Response deleteE2EserviceInstances(String requestJSON, - Action action, HashMap<String, String> instanceIdMap, String version) { - // TODO should be a new one or the same service instance Id - String requestId = instanceIdMap.get("serviceId"); - long startTime = System.currentTimeMillis(); - msoLogger.debug("requestId is: " + requestId); - E2EServiceInstanceDeleteRequest e2eDelReq = null; - - MsoRequest msoRequest = new MsoRequest(requestId); - - ObjectMapper mapper = new ObjectMapper(); - try { - e2eDelReq = mapper.readValue(requestJSON, - E2EServiceInstanceDeleteRequest.class); - - } catch (Exception e) { - - msoLogger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, - "Mapping of request to JSON object failed. " - + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, - null); - msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.SchemaError, - "Mapping of request to JSON object failed"); - msoLogger.debug("End of the transaction, the final response is: " - + (String) response.getEntity()); - createOperationStatusRecordForError(action, requestId); - return response; - } - - CatalogDatabase db = null; - RecipeLookupResult recipeLookupResult = null; - try { - db = CatalogDatabase.getInstance(); - recipeLookupResult = getServiceInstanceOrchestrationURI(db, action); - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, - "Exception while communciate with Catalog DB", e); - msoRequest - .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "No communication to catalog DB " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - alarmLogger.sendAlarm("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, Messages.errors - .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord(Status.FAILED, action); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.DBAccessError, - "Exception while communciate with DB"); - msoLogger.debug(END_OF_THE_TRANSACTION - + (String) response.getEntity()); - return response; - } finally { - closeCatalogDB(db); - } - if (recipeLookupResult == null) { - msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.DataError, "No recipe found in DB"); - msoRequest - .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); - msoRequest.createRequestRecord(Status.FAILED, action); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.DataNotFound, - "No recipe found in DB"); - msoLogger.debug(END_OF_THE_TRANSACTION - + (String) response.getEntity()); - createOperationStatusRecordForError(action, requestId); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - - long subStartTime = System.currentTimeMillis(); - // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - - try { - requestClient = RequestClientFactory.getRequestClient( - recipeLookupResult.getOrchestrationURI(), - MsoPropertiesUtils.loadMsoProperties()); - - JSONObject jjo = new JSONObject(requestJSON); - jjo.put("operationId", UUIDChecker.generateUUID(msoLogger)); - - String bpmnRequest = jjo.toString(); - - // Capture audit event - msoLogger - .debug("MSO API Handler Posting call to BPEL engine for url: " - + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceInstanceType = e2eDelReq.getServiceType(); - response = requestClient.post(requestId, false, - recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, serviceInstanceType, - null, null, null, bpmnRequest); - - msoLogger.recordMetricEvent(subStartTime, - MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully received response from BPMN engine", "BPMN", - recipeLookupResult.getOrchestrationURI(), null); - } catch (Exception e) { - msoLogger.recordMetricEvent(subStartTime, - MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.CommunicationError, - "Exception while communicate with BPMN engine", "BPMN", - recipeLookupResult.getOrchestrationURI(), null); - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - alarmLogger.sendAlarm("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, - "Exception while communicate with BPMN engine"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.CommunicationError, - "Exception while communicate with BPMN engine"); - msoLogger.debug("End of the transaction, the final response is: " - + (String) resp.getEntity()); - createOperationStatusRecordForError(action, requestId); - return resp; - } - - if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "bpelResponse is null", - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, - MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Null response from BPEL"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.InternalError, - "Null response from BPMN"); - msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity()); - createOperationStatusRecordForError(action, requestId); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler(response, - requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(requestId, startTime, msoRequest, - requestClient, respHandler, bpelStatus, action, instanceIdMap); - } - - private Response processE2EserviceInstances(String requestJSON, Action action, - HashMap<String, String> instanceIdMap, String version) { - - String requestId = UUIDChecker.generateUUID(msoLogger); - long startTime = System.currentTimeMillis(); - msoLogger.debug("requestId is: " + requestId); - E2EServiceInstanceRequest e2eSir = null; - - MsoRequest msoRequest = new MsoRequest(requestId); - ObjectMapper mapper = new ObjectMapper(); - try { - e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class); - - } catch (Exception e) { - //TODO update the service name - this.createOperationStatusRecordForError(action, requestId); - - msoLogger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null); - msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, - "Mapping of request to JSON object failed"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - return response; - } - - mapReqJsonToSvcInstReq(e2eSir, requestJSON); - sir.getRequestDetails().getRequestParameters().setaLaCarte(true); - try { - msoRequest.parse(sir, instanceIdMap, action, version); - } catch (Exception e) { - msoLogger.debug("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Error parsing request. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null); - if (msoRequest.getRequestId() != null) { - msoLogger.debug("Logging failed message to the database"); - //TODO update the service name - this.createOperationStatusRecordForError(action, requestId); - } - msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, - "Validation of the input request failed"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - return response; - } - - OperationStatus dup = null; - String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); - String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); - try { - if (!(instanceName == null && "service".equals(requestScope) - && (action == Action.createInstance || action == Action.activateInstance))) { - //TODO : Need to check for the duplicate record from the operation status, - //TODO : commenting this check for unblocking current testing for now... induces dead code... - dup = chkDuplicateServiceNameInOperStatus( instanceName); - } - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e); - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, - MsoException.ServiceException, e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, - "Error during duplicate check"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - return response; - } - - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - String instance = null; - if (instanceName != null) { - instance = instanceName; - } else { - instance = instanceIdMap.get(requestScope + "InstanceId"); - } - String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " - + "already has a request being worked with a status of " + dup.getProgress() + " (ServiceId - " - + dup.getServiceId() + "). The existing request must finish or be cleaned up before proceeding."; - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, - MsoException.ServiceException, dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - - msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, - "Duplicate request - Subscriber already has a request for this service"); - - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, - dupMessage); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - createOperationStatusRecordForError(action, requestId); - return response; - } - - CatalogDatabase db = null; - RecipeLookupResult recipeLookupResult = null; - try { - db = CatalogDatabase.getInstance(); - recipeLookupResult = getServiceInstanceOrchestrationURI(db, action); - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL, - Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, - "Exception while communciate with DB"); - msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity()); - createOperationStatusRecordForError(action, requestId); - return response; - } finally { - closeCatalogDB(db); - } - - if (recipeLookupResult == null) { - msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.DataError, "No recipe found in DB"); - msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, - "No recipe found in DB"); - msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity()); - createOperationStatusRecordForError(action, requestId); - return response; - } -// try { -// msoRequest.createRequestRecord(Status.PENDING, action); -// //createOperationStatusRecord(action, requestId); -// } catch (Exception e) { -// msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", -// MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e); -// msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); -// Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, -// MsoException.ServiceException, "Exception while creating record in DB " + e.getMessage(), -// ErrorNumbers.SVC_BAD_PARAMETER, null); -// msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, -// "Exception while creating record in DB"); -// msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); -// return response; -// } - - String serviceInstanceType = e2eSir.getService().getParameters().getServiceType(); - - String serviceId = ""; - RequestClient requestClient = null; - HttpResponse response = null; - - long subStartTime = System.currentTimeMillis(); - String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - - try { - requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(), - MsoPropertiesUtils.loadMsoProperties()); - - // Capture audit event - msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - - response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson); - - msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(), - null); - } catch (Exception e) { - msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", - recipeLookupResult.getOrchestrationURI(), null); - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, - Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, - "Exception while communicate with BPMN engine"); - msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity()); - createOperationStatusRecordForError(action, requestId); - return resp; - } - - if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, - "Null response from BPMN"); - msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap); - } - - private void closeCatalogDB(CatalogDatabase db) { - if (db != null) { - db.close(); - } - } - - private Response beplStatusUpdate(String requestId, long startTime, - MsoRequest msoRequest, RequestClient requestClient, - ResponseHandler respHandler, int bpelStatus, Action action, - HashMap<String, String> instanceIdMap) { - // BPMN accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String camundaJSONResponseBody = respHandler.getResponseBody(); - msoLogger - .debug("Received from Camunda: " + camundaJSONResponseBody); - - // currently only for delete case we update the status here - if (action == Action.deleteInstance) { - ObjectMapper mapper = new ObjectMapper(); - try { - DelE2ESvcResp jo = mapper.readValue( - camundaJSONResponseBody, DelE2ESvcResp.class); - String operationId = jo.getOperationId(); - this.createOperationStatusRecord("DELETE", requestId, - operationId); - } catch (Exception ex) { - msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, - requestClient.getUrl(), "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Response from BPEL engine is failed with HTTP Status=" - + bpelStatus); - } - } - msoLogger.recordAuditEvent(startTime, - MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "BPMN accepted the request, the request is in progress"); - msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody); - return Response.status(HttpStatus.SC_ACCEPTED) - .entity(camundaJSONResponseBody).build(); - } else { - List<String> variables = new ArrayList<>(); - variables.add(bpelStatus + ""); - String camundaJSONResponseBody = respHandler.getResponseBody(); - if (camundaJSONResponseBody != null - && !camundaJSONResponseBody.isEmpty()) { - Response resp = msoRequest.buildServiceErrorResponse( - bpelStatus, MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1 " - + '\n' + camundaJSONResponseBody, - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables); - msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, - requestClient.getUrl(), "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Response from BPEL engine is failed with HTTP Status=" - + bpelStatus); - msoLogger.recordAuditEvent(startTime, - MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.InternalError, - "Response from BPMN engine is failed"); - msoLogger.debug(END_OF_THE_TRANSACTION - + (String) resp.getEntity()); - return resp; - } else { - Response resp = msoRequest - .buildServiceErrorResponse( - bpelStatus, - MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - variables); - msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, - requestClient.getUrl(), "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent(startTime, - MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.InternalError, - "Response from BPEL engine is empty"); - msoLogger.debug(END_OF_THE_TRANSACTION - + (String) resp.getEntity()); - return resp; - } - } - } - - /** - * Getting recipes from catalogDb - * - * @param db - * @param action - * @return - */ - private RecipeLookupResult getServiceInstanceOrchestrationURI( - CatalogDatabase db, Action action) { - - RecipeLookupResult recipeLookupResult = getServiceURI(db, action); - - if (recipeLookupResult != null) { - msoLogger.debug("Orchestration URI is: " - + recipeLookupResult.getOrchestrationURI() - + ", recipe Timeout is: " - + Integer.toString(recipeLookupResult.getRecipeTimeout())); - } else { - msoLogger.debug("No matching recipe record found"); - } - return recipeLookupResult; - } - - /** - * Getting recipes from catalogDb - * - * @param db - * @param action - * @return - */ - private RecipeLookupResult getServiceURI(CatalogDatabase db, Action action) { - - String defaultServiceModelName = "UUI_DEFAULT"; - - Service serviceRecord = db - .getServiceByModelName(defaultServiceModelName); - ServiceRecipe recipe = db.getServiceRecipeByModelUUID( - serviceRecord.getModelUUID(), action.name()); - - if (recipe == null) { - return null; - } - return new RecipeLookupResult(recipe.getOrchestrationUri(), - recipe.getRecipeTimeout()); - - } - - /** - * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and - * passing it to camunda engine. - * - * @param e2eSir - * @return - */ - private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, - String requestJSON) { - - sir = new ServiceInstancesRequest(); - - String returnString = null; - RequestDetails requestDetails = new RequestDetails(); - ModelInfo modelInfo = new ModelInfo(); - - // ModelInvariantId - modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId()); - - // modelNameVersionId - modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId()); - - // String modelInfoValue = - // e2eSir.getService().getParameters().getNodeTemplateName(); - // String[] arrayOfInfo = modelInfoValue.split(":"); - // String modelName = arrayOfInfo[0]; - // String modelVersion = arrayOfInfo[1]; - - // TODO: To ensure, if we dont get the values from the UUI - String modelName = "voLTE"; - String modelVersion = "1.0"; - // modelName - modelInfo.setModelName(modelName); - - // modelVersion - modelInfo.setModelVersion(modelVersion); - - // modelType - modelInfo.setModelType(ModelType.service); - - // setting modelInfo to requestDetails - requestDetails.setModelInfo(modelInfo); - - SubscriberInfo subscriberInfo = new SubscriberInfo(); - - // globalsubscriberId - subscriberInfo.setGlobalSubscriberId(e2eSir.getService() - .getParameters().getGlobalSubscriberId()); - - // subscriberName - subscriberInfo.setSubscriberName(e2eSir.getService().getParameters() - .getSubscriberName()); - - // setting subscriberInfo to requestDetails - requestDetails.setSubscriberInfo(subscriberInfo); - - RequestInfo requestInfo = new RequestInfo(); - - // instanceName - requestInfo.setInstanceName(e2eSir.getService().getName()); - - // source - requestInfo.setSource("UUI"); - - // suppressRollback - requestInfo.setSuppressRollback(true); - - // setting requestInfo to requestDetails - requestDetails.setRequestInfo(requestInfo); - - RequestParameters requestParameters = new RequestParameters(); - - // subscriptionServiceType - requestParameters.setSubscriptionServiceType("MOG"); - - // Userparams - List<E2EUserParam> userParams; - // userParams = - // e2eSir.getService().getParameters().getRequestParameters().getUserParams(); - List<Map<String, String>> userParamList = new ArrayList<>(); - Map<String, String> userParamMap = new HashMap<>(); - // complete json request updated in the camunda - userParamMap.put("UUIRequest", requestJSON); - userParamMap.put("ServiceInstanceName", e2eSir.getService().getName()); - - // Map<String, String> userParamMap3 = null; - // for (E2EUserParam userp : userParams) { - // userParamMap.put(userp.getName(), userp.getValue()); - // - // } - userParamList.add(userParamMap); - requestParameters.setUserParams(userParamList); - - // setting requestParameters to requestDetails - requestDetails.setRequestParameters(requestParameters); - - sir.setRequestDetails(requestDetails); - - // converting to string - ObjectMapper mapper = new ObjectMapper(); - try { - returnString = mapper.writeValueAsString(sir); - } catch (IOException e) { - msoLogger - .debug("Exception while converting ServiceInstancesRequest object to string", - e); - } - - return returnString; - } - - private void createOperationStatusRecordForError(Action action, - String requestId) throws MsoDatabaseException { - - AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager(); - - Session session = null; - try { - - session = requestsDbSessionFactoryManager.getSessionFactory() - .openSession(); - session.beginTransaction(); - - OperationStatus os = new OperationStatus(); - os.setOperation(action.name()); - os.setOperationContent(""); - os.setOperationId(""); - os.setProgress("100"); - os.setReason(""); - os.setResult("error"); - os.setServiceId(requestId); - os.setUserId(""); - Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); - Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); - os.setFinishedAt(endTimeStamp); - os.setOperateAt(startTimeStamp); - - session.save(os); - session.getTransaction().commit(); - - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "", - MsoLogger.ErrorCode.DataError, - "Exception when creation record request in Operation", e); - throw new MsoDatabaseException( - "Data did inserted in Operatus Status Table for failure", e); - } finally { - if (null != session) { - session.close(); - } - } - } - - private void createOperationStatusRecord(String actionNm, String serviceId, - String operationId) throws MsoDatabaseException { - - AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager(); - - Session session = null; - try { - - session = requestsDbSessionFactoryManager.getSessionFactory() - .openSession(); - session.beginTransaction(); - - OperationStatus os = new OperationStatus(); - os.setOperation(actionNm); - os.setOperationContent(""); - os.setOperationId(operationId); - os.setProgress("0"); - os.setReason(""); - os.setResult("processing"); - os.setServiceId(serviceId); - // TODO : to be updated... - os.setUserId(""); - Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); - Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); - os.setFinishedAt(endTimeStamp); - os.setOperateAt(startTimeStamp); - - session.save(os); - session.getTransaction().commit(); - - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "", - MsoLogger.ErrorCode.DataError, - "Exception when creation record request in Operation", e); - throw new MsoDatabaseException( - "Data did inserted in Operatus Status Table", e); - } finally { - if (null != session) { - session.close(); - } - } - } - - private OperationStatus chkDuplicateServiceInOperStatus(String serviceId) { - OperationStatus dupServiceName = (RequestsDatabase.getInstance()) - .getOperationStatusByServiceId(serviceId); - - return dupServiceName; - } - - private OperationStatus chkDuplicateServiceNameInOperStatus( - String serviceName) { - OperationStatus dupServiceName = (RequestsDatabase.getInstance()) - .getOperationStatusByServiceName(serviceName); - - return dupServiceName; - } +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.apihandlerinfra;
+
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.hibernate.Session;
+import org.json.JSONObject;
+import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ResponseHandler;
+import org.openecomp.mso.apihandlerinfra.Messages;
+import org.openecomp.mso.apihandlerinfra.MsoException;
+import org.openecomp.mso.apihandlerinfra.MsoRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.DelE2ESvcResp;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoDatabaseException;
+import org.openecomp.mso.requestsdb.OperationStatus;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/e2eServiceInstances")
+@Api(value = "/e2eServiceInstances", description = "API Requests for E2E Service Instances")
+public class E2EServiceInstances {
+
+ private HashMap<String, String> instanceIdMap = new HashMap<>();
+ private static MsoLogger msoLogger = MsoLogger
+ .getMsoLogger(MsoLogger.Catalog.APIH);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ private ServiceInstancesRequest sir = null;
+
+ public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
+ public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
+ public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
+
+ /**
+ * POST Requests for E2E Service create Instance on a version provided
+ */
+
+ @POST
+ @Path("/{version:[vV][3-5]}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Create an E2E Service Instance on a version provided", response = Response.class)
+ public Response createE2EServiceInstance(String request,
+ @PathParam("version") String version) {
+
+ return processE2EserviceInstances(request, Action.createInstance, null,
+ version);
+ }
+
+ /**
+ * PUT Requests for E2E Service update Instance on a version provided
+ */
+
+ @PUT
+ @Path("/{version:[vV][3-5]}/{serviceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Update an E2E Service Instance on a version provided and serviceId", response = Response.class)
+ public Response updateE2EServiceInstance(String request,
+ @PathParam("version") String version,
+ @PathParam("serviceId") String serviceId) {
+
+ instanceIdMap.put("serviceId", serviceId);
+
+ return updateE2EserviceInstances(request, Action.updateInstance, instanceIdMap,
+ version);
+ }
+
+ /**
+ * DELETE Requests for E2E Service delete Instance on a specified version
+ * and serviceId
+ */
+
+ @DELETE
+ @Path("/{version:[vV][3-5]}/{serviceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
+ public Response deleteE2EServiceInstance(String request,
+ @PathParam("version") String version,
+ @PathParam("serviceId") String serviceId) {
+
+ instanceIdMap.put("serviceId", serviceId);
+
+ return deleteE2EserviceInstances(request, Action.deleteInstance,
+ instanceIdMap, version);
+ }
+
+ @GET
+ @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}")
+ @ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", response = Response.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getE2EServiceInstances(
+ @PathParam("serviceId") String serviceId,
+ @PathParam("version") String version,
+ @PathParam("operationId") String operationId) {
+ return getE2EServiceInstances(serviceId, operationId);
+ }
+
+ private Response getE2EServiceInstances(String serviceId, String operationId) {
+ RequestsDatabase requestsDB = RequestsDatabase.getInstance();
+
+ GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse();
+
+ MsoRequest msoRequest = new MsoRequest(serviceId);
+
+ long startTime = System.currentTimeMillis();
+
+ OperationStatus operationStatus = null;
+
+ try {
+ operationStatus = requestsDB.getOperationStatus(serviceId,
+ operationId);
+
+ } catch (Exception e) {
+ msoLogger
+ .error(MessageEnum.APIH_DB_ACCESS_EXC,
+ MSO_PROP_APIHANDLER_INFRA,
+ "",
+ "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Request DB - Infra Request Lookup",
+ e);
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ e.getMessage(),
+ ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL, Messages.errors
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with Request DB");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) response.getEntity());
+ return response;
+
+ }
+
+ if (operationStatus == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NO_CONTENT, MsoException.ServiceException,
+ "E2E serviceId " + serviceId + " is not found in DB",
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Null response from RequestDB when searching by serviceId");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DataNotFound,
+ "Null response from RequestDB when searching by serviceId");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) resp.getEntity());
+ return resp;
+
+ }
+
+ e2eServiceResponse.setOperationStatus(operationStatus);
+
+ return Response.status(200).entity(e2eServiceResponse).build();
+ }
+
+ private Response deleteE2EserviceInstances(String requestJSON,
+ Action action, HashMap<String, String> instanceIdMap, String version) {
+ // TODO should be a new one or the same service instance Id
+ String requestId = instanceIdMap.get("serviceId");
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceDeleteRequest e2eDelReq = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eDelReq = mapper.readValue(requestJSON,
+ E2EServiceInstanceDeleteRequest.class);
+
+ } catch (Exception e) {
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException,
+ "Mapping of request to JSON object failed. "
+ + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
+ null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ //TODO Get the service template model version uuid from AAI.
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, null, action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Catalog DB", e);
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL, Messages.errors
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(
+ recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ JSONObject jjo = new JSONObject(requestJSON);
+ jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
+
+ String bpmnRequest = jjo.toString();
+
+ // Capture audit event
+ msoLogger
+ .debug("MSO API Handler Posting call to BPEL engine for url: "
+ + requestClient.getUrl());
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eDelReq.getServiceType();
+ response = requestClient.post(requestId, false,
+ recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType,
+ null, null, null, bpmnRequest, recipeLookupResult.getRecipeParamXsd());
+
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ if (response == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "bpelResponse is null",
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response,
+ requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest,
+ requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ }
+
+ private Response updateE2EserviceInstances(String requestJSON, Action action,
+ HashMap<String, String> instanceIdMap, String version) {
+
+ String requestId = instanceIdMap.get("serviceId");
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceRequest e2eSir = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
+
+ } catch (Exception e) {
+
+ this.createOperationStatusRecordForError(action, requestId);
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version);
+ } catch (Exception e) {
+ msoLogger.debug("Validation failed: ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ if (msoRequest.getRequestId() != null) {
+ msoLogger.debug("Logging failed message to the database");
+ this.createOperationStatusRecordForError(action, requestId);
+ }
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Validation of the input request failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ //check for the current operation status
+ Response resp = checkE2ESvcInstStatus(action, requestId, startTime, msoRequest);
+ if(resp != null && resp.getStatus() != 200) {
+ return resp;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, e2eSir.getService().getTemplateId(), action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ String serviceInstanceType = e2eSir.getService().getParameters().getServiceType();
+
+ String serviceId = "";
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ // Capture audit event
+ msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+
+ response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson, recipeLookupResult.getRecipeParamXsd());
+
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
+ null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) getBPMNResp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return getBPMNResp;
+ }
+
+ if (response == null) {
+ Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) getBPMNResp.getEntity());
+ return getBPMNResp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ }
+
+ private Response checkE2ESvcInstStatus(Action action, String requestId, long startTime, MsoRequest msoRequest) {
+ OperationStatus curStatus = null;
+// String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ try {
+ if (!(requestId == null && "service".equals(requestScope) && (action == Action.updateInstance))) {
+ curStatus = chkSvcInstOperStatusbySvcId(requestId);
+ }
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "Error during current operation status check ", e);
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ MsoException.ServiceException, e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Error during current operation status check");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ if (curStatus != null && !curStatus.getProgress().equals("100")) {
+ String chkMessage = "Error: Locked instance - This " + requestScope + " (" + requestId + ") "
+ + "now being worked with a status of " + curStatus.getProgress() + " (ServiceName - "
+ + curStatus.getServiceName()
+ + "). The existing request must finish or be cleaned up before proceeding.";
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
+ MsoException.ServiceException, chkMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ chkMessage);
+
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+
+ createOperationStatusRecordForError(action, requestId);
+
+ return response;
+ }
+
+ return Response.status(200).entity(null).build();
+ }
+
+ private Response processE2EserviceInstances(String requestJSON, Action action,
+ HashMap<String, String> instanceIdMap, String version) {
+
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceRequest e2eSir = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
+
+ } catch (Exception e) {
+ //TODO update the service name
+ this.createOperationStatusRecordForError(action, requestId);
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version);
+ } catch (Exception e) {
+ msoLogger.debug("Validation failed: ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ if (msoRequest.getRequestId() != null) {
+ msoLogger.debug("Logging failed message to the database");
+ //TODO update the service name
+ this.createOperationStatusRecordForError(action, requestId);
+ }
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Validation of the input request failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ OperationStatus dup = null;
+ String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ try {
+ if (!(instanceName == null && "service".equals(requestScope)
+ && (action == Action.createInstance || action == Action.activateInstance))) {
+ //TODO : Need to check for the duplicate record from the operation status,
+ //TODO : commenting this check for unblocking current testing for now... induces dead code...
+ dup = chkDuplicateServiceNameInOperStatus( instanceName);
+ }
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ MsoException.ServiceException, e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Error during duplicate check");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ if (dup != null) {
+ // Found the duplicate record. Return the appropriate error.
+ String instance = null;
+ if (instanceName != null) {
+ instance = instanceName;
+ } else {
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
+ + "already has a request being worked with a status of " + dup.getProgress() + " (ServiceId - "
+ + dup.getServiceId() + "). The existing request must finish or be cleaned up before proceeding.";
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
+ MsoException.ServiceException, dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
+ "Duplicate request - Subscriber already has a request for this service");
+
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ dupMessage);
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, e2eSir.getService().getTemplateId(), action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+// try {
+// msoRequest.createRequestRecord(Status.PENDING, action);
+// //createOperationStatusRecord(action, requestId);
+// } catch (Exception e) {
+// msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "",
+// MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
+// msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+// Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+// MsoException.ServiceException, "Exception while creating record in DB " + e.getMessage(),
+// ErrorNumbers.SVC_BAD_PARAMETER, null);
+// msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+// "Exception while creating record in DB");
+// msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+// return response;
+// }
+
+ String serviceInstanceType = e2eSir.getService().getParameters().getServiceType();
+
+ String serviceId = "";
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ // Capture audit event
+ msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+
+ response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson, recipeLookupResult.getRecipeParamXsd());
+
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
+ null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ if (response == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ }
+
+ private void closeCatalogDB(CatalogDatabase db) {
+ if (db != null) {
+ db.close();
+ }
+ }
+
+ private Response beplStatusUpdate(String requestId, long startTime,
+ MsoRequest msoRequest, RequestClient requestClient,
+ ResponseHandler respHandler, int bpelStatus, Action action,
+ HashMap<String, String> instanceIdMap) {
+ // BPMN accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ String camundaJSONResponseBody = respHandler.getResponseBody();
+ msoLogger
+ .debug("Received from Camunda: " + camundaJSONResponseBody);
+
+ // currently only for delete case we update the status here
+ if (action == Action.deleteInstance) {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ DelE2ESvcResp jo = mapper.readValue(
+ camundaJSONResponseBody, DelE2ESvcResp.class);
+ String operationId = jo.getOperationId();
+ this.createOperationStatusRecord("DELETE", requestId,
+ operationId);
+ } catch (Exception ex) {
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Response from BPEL engine is failed with HTTP Status="
+ + bpelStatus);
+ }
+ }
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "BPMN accepted the request, the request is in progress");
+ msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
+ return Response.status(HttpStatus.SC_ACCEPTED)
+ .entity(camundaJSONResponseBody).build();
+ } else {
+ List<String> variables = new ArrayList<>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody();
+ if (camundaJSONResponseBody != null
+ && !camundaJSONResponseBody.isEmpty()) {
+ Response resp = msoRequest.buildServiceErrorResponse(
+ bpelStatus, MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1 "
+ + '\n' + camundaJSONResponseBody,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Response from BPEL engine is failed with HTTP Status="
+ + bpelStatus);
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
+ "Response from BPMN engine is failed");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) resp.getEntity());
+ return resp;
+ } else {
+ Response resp = msoRequest
+ .buildServiceErrorResponse(
+ bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1",
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ variables);
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Response from BPEL engine is empty");
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
+ "Response from BPEL engine is empty");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) resp.getEntity());
+ return resp;
+ }
+ }
+ }
+
+ /**
+ * Getting recipes from catalogDb
+ *
+ * @param db the catalog db
+ * @param serviceModelUUID the service model version uuid
+ * @param action the action for the service
+ * @return the service recipe result
+ */
+ private RecipeLookupResult getServiceInstanceOrchestrationURI(
+ CatalogDatabase db, String serviceModelUUID, Action action) {
+
+ RecipeLookupResult recipeLookupResult = getServiceURI(db, serviceModelUUID, action);
+
+ if (recipeLookupResult != null) {
+ msoLogger.debug("Orchestration URI is: "
+ + recipeLookupResult.getOrchestrationURI()
+ + ", recipe Timeout is: "
+ + Integer.toString(recipeLookupResult.getRecipeTimeout()));
+ } else {
+ msoLogger.debug("No matching recipe record found");
+ }
+ return recipeLookupResult;
+ }
+
+ /**
+ * Getting recipes from catalogDb
+ * If Service recipe is not set, use default recipe, if set , use special recipe.
+ * @param db the catalog db
+ * @param serviceModelUUID the service version uuid
+ * @param action the action of the service.
+ * @return the service recipe result.
+ */
+ private RecipeLookupResult getServiceURI(CatalogDatabase db, String serviceModelUUID, Action action) {
+
+ String defaultServiceModelName = "UUI_DEFAULT";
+
+ Service defaultServiceRecord = db
+ .getServiceByModelName(defaultServiceModelName);
+ ServiceRecipe defaultRecipe = db.getServiceRecipeByModelUUID(
+ defaultServiceRecord.getModelUUID(), action.name());
+ //set recipe as default generic recipe
+ ServiceRecipe recipe = defaultRecipe;
+ //check the service special recipe
+ if(null != serviceModelUUID && ! serviceModelUUID.isEmpty()){
+ ServiceRecipe serviceSpecialRecipe = db.getServiceRecipeByModelUUID(
+ serviceModelUUID, action.name());
+ if(null != serviceSpecialRecipe){
+ //set service special recipe.
+ recipe = serviceSpecialRecipe;
+ }
+ }
+
+ if (recipe == null) {
+ return null;
+ }
+ return new RecipeLookupResult(recipe.getOrchestrationUri(),
+ recipe.getRecipeTimeout(), recipe.getServiceParamXSD());
+
+ }
+
+ /**
+ * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and
+ * passing it to camunda engine.
+ *
+ * @param e2eSir
+ * @return
+ */
+ private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir,
+ String requestJSON) {
+
+ sir = new ServiceInstancesRequest();
+
+ String returnString = null;
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+
+ // ModelInvariantId
+ modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId());
+
+ // modelNameVersionId
+ modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
+
+ // String modelInfoValue =
+ // e2eSir.getService().getParameters().getNodeTemplateName();
+ // String[] arrayOfInfo = modelInfoValue.split(":");
+ // String modelName = arrayOfInfo[0];
+ // String modelVersion = arrayOfInfo[1];
+
+ // TODO: To ensure, if we dont get the values from the UUI
+ String modelName = "voLTE";
+ String modelVersion = "1.0";
+ // modelName
+ modelInfo.setModelName(modelName);
+
+ // modelVersion
+ modelInfo.setModelVersion(modelVersion);
+
+ // modelType
+ modelInfo.setModelType(ModelType.service);
+
+ // setting modelInfo to requestDetails
+ requestDetails.setModelInfo(modelInfo);
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+
+ // globalsubscriberId
+ subscriberInfo.setGlobalSubscriberId(e2eSir.getService()
+ .getParameters().getGlobalSubscriberId());
+
+ // subscriberName
+ subscriberInfo.setSubscriberName(e2eSir.getService().getParameters()
+ .getSubscriberName());
+
+ // setting subscriberInfo to requestDetails
+ requestDetails.setSubscriberInfo(subscriberInfo);
+
+ RequestInfo requestInfo = new RequestInfo();
+
+ // instanceName
+ requestInfo.setInstanceName(e2eSir.getService().getName());
+
+ // source
+ requestInfo.setSource("UUI");
+
+ // suppressRollback
+ requestInfo.setSuppressRollback(true);
+
+ // setting requestInfo to requestDetails
+ requestDetails.setRequestInfo(requestInfo);
+
+ RequestParameters requestParameters = new RequestParameters();
+
+ // subscriptionServiceType
+ requestParameters.setSubscriptionServiceType("MOG");
+
+ // Userparams
+ List<E2EUserParam> userParams;
+ // userParams =
+ // e2eSir.getService().getParameters().getRequestParameters().getUserParams();
+ List<Map<String, String>> userParamList = new ArrayList<>();
+ Map<String, String> userParamMap = new HashMap<>();
+ // complete json request updated in the camunda
+ userParamMap.put("UUIRequest", requestJSON);
+ userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
+
+ // Map<String, String> userParamMap3 = null;
+ // for (E2EUserParam userp : userParams) {
+ // userParamMap.put(userp.getName(), userp.getValue());
+ //
+ // }
+ userParamList.add(userParamMap);
+ requestParameters.setUserParams(userParamList);
+
+ // setting requestParameters to requestDetails
+ requestDetails.setRequestParameters(requestParameters);
+
+ sir.setRequestDetails(requestDetails);
+
+ // converting to string
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ returnString = mapper.writeValueAsString(sir);
+ } catch (IOException e) {
+ msoLogger
+ .debug("Exception while converting ServiceInstancesRequest object to string",
+ e);
+ }
+
+ return returnString;
+ }
+
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory()
+ .openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(action.name());
+ os.setOperationContent("");
+ os.setOperationId("");
+ os.setProgress("100");
+ os.setReason("");
+ os.setResult("error");
+ os.setServiceId(requestId);
+ os.setUserId("");
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ os.setFinishedAt(endTimeStamp);
+ os.setOperateAt(startTimeStamp);
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Exception when creation record request in Operation", e);
+ throw new MsoDatabaseException(
+ "Data did inserted in Operatus Status Table for failure", e);
+ } finally {
+ if (null != session) {
+ session.close();
+ }
+ }
+ }
+
+ private void createOperationStatusRecord(String actionNm, String serviceId,
+ String operationId) throws MsoDatabaseException {
+
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory()
+ .openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(actionNm);
+ os.setOperationContent("");
+ os.setOperationId(operationId);
+ os.setProgress("0");
+ os.setReason("");
+ os.setResult("processing");
+ os.setServiceId(serviceId);
+ // TODO : to be updated...
+ os.setUserId("");
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ os.setFinishedAt(endTimeStamp);
+ os.setOperateAt(startTimeStamp);
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Exception when creation record request in Operation", e);
+ throw new MsoDatabaseException(
+ "Data did inserted in Operatus Status Table", e);
+ } finally {
+ if (null != session) {
+ session.close();
+ }
+ }
+ }
+
+ private OperationStatus chkSvcInstOperStatusbySvcId(String serviceId) {
+ OperationStatus svcInstanceOperStatus = (RequestsDatabase.getInstance())
+ .getOperationStatusByServiceId(serviceId);
+
+ return svcInstanceOperStatus;
+ }
+
+ private OperationStatus chkDuplicateServiceNameInOperStatus(
+ String serviceName) {
+ OperationStatus dupServiceName = (RequestsDatabase.getInstance())
+ .getOperationStatusByServiceName(serviceName);
+
+ return dupServiceName;
+ }
}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java index 27c3c2b283..79ac76ff04 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java @@ -252,15 +252,12 @@ public class MsoRequest { } RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters(); - if(this.reqVersion >= 3){ - if(requestParameters!=null){ - this.aLaCarteFlag = sir.getRequestDetails().getRequestParameters().isaLaCarte(); - }else{ - this.aLaCarteFlag = false; - } - }else{ - this.aLaCarteFlag = true; - } + if (this.reqVersion >= 3) { + this.aLaCarteFlag = + requestParameters != null && sir.getRequestDetails().getRequestParameters().isaLaCarte(); + } else { + this.aLaCarteFlag = true; + } if(requestParameters != null && (reqVersion < 3) && requestParameters.getAutoBuildVfModules()){ throw new ValidationException("AutoBuildVfModule", version); @@ -741,7 +738,7 @@ public class MsoRequest { if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (this.errorMessage); aq.setResponseBody (this.responseBody); - aq.setProgress(new Long(100)); + aq.setProgress(100L); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java index bcea8fd8d5..2c7bd1cc36 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java @@ -130,33 +130,35 @@ public class NetworkInfoHandler { if (ar.getVnfType () != null) { vi.setNetworkType (ar.getVnfType ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + + break; } if (ar.getTenantId () != null) { @@ -295,8 +297,8 @@ public class NetworkInfoHandler { private String translateNetworkRequests (List <NetworkRequest> queryResponseList) { NetworkRequests queryResponses = new NetworkRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getNetworkRequest ().add (queryResponseList.get (i)); + for (NetworkRequest aQueryResponseList : queryResponseList) { + queryResponses.getNetworkRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java index c87b4f387d..3d419926f1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java @@ -147,24 +147,27 @@ public class NetworkMsoInfraRequest { } // Verify that the elements correspond to the version - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException ("format for v1 version of network request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException ("format for v2 version of network request"); - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null + || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v1 version of network request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v2 version of network request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of network request"); + } + break; } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of network request"); - } - } switch (action) { case UPDATE: diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java index 981fee9fb6..6a770202fa 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java @@ -158,33 +158,35 @@ public class NetworkRequestHandler { if (ar.getVnfType () != null) { vi.setNetworkType (ar.getVnfType ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + + break; } if (ar.getTenantId () != null) { @@ -323,8 +325,8 @@ public class NetworkRequestHandler { private String translateNetworkRequests (List <NetworkRequest> queryResponseList) { NetworkRequests queryResponses = new NetworkRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getNetworkRequest ().add (queryResponseList.get (i)); + for (NetworkRequest aQueryResponseList : queryResponseList) { + queryResponses.getNetworkRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java index b01c6d6e2a..43f2d2afbb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java @@ -78,13 +78,13 @@ public class NetworkTypesHandler { ObjectFactory beansObjectFactory = new ObjectFactory (); NetworkTypes networkTypes = beansObjectFactory.createNetworkTypes (); - for (int i = 0; i < networkResources.size (); i++) { - NetworkType networkType = beansObjectFactory.createNetworkType (); - NetworkResource vr = networkResources.get (i); - networkType.setType (vr.getModelName()); - networkType.setDescription (vr.getDescription ()); - networkType.setId (String.valueOf (vr.getModelUUID())); - networkTypes.getNetworkType ().add (networkType); + for (NetworkResource networkResource : networkResources) { + NetworkType networkType = beansObjectFactory.createNetworkType(); + NetworkResource vr = networkResource; + networkType.setType(vr.getModelName()); + networkType.setDescription(vr.getDescription()); + networkType.setId(String.valueOf(vr.getModelUUID())); + networkTypes.getNetworkType().add(networkType); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java index ac4c01175a..2a02344ab3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java @@ -25,12 +25,20 @@ public class RecipeLookupResult { private String orchestrationURI; private int recipeTimeout; + // the service recipe param. + private String recipeParamXsd; public RecipeLookupResult(String orchestrationURI, int recipeTimeout) { this.orchestrationURI = orchestrationURI; this.recipeTimeout = recipeTimeout; } + public RecipeLookupResult(String orchestrationURI, int recipeTimeout, String recipeParamXsd) { + this.orchestrationURI = orchestrationURI; + this.recipeTimeout = recipeTimeout; + this.recipeParamXsd = recipeParamXsd; + } + public String getOrchestrationURI () { return orchestrationURI; } @@ -46,5 +54,23 @@ public class RecipeLookupResult { public void setRecipeTimeout (int recipeTimeout) { this.recipeTimeout = recipeTimeout; } + + + /** + * @return Returns the recipeParamXsd. + */ + public String getRecipeParamXsd() { + return recipeParamXsd; + } + + + /** + * @param recipeParamXsd The recipeParamXsd to set. + */ + public void setRecipeParamXsd(String recipeParamXsd) { + this.recipeParamXsd = recipeParamXsd; + } + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index 6f6d2972d1..287b0ad812 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -633,7 +633,7 @@ public class ServiceInstances { serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, msoRequest.getServiceInstanceType (), msoRequest.getVnfType (), msoRequest.getVfModuleType (), - msoRequest.getNetworkType (), msoRequest.getRequestJSON()); + msoRequest.getNetworkType (), msoRequest.getRequestJSON(), null); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null); } catch (Exception e) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java index 57720dcfba..df51a8f96a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java @@ -74,17 +74,17 @@ public class VfModuleModelNamesHandler { ObjectFactory beansObjectFactory = new ObjectFactory (); VfModuleModelNames vfModuleModelNames = beansObjectFactory.createVfModuleModelNames (); - for (int i = 0; i < vfModules.size (); i++) { - VfModuleModelName vfModuleModelName = beansObjectFactory.createVfModuleModelName (); - VfModule vm = vfModules.get (i); - vfModuleModelName.setModelName (vm.getModelName ()); - vfModuleModelName.setModelVersion (vm.getVersion ()); - vfModuleModelName.setModelInvariantUuid (vm.getModelInvariantUuid ()); + for (VfModule vfModule : vfModules) { + VfModuleModelName vfModuleModelName = beansObjectFactory.createVfModuleModelName(); + VfModule vm = vfModule; + vfModuleModelName.setModelName(vm.getModelName()); + vfModuleModelName.setModelVersion(vm.getVersion()); + vfModuleModelName.setModelInvariantUuid(vm.getModelInvariantUuid()); vfModuleModelName.setIsBase(vm.isBase()); - vfModuleModelName.setDescription (vm.getDescription ()); - vfModuleModelName.setId (String.valueOf (vm.getModelUUID())); - vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion ()); - vfModuleModelNames.getVfModuleModelName ().add (vfModuleModelName); + vfModuleModelName.setDescription(vm.getDescription()); + vfModuleModelName.setId(String.valueOf(vm.getModelUUID())); + vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion()); + vfModuleModelNames.getVfModuleModelName().add(vfModuleModelName); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java index 7071ed50c3..d13212a483 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java @@ -148,50 +148,52 @@ public class VnfInfoHandler { if (ar.getVolumeGroupId () != null) { vi.setVolumeGroupId (ar.getVolumeGroupId ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + break; } qr.setVnfInputs (vi); @@ -332,8 +334,8 @@ public class VnfInfoHandler { private String translateVnfRequests (List <VnfRequest> queryResponseList) { VnfRequests queryResponses = new VnfRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getVnfRequest ().add (queryResponseList.get (i)); + for (VnfRequest aQueryResponseList : queryResponseList) { + queryResponses.getVnfRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java index 80d0c48a5e..1f3008aa1a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java @@ -157,26 +157,29 @@ public class VnfMsoInfraRequest { throw new ValidationException ("format for vnf request"); } // Verify that the elements correspond to the version - - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.vnfInputs.getVfModuleName () != null || this.vnfInputs.getVfModuleId () != null || - this.vnfInputs.getVfModuleModelName () != null || this.vnfInputs.getAsdcServiceModelVersion () != null || - this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || - this.vnfInputs.getServiceInstanceId () != null) { - throw new ValidationException ("format for v1 version of vnf request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null || this.vnfInputs.getServiceInstanceId () != null) { - throw new ValidationException ("format for v2 version of vnf request"); - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.vnfInputs.getVfModuleName() != null || this.vnfInputs.getVfModuleId() != null || + this.vnfInputs.getVfModuleModelName() != null || this.vnfInputs.getAsdcServiceModelVersion() != null + || + this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || + this.vnfInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v1 version of vnf request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null + || this.vnfInputs.getServiceInstanceId() != null) { + throw new ValidationException("format for v2 version of vnf request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of vnf request"); + } + break; } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of vnf request"); - } - } if (!InfraUtils.isActionAllowed (props, "vnf", version, action.value ())) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java index a61ca5fb30..098ed31b58 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java @@ -179,50 +179,52 @@ public class VnfRequestHandler { if (ar.getVolumeGroupId () != null) { vi.setVolumeGroupId (ar.getVolumeGroupId ()); } - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleName () != null) { - vi.setVfModuleName (ar.getVfModuleName ()); - } - if (ar.getVfModuleId () != null) { - vi.setVfModuleId (ar.getVfModuleId ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleName() != null) { + vi.setVfModuleName(ar.getVfModuleName()); + } + if (ar.getVfModuleId() != null) { + vi.setVfModuleId(ar.getVfModuleId()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + break; } qr.setVnfInputs (vi); @@ -307,7 +309,7 @@ public class VnfRequestHandler { queryValue, getRequestType ()); - List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + List <VnfRequest> queryResponseList = new LinkedList<>(); if (activeReqList != null) { // build response for active @@ -351,7 +353,7 @@ public class VnfRequestHandler { } private List <VnfRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { - List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + List <VnfRequest> queryResponseList = new LinkedList<>(); for (InfraRequests ar : arList) { VnfRequest qr = fillGeneric (ar); @@ -363,8 +365,8 @@ public class VnfRequestHandler { private String translateVnfRequests (List <VnfRequest> queryResponseList) { VnfRequests queryResponses = new VnfRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getVnfRequest ().add (queryResponseList.get (i)); + for (VnfRequest aQueryResponseList : queryResponseList) { + queryResponses.getVnfRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); @@ -711,12 +713,12 @@ public class VnfRequestHandler { requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); // Capture audit event msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()).toString (), - version, - null, - null); + response = requestClient.post(msoRequest.getRequestXML(), + requestId, + Integer.toString(recipe.getRecipeTimeout()), + version, + null, + null); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); } catch (Exception e) { msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java index 44cf038ef8..3d87d131b3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java @@ -85,12 +85,12 @@ public class VnfTypesHandler { ObjectFactory beansObjectFactory = new ObjectFactory (); VnfTypes vnfTypes = beansObjectFactory.createVnfTypes (); - for (int i = 0; i < vnfResources.size (); i++) { - VnfType vnfType = beansObjectFactory.createVnfType (); - VnfResource vr = vnfResources.get (i); - vnfType.setDescription (vr.getDescription ()); - vnfType.setId (String.valueOf (vr.getModelUuid())); - vnfTypes.getVnfType ().add (vnfType); + for (VnfResource vnfResource : vnfResources) { + VnfType vnfType = beansObjectFactory.createVnfType(); + VnfResource vr = vnfResource; + vnfType.setDescription(vr.getDescription()); + vnfType.setId(String.valueOf(vr.getModelUuid())); + vnfTypes.getVnfType().add(vnfType); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java index 6618fcfb00..c74bb0734d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java @@ -134,43 +134,45 @@ public class VolumeInfoHandler { if (ar.getVnfType () != null) { vi.setVnfType (ar.getVnfType ()); } - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + if (ar.getVnfId() != null) { + vi.setVnfId(ar.getVnfId()); + } + break; + } if (ar.getTenantId () != null) { vi.setTenantId (ar.getTenantId ()); } @@ -314,8 +316,8 @@ public class VolumeInfoHandler { private String translateVolumeRequests (List <VolumeRequest> queryResponseList) { VolumeRequests queryResponses = new VolumeRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getVolumeRequest ().add (queryResponseList.get (i)); + for (VolumeRequest aQueryResponseList : queryResponseList) { + queryResponses.getVolumeRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java index 0524a85bf3..f908a3f0d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java @@ -144,24 +144,27 @@ public class VolumeMsoInfraRequest { // Verify that the elements correspond to the version - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || - this.volumeInputs.getVfModuleModelName () != null || this.volumeInputs.getAsdcServiceModelVersion () != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v1 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v2 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of volume request"); - } - } + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || + this.volumeInputs.getVfModuleModelName() != null + || this.volumeInputs.getAsdcServiceModelVersion() != null || + this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { + throw new ValidationException("format for v1 version of volume request"); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || + this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { + throw new ValidationException("format for v2 version of volume request"); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { + throw new ValidationException("format for v3 version of volume request"); + } + break; + } if (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java index 9a8bf35e5c..e3af83df92 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java @@ -166,43 +166,45 @@ public class VolumeRequestHandler { if (ar.getVnfType () != null) { vi.setVnfType (ar.getVnfType ()); } - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (ar.getServiceType () != null) { - vi.setServiceType (ar.getServiceType ()); - } - if (ar.getAicNodeClli () != null) { - vi.setAicNodeClli (ar.getAicNodeClli ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (ar.getAaiServiceId () != null) { - vi.setServiceId (ar.getAaiServiceId ()); - } - if (ar.getAicCloudRegion () != null) { - vi.setAicCloudRegion (ar.getAicCloudRegion ()); - } - if (ar.getVfModuleModelName () != null) { - vi.setVfModuleModelName (ar.getVfModuleModelName ()); - } - if (ar.getServiceInstanceId () != null) { - vi.setServiceInstanceId (ar.getServiceInstanceId ()); - } - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - } + + switch (version) { + case Constants.SCHEMA_VERSION_V1: + if (ar.getServiceType() != null) { + vi.setServiceType(ar.getServiceType()); + } + if (ar.getAicNodeClli() != null) { + vi.setAicNodeClli(ar.getAicNodeClli()); + } + break; + case Constants.SCHEMA_VERSION_V2: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + break; + case Constants.SCHEMA_VERSION_V3: + if (ar.getAaiServiceId() != null) { + vi.setServiceId(ar.getAaiServiceId()); + } + if (ar.getAicCloudRegion() != null) { + vi.setAicCloudRegion(ar.getAicCloudRegion()); + } + if (ar.getVfModuleModelName() != null) { + vi.setVfModuleModelName(ar.getVfModuleModelName()); + } + if (ar.getServiceInstanceId() != null) { + vi.setServiceInstanceId(ar.getServiceInstanceId()); + } + if (ar.getVnfId() != null) { + vi.setVnfId(ar.getVnfId()); + } + break; + } if (ar.getTenantId () != null) { vi.setTenantId (ar.getTenantId ()); } @@ -289,7 +291,7 @@ public class VolumeRequestHandler { queryValue, "VOLUME"); - List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + List <VolumeRequest> queryResponseList = new LinkedList<>(); if (activeReqList != null) { // build response for active @@ -334,7 +336,7 @@ public class VolumeRequestHandler { } private List <VolumeRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { - List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + List <VolumeRequest> queryResponseList = new LinkedList<>(); for (InfraRequests ar : arList) { VolumeRequest qr = fillGeneric (ar); @@ -346,8 +348,8 @@ public class VolumeRequestHandler { private String translateVolumeRequests (List <VolumeRequest> queryResponseList) { VolumeRequests queryResponses = new VolumeRequests (); - for (int i = 0; i < queryResponseList.size (); i++) { - queryResponses.getVolumeRequest ().add (queryResponseList.get (i)); + for (VolumeRequest aQueryResponseList : queryResponseList) { + queryResponses.getVolumeRequest().add(aQueryResponseList); } StringWriter stringWriter = new StringWriter (); @@ -652,12 +654,12 @@ public class VolumeRequestHandler { requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); // Capture audit event msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()).toString (), - version, - null, - null); + response = requestClient.post(msoRequest.getRequestXML(), + requestId, + Integer.toString(recipe.getRecipeTimeout()), + version, + null, + null); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); } catch (Exception e) { msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java index 6121e47f83..4343847b59 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java @@ -35,7 +35,7 @@ public class NsParameters { private List<LocationConstraint> locationConstraints; - private Map<String, Object> additionalParamForNs = new HashMap<String,Object>(); + private Map<String, Object> additionalParamForNs = new HashMap<>(); /** * @return Returns the locationConstraints. */ diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java index 036694b9ae..a223d6e384 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java @@ -91,7 +91,7 @@ public class NetworkRequests { */ public List<NetworkRequest> getNetworkRequest() { if (networkRequest == null) { - networkRequest = new ArrayList<NetworkRequest>(); + networkRequest = new ArrayList<>(); } return this.networkRequest; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java index 0c0b622dd5..9e9a832843 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java @@ -91,7 +91,7 @@ public class NetworkTypes { */ public List<NetworkType> getNetworkType() { if (networkType == null) { - networkType = new ArrayList<NetworkType>(); + networkType = new ArrayList<>(); } return this.networkType; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java index 3655643507..652c6a32ef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java @@ -123,7 +123,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/network-request/v1", name = "network-params") public JAXBElement<Object> createNetworkParams(Object value) { - return new JAXBElement<Object>(_NetworkParams_QNAME, Object.class, null, value); + return new JAXBElement<>(_NetworkParams_QNAME, Object.class, null, value); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java index e4faf72016..a3ad61c989 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java @@ -148,7 +148,7 @@ public class ExceptionType { */ public List<String> getVariables() { if (variables == null) { - variables = new ArrayList<String>(); + variables = new ArrayList<>(); } return this.variables; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java index cfd49d296b..e77257c596 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java @@ -144,7 +144,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/vnf-request/v1", name = "vnf-params") public JAXBElement<Object> createVnfParams(Object value) { - return new JAXBElement<Object>(_VnfParams_QNAME, Object.class, null, value); + return new JAXBElement<>(_VnfParams_QNAME, Object.class, null, value); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java index c3f6ec7d19..371cbb8c9d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java @@ -91,7 +91,7 @@ public class VfModuleModelNames { */ public List<VfModuleModelName> getVfModuleModelName() { if (vfModuleModelName == null) { - vfModuleModelName = new ArrayList<VfModuleModelName>(); + vfModuleModelName = new ArrayList<>(); } return this.vfModuleModelName; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java index 336cad5210..993c76c588 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java @@ -91,7 +91,7 @@ public class VnfRequests { */ public List<VnfRequest> getVnfRequest() { if (vnfRequest == null) { - vnfRequest = new ArrayList<VnfRequest>(); + vnfRequest = new ArrayList<>(); } return this.vnfRequest; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java index eebb1d9879..c066ff461c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java @@ -91,7 +91,7 @@ public class VnfTypes { */ public List<VnfType> getVnfType() { if (vnfType == null) { - vnfType = new ArrayList<VnfType>(); + vnfType = new ArrayList<>(); } return this.vnfType; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java index 48cca8f1c2..2d4d588f9a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java @@ -109,7 +109,7 @@ public class ObjectFactory { */ @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/volume-request/v1", name = "volume-params") public JAXBElement<Object> createVolumeParams(Object value) { - return new JAXBElement<Object>(_VolumeParams_QNAME, Object.class, null, value); + return new JAXBElement<>(_VolumeParams_QNAME, Object.class, null, value); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java index 00c88a0fd7..318ff90136 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java @@ -91,7 +91,7 @@ public class VolumeRequests { */ public List<VolumeRequest> getVolumeRequest() { if (volumeRequest == null) { - volumeRequest = new ArrayList<VolumeRequest>(); + volumeRequest = new ArrayList<>(); } return this.volumeRequest; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index 238b6b677c..664f810b35 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -110,7 +110,7 @@ public class E2EServiceInstancesTest { String serviceInstanceId, String vnfId, String vfModuleId,
String volumeGroupId, String networkId, String serviceType,
String vnfType, String vfModuleType, String networkType,
- String requestDetails) {
+ String requestDetails, String recipeParamXsd) {
ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
HttpResponse resp = new BasicHttpResponse(pv, 202,
"test response");
@@ -127,7 +127,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -181,7 +181,7 @@ public class E2EServiceInstancesTest { String serviceInstanceId, String vnfId, String vfModuleId,
String volumeGroupId, String networkId, String serviceType,
String vnfType, String vfModuleType, String networkType,
- String requestDetails) {
+ String requestDetails, String recipeParamXsd) {
ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
HttpResponse resp = new BasicHttpResponse(pv, 500,
"test response");
@@ -198,7 +198,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -252,7 +252,7 @@ public class E2EServiceInstancesTest { String serviceInstanceId, String vnfId, String vfModuleId,
String volumeGroupId, String networkId, String serviceType,
String vnfType, String vfModuleType, String networkType,
- String requestDetails) {
+ String requestDetails, String recipeParamXsd) {
ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
HttpResponse resp = new BasicHttpResponse(pv, 500,
"test response");
@@ -269,7 +269,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -323,7 +323,7 @@ public class E2EServiceInstancesTest { String serviceInstanceId, String vnfId, String vfModuleId,
String volumeGroupId, String networkId, String serviceType,
String vnfType, String vfModuleType, String networkType,
- String requestDetails) {
+ String requestDetails, String recipeParamXsd) {
HttpResponse resp = null;
return resp;
}
@@ -333,7 +333,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -393,7 +393,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -434,7 +434,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -459,7 +459,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -485,7 +485,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -510,7 +510,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -527,7 +527,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
// assertTrue(true);
}
@@ -553,7 +553,7 @@ public class E2EServiceInstancesTest { String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
@Test
@@ -571,7 +571,7 @@ public class E2EServiceInstancesTest { Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
assertTrue(respStr
- .indexOf("Mapping of request to JSON object failed. No content to map to Object due to end of input") != -1);
+ .contains("Mapping of request to JSON object failed. No content to map to Object due to end of input"));
}
@Test
@@ -581,7 +581,7 @@ public class E2EServiceInstancesTest { Response resp = instance.deleteE2EServiceInstance(request, "v3",
"12345678");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
+ assertTrue(respStr.contains("SVC1000"));
}
@Test
@@ -610,4 +610,147 @@ public class E2EServiceInstancesTest { .getE2EServiceInstances("12345", "v3", "123456");
}
+
+ @Test
+ public void updateE2EServiceInstanceTestNormal() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("100");
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.contains("success"));
+ }
+
+ @Test
+ public void updateE2EServiceInstanceTestChkStatusFalse() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceId(
+ String serviceID) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails, String recipeParamXsd) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.contains("SVC2000"));
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java index 6a7fc2c723..c4a1c1fffc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java @@ -76,7 +76,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -101,7 +101,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -121,7 +121,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -141,7 +141,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -161,7 +161,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -181,7 +181,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON1, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -210,7 +210,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -230,7 +230,7 @@ public class MsoRequestTest { return; } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); MsoRequest msoRequest = new MsoRequest ("1234"); @@ -251,7 +251,7 @@ public class MsoRequestTest { } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); @@ -270,7 +270,7 @@ public class MsoRequestTest { } mapper = new ObjectMapper(); - instanceIdMap = new HashMap<String,String>(); + instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); @@ -291,7 +291,7 @@ public class MsoRequestTest { } ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); instanceIdMap.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java index 3c5c89fc92..c1da76e885 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java @@ -179,12 +179,12 @@ UriInfo uriInfo = null; public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, String queryValue, String requestType) { - List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>(); + List <InfraActiveRequests> list = new ArrayList<>(); InfraActiveRequests req = new InfraActiveRequests(); req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); @@ -206,7 +206,7 @@ UriInfo uriInfo = null; req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java index 08abf5702f..d3d995e851 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java @@ -64,7 +64,7 @@ public class ServiceInstanceTest { String requestJson = "{\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v5");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid model-info is specified"));
}
@Test
@@ -84,7 +84,8 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Locked instance - This service (testService) already has a request being worked with a status of null (RequestId - null). The existing request must finish or be cleaned up before proceeding.") != -1);
+ assertTrue(respBody.contains(
+ "Locked instance - This service (testService) already has a request being worked with a status of null (RequestId - null). The existing request must finish or be cleaned up before proceeding."));
}
@Test
@@ -121,7 +122,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Exception while creating record in DB null") != -1);
+ assertTrue(respBody.contains("Exception while creating record in DB null"));
}
@Test
@@ -165,7 +166,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Failed calling bpmn properties") != -1);
+ assertTrue(respBody.contains("Failed calling bpmn properties"));
}
@Test(expected = Exception.class)
@@ -216,7 +217,7 @@ public class ServiceInstanceTest { int recipeTimeout, String requestAction, String serviceInstanceId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
+ String requestDetails, String recipeParamXsd){
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -286,7 +287,7 @@ public class ServiceInstanceTest { int recipeTimeout, String requestAction, String serviceInstanceId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
+ String requestDetails, String recipeParamXsd){
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -306,7 +307,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Request Failed due to BPEL error with HTTP Status") != -1);
+ assertTrue(respBody.contains("Request Failed due to BPEL error with HTTP Status"));
}
@Test
@@ -357,7 +358,7 @@ public class ServiceInstanceTest { int recipeTimeout, String requestAction, String serviceInstanceId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
+ String requestDetails, String recipeParamXsd){
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -377,7 +378,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"vnf\",\"modelName\":\"serviceModel\",\"modelCustomizationName\":\"test\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v5");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("No valid modelVersionId is specified") != -1);
+ assertTrue(respBody.contains("No valid modelVersionId is specified"));
}
@Test
@@ -428,7 +429,7 @@ public class ServiceInstanceTest { int recipeTimeout, String requestAction, String serviceInstanceId,
String vnfId, String vfModuleId, String volumeGroupId, String networkId,
String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
+ String requestDetails, String recipeParamXsd){
return null;
}
};
@@ -441,7 +442,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("bpelResponse is null") != -1);
+ assertTrue(respBody.contains("bpelResponse is null"));
}
@Test
@@ -461,7 +462,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Recipe could not be retrieved from catalog DB null") != -1);
+ assertTrue(respBody.contains("Recipe could not be retrieved from catalog DB null"));
}
@@ -476,7 +477,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v5");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid modelVersionId is specified"));
}
@Test
@@ -490,7 +491,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid instanceName is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid instanceName is specified"));
}
@@ -505,7 +506,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid model-info is specified"));
}
@Test
@@ -519,7 +520,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"1234\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid modelType is specified"));
}
@Test
@@ -533,7 +534,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid modelType is specified"));
}
@@ -548,7 +549,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid modelType is specified"));
}
@Test
@@ -562,7 +563,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"testmodel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Mapping of request to JSON object failed.") != -1);
+ assertTrue(respBody.contains("Mapping of request to JSON object failed."));
}
@Test
@@ -576,7 +577,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid modelName is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid modelName is specified"));
}
@Test
@@ -590,7 +591,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": true},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. AutoBuildVfModule is not valid in the v2 version") != -1);
+ assertTrue(respBody.contains("Error parsing request. AutoBuildVfModule is not valid in the v2 version"));
}
@Test
@@ -604,7 +605,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid subscriptionServiceType is specified"));
}
@Test
@@ -618,7 +619,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respBody = resp.getEntity().toString();
- assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ assertTrue(respBody.contains("Error parsing request. No valid subscriptionServiceType is specified"));
}
@Test
@@ -627,7 +628,7 @@ public class ServiceInstanceTest { String requestJson = "{\"name\":\"test\"}";
Response resp = instance.createServiceInstance(requestJson, "v2");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ assertTrue(respStr.contains("Mapping of request to JSON object failed"));
}
/*** Activate Service Instance Test Cases ***/
@@ -638,7 +639,7 @@ public class ServiceInstanceTest { String requestJson = "{\"name\":\"test\"}";
Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ assertTrue(respStr.contains("Mapping of request to JSON object failed"));
}
@Test
@@ -652,7 +653,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid modelVersionId in relatedInstance is specified"));
}
@Test
@@ -666,7 +667,8 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ assertTrue(respStr.contains(
+ "Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified"));
}
@Test
@@ -680,7 +682,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Deactivate Service Instance Test Cases ***/
@@ -691,7 +693,7 @@ public class ServiceInstanceTest { String requestJson = "{\"name\":\"test\"}";
Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ assertTrue(respStr.contains("Mapping of request to JSON object failed"));
}
@Test
@@ -705,7 +707,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid modelVersionId in relatedInstance is specified"));
}
@Test
@@ -719,7 +721,8 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ assertTrue(respStr.contains(
+ "Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified"));
}
@Test
@@ -733,7 +736,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Delete Service Instance Test Cases ***/
@@ -744,7 +747,7 @@ public class ServiceInstanceTest { String requestJson = "{\"name\":\"test\"}";
Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ assertTrue(respStr.contains("Mapping of request to JSON object failed"));
}
@Test
@@ -758,7 +761,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid modelVersionId is specified"));
}
@Test
@@ -772,7 +775,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid modelVersionId is specified"));
}
@Test
@@ -786,7 +789,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Create Vnf Instance Test Cases ***/
@@ -802,7 +805,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid cloudConfiguration is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid cloudConfiguration is specified"));
}
@Test
@@ -817,7 +820,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid lcpCloudRegionId is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid lcpCloudRegionId is specified"));
}
@Test
@@ -832,7 +835,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Error parsing request. No valid tenantId is specified") != -1);
+ assertTrue(respStr.contains("Error parsing request. No valid tenantId is specified"));
}
@Test
@@ -847,7 +850,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Replace Vnf Instance Test Cases ***/
@@ -863,7 +866,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.replaceVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Update Vnf Instance Test Cases ***/
@@ -880,7 +883,7 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.updateVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
/*** Update Vnf Instance Test Cases ***/
@@ -897,6 +900,6 @@ public class ServiceInstanceTest { + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
Response resp = instance.deleteVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC2000") != -1);
+ assertTrue(respStr.contains("SVC2000"));
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java index 4305db3e72..1c3c85653b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java @@ -49,7 +49,7 @@ public class VfModuleModelNamesHandlerTest { new MockUp<CatalogDatabase>() { @Mock public List <VfModule> getAllVfModules(){ - List <VfModule> list = new ArrayList<VfModule>(); + List <VfModule> list = new ArrayList<>(); VfModule resource = new VfModule(); list.add(resource); return list; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java index 2d3a2a47a5..9c9ebaee35 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java @@ -177,12 +177,12 @@ public class VnfRequestHandlerTest { public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, String queryValue, String requestType) { - List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>(); + List <InfraActiveRequests> list = new ArrayList<>(); InfraActiveRequests req = new InfraActiveRequests(); req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); @@ -202,12 +202,12 @@ public class VnfRequestHandlerTest { public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, String queryValue, String requestType) { - List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>(); + List <InfraActiveRequests> list = new ArrayList<>(); InfraActiveRequests req = new InfraActiveRequests(); req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); @@ -229,7 +229,7 @@ public class VnfRequestHandlerTest { req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java index 7eabc1ac2a..1800bb4695 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java @@ -62,7 +62,7 @@ public class VnfTypesHandlerTest { new MockUp<CatalogDatabase>() { @Mock public List <VnfResource> getAllVnfResources(){ - List <VnfResource> list = new ArrayList<VnfResource>(); + List <VnfResource> list = new ArrayList<>(); VnfResource resource = new VnfResource(); list.add(resource); return list; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java index bf4d7c4d98..fa5e094336 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java @@ -151,12 +151,12 @@ public class VolumeRequestHandlerTest { public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, String queryValue, String requestType) { - List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>(); + List <InfraActiveRequests> list = new ArrayList<>(); InfraActiveRequests req = new InfraActiveRequests(); req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); @@ -177,7 +177,7 @@ public class VolumeRequestHandlerTest { req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); @@ -197,7 +197,7 @@ public class VolumeRequestHandlerTest { req.setAaiServiceId("299392"); req.setAction("CREATE"); req.setRequestStatus("COMPLETE"); - req.setProgress(10001l); + req.setProgress(10001L); req.setSource("test"); req.setStartTime(new Timestamp(10020100)); req.setEndTime(new Timestamp(20020100)); diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml index cdfa0fa8db..b14c87a0d4 100644 --- a/mso-api-handlers/mso-requests-db/pom.xml +++ b/mso-api-handlers/mso-requests-db/pom.xml @@ -3,7 +3,7 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> @@ -103,7 +103,7 @@ <version>1.0.0.Final</version> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java index e3c7cda3bd..c88f31c819 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java @@ -30,7 +30,7 @@ public class MockRequestsDatabase { private Map<String, InfraActiveRequests> activeRequests; public MockRequestsDatabase() { - activeRequests = new HashMap<String, InfraActiveRequests>(); + activeRequests = new HashMap<>(); } public void addRecord(InfraActiveRequests record) { diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index 98121d8490..d6b0b6b419 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -38,6 +38,7 @@ import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.openecomp.mso.db.AbstractSessionFactoryManager; +import org.openecomp.mso.requestsdb.RequestsDbConstant.Status; import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; import org.openecomp.mso.logger.MsoLogger; @@ -177,7 +178,7 @@ public class RequestsDatabase { long startTime = System.currentTimeMillis (); msoLogger.debug ("Execute query on infra active request table"); - List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>(); + List <InfraActiveRequests> results = new ArrayList<>(); Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); try { @@ -698,7 +699,7 @@ public class RequestsDatabase { * update the resource operation * <br> * - * @param operstatus the resource operation object + * @param operStatus the resource operation object * @since ONAP Amsterdam Release */ public void updateResOperStatus(ResourceOperationStatus operStatus) { @@ -757,9 +758,9 @@ public class RequestsDatabase { int resourceCount = lstResourceStatus.size(); int progress = 0; boolean isFinished = true; - for(int i = 0; i < resourceCount; i++) { - progress = progress + Integer.valueOf(lstResourceStatus.get(i).getProgress()) / resourceCount; - if(RequestsDbConstant.Status.PROCESSING.equals(lstResourceStatus.get(i).getStatus())) { + for (ResourceOperationStatus lstResourceStatu : lstResourceStatus) { + progress = progress + Integer.valueOf(lstResourceStatu.getProgress()) / resourceCount; + if (Status.PROCESSING.equals(lstResourceStatu.getStatus())) { isFinished = false; } } diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml index 4399c75155..06eedc5675 100644 --- a/mso-api-handlers/pom.xml +++ b/mso-api-handlers/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-api-handlers</artifactId> <name>API Handler</name> <description>API Handler for MSO</description> diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml index 0dc9e348e9..e3115f1ff1 100644 --- a/mso-catalog-db/pom.xml +++ b/mso-catalog-db/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <name>mso-catalog-db</name> <description>MSO Catalog Database definition and Hibernate objects</description> @@ -167,7 +167,7 @@ </exclusions> </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java index aefe0d5a8b..6b27c50609 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java @@ -36,6 +36,7 @@ import org.hibernate.Session; import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.db.catalog.beans.AllottedResource; import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.db.catalog.beans.ArRecipe; import org.openecomp.mso.db.catalog.beans.HeatEnvironment; import org.openecomp.mso.db.catalog.beans.HeatFiles; import org.openecomp.mso.db.catalog.beans.HeatNestedTemplate; @@ -87,6 +88,7 @@ public class CatalogDatabase implements Closeable { private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; private static final String MODEL_ID = "modelId"; private static final String MODEL_NAME = "modelName"; + private static final String MODEL_VERSION = "version"; private static final String TYPE = "type"; private static final String MODEL_TYPE = "modelType"; private static final String MODEL_VERSION_ID = "modelVersionId"; @@ -205,7 +207,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); @@ -366,7 +368,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByName", null); return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByName", null); @@ -528,7 +530,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null); @@ -600,7 +602,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); @@ -644,7 +646,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); @@ -671,7 +673,7 @@ public class CatalogDatabase implements Closeable { return Collections.EMPTY_LIST; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null); @@ -748,7 +750,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); @@ -874,7 +876,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); @@ -975,7 +977,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleModelName", null); return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); @@ -1073,7 +1075,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResource", null); return resultList.get(0); @@ -1122,13 +1124,15 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); return resultList.get(0); } + + /** * Return a VNF recipe that matches a given VNF_TYPE and ACTION * @@ -1137,14 +1141,13 @@ public class CatalogDatabase implements Closeable { * @return VnfRecipe object or null if none found */ public VnfRecipe getVnfRecipe(String vnfType, String action) { - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType + " and action " + action); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); query.setParameter(VNF_TYPE, vnfType); query.setParameter(ACTION, action); @@ -1156,12 +1159,66 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); + Collections.reverse(resultList); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); + return resultList.get(0); + } + + /** + * Return a VNF recipe that matches a given ModelName and Modelversion and ACTION + * + * @param modelName + * @param modelVersion + * @param action + * @return VnfRecipe object or null if none found + */ + public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) { + + long startTime = System.currentTimeMillis(); + LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + " and action " + action); + + Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); + query.setParameter(VNF_TYPE, modelName); + query.setParameter(MODEL_VERSION, modelVersion); + query.setParameter(ACTION, action); + + @SuppressWarnings("unchecked") + List <VnfRecipe> resultList = query.list(); + + if (resultList.isEmpty()) { + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfRecipe", null); + return null; + } + + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); return resultList.get(0); } + + /** + * Return a Network recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return NetworkRecipe object or null if none found + */ + public VnfRecipe getVnfRecipeByModuleUuid (String vnfModelUuid, String action) { + LOGGER.debug ("Catalog database - get vnf recipe with vnf resource model uuid " + vnfModelUuid + + " and action " + + action + ); + VnfResource vnfResource = getVnfResourceByModelUuid(vnfModelUuid); + if(null == vnfResource){ + return null; + } + + VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getModelVersion(), action); + return recipe; + } /** * Return a VNF recipe that matches a given VF_MODULE_ID and ACTION @@ -1172,12 +1229,10 @@ public class CatalogDatabase implements Closeable { */ public VnfRecipe getVnfRecipeByVfModuleId(String vnfType, String vfModuleId, String action) { - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); - long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - get VNF Recipe with vfModuleId " + vfModuleId); - Query query = getSession().createQuery(hql.toString ()); + Query query = getSession().createQuery("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); query.setParameter(VF_MODULE_MODEL_UUID, vfModuleId); query.setParameter(ACTION, action); @@ -1189,7 +1244,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort(resultList, new MavenLikeVersioningComparator()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(resultList); LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF Recipe Entry found", "CatalogDB", "getVnfRecipeByVfModuleId", null); @@ -1246,7 +1301,7 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleType", null); return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); @@ -1373,7 +1428,7 @@ public class CatalogDatabase implements Closeable { VfModule module = null; if (modules != null && ! modules.isEmpty()) { - Collections.sort (modules, new MavenLikeVersioningComparator ()); + modules.sort(new MavenLikeVersioningComparator()); Collections.reverse (modules); module = modules.get(0); } @@ -1580,7 +1635,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param getVnfResourceCustomizationByModelVersionId + * @param modelVersionId * @return VnfResourceCustomization or null if not found */ public VnfResourceCustomization getVnfResourceCustomizationByModelVersionId(String modelVersionId) { @@ -1829,7 +1884,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); @@ -1862,7 +1917,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param modelCustomizationUuid + * @param modelUuid * @return VnfResourceCustomization or null if not found */ public VnfResource getVnfResourceByModelUuid(String modelUuid) { @@ -1893,17 +1948,17 @@ public class CatalogDatabase implements Closeable { } else { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelUuid", null); } - return vnfResource; + return vnfResource; } - + public VnfResCustomToVfModuleCustom getVnfResCustomToVfModule(String vnfId, String vfId) { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - getVnfResCustomToVfModule - vnfResourceCustModelCustUuid: " + vnfId + ", vfModuleCustModelCustomUuid=" + vfId); - StringBuilder hql = new StringBuilder("FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue"); - HashMap<String, String> parameters = new HashMap<>(); + HashMap<String, String> parameters = new HashMap<>(); parameters.put("vnfIdValue", vnfId); parameters.put("vfIdValue", vfId); - VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow(hql.toString(), parameters, true); + VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow( + "FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue", parameters, true); if (vrctvmc == null) { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResCustomToVfModule", null); } else { @@ -1926,8 +1981,7 @@ public class CatalogDatabase implements Closeable { public List<VfModule> getVfModulesForVnfResource(String vnfResourceModelUuid) { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResourceModelUuid: " + vnfResourceModelUuid); - StringBuilder hql = new StringBuilder("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); query.setParameter("vnfResourceModelUUId", vnfResourceModelUuid); List<VfModule> resultList = null; try { @@ -2166,9 +2220,7 @@ public class CatalogDatabase implements Closeable { String networkModelCustomizationUuid = stn.getResourceModelCustomizationUUID(); LOGGER.debug("Now searching for NetworkResourceCustomization for " + networkModelCustomizationUuid); List<NetworkResourceCustomization> resultSet = this.getAllNetworksByNetworkModelCustomizationUuid(networkModelCustomizationUuid); - for (NetworkResourceCustomization nrc : resultSet) { - masterList.add(nrc); - } + masterList.addAll(resultSet); } LOGGER.debug("Returning " + masterList.size() + " NRC records"); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByServiceModelUuid", null); @@ -2177,8 +2229,7 @@ public class CatalogDatabase implements Closeable { public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2188,7 +2239,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2201,8 +2252,8 @@ public class CatalogDatabase implements Closeable { public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2216,7 +2267,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2230,18 +2281,18 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllNetworksByNetworkModelCustomizationUuid - " + networkModelCustomizationUuid); - StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid"); - //Query query = getSession().createQuery(hql.toString()); + //Query query = getSession().createQuery(hql.toString()); //query.setParameter("networkModelCustomizationUuid", networkModelCustomizationUuid); //LOGGER.debug("QUERY: " + hql.toString() + ", networkModelCustomizationUuid=" + networkModelCustomizationUuid); - + //@SuppressWarnings("unchecked") //List<NetworkResourceCustomization> resultList = query.list(); - + HashMap<String, String> params = new HashMap<>(); params.put("networkModelCustomizationUuid", networkModelCustomizationUuid); - List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows(hql.toString(), params, true); + List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows( + "FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid", params, true); if (resultList.isEmpty()) { LOGGER.debug("Unable to find an NMC with nmcu=" + networkModelCustomizationUuid); @@ -2250,7 +2301,6 @@ public class CatalogDatabase implements Closeable { for (NetworkResourceCustomization nrc : resultList) { nrc.setNetworkResource(this.getNetworkResourceById(nrc.getNetworkResourceModelUuid())); } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkModelCustomizationUuid", null); return resultList; @@ -2267,9 +2317,9 @@ public class CatalogDatabase implements Closeable { String networkResourceId = nr.getModelUUID(); LOGGER.debug("Now searching for NRC's with networkResourceId = " + networkResourceId); - StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); query.setParameter("networkResourceId", networkResourceId); @SuppressWarnings("unchecked") @@ -2288,7 +2338,7 @@ public class CatalogDatabase implements Closeable { } public ArrayList<VfModuleCustomization> getAllVfmcForVrc(VnfResourceCustomization vrc) { LOGGER.debug("Catalog database: getAllVfmcForVrc - " + vrc.getModelCustomizationUuid()); - + List<VnfResCustomToVfModuleCustom> vfmcs = this.getVRCtoVFMC(vrc.getModelCustomizationUuid(), null); if (vfmcs == null || vfmcs.isEmpty()) { return new ArrayList<>(); @@ -2308,8 +2358,7 @@ public class CatalogDatabase implements Closeable { public List<VnfResourceCustomization> getAllVnfsByServiceModelUuid(String serviceModelUuid) { LOGGER.debug("Catalog database: getAllVnfsByServiceModelUuid - " + serviceModelUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelUUID = :serviceModelUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelUUID = :serviceModelUuid"); query.setParameter("serviceModelUuid", serviceModelUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2319,7 +2368,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); // Step 2 - Now query to get the related VnfResourceCustomizations @@ -2330,7 +2379,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Unable to find any related vnfs to a service with modelUuid=" + serviceModelUuid); return new ArrayList<>(); } - + ArrayList<VnfResourceCustomization> allVrcs = new ArrayList<>(); for (ServiceToResourceCustomization strc : strcs) { LOGGER.debug("Try to find VRC for mcu=" + strc.getResourceModelCustomizationUUID()); @@ -2339,13 +2388,12 @@ public class CatalogDatabase implements Closeable { allVrcs.add(vrc); } return allVrcs; - + } public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hqlService = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hqlService.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> resultList = query.list(); @@ -2353,7 +2401,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return new ArrayList<>(); } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); //now just call the method that takes the version - the service object will have the highest version @@ -2363,8 +2411,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2374,7 +2422,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return new ArrayList<>(); } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByServiceModelInvariantUuid", null); @@ -2387,8 +2435,8 @@ public class CatalogDatabase implements Closeable { return this.getAllVnfsByServiceName(serviceName); } - StringBuilder hql = new StringBuilder("FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); query.setParameter("serviceName", serviceName); query.setParameter("serviceVersion", serviceVersion); @@ -2404,8 +2452,7 @@ public class CatalogDatabase implements Closeable { public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName) { LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelName = :serviceName"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelName = :serviceName"); query.setParameter("serviceName", serviceName); @SuppressWarnings("unchecked") @@ -2414,7 +2461,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty()) { return Collections.EMPTY_LIST; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); Service service = resultList.get(0); @@ -2425,8 +2472,7 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllVnfsByVnfModelCustomizationUuid - " + vnfModelCustomizationUuid); - StringBuilder hql1 = new StringBuilder("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); - Query query1 = getSession().createQuery(hql1.toString()); + Query query1 = getSession().createQuery("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); query1.setParameter("vrcmcu", vnfModelCustomizationUuid); @SuppressWarnings("unchecked") List<VnfResourceCustomization> resultList1 = query1.list(); @@ -2435,12 +2481,12 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Found no records matching " + vnfModelCustomizationUuid); return Collections.EMPTY_LIST; } - - for (VnfResourceCustomization vrc : resultList1) { - VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); - vrc.setVnfResource(vr); - vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); - } + + for (VnfResourceCustomization vrc : resultList1) { + VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); + vrc.setVnfResource(vr); + vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); + } LOGGER.debug("Returning " + resultList1.size() + " vnf modules"); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByVnfModelCustomizationUuid", null); @@ -2465,9 +2511,7 @@ public class CatalogDatabase implements Closeable { String arModelCustomizationUuid = star.getResourceModelCustomizationUUID(); LOGGER.debug("Now searching for AllottedResourceCustomization for " + arModelCustomizationUuid); List<AllottedResourceCustomization> resultSet = this.getAllAllottedResourcesByArModelCustomizationUuid(arModelCustomizationUuid); - for (AllottedResourceCustomization arc : resultSet) { - masterList.add(arc); - } + masterList.addAll(resultSet); } LOGGER.debug("Returning " + masterList.size() + " ARC records"); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByServiceModelUuid", null); @@ -2477,8 +2521,7 @@ public class CatalogDatabase implements Closeable { public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2488,7 +2531,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2501,8 +2544,8 @@ public class CatalogDatabase implements Closeable { public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); @@ -2514,7 +2557,7 @@ public class CatalogDatabase implements Closeable { return new ArrayList<>(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2527,8 +2570,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllAllottedResourcesByArModelCustomizationUuid - " + arModelCustomizationUuid); - StringBuilder hql = new StringBuilder("FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); query.setParameter("arModelCustomizationUuid", arModelCustomizationUuid); @SuppressWarnings("unchecked") @@ -2586,7 +2629,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2605,8 +2648,7 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); @SuppressWarnings("unchecked") List<Service> serviceList = query.list(); @@ -2616,7 +2658,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2636,8 +2678,8 @@ public class CatalogDatabase implements Closeable { long startTime = System.currentTimeMillis(); LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - Query query = getSession().createQuery(hql.toString()); + Query query = getSession().createQuery( + "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); query.setParameter("serviceModelVersion", serviceModelVersion); //TODO make this a unique query @@ -2649,7 +2691,7 @@ public class CatalogDatabase implements Closeable { return new ServiceMacroHolder(); } - Collections.sort (serviceList, new MavenLikeVersioningComparator ()); + serviceList.sort(new MavenLikeVersioningComparator()); Collections.reverse (serviceList); Service service = serviceList.get(0); @@ -2697,7 +2739,7 @@ public class CatalogDatabase implements Closeable { } private void populateNetworkResourceType(List<NetworkResourceCustomization> resultList) { - HashMap<String, NetworkResource> networkResources = new HashMap<String, NetworkResource>(); + HashMap<String, NetworkResource> networkResources = new HashMap<>(); for (NetworkResourceCustomization nrc : resultList) { String network_id = nrc.getNetworkResourceModelUuid(); @@ -2735,12 +2777,10 @@ public class CatalogDatabase implements Closeable { public VnfRecipe getVfModuleRecipe (String vnfType, String vfModuleModelName, String action) { String vfModuleType = vnfType + "::" + vfModuleModelName; - StringBuilder hql = new StringBuilder ("FROM VfModule WHERE type = :type "); - long startTime = System.currentTimeMillis (); LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType); - Query query = getSession ().createQuery (hql.toString ()); + Query query = getSession ().createQuery ("FROM VfModule WHERE type = :type "); query.setParameter (TYPE, vfModuleType); @SuppressWarnings("unchecked") @@ -2751,20 +2791,18 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); String vfModuleId = vfMod.getModelUUID(); - StringBuilder hql1 = new StringBuilder ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - LOGGER.debug ("Catalog database - get VNF recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2776,7 +2814,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVfModuleRecipe", null); @@ -2787,7 +2825,7 @@ public class CatalogDatabase implements Closeable { * Return a VNF Module List that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION * - * @param vnfModuleType + * @param vfModuleType * @parm modelCustomizationUuid * @param asdcServiceModelVersion * @param modelVersion @@ -2843,20 +2881,19 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); String vfModuleId = vfMod.getModelUUID(); - StringBuilder hql1 = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ( + "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2868,7 +2905,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); @@ -2898,20 +2935,19 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); VfModule vfMod = resultList.get(0); - String vfModuleId = vfMod.getModelName(); - - StringBuilder hql1 = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); + String vfModuleId = vfMod.getModelName(); LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId + " and action " + action); - Query query1 = getSession ().createQuery (hql1.toString ()); + Query query1 = getSession ().createQuery ( + "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); query1.setParameter (ACTION, action); @@ -2923,7 +2959,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList1, new MavenLikeVersioningComparator ()); + resultList1.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList1); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); @@ -3327,7 +3363,9 @@ public class CatalogDatabase implements Closeable { /** * Return a ServiceToResourceCustomization object * - * @param vfModuleModelUuid, heatFilesArtifactUuid + * @param serviceModelUuid + * @param resourceModelCustomizationUuid + * @param modelType * @return VfModuleToHeatFiles or null if none found */ public ServiceToResourceCustomization getServiceToResourceCustomization(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { @@ -3353,7 +3391,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Map<String, HeatFiles> for returning the heat files associated with a vfModule 1707 * - * @param parentHeatTemplateId + * @param vfModuleModelUuid * @return Map<String,Object> or null if none found */ public Map <String, HeatFiles> getHeatFilesForVfModule(String vfModuleModelUuid) { @@ -3468,7 +3506,7 @@ public class CatalogDatabase implements Closeable { StringBuilder sb = new StringBuilder("Parameters: "); for (HeatTemplateParam param : paramSet) { param.setHeatTemplateArtifactUuid(heat.getArtifactUuid()); - sb.append(param.getParamName() + ", "); + sb.append(param.getParamName()).append(", "); } LOGGER.debug(sb.toString()); heat.setParameters (paramSet); @@ -3569,7 +3607,7 @@ public class CatalogDatabase implements Closeable { /** * Retrieves a Heat environment from DB based on its unique key. 1707 * - * @param name the environment artifact name + * @param artifactUuid the environment artifact name * @param version the environment resource version * @return the heat environment from DB or null if not found */ @@ -3802,7 +3840,7 @@ public class CatalogDatabase implements Closeable { /** * Return the newest version of a specific Tosca CSAR Record resource (queried by Name). * - * @param ToscaCsar + * @param artifactChecksum * @return ToscaCsar object or null if none found */ public ToscaCsar getToscaCsar (String artifactChecksum) { @@ -3826,7 +3864,58 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsar", null); return resultList.get (0); } + + /** + * Return a specific Tosca CSAR Record resource (queried by atrifact uuid). + * + * @param toscaCsarArtifactUUID the artifact uuid of the tosca csar + * @return ToscaCsar object or null if none found + */ + public ToscaCsar getToscaCsarByUUID(String toscaCsarArtifactUUID){ + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactUUID " + toscaCsarArtifactUUID); + + String hql = "FROM ToscaCsar WHERE artifactUUID = :toscaCsarArtifactUUID"; + Query query = getSession ().createQuery (hql); + query.setParameter ("toscaCsarArtifactUUID", toscaCsarArtifactUUID); + + @SuppressWarnings("unchecked") + List <ToscaCsar> resultList = query.list (); + + // See if something came back. Name is unique, so + if (resultList.isEmpty ()) { + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsarByUUID", null); + return null; + } + + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByUUID", null); + return resultList.get (0); + } + /** + * Return a specific Tosca CSAR Record resource (queried by service model uuid). + * <br> + * + * @param serviceModelUUID the service model uuid + * @return ToscaCsar object or null if none found + * @since ONAP Beijing Release + */ + public ToscaCsar getToscaCsarByServiceModelUUID(String serviceModelUUID){ + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get Tosca CSAR record with serviceModelUUID " + serviceModelUUID); + Service service = getServiceByModelUUID(serviceModelUUID); + if(null == service){ + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); + return null; + } + ToscaCsar csar = getToscaCsarByUUID(service.getToscaCsarArtifactUUID()); + if(null == csar){ + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Tosca csar of the service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); + return null; + } + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByServiceModelUUID", null); + return csar; + } public void saveTempNetworkHeatTemplateLookup (TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) { long startTime = System.currentTimeMillis (); @@ -4034,7 +4123,7 @@ public class CatalogDatabase implements Closeable { newVnfRecipe.setDescription(vfRecipe.getDescription()); newVnfRecipe.setOrchestrationUri(vfRecipe.getOrchestrationUri()); newVnfRecipe.setRecipeTimeout(vfRecipe.getRecipeTimeout()); - newVnfRecipe.setVnfComponentParamXSD(vfRecipe.getVnfComponentParamXSD()); + newVnfRecipe.setParamXSD(vfRecipe.getParamXSD()); newVnfRecipe.setVfModuleModelUUId(newRecipe.getModelUUID()); newVnfRecipe.setVersion(vfRecipe.getVersion()); newVnfRecipe.setVnfComponentType(vfRecipe.getVnfComponentType()); @@ -4314,9 +4403,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelUUID * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelUuid(String modelUUID) { @@ -4336,7 +4423,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4387,7 +4474,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4396,6 +4483,26 @@ public class CatalogDatabase implements Closeable { } } + /** + * Return a Network recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return NetworkRecipe object or null if none found + */ + public NetworkRecipe getNetworkRecipeByModuleUuid (String networkModelUuid, String action) { + LOGGER.debug ("Catalog database - get network recipe with network model uuid " + networkModelUuid + + " and action " + + action + ); + NetworkResource networkResource = getNetworkResourceByModelUuid(networkModelUuid); + if(null == networkResource){ + return null; + } + + NetworkRecipe recipe = getNetworkRecipeByNameVersion(networkResource.getModelName(), networkResource.getModelVersion(), action); + return recipe; + } /** * Return a Network recipe that matches a given MODEL_NAME and ACTION @@ -4426,7 +4533,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4436,11 +4543,49 @@ public class CatalogDatabase implements Closeable { } /** + * get network recipe by module name and version and action. + * <br> + * + * @param modelName + * @param modelVersion + * @param action + * @return + * @since ONAP Beijing Release + */ + public NetworkRecipe getNetworkRecipeByNameVersion(String modelName, String modelVersion, String action) { + + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName + +"model version " + modelVersion + " and action " + action); + + try { + String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; + + Query query = getSession ().createQuery (hql); + query.setParameter (MODEL_NAME, modelName); + query.setParameter (MODEL_VERSION, modelVersion); + query.setParameter (ACTION, action); + + @SuppressWarnings("unchecked") + List <NetworkRecipe> resultList = query.list (); + + if (resultList.isEmpty ()) { + return null; + } + + resultList.sort(new MavenLikeVersioningComparator()); + Collections.reverse (resultList); + + return resultList.get (0); + } finally { + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); + } + } + + /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelCustomizationUuid * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) { @@ -4460,7 +4605,7 @@ public class CatalogDatabase implements Closeable { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4517,7 +4662,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4529,7 +4674,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VnfComponents recipe that matches a given VF_MODULE_ID, VNF_COMPONENT_TYPE, ACTION * - * @param vfModuleId + * @param vfModuleModelUUId * @param vnfComponentType * @param action * @return VnfComponentsRecipe object or null if none found @@ -4560,7 +4705,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4589,7 +4734,7 @@ public class CatalogDatabase implements Closeable { return Collections.EMPTY_LIST; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleRecipes", null); @@ -4639,7 +4784,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4651,7 +4796,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VfModule record that matches a given MODEL_NAME * - * @param modelName + * @param modelUUID * @return VfModule object or null if none found */ public VfModule getVfModuleByModelUUID (String modelUUID) { @@ -4673,7 +4818,7 @@ public class CatalogDatabase implements Closeable { if (resultList.isEmpty ()) { return null; } - Collections.sort (resultList, new MavenLikeVersioningComparator ()); + resultList.sort(new MavenLikeVersioningComparator()); Collections.reverse (resultList); return resultList.get (0); @@ -4714,7 +4859,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -4786,7 +4931,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -4834,7 +4979,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - modelResultList is null"); return null; } - Collections.sort(modelResultList, new MavenLikeVersioningComparator()); + modelResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(modelResultList); LOGGER.debug("Catalog database - modelResultList contains " + modelResultList.get(0).toString()); @@ -4851,7 +4996,7 @@ public class CatalogDatabase implements Closeable { LOGGER.debug("Catalog database - recipeResultList is null"); return null; } - Collections.sort(recipeResultList, new MavenLikeVersioningComparator()); + recipeResultList.sort(new MavenLikeVersioningComparator()); Collections.reverse(recipeResultList); LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); @@ -4887,7 +5032,7 @@ public class CatalogDatabase implements Closeable { StringBuilder sb = new StringBuilder(); if (variables != null) { for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey() + "=" + entry.getValue() + "\n"); + sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); query.setParameter(entry.getKey(), entry.getValue()); } } @@ -4938,7 +5083,7 @@ public class CatalogDatabase implements Closeable { StringBuilder sb = new StringBuilder(); if (variables != null) { for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey() + "=" + entry.getValue()+ "\n"); + sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); query.setParameter(entry.getKey(), entry.getValue()); } } @@ -4980,4 +5125,67 @@ public class CatalogDatabase implements Closeable { } return theObjects; } + + + /** + * get allotted resource recipe by module name and version and action. + * <br> + * + * @param modelName + * @param modelVersion + * @param action + * @return + * @since ONAP Beijing Release + */ + public ArRecipe getArRecipeByNameVersion(String modelName, String modelVersion, String action) { + + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get ar recipe with ar model name " + modelName + +"model version " + modelVersion + " and action " + action); + + try { + String hql = "FROM ArRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; + + Query query = getSession ().createQuery (hql); + query.setParameter (MODEL_NAME, modelName); + query.setParameter (MODEL_VERSION, modelVersion); + query.setParameter (ACTION, action); + + @SuppressWarnings("unchecked") + List <ArRecipe> resultList = query.list (); + + if (resultList.isEmpty ()) { + return null; + } + + resultList.sort(new MavenLikeVersioningComparator()); + Collections.reverse (resultList); + + return resultList.get (0); + } finally { + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); + } + } + + /** + * Return a allotted resource recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return ArRecipe object or null if none found + */ + public ArRecipe getArRecipeByModuleUuid (String ArModelUuid, String action) { + LOGGER.debug ("Catalog database - get ar recipe with ar model uuid " + ArModelUuid + + " and action " + + action + ); + AllottedResource arResource = this.getAllottedResourceByModelUuid(ArModelUuid); + if(null == arResource){ + return null; + } + + ArRecipe recipe = getArRecipeByNameVersion(arResource.getModelName(), arResource.getModelVersion(), action); + return recipe; + } + } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java index 66db7dfdec..6fdf236a27 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java @@ -130,20 +130,12 @@ public class AllottedResourceCustomization extends MavenLikeVersioning implement } @Override - public String toString () { - StringBuffer sb = new StringBuffer(); - sb.append("modelCustomizationUuid="); - sb.append(this.modelCustomizationUuid); - sb.append(",modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append(",modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append(",created="); - sb.append(this.created); - sb.append(",ar="); - sb.append(this.ar); - - return sb.toString(); + public String toString() { + return "modelCustomizationUuid=" + this.modelCustomizationUuid + + ",modelInstanceName=" + this.modelInstanceName + + ",modelInstanceName=" + this.modelInstanceName + + ",created=" + this.created + + ",ar=" + this.ar; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java new file mode 100644 index 0000000000..e22d1eb036 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.db.catalog.beans; + + +import java.io.Serializable; + +public class ArRecipe extends Recipe implements Serializable { + private static final long serialVersionUID = 768026109321305392L; + private String modelName; + public ArRecipe() {} + + public String getModelName() { + return modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + + @Override + public String toString () { + return super.toString() + ",modelName=" + modelName + ",arParamXSD=" + getParamXSD(); + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java index dd628bb863..fcd9211ec6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java @@ -88,7 +88,7 @@ public class HeatEnvironment extends MavenLikeVersioning implements Serializable @Override public String toString () { StringBuilder sb = new StringBuilder(); - sb.append ("Artifact UUID=" + this.artifactUuid); + sb.append("Artifact UUID=").append(this.artifactUuid); sb.append (", name="); sb.append (name); sb.append (", version="); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java index b90578d369..ec429c896e 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java @@ -103,23 +103,23 @@ public class HeatFiles extends MavenLikeVersioning implements Serializable { @Override public String toString () { StringBuilder sb = new StringBuilder(); - sb.append ("artifactUuid=" + this.artifactUuid); + sb.append("artifactUuid=").append(this.artifactUuid); if (this.description == null) { sb.append(", description=null"); } else { - sb.append(", description=" + this.description); + sb.append(", description=").append(this.description); } if (this.fileName == null) { sb.append(", fileName=null"); } else { - sb.append(",fileName=" + this.fileName); + sb.append(",fileName=").append(this.fileName); } if (this.fileBody == null) { sb.append(", fileBody=null"); } else { - sb.append(",fileBody=" + this.fileBody); + sb.append(",fileBody=").append(this.fileBody); } - sb.append(", artifactChecksum=" + this.artifactChecksum); + sb.append(", artifactChecksum=").append(this.artifactChecksum); if (created != null) { sb.append (",created="); sb.append (DateFormat.getInstance().format(created)); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java index eec0f410c6..df067445f6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java @@ -61,12 +61,12 @@ public class HeatNestedTemplate implements Serializable { @Override public String toString () { StringBuilder sb = new StringBuilder (); - sb.append ("ParentTemplateId=" + this.parentTemplateId); - sb.append (", ChildTemplateId=" + this.childTemplateId); + sb.append("ParentTemplateId=").append(this.parentTemplateId); + sb.append(", ChildTemplateId=").append(this.childTemplateId); if (this.providerResourceFile == null) { sb.append (", providerResourceFile=null"); } else { - sb.append (",providerResourceFile=" + this.providerResourceFile); + sb.append(",providerResourceFile=").append(this.providerResourceFile); } return sb.toString (); } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java index 2c79d7d48c..f6202b7365 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java @@ -44,15 +44,12 @@ public class HeatTemplateArtifactUuidModelUuid implements Serializable { public void setModelUuid(String modelUuid) {
this.modelUuid = modelUuid;
}
-
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid);
- sb.append(" modelUuid=" + this.modelUuid);
- return sb.toString();
+ return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid;
}
-
+
@Override
public boolean equals (Object o) {
if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) {
@@ -73,9 +70,7 @@ public class HeatTemplateArtifactUuidModelUuid implements Serializable { public int hashCode () {
// hash code does not have to be a unique result - only that two objects that should be treated as equal
// return the same value. so this should work.
- int result;
- result = this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode();
- return result;
+ return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode();
}
}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java index 77beeb71df..96e6c616bf 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java @@ -185,13 +185,13 @@ public class Model extends MavenLikeVersioning implements Serializable { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Model: "); - sb.append("modelCustomizationId=" + modelCustomizationId); - sb.append(",modelCustomizationName=" + modelCustomizationName); - sb.append(",modelInvariantId=" + modelInvariantId); - sb.append(",modelName=" + modelName); - sb.append(",modelType=" + modelType); - sb.append(",modelVersion=" + modelVersion); - sb.append(",modelVersionId=" + modelVersionId); + sb.append("modelCustomizationId=").append(modelCustomizationId); + sb.append(",modelCustomizationName=").append(modelCustomizationName); + sb.append(",modelInvariantId=").append(modelInvariantId); + sb.append(",modelName=").append(modelName); + sb.append(",modelType=").append(modelType); + sb.append(",modelVersion=").append(modelVersion); + sb.append(",modelVersionId=").append(modelVersionId); if (created != null) { sb.append (",created="); sb.append (DateFormat.getInstance().format(created)); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java index fddea4791b..7ef5a4a7b9 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java @@ -89,7 +89,7 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { } /** - * @param versionStr the versionStr to set + * @param schemaVersion the versionStr to set */ public void setSchemaVersion(String schemaVersion) { this.schemaVersion = schemaVersion; @@ -169,12 +169,12 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ModelRecipe: "); - sb.append("modelId=" + modelId.toString()); - sb.append(",action=" + action); - sb.append(",schemaVersion=" + schemaVersion); - sb.append(",orchestrationUri=" + orchestrationUri); - sb.append(",modelParamXSD=" + modelParamXSD); - sb.append(",recipeTimeout=" + recipeTimeout.toString()); + sb.append("modelId=").append(modelId.toString()); + sb.append(",action=").append(action); + sb.append(",schemaVersion=").append(schemaVersion); + sb.append(",orchestrationUri=").append(orchestrationUri); + sb.append(",modelParamXSD=").append(modelParamXSD); + sb.append(",recipeTimeout=").append(recipeTimeout.toString()); if (created != null) { sb.append (",created="); sb.append (DateFormat.getInstance().format(created)); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java index 9ef1fb6fd3..eeaa363aa6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java @@ -26,7 +26,6 @@ import java.io.Serializable; public class NetworkRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; private String modelName; - private String networkParamXSD; public NetworkRecipe() {} public String getModelName() { @@ -36,19 +35,8 @@ public class NetworkRecipe extends Recipe implements Serializable { this.modelName = modelName; } - public String getNetworkParamXSD() { - return networkParamXSD; - } - public void setNetworkParamXSD(String networkParamXSD) { - this.networkParamXSD = networkParamXSD; - } - @Override public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append (",modelName=" + modelName); - sb.append (",networkParamXSD=" + networkParamXSD); - return sb.toString(); + return super.toString() + ",modelName=" + modelName + ",networkParamXSD=" + getParamXSD(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java index ef09fef41f..b581545182 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java @@ -103,24 +103,14 @@ public class NetworkResourceCustomization implements Serializable{ } @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("modelCustomizationUuid="); - sb.append(this.modelCustomizationUuid); - sb.append("networkResourceModelUuid="); - sb.append(this.networkResourceModelUuid); - sb.append("modelInstanceName="); - sb.append(this.modelInstanceName); - sb.append("networkType="); - sb.append(this.networkType); - sb.append("networkTechnology="); - sb.append(this.networkTechnology); - sb.append("networkScope="); - sb.append(this.networkScope); - sb.append("networkRole="); - sb.append(this.networkRole); - - return sb.toString(); + public String toString() { + return "modelCustomizationUuid=" + this.modelCustomizationUuid + + "networkResourceModelUuid=" + this.networkResourceModelUuid + + "modelInstanceName=" + this.modelInstanceName + + "networkType=" + this.networkType + + "networkTechnology=" + this.networkTechnology + + "networkScope=" + this.networkScope + + "networkRole=" + this.networkRole; } @Override diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java index 668f666fcd..58c24412dc 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java @@ -37,7 +37,7 @@ public class Recipe extends MavenLikeVersioning implements Serializable { protected String orchestrationUri; private int recipeTimeout; private String serviceType; - + private String paramXSD; private Timestamp created; public Recipe () { @@ -100,11 +100,25 @@ public class Recipe extends MavenLikeVersioning implements Serializable { this.created = created; } - @Override + /** + * @return Returns the paramXSD. + */ + public String getParamXSD() { + return paramXSD; + } + + /** + * @param paramXSD The paramXSD to set. + */ + public void setParamXSD(String paramXSD) { + this.paramXSD = paramXSD; + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: " + action); - sb.append(",uri=" + orchestrationUri); + sb.append("RECIPE: ").append(action); + sb.append(",uri=").append(orchestrationUri); if (created != null) { sb.append (",created="); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java index beb021ac11..f518678b44 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java @@ -150,14 +150,17 @@ public class Service extends MavenLikeVersioning implements Serializable { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("SERVICE: name=" + modelName + ",modelVersion=" + modelVersion + ",description=" + description+",modelInvariantUUID="+modelInvariantUUID+",toscaCsarArtifactUUID="+toscaCsarArtifactUUID+",serviceType="+serviceType+",serviceRole="+serviceRole); + sb.append("SERVICE: name=").append(modelName).append(",modelVersion=").append(modelVersion) + .append(",description=").append(description).append(",modelInvariantUUID=").append(modelInvariantUUID) + .append(",toscaCsarArtifactUUID=").append(toscaCsarArtifactUUID).append(",serviceType=").append(serviceType) + .append(",serviceRole=").append(serviceRole); for (String recipeAction : recipes.keySet()) { ServiceRecipe recipe = recipes.get(recipeAction); - sb.append ("\n" + recipe.toString()); + sb.append("\n").append(recipe.toString()); } for(ServiceToResourceCustomization serviceResourceCustomization : serviceResourceCustomizations) { - sb.append("\n" + serviceResourceCustomization.toString()); + sb.append("\n").append(serviceResourceCustomization.toString()); } if (created != null) { sb.append (",created="); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java index d4d0507f20..78f94e40c1 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java @@ -43,7 +43,7 @@ public class ServiceMacroHolder implements Serializable { public ServiceMacroHolder() { super(); this.service = null; - this.vnfResources = new ArrayList<VnfResource>(); + this.vnfResources = new ArrayList<>(); this.networkResourceCustomizations = new ArrayList<>(); this.allottedResourceCustomizations = new ArrayList<>(); this.vnfResourceCustomizations = new ArrayList<>(); @@ -129,7 +129,7 @@ public class ServiceMacroHolder implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("ServicePlus: "); if (this.service != null) { - sb.append("service: " + this.service.toString()); + sb.append("service: ").append(this.service.toString()); } else { sb.append("service: null"); } @@ -137,7 +137,7 @@ public class ServiceMacroHolder implements Serializable { int i=0; sb.append("VnfResources: "); for (VnfResourceCustomization vrc : this.vnfResourceCustomizations) { - sb.append(", vnfResourceCustomization[" + i++ + "]:" + vrc.toString()); + sb.append(", vnfResourceCustomization[").append(i++).append("]:").append(vrc.toString()); } } else { sb.append("none"); @@ -146,7 +146,7 @@ public class ServiceMacroHolder implements Serializable { int i=0; sb.append("VnfResources: "); for (VnfResource vr : this.vnfResources) { - sb.append(", vnfResource[" + i++ + "]:" + vr.toString()); + sb.append(", vnfResource[").append(i++).append("]:").append(vr.toString()); } } else { sb.append("none"); @@ -155,14 +155,14 @@ public class ServiceMacroHolder implements Serializable { int i=0; sb.append("NetworkResourceCustomizations:"); for (NetworkResourceCustomization nrc : this.networkResourceCustomizations) { - sb.append("NRC[" + i++ + "]: " + nrc.toString()); + sb.append("NRC[").append(i++).append("]: ").append(nrc.toString()); } } if (this.allottedResourceCustomizations != null && this.allottedResourceCustomizations.size() > 0) { int i=0; sb.append("AllottedResourceCustomizations:"); for (AllottedResourceCustomization arc : this.allottedResourceCustomizations) { - sb.append("ARC[" + i++ + "]: " + arc.toString()); + sb.append("ARC[").append(i++).append("]: ").append(arc.toString()); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java index 3a3cc0aa69..303570a8d0 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java @@ -139,8 +139,8 @@ public class ServiceRecipe extends MavenLikeVersioning implements Serializable { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: " + action); - sb.append(",uri=" + orchestrationUri); + sb.append("RECIPE: ").append(action); + sb.append(",uri=").append(orchestrationUri); if (created != null) { sb.append (",created="); sb.append (DateFormat.getInstance().format(created)); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java index 59495f40c6..6515a12bc0 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java @@ -71,22 +71,16 @@ public class ServiceToAllottedResources implements Serializable { @Override public int hashCode() { - + int code = this.arModelCustomizationUuid == null ? 0 : this.arModelCustomizationUuid.hashCode(); code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); return code; } - + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("serviceModelUuid="); - sb.append(this.serviceModelUuid); - sb.append("arModelCustomizationUuid="); - sb.append(this.arModelCustomizationUuid); - - return sb.toString(); + return "serviceModelUuid=" + this.serviceModelUuid + "arModelCustomizationUuid=" + this.arModelCustomizationUuid; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java index f076e13e26..69dc32796f 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java @@ -80,14 +80,11 @@ public class ServiceToNetworks implements Serializable { return code; } - + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServiceToNetworks mapping: "); - sb.append("serviceModelUuid=" + this.serviceModelUuid); - sb.append(",networkModelCustomizationUuid=" + networkModelCustomizationUuid); - return sb.toString(); + return "ServiceToNetworks mapping: " + "serviceModelUuid=" + this.serviceModelUuid + + ",networkModelCustomizationUuid=" + networkModelCustomizationUuid; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java index fcd20ef963..6d74ab38aa 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java @@ -99,7 +99,8 @@ public class ServiceToResourceCustomization implements Serializable { @Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("ServiceToResourceCustomization: modelType=" + modelType + ",serviceModelUUID=" + serviceModelUUID+",resourceModelCustomizationUUID="+resourceModelCustomizationUUID);
+ sb.append("ServiceToResourceCustomization: modelType=").append(modelType).append(",serviceModelUUID=")
+ .append(serviceModelUUID).append(",resourceModelCustomizationUUID=").append(resourceModelCustomizationUUID);
if (created != null) {
sb.append (",created=");
sb.append (DateFormat.getInstance().format(created));
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java index 20801c105e..3ef7e6e237 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java @@ -23,7 +23,7 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable;
public class TempNetworkHeatTemplateLookup implements Serializable {
-
+
private String networkResourceModelName;
private String heatTemplateArtifactUuid;
private String aicVersionMin;
@@ -33,14 +33,14 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public TempNetworkHeatTemplateLookup() {
super();
}
-
+
public String getNetworkResourceModelName() {
return this.networkResourceModelName;
}
public void setNetworkResourceModelName(String networkResourceModelName) {
this.networkResourceModelName = networkResourceModelName;
}
-
+
public String getHeatTemplateArtifactUuid() {
return this.heatTemplateArtifactUuid;
}
@@ -50,29 +50,26 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public String getAicVersionMin() {
return this.aicVersionMin;
}
-
+
public void setAicVersionMin(String aicVersionMin) {
this.aicVersionMin = aicVersionMin;
}
-
+
public String getAicVersionMax() {
return this.aicVersionMax;
}
-
+
public void setAicVersionMax(String aicVersionMax) {
this.aicVersionMax = aicVersionMax;
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("NetworkResourceModelName=" + this.networkResourceModelName);
- sb.append("HeatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid);
- sb.append("aicVersionMin=" + this.aicVersionMin);
- sb.append("aicVersionMax=" + this.aicVersionMax);
- return sb.toString();
+ return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" +
+ this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof TempNetworkHeatTemplateLookup)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java index 88a358d364..591e648a33 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java @@ -100,9 +100,11 @@ public class ToscaCsar extends MavenLikeVersioning implements Serializable { @Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("TOSCACSAR: artifactUUID=" + artifactUUID + ",name=" + name + ",version=" + version + ",description=" + description+",artifactChecksum="+artifactChecksum+",url="+url);
+ sb.append("TOSCACSAR: artifactUUID=").append(artifactUUID).append(",name=").append(name).append(",version=")
+ .append(version).append(",description=").append(description).append(",artifactChecksum=")
+ .append(artifactChecksum).append(",url=").append(url);
for (Service service : services) {
- sb.append ("\n" + service.toString());
+ sb.append("\n").append(service.toString());
}
if (created != null) {
sb.append (",created=");
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java index fd2b6ff37b..cd2821a7b0 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java @@ -142,7 +142,7 @@ public class VfModule extends MavenLikeVersioning implements Serializable { @Override public String toString () { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append("VFModule:"); buf.append("modelName="); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java index 4404834585..db3a2664a8 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java @@ -109,22 +109,22 @@ public class VfModuleCustomization implements Serializable { public void setVfModule(VfModule vfModule) {
this.vfModule = vfModule;
}
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("modelCustomizationUuid=" + this.modelCustomizationUuid);
- sb.append("vfModuleModelUuid=" + this.vfModuleModelUuid);
- sb.append("label=" + this.label);
- sb.append("initalCount=" + this.initialCount);
- sb.append("minInstances=" + this.minInstances);
- sb.append("maxInstances=" + this.maxInstances);
- sb.append("availabilityZoneCount=" + this.availabilityZoneCount);
- sb.append("heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid);
- sb.append("volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid);
- sb.append("created=" + this.created);
- return sb.toString();
+ return "modelCustomizationUuid=" + this.modelCustomizationUuid +
+ "vfModuleModelUuid=" + this.vfModuleModelUuid +
+ "label=" + this.label +
+ "initalCount=" + this.initialCount +
+ "minInstances=" + this.minInstances +
+ "maxInstances=" + this.maxInstances +
+ "availabilityZoneCount=" + this.availabilityZoneCount +
+ "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid +
+ "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid +
+ "created=" + this.created;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof VfModuleCustomization)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java index 63395c215c..611604e830 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java @@ -46,13 +46,10 @@ public class VfModuleToHeatFiles implements Serializable { public void setHeatFilesArtifactUuid(String heatFilesArtifactUuid) { this.heatFilesArtifactUuid = heatFilesArtifactUuid; } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder (); - sb.append ("vfModuleModelUuid=" + this.vfModuleModelUuid); - sb.append (", heatFilesArtifactUuid=" + this.heatFilesArtifactUuid); - return sb.toString (); - } + + @Override + public String toString() { + return "vfModuleModelUuid=" + this.vfModuleModelUuid + ", heatFilesArtifactUuid=" + this.heatFilesArtifactUuid; + } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java index b0a8c3ee1e..e1795e1b04 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java @@ -78,10 +78,10 @@ public class VnfComponent implements Serializable { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("VnfComponent: "); - sb.append("vnfId=" + vnfId); - sb.append(",componentType=" + componentType); - sb.append(",heatTemplateId=" + heatTemplateId); - sb.append(",heatEnvironmentId=" + heatEnvironmentId); + sb.append("vnfId=").append(vnfId); + sb.append(",componentType=").append(componentType); + sb.append(",heatTemplateId=").append(heatTemplateId); + sb.append(",heatEnvironmentId=").append(heatEnvironmentId); if (created != null) { sb.append (",created="); @@ -109,7 +109,7 @@ public class VnfComponent implements Serializable { public int hashCode () { // return the hashCode of the concat string of type+vnfId - should be okay. int result = 0; - result = (this.componentType + this.vnfId).toString().hashCode(); + result = (this.componentType + this.vnfId).hashCode(); return result; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java index 1e5f69c622..30a5133bd5 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java @@ -27,7 +27,6 @@ public class VnfComponentsRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; private String vnfType; - private String vnfComponentParamXSD; private String vnfComponentType; private String vfModuleModelUUId; @@ -39,13 +38,6 @@ public class VnfComponentsRecipe extends Recipe implements Serializable { public void setVnfType(String vnfType) { this.vnfType = vnfType; } - - public String getVnfComponentParamXSD() { - return vnfComponentParamXSD; - } - public void setVnfComponentParamXSD(String vnfComponentParamXSD) { - this.vnfComponentParamXSD = vnfComponentParamXSD; - } public String getVnfComponentType() { return vnfComponentType; @@ -64,12 +56,7 @@ public class VnfComponentsRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuffer sb = new StringBuffer(); - sb.append(super.toString()); - sb.append (",vnfComponentParamXSD=" + vnfComponentParamXSD); - sb.append (",serviceType=" + getServiceType ()); - sb.append (",vnfComponentType=" + getVnfComponentType ()); - sb.append (",vfModuleId=" + getVfModuleModelUUId()); - return sb.toString(); + return super.toString() + ",vnfComponentParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + + ",vnfComponentType=" + getVnfComponentType() + ",vfModuleId=" + getVfModuleModelUUId(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java index 55bb33a4ef..0dd38cbbc1 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java @@ -27,7 +27,6 @@ public class VnfRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; private String vnfType; - private String vnfParamXSD; private String vfModuleId; public VnfRecipe() {} @@ -38,13 +37,6 @@ public class VnfRecipe extends Recipe implements Serializable { public void setVnfType(String vnfType) { this.vnfType = vnfType; } - - public String getVnfParamXSD() { - return vnfParamXSD; - } - public void setVnfParamXSD(String vnfParamXSD) { - this.vnfParamXSD = vnfParamXSD; - } public String getVfModuleId() { return vfModuleId; @@ -56,11 +48,7 @@ public class VnfRecipe extends Recipe implements Serializable { @Override public String toString () { - StringBuffer sb = new StringBuffer(); - sb.append(super.toString()); - sb.append (",vnfParamXSD=" + vnfParamXSD); - sb.append (",serviceType=" + getServiceType ()); - sb.append (",vfModuleId=" + getVfModuleId ()); - return sb.toString(); + return super.toString() + ",vnfParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + ",vfModuleId=" + + getVfModuleId(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java index 9cd9f1ca78..fd1e6b67b8 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java @@ -53,15 +53,14 @@ public class VnfResCustomToVfModuleCustom implements Serializable { public void setCreated(Timestamp created) {
this.created = created;
}
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid);
- sb.append("vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid);
- sb.append("created=" + this.created);
- return sb.toString();
+ return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid +
+ "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created;
}
- @Override
+
+ @Override
public boolean equals (Object o) {
if (!(o instanceof VnfResCustomToVfModuleCustom)) {
return false;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java index 0872f146ad..806cbeb076 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java @@ -195,7 +195,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { } public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations == null ? new ArrayList<VfModuleCustomization>() : this.vfModuleCustomizations; + return this.vfModuleCustomizations == null ? new ArrayList<>() : this.vfModuleCustomizations; } public void setVfModuleCustomizations(ArrayList<VfModuleCustomization> vfModuleCustomizations) { this.vfModuleCustomizations = vfModuleCustomizations; @@ -205,7 +205,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModuleCustomizations != null) { this.vfModuleCustomizations.add(vfmc); } else { - this.vfModuleCustomizations = new ArrayList<VfModuleCustomization>(); + this.vfModuleCustomizations = new ArrayList<>(); this.vfModuleCustomizations.add(vfmc); } } @@ -216,7 +216,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModules != null) { this.vfModules.add(vfm); } else { - this.vfModules = new HashSet<VfModule>(); + this.vfModules = new HashSet<>(); this.vfModules.add(vfm); } } @@ -225,10 +225,8 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { if (this.vfModules == null || this.vfModules.size() < 1) { return null; } - ArrayList<VfModule> list = new ArrayList<VfModule>(); - for (VfModule vfm : this.vfModules) { - list.add(vfm); - } + ArrayList<VfModule> list = new ArrayList<>(); + list.addAll(this.vfModules); return list; } @@ -242,45 +240,45 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { @Override public String toString () { - StringBuffer buf = new StringBuffer(); - - buf.append("VNF="); - buf.append(",modelVersion="); - buf.append(modelVersion); - buf.append(",mode="); - buf.append(orchestrationMode); - buf.append(",heatTemplateArtifactUUId="); - buf.append(heatTemplateArtifactUUId); - buf.append(",envtId="); - buf.append(",asdcUuid="); - buf.append(",aicVersionMin="); - buf.append(this.aicVersionMin); - buf.append(",aicVersionMax="); - buf.append(this.aicVersionMax); - buf.append(",modelInvariantUuid="); - buf.append(this.modelInvariantUuid); - buf.append(",modelVersion="); - buf.append(",modelCustomizationName="); - buf.append(",modelName="); - buf.append(this.modelName); - buf.append(",serviceModelInvariantUUID="); - buf.append(",modelCustomizationUuid="); - buf.append(",toscaNodeType="); - buf.append(toscaNodeType); + StringBuilder sb = new StringBuilder(); + + sb.append("VNF="); + sb.append(",modelVersion="); + sb.append(modelVersion); + sb.append(",mode="); + sb.append(orchestrationMode); + sb.append(",heatTemplateArtifactUUId="); + sb.append(heatTemplateArtifactUUId); + sb.append(",envtId="); + sb.append(",asdcUuid="); + sb.append(",aicVersionMin="); + sb.append(this.aicVersionMin); + sb.append(",aicVersionMax="); + sb.append(this.aicVersionMax); + sb.append(",modelInvariantUuid="); + sb.append(this.modelInvariantUuid); + sb.append(",modelVersion="); + sb.append(",modelCustomizationName="); + sb.append(",modelName="); + sb.append(this.modelName); + sb.append(",serviceModelInvariantUUID="); + sb.append(",modelCustomizationUuid="); + sb.append(",toscaNodeType="); + sb.append(toscaNodeType); if (created != null) { - buf.append(",created="); - buf.append(DateFormat.getInstance().format(created)); + sb.append(",created="); + sb.append(DateFormat.getInstance().format(created)); } for(VnfResourceCustomization vrc : vnfResourceCustomizations) { - buf.append("/n" + vrc.toString()); + sb.append("/n").append(vrc.toString()); } for(VfModule vfm : vfModules) { - buf.append("/n" + vfm.toString()); + sb.append("/n").append(vfm.toString()); } - return buf.toString(); + return sb.toString(); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java index 8d580fd9a0..cb5bf64b8c 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java @@ -155,7 +155,7 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser if (this.vfModuleCustomizations != null) { this.vfModuleCustomizations.add(vfmc); } else { - this.vfModuleCustomizations = new ArrayList<VfModuleCustomization>(); + this.vfModuleCustomizations = new ArrayList<>(); this.vfModuleCustomizations.add(vfmc); } } @@ -179,21 +179,17 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser @Override public String toString() { - StringBuilder sb = new StringBuilder("VnfResourceCustomization: "); - sb.append("ModelCustUuid=" + this.modelCustomizationUuid ); - sb.append(", ModelInstanceName=" + this.modelInstanceName); - sb.append(", vnfResourceModelUuid=" + this.vnfResourceModelUUID); - sb.append(", creationTimestamp=" + this.created); - sb.append(", minInstances=" + this.minInstances); - sb.append(", maxInstances=" + this.maxInstances); - sb.append(", availabilityZoneMaxCount=" + this.availabilityZoneMaxCount); -// sb.append(", vnfResource:\n" + this.vnfResource == null ? "null" : this.vnfResource.toString()); - sb.append(", nfFunction=" + this.nfFunction); - sb.append(", nfType=" + this.nfType); - sb.append(", nfRole=" + this.nfRole); - sb.append(", nfNamingCode=" + this.nfNamingCode); - - return sb.toString(); + return "VnfResourceCustomization: " + "ModelCustUuid=" + this.modelCustomizationUuid + + ", ModelInstanceName=" + this.modelInstanceName + + ", vnfResourceModelUuid=" + this.vnfResourceModelUUID + + ", creationTimestamp=" + this.created + + ", minInstances=" + this.minInstances + + ", maxInstances=" + this.maxInstances + + ", availabilityZoneMaxCount=" + this.availabilityZoneMaxCount + + ", nfFunction=" + this.nfFunction + + ", nfType=" + this.nfType + + ", nfRole=" + this.nfRole + + ", nfNamingCode=" + this.nfNamingCode; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java index 564fd5a019..e42f734a64 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java @@ -51,29 +51,32 @@ public class MavenLikeVersioning implements Serializable { * */ public boolean isMoreRecentThan (String versionToCompare) { - if (versionToCompare == null || versionToCompare.trim().equals("") || this.version == null || this.version.trim().equals("")) { + if (versionToCompare == null || versionToCompare.trim().isEmpty() || this.version == null || this.version.trim().isEmpty()) { return false; } - String [] currentVersionArray = this.version.split("\\."); - String [] specifiedVersionArray = versionToCompare.split("\\."); + String[] currentVersionArray = this.version.split("\\."); + String[] specifiedVersionArray = versionToCompare.split("\\."); - int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); + int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); - for (int currentVersionIndex=0;currentVersionIndex < smalestStringLength;++currentVersionIndex) { + for (int currentVersionIndex = 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) { - if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer + .parseInt(specifiedVersionArray[currentVersionIndex])) { return false; - } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { + } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer + .parseInt(specifiedVersionArray[currentVersionIndex])) { return true; } } - - // Even if versionToCompare has more digits, it means versionToCompare is more recent - if (Integer.parseInt(currentVersionArray[smalestStringLength-1]) == Integer.parseInt(specifiedVersionArray[smalestStringLength-1])) { - return currentVersionArray.length > specifiedVersionArray.length; + try { + // Even if versionToCompare has more digits, it means versionToCompare is more recent + return Integer.parseInt(currentVersionArray[smalestStringLength - 1]) != Integer + .parseInt(specifiedVersionArray[smalestStringLength - 1]) + || currentVersionArray.length > specifiedVersionArray.length; + } catch (NumberFormatException e) { + return false; } - - return true; } /** diff --git a/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml b/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml new file mode 100644 index 0000000000..fedfe31551 --- /dev/null +++ b/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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========================================================= + */ + --> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> + <class name="ArRecipe" table="AR_RECIPE"> + <meta attribute="class-description"> + This class describes a AR recipe + </meta> + + <id name="id" type="int" column="id"> + <generator class="native"/> + </id> + + <properties name="uk_ar_recipe" unique="true"> + <property name="modelName" type="string" > + <column name="MODEL_NAME" not-null="true" length="20"/> + </property> + <property name="action" type="string" > + <column name="ACTION" not-null="true" length="20"/> + </property> + <property name="version" type="string"> + <column name="VERSION_STR" not-null="true" length="20"/> + </property> + + </properties> + + <property name="serviceType" type="string" length="45"> + <column name="SERVICE_TYPE" not-null="false" length="45"/> + </property> + <property name="description" column="DESCRIPTION" type="string" length="1200"/> + <property name="orchestrationUri" type="string"> + <column name="ORCHESTRATION_URI" not-null="true" length="256"/> + </property> + <property name="paramXSD" column="AR_PARAM_XSD" type="string" length="2048"/> + <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> + <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> + <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> + </property> + </class> + +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml b/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml index 1ed9c7c392..4490dbadd0 100644 --- a/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml +++ b/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml @@ -51,7 +51,7 @@ <property name="orchestrationUri" type="string"> <column name="ORCHESTRATION_URI" not-null="true" length="256"/> </property> - <property name="networkParamXSD" column="NETWORK_PARAM_XSD" type="string" length="2048"/> + <property name="paramXSD" column="NETWORK_PARAM_XSD" type="string" length="2048"/> <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> diff --git a/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml index 20b9cab252..d2ca635c9a 100644 --- a/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml +++ b/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml @@ -46,7 +46,7 @@ <property name="orchestrationUri" type="string"> <column name="ORCHESTRATION_URI" not-null="true" length="256"/> </property> - <property name="vnfComponentParamXSD" column="VNF_COMPONENT_PARAM_XSD" type="string" length="2048"/> + <property name="paramXSD" column="VNF_COMPONENT_PARAM_XSD" type="string" length="2048"/> <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> diff --git a/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml index 4dc7f968b4..910cb9bf5c 100644 --- a/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml +++ b/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml @@ -59,7 +59,7 @@ <column name="ORCHESTRATION_URI" not-null="true" length="256"/> </property> - <property name="vnfParamXSD" column="VNF_PARAM_XSD" type="string" length="2048"/> + <property name="paramXSD" column="VNF_PARAM_XSD" type="string" length="2048"/> <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java index e9f080b1dd..3cab4f243b 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java @@ -2445,7 +2445,7 @@ public class CatalogDatabaseTest { @Test(expected = Exception.class) public void saveHeatTemplateTest(){ HeatTemplate heat = new HeatTemplate(); - Set <HeatTemplateParam> paramSet = new HashSet<HeatTemplateParam>(); + Set <HeatTemplateParam> paramSet = new HashSet<>(); cd.saveHeatTemplate(heat,paramSet); } @Test(expected = Exception.class) @@ -2665,12 +2665,12 @@ public class CatalogDatabaseTest { @Test(expected = Exception.class) public void executeQuerySingleRow(){ VnfComponent ar = new VnfComponent(); - HashMap<String, String> variables = new HashMap<String, String>(); + HashMap<String, String> variables = new HashMap<>(); cd.executeQuerySingleRow("tets",variables,false); } @Test(expected = Exception.class) public void executeQueryMultipleRows(){ - HashMap<String, String> variables = new HashMap<String, String>(); + HashMap<String, String> variables = new HashMap<>(); cd.executeQueryMultipleRows("select",variables,false); } } diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java index c3d5357ab6..cf79d5b0d1 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java @@ -67,7 +67,7 @@ public class HeatTemplateTest { heatTemplate.setParameters (set); String heatStr = heatTemplate.toString (); assertTrue (heatStr.contains ("param name")); - assertTrue (heatStr.toString ().contains ("param 2(reqd)")); + assertTrue (heatStr.contains ("param 2(reqd)")); File tempFile; try { diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java index 5bcadb760b..c99a714b11 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java @@ -153,7 +153,7 @@ public class MavenVersioningTest { MavenLikeVersioning test12 = new MavenLikeVersioning(); test12.setVersion("2.0"); - List<MavenLikeVersioning> list= new LinkedList<MavenLikeVersioning>(); + List<MavenLikeVersioning> list= new LinkedList<>(); list.add(test1); list.add(test2); list.add(test3); @@ -167,7 +167,7 @@ public class MavenVersioningTest { list.add(test11); list.add(test12); - Collections.sort(list,new MavenLikeVersioningComparator()); + list.sort(new MavenLikeVersioningComparator()); //Collections.reverse(list); assertTrue(list.get(0).getVersion().equals("0.02")); assertTrue(list.get(1).getVersion().equals("1.1")); diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java index 97eadb3f1d..c17b50e738 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java @@ -46,8 +46,8 @@ public class NetworkRecipeTest { assertTrue(networkRecipe.getId() == 1); networkRecipe.setModelName("modelName"); assertTrue(networkRecipe.getModelName().equalsIgnoreCase("modelName")); - networkRecipe.setNetworkParamXSD("networkParamXSD"); - assertTrue(networkRecipe.getNetworkParamXSD().equalsIgnoreCase("networkParamXSD")); + networkRecipe.setParamXSD("networkParamXSD"); + assertTrue(networkRecipe.getParamXSD().equalsIgnoreCase("networkParamXSD")); networkRecipe.setOrchestrationUri("orchestrationUri"); assertTrue(networkRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); networkRecipe.setRecipeTimeout(1); diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java index 95e45f7b52..3f707871a6 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java @@ -52,8 +52,8 @@ public class VnfRecipeTest { assertTrue(vnfRecipe.getServiceType().equalsIgnoreCase("serviceType"));
vnfRecipe.setVersion("version");
assertTrue(vnfRecipe.getVersion().equalsIgnoreCase("version"));
- vnfRecipe.setVnfParamXSD("vnfParamXSD");
- assertTrue(vnfRecipe.getVnfParamXSD().equalsIgnoreCase("vnfParamXSD"));
+ vnfRecipe.setParamXSD("vnfParamXSD");
+ assertTrue(vnfRecipe.getParamXSD().equalsIgnoreCase("vnfParamXSD"));
vnfRecipe.setVfModuleId("vfModuleId");
assertTrue(vnfRecipe.getVfModuleId().equalsIgnoreCase("vfModuleId"));
// assertTrue(vnfRecipe.toString() == null);
diff --git a/packages/arquillian-unit-tests/pom.xml b/packages/arquillian-unit-tests/pom.xml index 0abe819253..8420cf457d 100644 --- a/packages/arquillian-unit-tests/pom.xml +++ b/packages/arquillian-unit-tests/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>packages</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.packages</groupId> + <groupId>org.onap.so.packages</groupId> <name>Arquillian Unit Testing on MSO</name> <artifactId>arquillian-unit-tests</artifactId> @@ -197,7 +197,7 @@ </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>asdc-controller</artifactId> <version>${project.version}</version> <scope>test</scope> @@ -226,7 +226,7 @@ </dependency> <dependency> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/packages/deliveries/pom.xml b/packages/deliveries/pom.xml index 9ce0ac8551..a90568811a 100644 --- a/packages/deliveries/pom.xml +++ b/packages/deliveries/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>packages</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.so.packages</groupId> + <groupId>org.onap.so.packages</groupId> <artifactId>mso-deliveries</artifactId> <packaging>pom</packaging> diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 41086eab04..1957dc7928 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -3,13 +3,13 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>packages</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> <packaging>pom</packaging> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>docker</artifactId> <name>MSO Docker Deliveries</name> diff --git a/packages/pom.xml b/packages/pom.xml index ff1be1fad0..74d4c309a4 100644 --- a/packages/pom.xml +++ b/packages/pom.xml @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>packages</artifactId>
<packaging>pom</packaging>
<name>MSO Packages</name>
@@ -1,7 +1,6 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent</artifactId> @@ -9,7 +8,7 @@ <relativePath /> </parent> - <groupId>org.openecomp.so</groupId> + <groupId>org.onap.so</groupId> <artifactId>so</artifactId> <packaging>pom</packaging> <!-- <version>1.2.0-SNAPSHOT</version> --> @@ -32,7 +31,7 @@ <module>status-control</module> <module>bpmn</module> <module>packages</module> - <!-- <module>aria/aria-rest-server</module> --> + <!--module>aria</module--> </modules> <properties> <project.mso.base.folder>.</project.mso.base.folder> diff --git a/status-control/pom.xml b/status-control/pom.xml index 2339825be4..e8ba05e065 100644 --- a/status-control/pom.xml +++ b/status-control/pom.xml @@ -4,29 +4,29 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<name>MSO Status Control module</name>
<description>Contains classes to update and query the MSO status per site</description>
<dependencies>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
<version>${project.version}</version>
</dependency>
|