Initial source code
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / SetParameterAttributes.java
diff --git a/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/SetParameterAttributes.java b/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/SetParameterAttributes.java
new file mode 100644 (file)
index 0000000..26de442
--- /dev/null
@@ -0,0 +1,82 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.acs.cpe.rpc;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.xml.soap.SOAPBodyElement;\r
+import javax.xml.soap.SOAPElement;\r
+import javax.xml.soap.SOAPException;\r
+import javax.xml.soap.SOAPFactory;\r
+\r
+import org.commscope.tr069adapter.acs.cpe.TR069RPC;\r
+\r
+public class SetParameterAttributes extends TR069RPC {\r
+\r
+  private static final long serialVersionUID = 1L;\r
+\r
+  public SetParameterAttributes() {\r
+    name = "SetParameterAttributes";\r
+    attrs = new ArrayList<>();\r
+  }\r
+\r
+  public void addAttribute(String name, boolean notificationChange, int notification,\r
+      boolean accessListChange, String[] accessList) {\r
+    attrs.add(new SetParameterAttributesStruct(name, notificationChange, notification,\r
+        accessListChange, accessList));\r
+  }\r
+\r
+  protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
+    SOAPElement elm = body.addChildElement(spf.createName("ParameterList"));\r
+    elm.setAttribute(SOAP_ARRAY_TYPE, "cwmp:SetParameterAttributesStruct[" + attrs.size() + "]");\r
+    int c = attrs.size();\r
+    for (int i = 0; i < c; i++) {\r
+      SOAPElement param = elm.addChildElement("SetParameterAttributesStruct");\r
+      param.addChildElement("Name").setValue(attrs.get(i).getName());\r
+      param.addChildElement("NotificationChange")\r
+          .setValue(b2s(attrs.get(i).isNotificationChange()));\r
+      param.addChildElement("Notification")\r
+          .setValue(String.valueOf(attrs.get(i).getNotification()));\r
+\r
+      param.addChildElement("AccessListChange").setValue(b2s(attrs.get(i).isAccessListChange()));\r
+\r
+      SOAPElement al = param.addChildElement(spf.createName("AccessList"));\r
+      if (null != attrs.get(i).getAccessList()) {\r
+        String[] acl = attrs.get(i).getAccessList();\r
+        int ca = 0;\r
+        if (acl != null)\r
+          ca = acl.length;\r
+        al.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + ca + "]");\r
+        for (int i2 = 0; i2 < ca; i2++) {\r
+          SOAPElement acle = al.addChildElement("string");\r
+          acle.setValue(acl[i2]);\r
+          acle.setAttribute(XSI_TYPE, XSD_STRING);\r
+        }\r
+      }\r
+\r
+    }\r
+  }\r
+\r
+  protected void parseBody(SOAPBodyElement body, SOAPFactory f) throws SOAPException {\r
+    logger.isDebugEnabled();\r
+  }\r
+\r
+  private List<SetParameterAttributesStruct> attrs;\r
+}\r