diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 03:53:18 -0700 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-02 06:59:21 -0700 |
commit | 94ee92559b051f2f82ed681f841f4f13016842ed (patch) | |
tree | 9760a0ad7da03572ed4c9dc596c4b0f537e64112 /adapters | |
parent | 43bbca64032716730d2e7795b6569d5fdbda9d12 (diff) |
[MSO-8] Second step of the rebase for MSO
Second rebase containing additional features for MSO + total reworking
of the BPMN structure + Notification flow can now be added at the end of
some BPMN flows
Change-Id: I7e937c7a0ba1593ca85e164a093f79c7e38b6ce0
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'adapters')
58 files changed, 2903 insertions, 1264 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java index a765f8004e..5ef33a3e04 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java @@ -1,29 +1,29 @@ -/*- - * ============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.cloud; - -/** - * This interface provides the method signature for mapping registration. - * All mappings should be registered by the implementing class. - */ -public interface CloudConfigIdentityMapper { - - public void registerAllMappings(); -} +/*-
+ * ============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.cloud;
+
+/**
+ * This interface provides the method signature for mapping registration.
+ * All mappings should be registered by the implementing class.
+ */
+public interface CloudConfigIdentityMapper {
+
+ public void registerAllMappings();
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java index 45a79730ad..d36f775be9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java @@ -1,75 +1,75 @@ -/*- - * ============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.cloud; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; - -public abstract class IdentityAuthenticationTypeAbstract { - - // This map will prevent duplicates (as if it was an Enum). - // Without this, using an instance specific field for the class could allow - // different classes bound to the same entry name. - private static final Map<String, IdentityAuthenticationTypeAbstract> entries = new ConcurrentHashMap<>(); - - private String identityType; - - private Class<? extends AuthenticationWrapper> wrapperClass; - - protected IdentityAuthenticationTypeAbstract(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) { - try { - this.identityType = identityType; - this.wrapperClass = wrapperClass; - entries.put(identityType, this); - AuthenticationWrapper.register(this.toString(), wrapperClass); - } catch (IllegalAccessException | InstantiationException e) { - // Do not add the class if an exception occurs as we won't get the class anyway - } - } - - public static final IdentityAuthenticationTypeAbstract valueOf(String serverType) { - return entries.get(serverType); - } - - @Override - public final String toString() { - return this.identityType; - } - - public final String name() { - return this.identityType; - } - - public static final IdentityAuthenticationTypeAbstract[] values() { - return (IdentityAuthenticationTypeAbstract[]) entries.values().stream().toArray(IdentityAuthenticationTypeAbstract[]::new); - } - - public final Class<? extends AuthenticationWrapper> getWrapperClass() { - return this.wrapperClass; - } - - @Override - public final boolean equals(Object other) { - return ((this.identityType != null) && (other != null) && (other instanceof IdentityAuthenticationTypeAbstract) && (this.identityType.equals(other.toString()))); - } - -} +/*-
+ * ============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.cloud;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+
+public abstract class IdentityAuthenticationTypeAbstract {
+
+ // This map will prevent duplicates (as if it was an Enum).
+ // Without this, using an instance specific field for the class could allow
+ // different classes bound to the same entry name.
+ private static final Map<String, IdentityAuthenticationTypeAbstract> entries = new ConcurrentHashMap<>();
+
+ private String identityType;
+
+ private Class<? extends AuthenticationWrapper> wrapperClass;
+
+ protected IdentityAuthenticationTypeAbstract(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) {
+ try {
+ this.identityType = identityType;
+ this.wrapperClass = wrapperClass;
+ entries.put(identityType, this);
+ AuthenticationWrapper.register(this.toString(), wrapperClass);
+ } catch (IllegalAccessException | InstantiationException e) {
+ // Do not add the class if an exception occurs as we won't get the class anyway
+ }
+ }
+
+ public static final IdentityAuthenticationTypeAbstract valueOf(String serverType) {
+ return entries.get(serverType);
+ }
+
+ @Override
+ public final String toString() {
+ return this.identityType;
+ }
+
+ public final String name() {
+ return this.identityType;
+ }
+
+ public static final IdentityAuthenticationTypeAbstract[] values() {
+ return (IdentityAuthenticationTypeAbstract[]) entries.values().stream().toArray(IdentityAuthenticationTypeAbstract[]::new);
+ }
+
+ public final Class<? extends AuthenticationWrapper> getWrapperClass() {
+ return this.wrapperClass;
+ }
+
+ @Override
+ public final boolean equals(Object other) {
+ return ((this.identityType != null) && (other != null) && (other instanceof IdentityAuthenticationTypeAbstract) && (this.identityType.equals(other.toString())));
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java index c7b2c14cb8..fd6ead2223 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java @@ -1,44 +1,43 @@ -/*- - * ============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.cloud; - -import java.io.IOException; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.JsonToken; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; - - -public class IdentityAuthenticationTypeJsonDeserializer extends JsonDeserializer<IdentityAuthenticationTypeAbstract> { - - @Override - public IdentityAuthenticationTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) - throws IOException, JsonProcessingException { - JsonToken token = jsonParser.getCurrentToken(); - if (JsonToken.VALUE_STRING.equals(token)) { - return IdentityAuthenticationTypeAbstract.valueOf(jsonParser.getText()); - } else { - return null; - } - } -} +/*-
+ * ============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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+public class IdentityAuthenticationTypeJsonDeserializer extends JsonDeserializer<IdentityAuthenticationTypeAbstract> {
+
+ @Override
+ public IdentityAuthenticationTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
+ throws IOException, JsonProcessingException {
+ JsonToken token = jsonParser.getCurrentToken();
+ if (JsonToken.VALUE_STRING.equals(token)) {
+ return IdentityAuthenticationTypeAbstract.valueOf(jsonParser.getText());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java index 06d877d4fa..b599066677 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java @@ -1,38 +1,38 @@ -/*- - * ============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.cloud; - -import java.io.IOException; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; - - -public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> { - - @Override - public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) - throws IOException, JsonProcessingException { - jsonGenerator.writeObject(tmpObj.toString()); - } -} +/*-
+ * ============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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> {
+
+ @Override
+ public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+ throws IOException, JsonProcessingException {
+ jsonGenerator.writeObject(tmpObj.toString());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java index 38f1f87ddc..d2658bcd23 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java @@ -1,77 +1,77 @@ -/*- - * ============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.cloud; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.openecomp.mso.openstack.utils.MsoTenantUtils; - - -public abstract class IdentityServerTypeAbstract { - - // This map will prevent duplicates (as if it was an Enum). - // Without this, using an instance specific field for the class could allow - // different classes bound to the same entry name. - private static final Map<String, IdentityServerTypeAbstract> entries = new ConcurrentHashMap<>(); - - private String serverType; - - private Class<? extends MsoTenantUtils> utilsClass; - - protected IdentityServerTypeAbstract(String serverType, Class<? extends MsoTenantUtils> utilsClass) { - if ((serverType == null) || (serverType.isEmpty())) { - throw new IllegalArgumentException("Server Type name cannot be null or empty, provided value was " + serverType); - } - if (entries.containsKey(serverType)) { - throw new IllegalArgumentException("Duplicate Server Type entry for registration: " + serverType); - } - this.serverType = serverType; - this.utilsClass = utilsClass; - entries.put(serverType, this); - } - - public static final IdentityServerTypeAbstract valueOf(String serverType) { - return entries.get(serverType); - } - - @Override - public final String toString() { - return this.serverType; - } - - public final String name() { - return this.serverType; - } - - public static final IdentityServerTypeAbstract[] values() { - return (IdentityServerTypeAbstract[]) entries.values().stream().toArray(IdentityServerTypeAbstract[]::new); - } - - public final Class<? extends MsoTenantUtils> getMsoTenantUtilsClass() { - return this.utilsClass; - } - - @Override - public final boolean equals(Object other) { - return ((this.serverType != null) && (other != null) && (other instanceof IdentityServerTypeAbstract) && (this.serverType.equals(other.toString()))); - } - -} +/*-
+ * ============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.cloud;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.mso.openstack.utils.MsoTenantUtils;
+
+
+public abstract class IdentityServerTypeAbstract {
+
+ // This map will prevent duplicates (as if it was an Enum).
+ // Without this, using an instance specific field for the class could allow
+ // different classes bound to the same entry name.
+ private static final Map<String, IdentityServerTypeAbstract> entries = new ConcurrentHashMap<>();
+
+ private String serverType;
+
+ private Class<? extends MsoTenantUtils> utilsClass;
+
+ protected IdentityServerTypeAbstract(String serverType, Class<? extends MsoTenantUtils> utilsClass) {
+ if ((serverType == null) || (serverType.isEmpty())) {
+ throw new IllegalArgumentException("Server Type name cannot be null or empty, provided value was " + serverType);
+ }
+ if (entries.containsKey(serverType)) {
+ throw new IllegalArgumentException("Duplicate Server Type entry for registration: " + serverType);
+ }
+ this.serverType = serverType;
+ this.utilsClass = utilsClass;
+ entries.put(serverType, this);
+ }
+
+ public static final IdentityServerTypeAbstract valueOf(String serverType) {
+ return entries.get(serverType);
+ }
+
+ @Override
+ public final String toString() {
+ return this.serverType;
+ }
+
+ public final String name() {
+ return this.serverType;
+ }
+
+ public static final IdentityServerTypeAbstract[] values() {
+ return (IdentityServerTypeAbstract[]) entries.values().stream().toArray(IdentityServerTypeAbstract[]::new);
+ }
+
+ public final Class<? extends MsoTenantUtils> getMsoTenantUtilsClass() {
+ return this.utilsClass;
+ }
+
+ @Override
+ public final boolean equals(Object other) {
+ return ((this.serverType != null) && (other != null) && (other instanceof IdentityServerTypeAbstract) && (this.serverType.equals(other.toString())));
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java index 8b9da1a3f4..c07954d733 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java @@ -1,44 +1,46 @@ -/*- - * ============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.cloud; - -import java.io.IOException; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.JsonToken; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; - - -public class IdentityServerTypeJsonDeserializer extends JsonDeserializer<IdentityServerTypeAbstract> { - - @Override - public IdentityServerTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) - throws IOException, JsonProcessingException { - JsonToken token = jsonParser.getCurrentToken(); - if (JsonToken.VALUE_STRING.equals(token)) { - return IdentityServerTypeAbstract.valueOf(jsonParser.getText()); - } else { - return null; - } - } -} +/*-
+ * ============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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityServerTypeJsonDeserializer extends JsonDeserializer<IdentityServerTypeAbstract> {
+
+ @Override
+ public IdentityServerTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
+ throws IOException, JsonProcessingException {
+ JsonToken token = jsonParser.getCurrentToken();
+ if (JsonToken.VALUE_STRING.equals(token)) {
+ return IdentityServerTypeAbstract.valueOf(jsonParser.getText());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java index c008860264..6db8e5b7ac 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java @@ -1,38 +1,38 @@ -/*- - * ============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.cloud; - -import java.io.IOException; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; - - -public class IdentityServerTypeJsonSerializer extends JsonSerializer<IdentityServerTypeAbstract> { - - @Override - public void serialize(IdentityServerTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) - throws IOException, JsonProcessingException { - jsonGenerator.writeObject(tmpObj.toString()); - } -} +/*-
+ * ============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.cloud;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+
+
+public class IdentityServerTypeJsonSerializer extends JsonSerializer<IdentityServerTypeAbstract> {
+
+ @Override
+ public void serialize(IdentityServerTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+ throws IOException, JsonProcessingException {
+ jsonGenerator.writeObject(tmpObj.toString());
+ }
+}
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 feaafd3c07..8236307f45 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 @@ -1,79 +1,79 @@ -/* - * ============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 java.io.IOException; -import java.net.URISyntaxException; -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 { - - private static Map<String, AuthenticationWrapper> authWrappers = new ConcurrentHashMap<>(); - - /** - * - */ - private AuthenticationMethodFactory() {} - - /** - * Function to be called by classes implementing the abstract {@link AuthenticationWrapper#register(String, Class)}. - */ - static final synchronized void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException { - if ((authenticationType == null) || ("".equals(authenticationType))) { - throw new IllegalArgumentException("Authentication Type to register cannot be null or an empty name string, provided value is " + authenticationType + "."); - } - if (wrapperClass == null) { - throw new IllegalArgumentException("Wrapper Class to register for Authentication cannot be null"); - } - - if (!authWrappers.containsKey(authenticationType)) { - authWrappers.put(authenticationType, wrapperClass.newInstance()); - } - } - - public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException { - if (cloudIdentity == null) { - throw new IllegalArgumentException("Cloud identity cannot be null"); - } - if ((cloudIdentity.getIdentityAuthenticationType() == null) || ("".equals(cloudIdentity.getIdentityAuthenticationType().toString()))) { - throw new IllegalArgumentException("Cloud identity authentication type cannot be null or empty, provided value is " + cloudIdentity.getIdentityAuthenticationType() + "."); - } - String authenticationType = cloudIdentity.getIdentityAuthenticationType().toString(); - - if (authWrappers.containsKey(authenticationType)) { - return authWrappers.get(authenticationType).getAuthentication(cloudIdentity); - } else { - throw new IllegalArgumentException("Provided authentication type (" + authenticationType + ") is not implemented by any wrapper."); - } - } -} +/*
+ * ============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 java.io.IOException;
+import java.net.URISyntaxException;
+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 {
+
+ private static Map<String, AuthenticationWrapper> authWrappers = new ConcurrentHashMap<>();
+
+ /**
+ *
+ */
+ private AuthenticationMethodFactory() {}
+
+ /**
+ * Function to be called by classes implementing the abstract {@link AuthenticationWrapper#register(String, Class)}.
+ */
+ static final synchronized void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException {
+ if ((authenticationType == null) || ("".equals(authenticationType))) {
+ throw new IllegalArgumentException("Authentication Type to register cannot be null or an empty name string, provided value is " + authenticationType + ".");
+ }
+ if (wrapperClass == null) {
+ throw new IllegalArgumentException("Wrapper Class to register for Authentication cannot be null");
+ }
+
+ if (!authWrappers.containsKey(authenticationType)) {
+ authWrappers.put(authenticationType, wrapperClass.newInstance());
+ }
+ }
+
+ public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException {
+ if (cloudIdentity == null) {
+ throw new IllegalArgumentException("Cloud identity cannot be null");
+ }
+ if ((cloudIdentity.getIdentityAuthenticationType() == null) || ("".equals(cloudIdentity.getIdentityAuthenticationType().toString()))) {
+ throw new IllegalArgumentException("Cloud identity authentication type cannot be null or empty, provided value is " + cloudIdentity.getIdentityAuthenticationType() + ".");
+ }
+ String authenticationType = cloudIdentity.getIdentityAuthenticationType().toString();
+
+ if (authWrappers.containsKey(authenticationType)) {
+ return authWrappers.get(authenticationType).getAuthentication(cloudIdentity);
+ } else {
+ throw new IllegalArgumentException("Provided authentication type (" + authenticationType + ") is not implemented by any wrapper.");
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java index 8b3725cd41..77f405a660 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java @@ -1,58 +1,58 @@ -/* - * ============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 org.openecomp.mso.cloud.CloudIdentity; - -import com.woorea.openstack.keystone.model.Authentication; - -/** - * This abstract class provides the necessary method for registering authentication - * types with wrapper classes, and also defines the contract for providing - * Openstack-compatible Authentication implementations for said authentication types. - * - */ -public abstract class AuthenticationWrapper { - - /** - * Registers the implementing class to the list of Authentication Wrappers. - * - * @param authenticationType The authentication type that is provided by the implementing class - * @param wrapperClass The implementing class Class object - * @throws InstantiationException If the provided implementing class cannot be instantiated - * @throws IllegalAccessException If the provided implementing class cannot be instantiated - */ - public static final void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException { - AuthenticationMethodFactory.register(authenticationType, wrapperClass); - } - - /** - * Returns an OpenStack Authentication object for the provided CloudIdentity. - * - * @param cloudIdentity The input Cloud Identity instance - * @return the OpenStack Authentication associated with this cloud identity instance - */ - protected abstract Authentication getAuthentication(CloudIdentity cloudIdentity); - -} +/*
+ * ============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 org.openecomp.mso.cloud.CloudIdentity;
+
+import com.woorea.openstack.keystone.model.Authentication;
+
+/**
+ * This abstract class provides the necessary method for registering authentication
+ * types with wrapper classes, and also defines the contract for providing
+ * Openstack-compatible Authentication implementations for said authentication types.
+ *
+ */
+public abstract class AuthenticationWrapper {
+
+ /**
+ * Registers the implementing class to the list of Authentication Wrappers.
+ *
+ * @param authenticationType The authentication type that is provided by the implementing class
+ * @param wrapperClass The implementing class Class object
+ * @throws InstantiationException If the provided implementing class cannot be instantiated
+ * @throws IllegalAccessException If the provided implementing class cannot be instantiated
+ */
+ public static final void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException {
+ AuthenticationMethodFactory.register(authenticationType, wrapperClass);
+ }
+
+ /**
+ * Returns an OpenStack Authentication object for the provided CloudIdentity.
+ *
+ * @param cloudIdentity The input Cloud Identity instance
+ * @return the OpenStack Authentication associated with this cloud identity instance
+ */
+ protected abstract Authentication getAuthentication(CloudIdentity cloudIdentity);
+
+}
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 87ff2582de..5cf5587481 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 @@ -1,55 +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 org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; -import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; - -import com.woorea.openstack.keystone.model.Authentication; - -/** - * This class implements the authentication wrapper for Rackspace 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) { - throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password"); - } - return new RackspaceAuthentication (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ()); - } -} +/*
+ * ============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;
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
+
+import com.woorea.openstack.keystone.model.Authentication;
+
+/**
+ * This class implements the authentication wrapper for Rackspace 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) {
+ throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password");
+ }
+ return new RackspaceAuthentication (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ());
+ }
+}
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 2eebbb7d4b..5fd3e521f0 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 @@ -1,55 +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 org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; - -import com.woorea.openstack.keystone.model.Authentication; -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) { - throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password"); - } - return new UsernamePassword (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ()); - } -} +/*
+ * ============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;
+import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+
+import com.woorea.openstack.keystone.model.Authentication;
+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) {
+ throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password");
+ }
+ return new UsernamePassword (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java index 11a74d4494..0125cce287 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkRollback.java @@ -7,9 +7,9 @@ * 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. @@ -43,6 +43,7 @@ public class NetworkRollback { private String tenantId; private String cloudId; private String networkType; + private String modelCustomizationUuid; private boolean networkCreated = false; // Previous values for updates private String networkName = null; @@ -63,7 +64,7 @@ public class NetworkRollback { public void setNeutronNetworkId(String neutronNetworkId) { this.neutronNetworkId = neutronNetworkId; } - + public String getNetworkStackId() { return networkStackId; } @@ -91,6 +92,14 @@ public class NetworkRollback { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public boolean getNetworkCreated() { return networkCreated; } @@ -125,7 +134,7 @@ public class NetworkRollback { public void setMsoRequest (MsoRequest msoRequest) { this.msoRequest = msoRequest; } - + @Override public String toString() { return "NetworkRollback [networkId=" + networkId @@ -135,5 +144,5 @@ public class NetworkRollback { + ", networkCreated=" + networkCreated + ", networkName=" + networkName + ", physicalNetwork=" + physicalNetwork + "]"; } - + } 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 99d5863819..1c91fe2430 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 @@ -984,6 +984,7 @@ public class MsoHeatUtils extends MsoCommonUtils { String heatUrl = null; try { heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public"); + LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region); } catch (RuntimeException e) { // This comes back for not found (probably an incorrect region ID) String error = "Orchestration service not found: region=" + region + ",cloud=" + cloudIdentity.getId (); 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 beb85a4a8e..ccfede7297 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 @@ -1,115 +1,115 @@ -/* - * ============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.junit.Assert.assertTrue; - -import java.io.IOException; -import java.net.URISyntaxException; - -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 - * types and their associated wrapper classes. Here it is assumed that core types - * only are tested. - * - */ -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(); - } - } - - @Test - public void testCoreUsernamePasswordAuthFromCloudIdentity() { - CloudIdentity ci = new CloudIdentity(); - 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(); - } - } -} +/*
+ * ============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.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+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
+ * types and their associated wrapper classes. Here it is assumed that core types
+ * only are tested.
+ *
+ */
+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();
+ }
+ }
+
+ @Test
+ public void testCoreUsernamePasswordAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ 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();
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java index 1cbba3c45e..4b4f2b8c94 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java @@ -1,56 +1,56 @@ -/** - * - */ -package org.openecomp.mso.cloud.servertype; - -import java.util.Map; - -import org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.openstack.beans.MsoTenant; -import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.utils.MsoTenantUtils; - - -public class NewServerTypeUtils extends MsoTenantUtils { - - /** - * @param msoPropID - */ - public NewServerTypeUtils(String msoPropID) { - super(msoPropID); - } - - @Override - public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout) - throws MsoException { - // TODO Auto-generated method stub - return null; - } - - @Override - public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound { - // TODO Auto-generated method stub - return null; - } - - @Override - public MsoTenant queryTenantByName(String tenantName, String cloudSiteId) - throws MsoException, MsoCloudSiteNotFound { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) - throws MsoException { - return msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl(); - } - -} +/**
+ *
+ */
+package org.openecomp.mso.cloud.servertype;
+
+import java.util.Map;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.openstack.beans.MsoTenant;
+import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoTenantUtils;
+
+
+public class NewServerTypeUtils extends MsoTenantUtils {
+
+ /**
+ * @param msoPropID
+ */
+ public NewServerTypeUtils(String msoPropID) {
+ super(msoPropID);
+ }
+
+ @Override
+ public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
+ throws MsoException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MsoTenant queryTenantByName(String tenantName, String cloudSiteId)
+ throws MsoException, MsoCloudSiteNotFound {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity)
+ throws MsoException {
+ return msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl();
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java index e2a0f865a0..9ac25136cc 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java @@ -1,63 +1,63 @@ -/** - * - */ -package org.openecomp.mso.cloud.servertype; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.Test; -import org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; -import org.openecomp.mso.cloud.IdentityServerTypeAbstract; -import org.openecomp.mso.openstack.exceptions.MsoException; - -public class ServerTypeTest { - - @Test - public void testKeystoneServerType() { - IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE"); - assertNotNull(keystoneServerType); - } - - @Test - public void testNewServerType() { - IdentityServerTypeAbstract customServerType = null; - try { - customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class); - - } catch (IllegalArgumentException e) { - fail("An exception should not be raised when we register a new server type for the first time"); - } finally { - System.out.println(IdentityServerType.values().toString()); - assertEquals(customServerType, IdentityServerType.valueOf("NewServerType")); - } - - // Create it a second time - IdentityServerTypeAbstract customServerType2 = null; - try { - customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class); - fail("An exception should be raised as server type does not exist"); - } catch (IllegalArgumentException e) { - // Fail silently -- it simply indicates we already registered it - customServerType2 = IdentityServerType.valueOf("NewServerType"); - } finally { - System.out.println(IdentityServerType.values().toString()); - assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType")); - } - - // Check the KeystoneURL for this custom TenantUtils - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setIdentityUrl("LocalIdentity"); - cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY); - cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType")); - String regionId = "RegionA"; - String msoPropID = "12345"; - try { - assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl()); - } catch (MsoException e) { - fail("No MSO Exception should have occured here"); - } - } -} +/**
+ *
+ */
+package org.openecomp.mso.cloud.servertype;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
+import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+
+public class ServerTypeTest {
+
+ @Test
+ public void testKeystoneServerType() {
+ IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
+ assertNotNull(keystoneServerType);
+ }
+
+ @Test
+ public void testNewServerType() {
+ IdentityServerTypeAbstract customServerType = null;
+ try {
+ customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
+
+ } catch (IllegalArgumentException e) {
+ fail("An exception should not be raised when we register a new server type for the first time");
+ } finally {
+ System.out.println(IdentityServerType.values().toString());
+ assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
+ }
+
+ // Create it a second time
+ IdentityServerTypeAbstract customServerType2 = null;
+ try {
+ customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
+ fail("An exception should be raised as server type does not exist");
+ } catch (IllegalArgumentException e) {
+ // Fail silently -- it simply indicates we already registered it
+ customServerType2 = IdentityServerType.valueOf("NewServerType");
+ } finally {
+ System.out.println(IdentityServerType.values().toString());
+ assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
+ }
+
+ // Check the KeystoneURL for this custom TenantUtils
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl("LocalIdentity");
+ cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
+ cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
+ String regionId = "RegionA";
+ String msoPropID = "12345";
+ try {
+ assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
+ } catch (MsoException e) {
+ fail("No MSO Exception should have occured here");
+ }
+ }
+}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java index b8c70dd193..4183cbb974 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/CreateNetworkRequest.java @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,7 @@ import org.codehaus.jackson.map.annotate.JsonRootName; /* README * 1) Used JAXB/Jettison - see @NoJackson annotation on class to get RootElements REad by RestEasy -* 2) due to 1) Maps need to use this format +* 2) due to 1) Maps need to use this format "networkParams": {"entry": [ {"key": "network_id", @@ -47,7 +47,7 @@ import org.codehaus.jackson.map.annotate.JsonRootName; {"key": "server_name_0", "value": "RaaNetwork1"} ]}, - * 3) to output json see toJSonString method below which required the @JsonRootName annotation and the WRAP_ROOT feature enabled + * 3) to output json see toJSonString method below which required the @JsonRootName annotation and the WRAP_ROOT feature enabled * 4) Tryong to work with RESTEASY JACKSON and JAXB/JETTISON to conform to Json input/output specs */ @JsonRootName("createNetworkRequest") @@ -60,6 +60,7 @@ public class CreateNetworkRequest extends NetworkRequestCommon { private String networkName; private String networkType; private String networkTypeVersion; + private String modelCustomizationUuid; private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; @@ -113,6 +114,14 @@ public class CreateNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getNetworkTypeVersion() { return networkTypeVersion; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java index 62c308d142..8bfad978d0 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/DeleteNetworkRequest.java @@ -7,9 +7,9 @@ * 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. @@ -39,10 +39,11 @@ public class DeleteNetworkRequest extends NetworkRequestCommon { private String networkId; private String networkStackId; private String networkType; + private String modelCustomizationUuid; private MsoRequest msoRequest = new MsoRequest(); public DeleteNetworkRequest() {} - + public String getCloudSiteId() { return cloudSiteId; } @@ -83,6 +84,14 @@ public class DeleteNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public MsoRequest getMsoRequest() { return msoRequest; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java index 5ddc050131..db2c2132e6 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java @@ -7,9 +7,9 @@ * 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. @@ -44,6 +44,7 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { private String networkName; private String networkType; private String networkTypeVersion; + private String modelCustomizationUuid; private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; @@ -104,6 +105,14 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { this.networkType = networkType; } + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getNetworkTypeVersion() { return networkTypeVersion; } diff --git a/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml index 98b6860366..750bba7633 100644 --- a/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-catalog-db-adapter/WebContent/WEB-INF/web.xml @@ -24,7 +24,22 @@ <servlet-name>Resteasy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> - + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/logging/*</url-pattern> + <url-pattern>/properties/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> <filter> <filter-name>LogFilter</filter-name> <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 828edf772d..e7c4b533c7 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -70,12 +70,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-adapters-rest-interface</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.0.19.Final</version> @@ -96,10 +90,15 @@ </exclusions> </dependency> <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jackson-provider</artifactId> + <version>3.0.16.Final</version> + </dependency> + <!--<dependency> <groupId>org.openecomp.mso</groupId> <artifactId>status-control</artifactId> <version>${project.version}</version> - </dependency> + </dependency>--> </dependencies> </project>
\ No newline at end of file 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 210e5e7074..20198d1543 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 @@ -73,12 +73,13 @@ import org.apache.http.HttpStatus; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; -import org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse; -import org.openecomp.mso.adapters.catalogrest.QueryServiceVnfs; -import org.openecomp.mso.adapters.catalogrest.QueryServiceNetworks; -import org.openecomp.mso.adapters.catalogrest.QueryServiceMacroHolder; -import org.openecomp.mso.adapters.catalogrest.QueryAllottedResourceCustomization; +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.db.catalog.CatalogDatabase; import org.openecomp.mso.db.catalog.beans.VnfResource; import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; @@ -90,16 +91,28 @@ import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. * Requests respond synchronously only */ -@Path("/v1") +@Path("/{version: v[0-9]+}") public class CatalogDbAdapterRest { private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final boolean IS_ARRAY = true; + + public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { + return Response + .status(respStatus) + //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {}) + .entity(qryResp.toJsonString(version, isArray)) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } @HEAD @GET @Path("healthcheck") @Produces(MediaType.TEXT_HTML) - public Response healthcheck () { - String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + public Response healthcheck ( + @PathParam("version") String version + ) { + String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application "+ version+ " ready</body></html>"; return Response.ok().entity(CHECK_HTML).build(); } @@ -109,23 +122,38 @@ public class CatalogDbAdapterRest { * RESP: * {"queryVfModule":{"version":1,"asdcUuid":"MANUAL RECORD","created":{"nanos":0},"description":"vSAMP10","environmentId":15184,"id":2312,"isBase":1,"modelName":"vSAMP10::base::module-0","modelVersion":1,"templateId":15123,"type":"Test\/vSAMP10::vSAMP10::base::module-0","vnfResourceId":15187}} */ + + @GET + @Path("vnfs/{vnfModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceVnfs ( + @PathParam("version") String version, + @PathParam("vnfModelCustomizationUuid") String vnfUuid + ) { + return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null); + } + @GET @Path("serviceVnfs") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response serviceVnfs( + @PathParam("version") String version, @QueryParam("vnfModelCustomizationUuid") String vnfUuid, @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid, @QueryParam("serviceModelVersion") String smVer, @QueryParam("serviceModelName") String smName - ) { + ) { + return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName); + } + + public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String smUuid, String smiUuid, String smVer, String smName) { QueryServiceVnfs qryResp; int respStatus = HttpStatus.SC_OK; String uuid = ""; List<VnfResource> ret; - try (CatalogDatabase db = new CatalogDatabase()) { - + try (CatalogDatabase db = new CatalogDatabase()) { if (vnfUuid != null && !vnfUuid.equals("")) { uuid = vnfUuid; LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid); @@ -157,6 +185,16 @@ public class CatalogDbAdapterRest { ret = db.getAllVnfsByServiceName(smName); } } + else if (smName != null && !smName.equals("")) { + if (smVer != null && !smVer.equals("")) { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer); + ret = db.getAllVnfsByServiceName(smName, smVer); + } + else { + LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName); + ret = db.getAllVnfsByServiceName(smName); + } + } else { throw(new Exception("no matching parameters")); } @@ -169,41 +207,50 @@ public class CatalogDbAdapterRest { LOGGER.debug ("serviceVnfs found"); qryResp = new QueryServiceVnfs(ret); LOGGER.debug ("serviceVnfs qryResp="+ qryResp); - LOGGER.debug ("serviceVnfs tojsonstring="+ qryResp.toJsonString()); } LOGGER.debug ("Query serviceVnfs exit"); - return Response - .status(respStatus) - //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {}) - .entity(qryResp.toJsonString()) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); + return respond(version, respStatus, isArray, qryResp); } catch (Exception e) { LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e); - VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) .build(); } } @GET + @Path("networks/{networkModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceNetworks ( + @PathParam("version") String version, + @PathParam("networkModelCustomizationUuid") String nUuid + ) { + return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null); + } + + @GET @Path("serviceNetworks") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response serviceNetworks ( + @PathParam("version") String version, @QueryParam("networkModelCustomizationUuid") String nUuid, @QueryParam("networkType") String nType, @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid, @QueryParam("serviceModelVersion") String smVer - ) { + ) { + return serviceNetworksImpl (version, IS_ARRAY, nUuid, nType, smUuid, smiUuid, smVer); + } + + public Response serviceNetworksImpl (String version, boolean isArray, String nUuid, String nType, String smUuid, String smiUuid, String smVer) { QueryServiceNetworks qryResp; int respStatus = HttpStatus.SC_OK; String uuid = ""; List<NetworkResourceCustomization> ret; - try (CatalogDatabase db = new CatalogDatabase()) { + try (CatalogDatabase db = new CatalogDatabase()) { if (nUuid != null && !nUuid.equals("")) { uuid = nUuid; LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid); @@ -242,21 +289,15 @@ public class CatalogDbAdapterRest { LOGGER.debug ("serviceNetworks found"); qryResp = new QueryServiceNetworks(ret); LOGGER.debug ("serviceNetworks qryResp="+ qryResp); - LOGGER.debug ("serviceNetworks tojsonstring="+ qryResp.toJsonString()); } LOGGER.debug ("Query serviceNetworks exit"); - return Response - .status(respStatus) - //.entity(new GenericEntity<QueryServiceNetworks>(qryResp) {}) - .entity(qryResp.toJsonString()) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); + return respond(version, respStatus, isArray, qryResp); } catch (Exception e) { LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e); - VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) .build(); } } @@ -265,17 +306,16 @@ public class CatalogDbAdapterRest { @Path("serviceResources") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response serviceResources( + @PathParam("version") String version, @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid, - @QueryParam("serviceModelVersion") String smVer - ) { + @QueryParam("serviceModelVersion") String smVer) { QueryServiceMacroHolder qryResp; int respStatus = HttpStatus.SC_OK; String uuid = ""; ServiceMacroHolder ret; - try (CatalogDatabase db = new CatalogDatabase()) { - + try (CatalogDatabase db = new CatalogDatabase()) { if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid); @@ -304,41 +344,49 @@ public class CatalogDbAdapterRest { LOGGER.debug ("serviceMacroHolder found"); qryResp = new QueryServiceMacroHolder(ret); LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp); - LOGGER.debug ("serviceMacroHolder tojsonstring="+ qryResp.toJsonString()); } LOGGER.debug ("Query serviceMacroHolder exit"); - return Response - .status(respStatus) - //.entity(new GenericEntity<QueryServiceMacroHolder>(qryResp) {}) - .entity(qryResp.toJsonString()) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); + return respond(version, respStatus, IS_ARRAY, qryResp); } catch (Exception e) { LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e); - VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) .build(); } } @GET + @Path("allottedResources/{arModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceAllottedResources ( + @PathParam("version") String version, + @PathParam("arModelCustomizationUuid") String aUuid + ) { + return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null); + } + + @GET @Path("serviceAllottedResources") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response serviceAllottedResources( + @PathParam("version") String version, @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid, @QueryParam("serviceModelVersion") String smVer, @QueryParam("arModelCustomizationUuid") String aUuid - ) { + ) { + return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer); + } + + public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String smiUuid, String smVer) { QueryAllottedResourceCustomization qryResp; int respStatus = HttpStatus.SC_OK; String uuid = ""; List<AllottedResourceCustomization > ret; - try (CatalogDatabase db = new CatalogDatabase()) { - + try (CatalogDatabase db = new CatalogDatabase()) { if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid); @@ -372,21 +420,15 @@ public class CatalogDbAdapterRest { LOGGER.debug ("AllottedResourceCustomization found"); qryResp = new QueryAllottedResourceCustomization(ret); LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp); - LOGGER.debug ("AllottedResourceCustomization tojsonstring="+ qryResp.toJsonString()); } LOGGER.debug ("Query AllottedResourceCustomization exit"); - return Response - .status(respStatus) - //.entity(new GenericEntity<QueryAllottedResourceCustomization>(qryResp) {}) - .entity(qryResp.toJsonString()) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); + return respond(version, respStatus, isArray, qryResp); } catch (Exception e) { LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e); - VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}) + .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 new file mode 100644 index 0000000000..565c4ff1e9 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.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.adapters.catalogdb.catalogrest; + +import org.openecomp.mso.logger.MsoLogger; +import org.codehaus.jackson.map.ObjectMapper; + +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class CatalogQuery { + protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + private static final boolean IS_EMBED = true; + + public abstract String JSON2(boolean isArray, boolean isEmbed); + + protected void put(Map<String, String> valueMap, String key, String value) { + valueMap.put(key, value == null? "null": '"'+ value+ '"'); + } + + protected void put(Map<String, String> valueMap, String key, Integer value) { + valueMap.put(key, value == null? "null": value.toString()); + } + + protected void put(Map<String, String> valueMap, String key, Boolean value) { + valueMap.put(key, value == null? "null": value? "true": "false"); + } + + protected String setTemplate(String template, Map<String, String> valueMap) { + 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\""); + } + m.appendTail(result); + LOGGER.debug ("CatalogQuery return:"+ result.toString()); + return result.toString(); + } + + /** + * The simple, clean, generic way to handle the interface + */ + protected String smartToJSON() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonString = mapper.writeValueAsString(this); + } + catch (Exception e) { + LOGGER.debug ("jsonString exception:"+e.getMessage()); + jsonString = "invalid"; //throws instead? + } + return jsonString; + } + + public String toJsonString(String version, boolean isArray) { + switch(version) { + case "v1": return smartToJSON(); + case "v2": return JSON2(isArray, !IS_EMBED); + default: + return ("invalid version: "+ version); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java new file mode 100644 index 0000000000..0fed791b0e --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java @@ -0,0 +1,57 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +@XmlRootElement(name = "catalogQueryException") +@NoJackson +public class CatalogQueryException extends CatalogQueryExceptionCommon implements Serializable { + private static final long serialVersionUID = -9062290006520066109L; + + private String message; + private CatalogQueryExceptionCategory category; + private Boolean rolledBack; + + public CatalogQueryException () {} + + public CatalogQueryException (String message) { + this.message = message; + } + + public CatalogQueryException (String message, CatalogQueryExceptionCategory category, boolean rolledBack, String messageid) { + super(messageid); + this.message = message; + this.category = category; + this.rolledBack = rolledBack; + } + + public String getMessage() { return message; } + public void setMessage(String message) { this.message = message; } + + public CatalogQueryExceptionCategory getCategory () { return category; } + public void setCategory (CatalogQueryExceptionCategory category) { this.category = category; } + + public Boolean getRolledBack() { return rolledBack; } + public void setRolledBack(Boolean rolledBack) { this.rolledBack = rolledBack; } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java new file mode 100644 index 0000000000..4fef8ac777 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java @@ -0,0 +1,22 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +public enum CatalogQueryExceptionCategory { OPENSTACK, IO, INTERNAL, USERDATA } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java new file mode 100644 index 0000000000..09a469d893 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java @@ -0,0 +1,64 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import java.io.ByteArrayOutputStream; + +public abstract class CatalogQueryExceptionCommon { + private String messageId; + + public CatalogQueryExceptionCommon() { messageId = null; } + public CatalogQueryExceptionCommon(String messageId) { this.messageId = messageId; } + + public String getMessageId() { return messageId; } + public void setMessageId(String messageId) { this.messageId = messageId; } + + public String toJsonString() { + try { + String jsonString = null; + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + return jsonString; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } +} 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 new file mode 100644 index 0000000000..9c81476f5d --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -0,0 +1,93 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceAllottedResources") +@NoJackson +public class QueryAllottedResourceCustomization extends CatalogQuery { + private List<AllottedResourceCustomization> allottedResourceCustomization; + private final String template = + "\t{ \"allottedResource\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n"+ + "\t}}"; + + public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<AllottedResourceCustomization>(); } + public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; } + + public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; } + public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { this.allottedResourceCustomization = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (AllottedResourceCustomization o : allottedResourceCustomization) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceAllottedResources\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (AllottedResourceCustomization o : allottedResourceCustomization) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } + +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java new file mode 100644 index 0000000000..5ac54164c7 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -0,0 +1,82 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.HashMap; +import java.util.Map; + +@XmlRootElement(name = "serviceResources") +@NoJackson +public class QueryServiceMacroHolder extends CatalogQuery { + private ServiceMacroHolder serviceMacroHolder; + private final String template = + "{ \"serviceResources\" : {\n"+ + "\t\"modelName\" : <SERVICE_MODEL_NAME>,\n"+ + "\t\"modelUuid\" : <SERVICE_MODEL_UUID>,\n"+ + "\t\"modelInvariantUuid\" : <SERVICE_MODEL_INVARIANT_ID>,\n"+ + "\t\"modelVersion\" : <SERVICE_MODEL_VERSION>,\n"+ + + "<_SERVICEVNFS_>,\n"+ + "<_SERVICENETWORKS_>,\n"+ + "<_SERVICEALLOTTEDRESOURCES_>\n"+ + "\t}}"; + + public QueryServiceMacroHolder() { super(); serviceMacroHolder = new ServiceMacroHolder(); } + public QueryServiceMacroHolder(ServiceMacroHolder vlist) { serviceMacroHolder = vlist; } + + public ServiceMacroHolder getServiceResources(){ return this.serviceMacroHolder; } + public void setServiceResources(ServiceMacroHolder v) { this.serviceMacroHolder = v; } + + @Override + public String toString () { return serviceMacroHolder.toString(); } + + @Override + public String JSON2(boolean isArray, boolean x) { + Service service = serviceMacroHolder.getService(); + if (service == null) return "\"serviceResources\": null"; + + StringBuffer buf = new StringBuffer(); + Map<String, String> valueMap = new HashMap<String, String>(); + + put(valueMap, "SERVICE_MODEL_NAME", service.getServiceName()); //getServiceModelName()); + put(valueMap, "SERVICE_MODEL_UUID", service.getServiceNameVersionId()); //getServiceModelUuid()); + put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID()); //getServiceModelInvariantId()); + put(valueMap, "SERVICE_MODEL_VERSION", service.getServiceVersion()); //getServiceModelVersion()); + + String subitem; + subitem = new QueryServiceVnfs(serviceMacroHolder.getVnfResources()).JSON2(true, true); + valueMap.put("_SERVICEVNFS_", subitem.replaceAll("(?m)^", "\t")); + + subitem = new QueryServiceNetworks(serviceMacroHolder.getNetworkResourceCustomization()).JSON2(true, true); + valueMap.put("_SERVICENETWORKS_", subitem.replaceAll("(?m)^", "\t")); + + subitem = new QueryAllottedResourceCustomization(serviceMacroHolder.getAllottedResourceCustomization()).JSON2(true, true); + valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll("(?m)^", "\t")); + + buf.append(this.setTemplate(template, valueMap)); + return buf.toString(); + } + +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..573a0c77a2 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -0,0 +1,102 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceNetworks") +@NoJackson +public class QueryServiceNetworks extends CatalogQuery { + private List<NetworkResourceCustomization> serviceNetworks; + private final String template = + "\t{ \"network\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>,\n"+ + "\t\t\"networkType\" : <NETWORK_TYPE>\n"+ + "\t}}"; + + public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<NetworkResourceCustomization>(); } + public QueryServiceNetworks(List<NetworkResourceCustomization> vlist) { + LOGGER.debug ("QueryServiceNetworks:"); + serviceNetworks = new ArrayList<NetworkResourceCustomization>(); + for (NetworkResourceCustomization o : vlist) { + LOGGER.debug (o.toString()); + serviceNetworks.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<NetworkResourceCustomization> getServiceNetworks(){ return this.serviceNetworks; } + public void setServiceNetworks(List<NetworkResourceCustomization> v) { this.serviceNetworks = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (NetworkResourceCustomization o : serviceNetworks) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceNetworks\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (NetworkResourceCustomization o : serviceNetworks) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + put(valueMap, "NETWORK_TYPE", o.getNetworkType()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..a917cd9efe --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -0,0 +1,106 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; +/* should be called QueryVnfResource.java */ + +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceVnfs") +@NoJackson +public class QueryServiceVnfs extends CatalogQuery { + private List<VnfResource> serviceVnfs; + private final String template = + "\t{ \"vnf\" : {\n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>,\n"+ + "<_VFMODULES_>\n"+ + "\t}}"; + + public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<VnfResource>(); } + public QueryServiceVnfs(List<VnfResource> vlist) { + LOGGER.debug ("QueryServiceVnfs:"); + serviceVnfs = new ArrayList<VnfResource>(); + for (VnfResource o : vlist) { + LOGGER.debug ("-- o is a serviceVnfs ----"); + LOGGER.debug (o.toString()); + serviceVnfs.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<VnfResource> getServiceVnfs(){ return this.serviceVnfs; } + public void setServiceVnfs(List<VnfResource> v) { this.serviceVnfs = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (VnfResource o : serviceVnfs) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuffer buf = new StringBuffer(); + if (!isEmbed && isArray) buf.append("{ "); + if (isArray) buf.append("\"serviceVnfs\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (VnfResource o : serviceVnfs) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); + + String subitem = new QueryVfModule(o.getVfModules()).JSON2(true, true); + valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + if (!isEmbed && isArray) buf.append("}"); + return buf.toString(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..e7113e60c5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java @@ -0,0 +1,105 @@ +/*- + * ============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.adapters.catalogdb.catalogrest; + +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.jboss.resteasy.annotations.providers.NoJackson; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "vfModules") +@NoJackson +public class QueryVfModule extends CatalogQuery { + private List<VfModule> vfModules; + private final String template = + "\t{ \"vfModule\" : { \n"+ + "\t\t\"modelName\" : <MODEL_NAME>,\n"+ + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+ + "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+ + "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+ + "\t\t\"vfModuleType\" : <VF_MODULE_TYPE>,\n"+ + "\t\t\"isBase\" : <IS_BASE>,\n"+ + "\t\t\"vfModuleLabel\" : <VF_MODULE_LABEL>,\n"+ + "\t\t\"initialCount\" : <INITIAL_COUNT>\n"+ + "\t}}"; + + public QueryVfModule() { super(); vfModules = new ArrayList<VfModule>(); } + public QueryVfModule(List<VfModule> vlist) { + LOGGER.debug ("QueryVfModule:"); + vfModules = new ArrayList<VfModule>(); + for (VfModule o : vlist) { + LOGGER.debug ("-- o is a vfModules ----"); + LOGGER.debug (o.toString()); + vfModules.add(o); + LOGGER.debug ("-------------------"); + } + } + + public List<VfModule> getVfModule(){ return this.vfModules; } + public void setVfModule(List<VfModule> v) { this.vfModules = v; } + + @Override + public String toString () { + StringBuffer buf = new StringBuffer(); + + boolean first = true; + int i = 1; + for (VfModule o : vfModules) { + buf.append(i+"\t"); + if (!first) buf.append("\n"); first = false; + buf.append(o); + } + return buf.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean x) { + StringBuffer buf = new StringBuffer(); + if (isArray) buf.append("\"vfModules\": ["); + Map<String, String> valueMap = new HashMap<String, String>(); + String sep = ""; + boolean first = true; + + for (VfModule o : vfModules) { + if (first) buf.append("\n"); first = false; + + put(valueMap, "MODEL_NAME", o.getModelName()); + put(valueMap, "MODEL_UUID", o.getModelUuid()); + put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId()); + put(valueMap, "MODEL_VERSION", o.getModelVersion()); + put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); + put(valueMap, "VF_MODULE_TYPE", o.getVfModuleType()); + put(valueMap, "IS_BASE", new Boolean(o.isBase()? true: false)); + put(valueMap, "VF_MODULE_LABEL", o.getVfModuleLabel()); + put(valueMap, "INITIAL_COUNT", o.getInitialCount()); + + buf.append(sep+ this.setTemplate(template, valueMap)); + sep = ",\n"; + } + if (!first) buf.append("\n"); + if (isArray) buf.append("]"); + return buf.toString(); + } +}
\ No newline at end of file diff --git a/adapters/mso-network-adapter-async-client/pom.xml b/adapters/mso-network-adapter-async-client/pom.xml index e1ed626f7e..7fad404f9b 100644 --- a/adapters/mso-network-adapter-async-client/pom.xml +++ b/adapters/mso-network-adapter-async-client/pom.xml @@ -1,91 +1,91 @@ -<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.openecomp.mso</groupId> - <artifactId>adapters</artifactId> +<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.openecomp.mso</groupId>
+ <artifactId>adapters</artifactId>
<version>1.1.0-SNAPSHOT</version> - </parent> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-network-adapter-async-client</artifactId> - <packaging>jar</packaging> - <name>mso-network-adapter-async-client</name> - <description>MSO Network Adapter Async Client</description> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <configuration> - <classesDirectory>target/classes</classesDirectory> - </configuration> - </plugin> - <plugin> - <groupId>org.jvnet.jax-ws-commons</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <id>generate-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources</wsdlDirectory> - <wsdlFiles> - <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> - <packageName>org.openecomp.mso.adapters.network.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.jvnet.jax-ws-commons - </groupId> - <artifactId> - jaxws-maven-plugin - </artifactId> - <versionRange> - [2.3,) - </versionRange> - <goals> - <goal>wsimport</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore></ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - -</project> + </parent>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-network-adapter-async-client</artifactId>
+ <packaging>jar</packaging>
+ <name>mso-network-adapter-async-client</name>
+ <description>MSO Network Adapter Async Client</description>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <classesDirectory>target/classes</classesDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jax-ws-commons</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <id>generate-stubs</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <vmArgs>
+ <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
+ </vmArgs>
+ <wsdlDirectory>src/main/resources</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile>
+ </wsdlFiles>
+ <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation>
+ <packageName>org.openecomp.mso.adapters.network.async.client</packageName>
+ <xnocompile>false</xnocompile>
+ <keep>true</keep>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.jvnet.jax-ws-commons
+ </groupId>
+ <artifactId>
+ jaxws-maven-plugin
+ </artifactId>
+ <versionRange>
+ [2.3,)
+ </versionRange>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml index a0c726a6f4..c02d2a52d0 100644 --- a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml @@ -77,6 +77,19 @@ <role-name>BPEL-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -87,9 +100,12 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> <filter> <filter-name>LogFilter</filter-name> - <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> </filter> <filter-mapping> <filter-name>LogFilter</filter-name> diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java index 4f6fc3ca7f..01f2e752e4 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java @@ -7,9 +7,9 @@ * 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. @@ -50,6 +50,7 @@ public interface MsoNetworkAdapter public void createNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") String physicalNetworkName, @WebParam(name="vlans") List<Integer> vlans, @@ -67,6 +68,7 @@ public interface MsoNetworkAdapter public void createNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="routeTargets") List<String> routeTargets, @WebParam(name="shared") String shared, @@ -92,6 +94,7 @@ public interface MsoNetworkAdapter public void updateNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @@ -106,6 +109,7 @@ public interface MsoNetworkAdapter public void updateNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="routeTargets") List<String> routeTargets, @@ -199,6 +203,7 @@ public interface MsoNetworkAdapter public void deleteNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="networkDeleted", mode=Mode.OUT) Holder<Boolean> networkDeleted) diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java index 99394f2256..e5152578bb 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java @@ -7,9 +7,9 @@ * 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. @@ -49,6 +49,7 @@ public interface MsoNetworkAdapterAsync public void createNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") String physicalNetworkName, @WebParam(name="vlans") List<Integer> vlans, @@ -58,12 +59,13 @@ public interface MsoNetworkAdapterAsync @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); - + @WebMethod @Oneway public void updateNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @@ -87,6 +89,7 @@ public interface MsoNetworkAdapterAsync public void deleteNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="networkType") @XmlElement(required=true) String networkType, + @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name="networkId") @XmlElement(required=true) String networkId, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @@ -97,7 +100,7 @@ public interface MsoNetworkAdapterAsync public void rollbackNetworkA (@WebParam(name="rollback") @XmlElement(required=true) NetworkRollback rollback, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); - + @WebMethod public void healthCheckA (); } diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java index 11b16365d9..c643443791 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -7,9 +7,9 @@ * 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. @@ -105,6 +105,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void createNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -140,6 +141,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkAdapter.createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -222,6 +224,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void updateNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -255,6 +258,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkAdapter.updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, physicalNetworkName, @@ -416,6 +420,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { public void deleteNetworkA (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String messageId, MsoRequest msoRequest, @@ -435,7 +440,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { Holder <Boolean> networkDeleted = new Holder <Boolean> (); try { - networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, networkId, msoRequest, networkDeleted); + networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted); MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); 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 c1c351916c..e9288ab408 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 @@ -117,6 +117,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void createNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -132,6 +133,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -155,6 +157,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void createNetworkContrail (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, List <String> routeTargets, String shared, @@ -173,6 +176,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { createNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkName, null, null, @@ -224,6 +228,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private void createNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, @@ -260,6 +265,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setCloudId (cloudSiteId); networkRollback.setTenantId (tenantId); networkRollback.setMsoRequest (msoRequest); + networkRollback.setModelCustomizationUuid(modelCustomizationUuid); // tenant query is not required here. // If the tenant doesn’t exist, the Heat calls will fail anyway (when the HeatUtils try to obtain a token). @@ -289,6 +295,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { NetworkResource networkResource = networkCheck (db, startTime, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -661,6 +668,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void updateNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -672,6 +680,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, physicalNetworkName, @@ -692,6 +701,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void updateNetworkContrail (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, List <String> routeTargets, @@ -706,6 +716,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { updateNetwork (cloudSiteId, tenantId, networkType, + modelCustomizationUuid, networkId, networkName, null, @@ -750,6 +761,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private void updateNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, @@ -806,6 +818,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { NetworkResource networkResource = networkCheck(db, startTime, networkType, + modelCustomizationUuid, networkName, physicalNetworkName, vlans, @@ -1116,16 +1129,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private NetworkResource networkCheck (CatalogDatabase db, long startTime, String networkType, + String modelCustomizationUuid, String networkName, String physicalNetworkName, List <Integer> vlans, List <String> routeTargets, CloudSite cloudSite) throws NetworkException { // Retrieve the Network Resource definition - NetworkResource networkResource = db.getNetworkResource (networkType); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + networkResource = db.getNetworkResource (networkType); + } + else + { + networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); + } if (networkResource == null) { - String error = "CreateNetwork: Unknown Network Type: " + networkType; - LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "Network Type", networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "CreateNetwork: Unknown Network Type"); + String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:" + networkType + " or ModelCustomizationUUID:" + modelCustomizationUuid ; + LOGGER.error (MessageEnum.RA_UNKOWN_PARAM, "NetworkType/ModelCustomizationUUID", networkType + "/" + modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create/UpdateNetwork: Unknown NetworkType/ModelCustomizationUUID"); throw new NetworkException (error, MsoExceptionCategory.USERDATA); } @@ -1424,6 +1445,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { public void deleteNetwork (String cloudSiteId, String tenantId, String networkType, + String modelCustomizationUuid, String networkId, MsoRequest msoRequest, Holder <Boolean> networkDeleted) throws NetworkException { @@ -1453,7 +1475,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } // Retrieve the Network Resource definition - NetworkResource networkResource = db.getNetworkResource (networkType); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + 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 ()); @@ -1562,6 +1591,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String tenantId = rollback.getTenantId (); String networkId = rollback.getNetworkStackId (); String networkType = rollback.getNetworkType (); + String modelCustomizationUuid = rollback.getModelCustomizationUuid(); LOGGER.debug ("*** ROLLBACK Network " + networkId + " in " + cloudSiteId + "/" + tenantId); @@ -1573,7 +1603,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { try { // Retrieve the Network Resource definition - NetworkResource networkResource = db.getNetworkResource (networkType); + NetworkResource networkResource = null; + if (isNullOrEmpty(modelCustomizationUuid)) { + networkResource = db.getNetworkResource (networkType); + } + else + { + networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid); + } String mode = ""; if (networkResource != null) { diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java index c813534212..18d55096e4 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java @@ -7,9 +7,9 @@ * 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. @@ -162,6 +162,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), req.getContrailNetwork().getShared(), @@ -187,6 +188,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), req.getProviderVlanNetwork().getVlans(), @@ -298,6 +300,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(), networkDeleted); @@ -538,6 +541,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), @@ -559,6 +563,7 @@ public class NetworkAdapterRest { req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java index f099046e03..4900d28556 100644 --- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java +++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java @@ -81,6 +81,7 @@ public class NetworkAdapterTest { adapter.createNetwork ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkName", "physicalNetworkName", vlans, @@ -121,6 +122,7 @@ public class NetworkAdapterTest { adapter.createNetworkContrail ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkName", routeTargets, "shared", @@ -155,6 +157,7 @@ public class NetworkAdapterTest { adapter.updateNetwork ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkId", "networkName", "physicalNetworkName", @@ -188,6 +191,7 @@ public class NetworkAdapterTest { adapter.updateNetworkContrail ("toto", "tenant", "PROVIDER", + "modelCustUuid", "networkId", "networkName", routeTargets, @@ -259,7 +263,7 @@ public class NetworkAdapterTest { Holder <Boolean> networkDeleted = new Holder<> (); MsoRequest msoRequest = new MsoRequest (); try { - adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "networkId", msoRequest, networkDeleted); + adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "modelCustUuid","networkId", msoRequest, networkDeleted); } catch (NetworkException e) { e.printStackTrace(); assertTrue (e.getMessage ().contains ("Cloud Site [toto] not found")); diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml index d43d244099..977ab76050 100644 --- a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml @@ -29,7 +29,7 @@ <servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
-
+
<filter>
<filter-name>LogFilter</filter-name>
<filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
@@ -78,6 +78,19 @@ <role-name>SiteControl-Client</role-name>
</auth-constraint>
</security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>MSO internal Requests</web-resource-name>
+ <description>Internal Requests</description>
+ <url-pattern>/logging/*</url-pattern>
+ <url-pattern>/properties/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>MSO-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
@@ -85,4 +98,7 @@ <security-role>
<role-name>SiteControl-Client</role-name>
</security-role>
+ <security-role>
+ <role-name>MSO-Client</role-name>
+ </security-role>
</web-app>
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java index 52b1f19b5f..0e3e6278b5 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java @@ -35,7 +35,7 @@ import org.apache.http.util.EntityUtils; import javax.xml.bind.DatatypeConverter; /** - * Sends asynchronous messages to the BPMN workflow message service. + * Sends asynchronous messages to the BPMN WorkflowMessage service. */ public class BPRestCallback { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); diff --git a/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml index 9118bba5a8..780bdd08ee 100644 --- a/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-tenant-adapter/WebContent/WEB-INF/web.xml @@ -44,7 +44,7 @@ <filter> <filter-name>LogFilter</filter-name> - <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> + <filter-class>org.openecomp.mso.logger.LogFilter</filter-class> </filter> <filter-mapping> <filter-name>LogFilter</filter-name> @@ -89,6 +89,19 @@ <role-name>BPEL-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -99,5 +112,8 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> </web-app> diff --git a/adapters/mso-vnf-adapter-async-client/pom.xml b/adapters/mso-vnf-adapter-async-client/pom.xml index d00044ed4b..27e555b815 100644 --- a/adapters/mso-vnf-adapter-async-client/pom.xml +++ b/adapters/mso-vnf-adapter-async-client/pom.xml @@ -1,91 +1,91 @@ -<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.openecomp.mso</groupId> - <artifactId>adapters</artifactId> +<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.openecomp.mso</groupId>
+ <artifactId>adapters</artifactId>
<version>1.1.0-SNAPSHOT</version> - </parent> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-vnf-adapter-async-client</artifactId> - <packaging>jar</packaging> - <name>mso-vnf-adapter-async-client</name> - <description>MSO VNF Adapter Async Client</description> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <configuration> - <classesDirectory>target/classes</classesDirectory> - </configuration> - </plugin> - <plugin> - <groupId>org.jvnet.jax-ws-commons</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <id>generate-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources</wsdlDirectory> - <wsdlFiles> - <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> - <packageName>org.openecomp.mso.adapters.vnf.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.jvnet.jax-ws-commons - </groupId> - <artifactId> - jaxws-maven-plugin - </artifactId> - <versionRange> - [2.3,) - </versionRange> - <goals> - <goal>wsimport</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore></ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - -</project> + </parent>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-vnf-adapter-async-client</artifactId>
+ <packaging>jar</packaging>
+ <name>mso-vnf-adapter-async-client</name>
+ <description>MSO VNF Adapter Async Client</description>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <classesDirectory>target/classes</classesDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jax-ws-commons</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <id>generate-stubs</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <vmArgs>
+ <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
+ </vmArgs>
+ <wsdlDirectory>src/main/resources</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile>
+ </wsdlFiles>
+ <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation>
+ <packageName>org.openecomp.mso.adapters.vnf.async.client</packageName>
+ <xnocompile>false</xnocompile>
+ <keep>true</keep>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.jvnet.jax-ws-commons
+ </groupId>
+ <artifactId>
+ jaxws-maven-plugin
+ </artifactId>
+ <versionRange>
+ [2.3,)
+ </versionRange>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml index 3a50781b22..e69486e1fd 100644 --- a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml +++ b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml @@ -79,6 +79,19 @@ <role-name>SiteControl-Client</role-name> </auth-constraint> </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name> @@ -89,6 +102,9 @@ <security-role> <role-name>SiteControl-Client</role-name> </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> <filter> <filter-name>LogFilter</filter-name> diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index bc32498b20..ced5c3ae6e 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -1,159 +1,159 @@ -<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.openecomp.mso</groupId> - <artifactId>adapters</artifactId> +<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.openecomp.mso</groupId>
+ <artifactId>adapters</artifactId>
<version>1.1.0-SNAPSHOT</version> - </parent> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-vnf-adapter</artifactId> - <packaging>war</packaging> - <name>mso-vnf-adapter</name> - <description>Web Service and REST endpoint for VNF operations</description> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.4</version> - <configuration> - <warSourceDirectory>WebContent</warSourceDirectory> - <failOnMissingWebXml>false</failOnMissingWebXml> - <attachClasses>true</attachClasses> - </configuration> - </plugin> - <plugin> - <groupId>org.jvnet.jax-ws-commons</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <id>Synch</id> - <goals> - <goal>wsgen</goal> - </goals> - <configuration> - <verbose>true</verbose> - <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei> - <genWsdl>true</genWsdl> - <inlineSchemas>true</inlineSchemas> - </configuration> - </execution> - <execution> - <id>Asynch</id> - <goals> - <goal>wsgen</goal> - </goals> - <configuration> - <verbose>true</verbose> - <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei> - <genWsdl>true</genWsdl> - <inlineSchemas>true</inlineSchemas> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-adapter-utils</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.sun.xml.ws</groupId> - <artifactId>jaxws-tools</artifactId> - <version>2.2.7</version> - </dependency> - </dependencies> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.jvnet.jax-ws-commons - </groupId> - <artifactId> - jaxws-maven-plugin - </artifactId> - <versionRange> - [2.3,) - </versionRange> - <goals> - <goal>wsgen</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore></ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - <dependencies> - <dependency> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-adapter-utils</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-adapters-rest-interface</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.mso.adapters</groupId> - <artifactId>mso-vnf-adapter-async-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>javax</groupId> - <artifactId>javaee-web-api</artifactId> - <version>6.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.jboss.spec.javax.ejb</groupId> - <artifactId>jboss-ejb-api_3.2_spec</artifactId> - <version>1.0.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.jboss.ejb3</groupId> - <artifactId>jboss-ejb3-ext-api</artifactId> - <version>2.2.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.openecomp.mso</groupId> - <artifactId>status-control</artifactId> - <version>${project.version}</version> - </dependency> - - <!-- <dependency> --> - <!-- <groupId>org.openecomp.mso</groupId> --> - <!-- <artifactId>mso-catalog-db</artifactId> --> - <!-- <version>${project.version}</version> --> - <!-- </dependency> --> - <!-- <dependency> --> - <!-- <groupId>log4j</groupId> --> - <!-- <artifactId>log4j</artifactId> --> - <!-- <version>1.2.17</version> --> - <!-- </dependency> --> - </dependencies> -</project> + </parent>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-vnf-adapter</artifactId>
+ <packaging>war</packaging>
+ <name>mso-vnf-adapter</name>
+ <description>Web Service and REST endpoint for VNF operations</description>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jax-ws-commons</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <id>Synch</id>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <verbose>true</verbose>
+ <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei>
+ <genWsdl>true</genWsdl>
+ <inlineSchemas>true</inlineSchemas>
+ </configuration>
+ </execution>
+ <execution>
+ <id>Asynch</id>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <verbose>true</verbose>
+ <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei>
+ <genWsdl>true</genWsdl>
+ <inlineSchemas>true</inlineSchemas>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-adapter-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-tools</artifactId>
+ <version>2.2.7</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.jvnet.jax-ws-commons
+ </groupId>
+ <artifactId>
+ jaxws-maven-plugin
+ </artifactId>
+ <versionRange>
+ [2.3,)
+ </versionRange>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-adapter-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-adapters-rest-interface</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-vnf-adapter-async-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-web-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <version>1.0.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>2.2.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.mso</groupId>
+ <artifactId>status-control</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- <dependency> -->
+ <!-- <groupId>org.openecomp.mso</groupId> -->
+ <!-- <artifactId>mso-catalog-db</artifactId> -->
+ <!-- <version>${project.version}</version> -->
+ <!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>log4j</groupId> -->
+ <!-- <artifactId>log4j</artifactId> -->
+ <!-- <version>1.2.17</version> -->
+ <!-- </dependency> -->
+ </dependencies>
+</project>
diff --git a/adapters/mso-workflow-message-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-workflow-message-adapter/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..bbf7aa0cf9 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Dependencies: org.jboss.logging +Class-Path: + diff --git a/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..9a24bfc509 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,17 @@ +<jboss-deployment-structure> + <deployment> + <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> + <exclusions> + <module name="org.apache.log4j" /> + <module name="org.slf4j" /> + <module name="org.slf4j.impl" /> + </exclusions> + <dependencies> + <module name="org.jboss.jandex" slot="main" /> + <module name="org.javassist" slot="main" /> + <module name="org.antlr" slot="main" /> + <module name="org.dom4j" slot="main" /> + </dependencies> + </deployment> +</jboss-deployment-structure> + diff --git a/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..a6ab6790c1 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ +<jboss-web> + <context-root>workflows/messages</context-root> +</jboss-web>
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..2adea83c4e --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/WEB-INF/web.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://java.sun.com/xml/ns/javaee" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" + version="3.0"> + <display-name>mso-workflow-message-adapter</display-name> + <welcome-file-list> + <welcome-file>check.html</welcome-file> + </welcome-file-list> + <context-param> + <param-name>log.configuration</param-name> + <param-value>logback.workflow-message-adapter.xml</param-value> + </context-param> + <context-param> + <param-name>mso.configuration</param-name> + <param-value>MSO_PROP_WORKFLOW_MESSAGE_ADAPTER=mso.workflow-message-adapter.properties,MSO_PROP_TOPOLOGY=topology.properties,MSO_PROP_AAF=cadi.properties</param-value> + </context-param> + <context-param> + <param-name>resteasy.resources</param-name> + <param-value> + org.openecomp.mso.logger.MsoLoggingServlet, + org.openecomp.mso.MsoStatusHandler, + org.openecomp.mso.adapters.workflowmessage.WMAdapterRest + </param-value> + </context-param> + <servlet> + <servlet-name>Resteasy</servlet-name> + <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Resteasy</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <filter> + <filter-name>LogFilter</filter-name> + <filter-class>com.att.ecomp.mso.logger.LogFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>LogFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <listener> + <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> + </listener> + <security-constraint> + <web-resource-collection> + <web-resource-name>SiteStatus</web-resource-name> + <description>SiteStatus APIs</description> + <url-pattern>/rest/setStatus/*</url-pattern> + <http-method>POST</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>SiteControl-Client</role-name> + </auth-constraint> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>MSO internal Requests</web-resource-name> + <description>Internal Requests</description> + <url-pattern>/rest/logging/*</url-pattern> + <url-pattern>/rest/properties/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + </web-resource-collection> + <auth-constraint> + <role-name>MSO-Client</role-name> + </auth-constraint> + </security-constraint> + <login-config> + <auth-method>BASIC</auth-method> + <realm-name>ApplicationRealm</realm-name> + </login-config> + <security-role> + <role-name>SiteControl-Client</role-name> + </security-role> + <security-role> + <role-name>MSO-Client</role-name> + </security-role> +</web-app> diff --git a/adapters/mso-workflow-message-adapter/WebContent/check.html b/adapters/mso-workflow-message-adapter/WebContent/check.html new file mode 100644 index 0000000000..454997901e --- /dev/null +++ b/adapters/mso-workflow-message-adapter/WebContent/check.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="ISO-8859-1"> +<title>Health Check</title> +</head> +<body> +Application ready +</body> +</html>
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/pom.xml b/adapters/mso-workflow-message-adapter/pom.xml new file mode 100644 index 0000000000..bde619f509 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/pom.xml @@ -0,0 +1,76 @@ +<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.openecomp.mso</groupId> + <artifactId>adapters</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-workflow-message-adapter</artifactId> + <packaging>war</packaging> + <name>mso-workflow-message-adapter</name> + <description>mso workflow message adapter</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>${basedir}/WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.1_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <!-- For UriUtils which does URL encoding according to RFC 3986 Section 2 --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.3.2.RELEASE</version> + </dependency> + </dependencies> +</project> diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java new file mode 100644 index 0000000000..cb3aea62c7 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java @@ -0,0 +1,178 @@ +/*- + * ============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.adapters.workflowmessage; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpResponse; +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.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Sends asynchronous messages to the BPMN WorkflowMessage service. + */ +public class BPRestCallback { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + /** + * Sends a message to the BPMN workflow message service. The URL path is + * constructed using the specified message type and correlator. + * @param workflowMessageUrl the base BPMN WorkflowMessage URL + * @param messageType the message type + * @param correlator the message correlator + * @param contentType the value for the HTTP Content-Type header (possibly null) + * @param message the content (possibly null) + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String workflowMessageUrl, String messageType, + String correlator, ContentType contentType, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "workflowMessageUrl=" + workflowMessageUrl + + " messageType=" + messageType + + " correlator=" + correlator + + " contentType=" + contentType + + " message=" + message + + ")"); + + while (workflowMessageUrl.endsWith("/")) { + workflowMessageUrl = workflowMessageUrl.substring(0, workflowMessageUrl.length()-1); + } + + String endpoint = workflowMessageUrl + "/" + WMAdapterUtils.encodeURLPathSegment(messageType) + + "/" + WMAdapterUtils.encodeURLPathSegment(correlator); + + return send(endpoint, contentType, message); + } + + /** + * Sends a message to the BPMN workflow message service. The specified URL + * must have the message type and correlator already embedded in it. + * @param url the endpoint URL + * @param message the content (possibly null) + * @param contentType the value for the HTTP Content-Type header (possibly null) + * @return true if the message was consumed successfully by the endpoint + */ + public boolean send(String url, ContentType contentType, String message) { + LOGGER.debug(getClass().getSimpleName() + ".send(" + + "url=" + url + + " contentType=" + contentType + + " message=" + message + + ")"); + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, "Camunda", ""); + + HttpPost method = null; + HttpResponse httpResponse = null; + + try { + // TODO: configurable timeout? + int timeout = 60 * 1000; + + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(timeout) + .setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .build(); + + HttpClient client = HttpClientBuilder.create().build(); + method = new HttpPost(url); + method.setConfig(requestConfig); + + if (message != null) { + method.setEntity(new StringEntity(message, contentType)); + } + + boolean error = false; + + try { + // AAF Integration, disabled for now due to the constrains from other party + // String userCredentials = CredentialConstants.getDecryptedCredential(WMAdapterConstants.DEFAULT_BPEL_AUTH); + // Once AAF enabled, the credential shall be get by triggering the CredentialConstants.getDecryptedCredential -- remove line + String userCredentials = WMAdapterProperties.getEncryptedProperty(WMAdapterConstants.BPEL_AUTH_PROP, + WMAdapterConstants.DEFAULT_BPEL_AUTH, WMAdapterConstants.ENCRYPTION_KEY); + String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + method.setHeader("Authorization", authorization); + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Unable to set authorization in callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Unable to set authorization in callback request: " + e.getMessage()); + error = true; + } + + if (!error) { + httpResponse = client.execute(method); + + @SuppressWarnings("unused") + String responseContent = null; + + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, msg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg); + } + + httpResponse = null; + } + + method.reset(); + method = null; + return true; + } catch (Exception e) { + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + "Error sending callback request", e); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + "Error sending callback request: " + e.getMessage()); + return false; + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + // Ignore + } + } + + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + // Ignore + } + } + + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, "Camunda", ""); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.java new file mode 100644 index 0000000000..a92051da12 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterConstants.java @@ -0,0 +1,30 @@ +/*- + * ============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.adapters.workflowmessage; + +public interface WMAdapterConstants { + public static final String MSO_PROPERTIES_ID = "MSO_PROP_WORKFLOW_MESSAGE_ADAPTER"; + public static final String BPEL_URL_PROP = "org.openecomp.mso.adapters.workflow.message.bpelurl"; + + // Once AAF enabled, the credential shall be get by triggering the CredentialConstants.getEncryptedPropValue + public static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.workflow.message.bpelauth"; + public static final String DEFAULT_BPEL_AUTH = "05FDA034C27D1CA51AAB8FAE512EDE45241E16FC8C137D292AA3A964431C82DB"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java new file mode 100644 index 0000000000..e63c404024 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterProperties.java @@ -0,0 +1,89 @@ +/*- + * ============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.adapters.workflowmessage; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +/** + * Static methods to access Workflow Message Adapter properties. + */ +public final class WMAdapterProperties { + private static final MsoPropertiesFactory MSO_PROPERTIES_FACTORY = new MsoPropertiesFactory(); + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + /** + * Gets the value of a Workflow Message Adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getProperty(String key, String defaultValue) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, + "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID, + "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError, + "Exception - MSO Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getProperty(key, defaultValue); + LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID + + " - key:" + key + " value:" + value); + return value; + } + + /** + * Gets the value of an Workflow Message Adapter property. + * @param key the property key + * @param defaultValue the default value to use if the property does not + * exist or if an error occurs + */ + public static String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { + MsoJavaProperties properties; + + try { + properties = MSO_PROPERTIES_FACTORY.getMsoJavaProperties(WMAdapterConstants.MSO_PROPERTIES_ID); + } catch (MsoPropertiesException e) { + LOGGER.error (MessageEnum.NO_PROPERTIES, + "Unknown. MSO Properties ID not found in cache: " + WMAdapterConstants.MSO_PROPERTIES_ID, + "WorkflowMessageAdatper", "", MsoLogger.ErrorCode.DataError, + "Exception - MSO Properties ID not found in cache", e); + return defaultValue; + } + + String value = properties.getEncryptedProperty(key, defaultValue, encryptionKey); + LOGGER.debug("Config read for " + WMAdapterConstants.MSO_PROPERTIES_ID + " - key:" + key); + return value; + } + + /** + * Instantiation is not allowed. + */ + private WMAdapterProperties() { + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java new file mode 100644 index 0000000000..db7e47f00e --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRest.java @@ -0,0 +1,140 @@ +/*- + * ============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.adapters.workflowmessage; + +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.http.entity.ContentType; + +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +/** + * Workflow Message Adapter interface added in 1707. Supports delivery of + * callbacks from external systems to waiting BPMN workflows. + */ +@Path("/") +public class WMAdapterRest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + @HEAD + @GET + @Path("/healthcheck") + @Produces(MediaType.TEXT_HTML) + public Response healthcheck(@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis(); + MsoLogger.setServiceName("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, LOGGER); + HealthCheckUtils healthCheck = new HealthCheckUtils(); + + if (!healthCheck.siteStatusCheck(LOGGER, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (!healthCheck.configFileCheck(LOGGER, startTime, WMAdapterConstants.MSO_PROPERTIES_ID)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + LOGGER.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + /** + * Receives a message from a remote system. + * @param content the message content + */ + @POST + @Path("/message/{messageType}/{correlator}") + @Consumes("*/*") + @Produces({MediaType.TEXT_PLAIN}) + public Response receiveWorkflowMessage( + @HeaderParam("Content-Type") String contentTypeHeader, + @PathParam("messageType") String messageType, + @PathParam("correlator") String correlator, + String content) { + + String path= "workflow/" + messageType + "/" + correlator; + LOGGER.info(MessageEnum.RA_RECEIVE_WORKFLOW_MESSAGE, content, "WorkflowMessageAdapter", path); + + long startTime = System.currentTimeMillis(); + + ContentType contentType = null; + + if (contentTypeHeader != null) { + try { + contentType = ContentType.parse(contentTypeHeader); + } catch (Exception e) { + // If we don't get a valid one, we handle it below. + } + } + + if (contentType == null && content != null) { + String error = "Missing or Invalid Content-Type"; + LOGGER.error(MessageEnum.RA_PARSING_REQUEST_ERROR, error, "WorkflowMessageAdapter", path, + MsoLogger.ErrorCode.DataError, "Bad Request"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE).entity(error).build(); + } + + String bpUrl = WMAdapterProperties.getProperty(WMAdapterConstants.BPEL_URL_PROP, null); + + if (bpUrl == null) { + String error = "Missing configuration for: " + WMAdapterConstants.BPEL_URL_PROP; + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "WorkflowMessageAdapter", path, + MsoLogger.ErrorCode.DataError, "Configuration Error"); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(error).build(); + } + + long bpStartTime = System.currentTimeMillis(); + BPRestCallback callback = new BPRestCallback(); + boolean callbackSuccess = callback.send(bpUrl, messageType, correlator, contentType, content); + + if (callbackSuccess) { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Sent notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification", "BPMN", bpUrl, null); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Failed to send notification"); + } + + return Response.status(204).build(); + } +} diff --git a/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java new file mode 100644 index 0000000000..b371d2dd9b --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterUtils.java @@ -0,0 +1,48 @@ +/*- + * ============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.adapters.workflowmessage; + +import java.io.UnsupportedEncodingException; + +import org.springframework.web.util.UriUtils; + +/** + * Utility methods used by WMAdapterRest. + */ +public final class WMAdapterUtils { + /** + * Encodes a URL path segment according to RFC 3986 Section 2. + * @param pathSegment the path segment to encode + * @return the encoded path segment + */ + public static String encodeURLPathSegment(String pathSegment) { + try { + return UriUtils.encodePathSegment(pathSegment, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 encoding is not supported"); + } + } + + /** + * Instantiation is not allowed. + */ + private WMAdapterUtils() { + } +}
\ No newline at end of file diff --git a/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml b/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..bc3d7f36b6 --- /dev/null +++ b/adapters/mso-workflow-message-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,25 @@ +<configuration > + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/adapters/pom.xml b/adapters/pom.xml index 67946aabf8..a96b04aed9 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -25,6 +25,7 @@ <module>mso-vnf-adapter-async-client</module> <module>mso-requests-db-adapter</module> <module>mso-catalog-db-adapter</module> + <module>mso-workflow-message-adapter</module> </modules> <dependencies> |