2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Modifications Copyright (c) 2019 Samsung
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.so.adapters.sdnc.sdncrest;
26 import java.util.ArrayList;
27 import java.util.List;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.web.util.UriUtils;
32 import org.w3c.dom.Element;
33 import org.w3c.dom.Node;
34 import org.w3c.dom.NodeList;
37 * Utility methods used by SDNCAdapterRest.
39 public final class SDNCAdapterUtils {
40 private static final Logger logger = LoggerFactory.getLogger(SDNCAdapterUtils.class);
42 * Instantiation is not allowed.
44 private SDNCAdapterUtils() {
48 * Returns a node's child elements in a list.
50 public static List<Element> childElements(Node node) {
51 List<Element> elements = new ArrayList<>();
53 NodeList nodeList = node.getChildNodes();
54 for (int i = 0; i < nodeList.getLength(); i++) {
55 Node child = nodeList.item(i);
56 if (child.getNodeType() == Node.ELEMENT_NODE) {
57 elements.add((Element) child);
65 * Encodes a URL path segment according to RFC 3986 Section 2.
66 * @param pathSegment the path segment to encode
67 * @return the encoded path segment
69 public static String encodeURLPathSegment(String pathSegment) {
70 return UriUtils.encodePathSegment(pathSegment, "UTF-8");