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 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.adapters.sdnc.sdncrest;
24 import java.io.UnsupportedEncodingException;
25 import java.util.ArrayList;
26 import java.util.List;
28 import org.onap.so.logger.MsoLogger;
29 import org.springframework.web.util.UriUtils;
30 import org.w3c.dom.Element;
31 import org.w3c.dom.Node;
32 import org.w3c.dom.NodeList;
35 * Utility methods used by SDNCAdapterRest.
37 public final class SDNCAdapterUtils {
38 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, SDNCAdapterUtils.class);
40 * Instantiation is not allowed.
42 private SDNCAdapterUtils() {
46 * Returns a node's child elements in a list.
48 public static List<Element> childElements(Node node) {
49 List<Element> elements = new ArrayList<>();
51 NodeList nodeList = node.getChildNodes();
52 for (int i = 0; i < nodeList.getLength(); i++) {
53 Node child = nodeList.item(i);
54 if (child.getNodeType() == Node.ELEMENT_NODE) {
55 elements.add((Element) child);
63 * Encodes a URL path segment according to RFC 3986 Section 2.
64 * @param pathSegment the path segment to encode
65 * @return the encoded path segment
67 public static String encodeURLPathSegment(String pathSegment) {
68 return UriUtils.encodePathSegment(pathSegment, "UTF-8");