Initial source code
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / GetOptionsResponse.java
diff --git a/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/GetOptionsResponse.java b/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/GetOptionsResponse.java
new file mode 100644 (file)
index 0000000..6e7f0be
--- /dev/null
@@ -0,0 +1,111 @@
+/*\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.Iterator;\r
+import java.util.List;\r
+\r
+import javax.xml.soap.Name;\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 GetOptionsResponse extends TR069RPC {\r
+\r
+  private static final long serialVersionUID = -9160354248384671344L;\r
+\r
+  public class OptionStruct {\r
+    private String optionName;\r
+    private String voucherSN;\r
+    private int state;\r
+    private int mode;\r
+    private String startDate;\r
+    private String expirationDate;\r
+    private boolean isTransferable;\r
+\r
+    public String getOptionName() {\r
+      return optionName;\r
+    }\r
+\r
+    public String getVoucherSN() {\r
+      return voucherSN;\r
+    }\r
+\r
+    public int getState() {\r
+      return state;\r
+    }\r
+\r
+    public int getMode() {\r
+      return mode;\r
+    }\r
+\r
+    public String getStartDate() {\r
+      return startDate;\r
+    }\r
+\r
+    public String getExpirationDate() {\r
+      return expirationDate;\r
+    }\r
+\r
+    public boolean isTransferable() {\r
+      return isTransferable;\r
+    }\r
+  }\r
+\r
+  public GetOptionsResponse() {\r
+    name = "GetOptionsResponse";\r
+  }\r
+\r
+  protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
+    logger.isDebugEnabled();\r
+  }\r
+\r
+  @SuppressWarnings("rawtypes")\r
+  protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
+    Iterator<SOAPElement> pi = getRequestChildElement(spf, body, "OptionList")\r
+        .getChildElements(spf.createName("OptionStruct"));\r
+    Name nameOptionName = spf.createName("OptionName");\r
+    Name nameVoucherSN = spf.createName("VoucherSN");\r
+    Name nameState = spf.createName("State");\r
+    Name nameMode = spf.createName("Mode");\r
+    Name nameStartDate = spf.createName("StartDate");\r
+    Name nameExpirationDate = spf.createName("ExpirationDate");\r
+    Name nameIsTransferable = spf.createName("IsTransferable");\r
+\r
+    List<OptionStruct> optionList = new ArrayList<>();\r
+\r
+    while (pi.hasNext()) {\r
+      SOAPElement option = pi.next();\r
+      OptionStruct o = new OptionStruct();\r
+      o.optionName = getRequestElement(option, nameOptionName);\r
+      o.voucherSN = getRequestElement(option, nameVoucherSN);\r
+      o.state = Integer.parseInt(getRequestElement(option, nameState));\r
+      o.mode = Integer.parseInt(getRequestElement(option, nameMode));\r
+      o.startDate = getRequestElement(option, nameStartDate);\r
+      o.expirationDate = getRequestElement(option, nameExpirationDate);\r
+      o.isTransferable = Boolean.parseBoolean(getRequestElement(option, nameIsTransferable));\r
+      optionList.add(o);\r
+    }\r
+  }\r
+\r
+}\r