aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrestapi-call-node/provider/pom.xml1
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java40
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java25
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java51
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java31
5 files changed, 123 insertions, 25 deletions
diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml
index 1f698ead..32089455 100755
--- a/restapi-call-node/provider/pom.xml
+++ b/restapi-call-node/provider/pom.xml
@@ -93,4 +93,5 @@
<scope>test</scope>
</dependency>
</dependencies>
+
</project>
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
new file mode 100644
index 00000000..b4a30d3a
--- /dev/null
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+
+@Path("get-cookie")
+public class MockCookieAuthServer {
+ @GET
+ @Path("cookie")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response getCookie() {
+ return Response.status(200).entity("success").cookie(new NewCookie("cookieResponse", "cookieValueInReturn")).build();
+ }
+}
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
index 7a24ca1a..52da4615 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
@@ -25,6 +25,7 @@ import java.net.URI;
import java.util.HashMap;
import java.util.Map;
+import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.junit.Test;
@@ -666,7 +667,7 @@ public class TestRestapiCallNode {
public void testMultipartFormData() throws SvcLogicException {
final ResourceConfig resourceConfig = new ResourceConfig(
MultipartServerMock.class, MultiPartFeature.class);
- GrizzlyHttpServerFactory.createHttpServer(
+ HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
URI.create("http://localhost:8080/"),resourceConfig);
Map<String, String> p = new HashMap<>();
@@ -680,5 +681,27 @@ public class TestRestapiCallNode {
rcn.sendRequest(p, ctx);
assertThat(ctx.getAttribute("response-code"), is("200"));
assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json"));
+ server.shutdownNow();
+ }
+
+ @Test
+ public void testCookieResponse() throws SvcLogicException {
+ final ResourceConfig resourceConfig = new ResourceConfig(
+ MockCookieAuthServer.class);
+ HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
+ URI.create("http://localhost:8080/"),resourceConfig);
+
+ Map<String, String> p = new HashMap<>();
+ p.put("format", "none");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie");
+ p.put("dumpHeaders", "true");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ RestapiCallNode rcn = new RestapiCallNode();
+ rcn.sendRequest(p, ctx);
+ assertThat(ctx.getAttribute("response-code"), is("200"));
+ assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1"));
+ server.shutdownNow();
}
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
index 759fe802..0eca40d0 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
@@ -29,6 +29,8 @@ import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.DOT_REGEX;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.SLASH;
@@ -52,6 +54,8 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.S
*/
public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<SchemaNode, SchemaContext> {
+ private static final Logger log = LoggerFactory.getLogger(
+ MdsalPropertiesNodeSerializer.class);
private SchemaNode curSchema;
private PropertiesNode node;
@@ -111,6 +115,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
fixedParams.put(fixedUri, entry.getValue());
} catch (IllegalArgumentException | RestconfDocumentedException
| NullPointerException e) {
+ log.info("Exception while processing properties by replacing " +
+ "underscore with colon. Process the properties as it is." + e);
fixedParams.put(entry.getKey(), entry.getValue());
}
}
@@ -158,26 +164,45 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
break;
case SINGLE_INSTANCE_LEAF_NODE:
- Namespace valNs = getValueNamespace(value, schemaCtx());
- value = getParsedValue(valNs, value);
- node = node.addChild(localName, ns, SINGLE_INSTANCE_LEAF_NODE,
- value, valNs, schema);
- node = node.endNode();
- curSchema = ((SchemaNode) node.appInfo());
+ addLeafNode(value, SINGLE_INSTANCE_LEAF_NODE, localName,
+ ns, schema, name);
break;
case MULTI_INSTANCE_LEAF_NODE:
- valNs = getValueNamespace(value, schemaCtx());
- value = getParsedValue(valNs, value);
- node = node.addChild(getIndex(name), localName, ns,
- MULTI_INSTANCE_LEAF_NODE, value,
- valNs, schema);
- node = node.endNode();
- curSchema = ((SchemaNode) node.appInfo());
+ addLeafNode(value, MULTI_INSTANCE_LEAF_NODE, localName,
+ ns, schema, name);
break;
default:
throw new SvcLogicException("Invalid node type");
}
}
+
+ /**
+ * Adds leaf property node to the current node.
+ *
+ * @param value value of the leaf node
+ * @param type single instance or multi instance leaf node
+ * @param localName name of the leaf node
+ * @param ns namespace of the leaf node
+ * @param schema schema of the leaf node
+ * @param name name of the leaf in properties
+ * @throws SvcLogicException exception while adding leaf node
+ */
+ private void addLeafNode(String value, NodeType type,
+ String localName, Namespace ns,
+ SchemaNode schema, String name) throws SvcLogicException {
+ Namespace valNs = getValueNamespace(value, schemaCtx());
+ value = getParsedValue(valNs, value);
+ if (SINGLE_INSTANCE_LEAF_NODE == type) {
+ node = node.addChild(localName, ns, SINGLE_INSTANCE_LEAF_NODE,
+ value, valNs, schema);
+ } else {
+ node = node.addChild(getIndex(name), localName, ns,
+ MULTI_INSTANCE_LEAF_NODE, value,
+ valNs, schema);
+ }
+ node = node.endNode();
+ curSchema = ((SchemaNode) node.appInfo());
+ }
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
index d0b34f9b..2a3b1761 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
@@ -177,17 +177,20 @@ public final class MdsalPropertiesNodeUtils {
public static PropertiesNode getAugmentationNode(
AugmentationSchemaNode augSchema,
PropertiesNode parent, String name) {
- if (augSchema != null) {
- Collection<PropertiesNode> childsFromAugmentation = parent
- .augmentations().get(augSchema);
- if (!childsFromAugmentation.isEmpty()) {
- for (PropertiesNode pNode : childsFromAugmentation) {
- if (pNode.name().equals(name)) {
- return pNode;
- }
+ if (augSchema == null) {
+ return null;
+ }
+
+ Collection<PropertiesNode> childsFromAugmentation = parent
+ .augmentations().get(augSchema);
+ if (!childsFromAugmentation.isEmpty()) {
+ for (PropertiesNode pNode : childsFromAugmentation) {
+ if (pNode.name().equals(name)) {
+ return pNode;
}
}
}
+
return null;
}
@@ -218,10 +221,12 @@ public final class MdsalPropertiesNodeUtils {
* @param appInfo application info
* @param type node type
* @return new properties node
+ * @throws SvcLogicException exception while creating properties node
*/
public static PropertiesNode createNode(String name, Namespace namespace,
String uri, PropertiesNode parent,
- Object appInfo, NodeType type) {
+ Object appInfo, NodeType type)
+ throws SvcLogicException {
switch (type) {
case SINGLE_INSTANCE_NODE:
return new SingleInstanceNode(name, namespace, uri, parent, appInfo, type);
@@ -230,7 +235,7 @@ public final class MdsalPropertiesNodeUtils {
case MULTI_INSTANCE_LEAF_HOLDER_NODE:
return new LeafListHolderNode(name, namespace, uri, parent, appInfo, type);
default:
- throw new RuntimeException("Invalid node type");
+ throw new SvcLogicException("Invalid node type " + type);
}
}
@@ -265,6 +270,9 @@ public final class MdsalPropertiesNodeUtils {
return new SchemaPathHolder(id, uri1);
} catch (IllegalArgumentException | RestconfDocumentedException
| NullPointerException e) {
+ log.info("Exception while converting uri to instance identifier" +
+ " context. Process each node in uri to get instance identifier" +
+ " context " + e);
return processNodesAndAppendPath(uri, context);
}
}
@@ -294,6 +302,7 @@ public final class MdsalPropertiesNodeUtils {
try {
id = processIdentifier(uriParts[i], context, actPath);
} catch (IllegalArgumentException e) {
+ log.info(format(EXC_MSG, e));
id.setUri(actPath+ uriParts[i] + sec);
return id;
}
@@ -340,7 +349,7 @@ public final class MdsalPropertiesNodeUtils {
return new SchemaPathHolder(id, val);
} catch (IllegalArgumentException | RestconfDocumentedException |
NullPointerException e) {
- log.info(format(INFO_MSG, val));
+ log.info(format(INFO_MSG, val, e));
}
firstHalf.append(values[i]).append(UNDERSCORE);
secondHalf = secondHalf.replaceFirst(