+ if (decision.getData().getData().length != 0) {
+ final COPSPrObjBase obj = new COPSPrObjBase(decision.getData().getData());
+ switch (obj.getSNum()) {
+ case COPSPrObjBase.PR_PRID:
+ prid = obj.getData().str();
+ break;
+ case COPSPrObjBase.PR_EPD:
+ installDecs.put(prid, obj.getData().str());
+ break;
+ }
+ }
+ if (decision.getFlag().equals(DecisionFlag.REQERROR)) {
+ // This is assuming a gate set right or wrong
+ if (dMsg.getDecisions().size() == 1 && dMsg.getDecSI() != null) {
+ final PCMMGateReq gateReq = new PCMMGateReq(dMsg.getDecSI().getData().getData());
+ // TODO - Check and/or Set state here
+ // Gate ADD gateReq.getTrafficProfile() != null
+ // Gate REMOVE gateReq.getTrafficProfile() == null
+// final String gateName = trafficProfile.getData().str();
+// final Direction gateDir = gateReq.getGateSpec().getDirection();
+ final boolean success = true;
+
+ // Set response
+ final List<Byte> data = new ArrayList<>();
+ for (final byte val : gateReq.getTransactionID().getAsBinaryArray())
+ data.add(val);
+ for (final byte val : gateReq.getAMID().getAsBinaryArray())
+ data.add(val);
+ for (final byte val : gateReq.getSubscriberID().getAsBinaryArray())
+ data.add(val);
+
+ // Assign a gate ID
+ final GateID gateID = new GateID();
+ gateID.setGateID(UUID.randomUUID().hashCode());
+ for (final byte val : gateID.getAsBinaryArray())
+ data.add(val);
+
+
+ final byte[] csiArr = new byte[data.size()];
+ for (int i = 0; i < data.size(); i++) {
+ csiArr[i] = data.get(i);
+ }
+ final COPSClientSI si = new COPSClientSI(CNum.CSI, CType.DEF, new COPSData(csiArr, 0, csiArr.length));
+
+ final COPSReportMsg reportMsg;
+ // TODO FIXME - success is always true
+ if (success) {
+ reportMsg = new COPSReportMsg(_clientType, getClientHandle(),
+ new COPSReportType(ReportType.SUCCESS), si, null);
+ } else {
+ reportMsg = new COPSReportMsg(_clientType, getClientHandle(),
+ new COPSReportType(ReportType.FAILURE), si, null);
+ }
+
+ try {
+ reportMsg.writeData(socket);
+ } catch (IOException e) {
+ throw new COPSPepException("Error writing gate set SUCCESS Report", e);
+ }
+ }