Fix: Update Sonar needed parameters
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / SetParameterAttributes.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.util.ArrayList;\r
22 import java.util.List;\r
23 \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
28 \r
29 import org.commscope.tr069adapter.acs.cpe.TR069RPC;\r
30 \r
31 public class SetParameterAttributes extends TR069RPC {\r
32 \r
33   private static final long serialVersionUID = 1L;\r
34 \r
35   public SetParameterAttributes() {\r
36     name = "SetParameterAttributes";\r
37     attrs = new ArrayList<>();\r
38   }\r
39 \r
40   public void addAttribute(String name, boolean notificationChange, int notification,\r
41       boolean accessListChange, String[] accessList) {\r
42     attrs.add(new SetParameterAttributesStruct(name, notificationChange, notification,\r
43         accessListChange, accessList));\r
44   }\r
45 \r
46   protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
47     SOAPElement elm = body.addChildElement(spf.createName("ParameterList"));\r
48     elm.setAttribute(SOAP_ARRAY_TYPE, "cwmp:SetParameterAttributesStruct[" + attrs.size() + "]");\r
49     int c = attrs.size();\r
50     for (int i = 0; i < c; i++) {\r
51       SOAPElement param = elm.addChildElement("SetParameterAttributesStruct");\r
52       param.addChildElement("Name").setValue(attrs.get(i).getName());\r
53       param.addChildElement("NotificationChange")\r
54           .setValue(b2s(attrs.get(i).isNotificationChange()));\r
55       param.addChildElement("Notification")\r
56           .setValue(String.valueOf(attrs.get(i).getNotification()));\r
57 \r
58       param.addChildElement("AccessListChange").setValue(b2s(attrs.get(i).isAccessListChange()));\r
59 \r
60       SOAPElement al = param.addChildElement(spf.createName("AccessList"));\r
61       if (null != attrs.get(i).getAccessList()) {\r
62         String[] acl = attrs.get(i).getAccessList();\r
63         int ca = 0;\r
64         if (acl != null)\r
65           ca = acl.length;\r
66         al.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + ca + "]");\r
67         for (int i2 = 0; i2 < ca; i2++) {\r
68           SOAPElement acle = al.addChildElement("string");\r
69           acle.setValue(acl[i2]);\r
70           acle.setAttribute(XSI_TYPE, XSD_STRING);\r
71         }\r
72       }\r
73 \r
74     }\r
75   }\r
76 \r
77   protected void parseBody(SOAPBodyElement body, SOAPFactory f) throws SOAPException {\r
78     logger.isDebugEnabled();\r
79   }\r
80 \r
81   private List<SetParameterAttributesStruct> attrs;\r
82 }\r