2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package org.commscope.tr069adapter.acs.cpe.rpc;
\r
21 import java.util.ArrayList;
\r
22 import java.util.Iterator;
\r
24 import javax.xml.soap.SOAPBodyElement;
\r
25 import javax.xml.soap.SOAPElement;
\r
26 import javax.xml.soap.SOAPException;
\r
27 import javax.xml.soap.SOAPFactory;
\r
29 import org.commscope.tr069adapter.acs.cpe.TR069RPC;
\r
31 public class GetRPCMethodsResponse extends TR069RPC {
\r
33 private static final long serialVersionUID = -2718028310071462414L;
\r
35 /** Creates a new instance of GetRPCMethodsResponse */
\r
36 public GetRPCMethodsResponse() {}
\r
38 public GetRPCMethodsResponse(GetRPCMethods req) {
\r
39 this.id = req.getId();
\r
40 methods = new String[] {"Inform", "TransferComplete", "GetRPCMethods"};
\r
41 name = "GetRPCMethodsResponse";
\r
45 protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {
\r
46 SOAPElement mlst = body.addChildElement(spf.createName("MethodList"));
\r
47 mlst.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + methods.length + "]");
\r
48 for (String m : methods) {
\r
49 mlst.addChildElement("string").setValue(m);
\r
54 @SuppressWarnings({"rawtypes", "unused"})
\r
56 protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {
\r
57 SOAPElement ml = getRequestChildElement(spf, body, "MethodList");
\r
58 getArrayCount(spf, ml);
\r
59 Iterator<Object> mlist = ml.getChildElements();
\r
60 ArrayList<String> m = new ArrayList<>();
\r
61 while (mlist.hasNext()) {
\r
62 Object e = mlist.next();
\r
63 if (e instanceof SOAPElement) {
\r
64 SOAPElement el = (SOAPElement) e;
\r
65 if (el.getElementQName().getLocalPart().equals("string")) {
\r
66 m.add(el.getValue());
\r
70 methods = m.toArray(new String[1]);
\r
73 private String[] methods;
\r
75 public String[] getMethods() {
\r