Fix: Update Sonar needed parameters
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / GetParameterAttributesResponse.java
1 /*\r
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
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\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
17  */\r
18 \r
19 package org.commscope.tr069adapter.acs.cpe.rpc;\r
20 \r
21 import java.io.Serializable;\r
22 import java.util.Iterator;\r
23 \r
24 import javax.xml.soap.Name;\r
25 import javax.xml.soap.SOAPBodyElement;\r
26 import javax.xml.soap.SOAPElement;\r
27 import javax.xml.soap.SOAPException;\r
28 import javax.xml.soap.SOAPFactory;\r
29 \r
30 import org.commscope.tr069adapter.acs.cpe.TR069RPC;\r
31 \r
32 public class GetParameterAttributesResponse extends TR069RPC {\r
33 \r
34   private static final long serialVersionUID = 5241691699448063027L;\r
35 \r
36   /** Creates a new instance of GetParameterAttributes */\r
37   public GetParameterAttributesResponse() {\r
38     name = "GetParameterAttributesResponse";\r
39   }\r
40 \r
41   protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
42     logger.isDebugEnabled();\r
43   }\r
44 \r
45   @SuppressWarnings({"rawtypes", "unused"})\r
46   protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
47     SOAPElement ml = getRequestChildElement(spf, body, "ParameterList");\r
48     int i = getArrayCount(spf, ml);\r
49     Iterator<SOAPElement> mlist = ml.getChildElements(spf.createName("ParameterAttributeStruct"));\r
50     attributes = new ParameterAttributeStruct[i];\r
51     Name nameKey = spf.createName("Name");\r
52     Name nameNotification = spf.createName("Notification");\r
53     Name nameString = spf.createName("string");\r
54     i = 0;\r
55     while (mlist.hasNext()) {\r
56       SOAPElement param = mlist.next();\r
57       attributes[i] = new ParameterAttributeStruct();\r
58       attributes[i].name = getRequestElement(param, nameKey);\r
59       attributes[i].notification = Integer.parseInt(getRequestElement(param, nameNotification));\r
60       // get acl array\r
61       SOAPElement elementAccessList = getRequestChildElement(spf, param, "AccessList");\r
62       int ii = getArrayCount(spf, elementAccessList);\r
63       attributes[i].accessList = new String[ii];\r
64 \r
65       ii = 0;\r
66       Iterator<SOAPElement> iteratorAccessList = elementAccessList.getChildElements(nameString);\r
67       while (iteratorAccessList.hasNext()) {\r
68         attributes[i].accessList[ii++] = ((SOAPElement) iteratorAccessList.next()).getValue();\r
69       }\r
70       i++;\r
71     }\r
72 \r
73   }\r
74 \r
75   private ParameterAttributeStruct[] attributes;\r
76 \r
77   public ParameterAttributeStruct[] getAttributes() {\r
78     return attributes;\r
79   }\r
80 \r
81   public void setAttributes(ParameterAttributeStruct[] attributes) {\r
82     this.attributes = attributes;\r
83   }\r
84 \r
85   public class ParameterAttributeStruct implements Serializable {\r
86 \r
87     private static final long serialVersionUID = -5185719453218694220L;\r
88 \r
89     ParameterAttributeStruct() {}\r
90 \r
91     private String name;\r
92     private int notification;\r
93     private String[] accessList;\r
94 \r
95     public String getName() {\r
96       return name;\r
97     }\r
98 \r
99     public int getNotification() {\r
100       return notification;\r
101     }\r
102 \r
103     public String[] getAccessList() {\r
104       return accessList;\r
105     }\r
106   }\r
107 }\r