Completed COPS PEP request state manager refactor primarily to remove redundant code. 62/19662/2
authorSteven Pisarski <s.pisarski@cablelabs.com>
Tue, 5 May 2015 20:40:12 +0000 (14:40 -0600)
committerThomas Kee <xsited@yahoo.com>
Fri, 8 May 2015 19:52:02 +0000 (12:52 -0700)
Change-Id: I07f7f1bcb0c53e47f069919fe4dbd46ec255b296
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSReqStateMan.java
packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepReqStateMan.java

index 0361c7bda5de89e4f3e274d08bd40a206f82fc5f..fe7c891197275b97ac4caaa3ad4390ea1281ab2e 100644 (file)
@@ -23,17 +23,12 @@ public class COPSPepOSReqStateMan extends COPSPepReqStateMan {
     /**
         Object for performing policy data processing
      */
-    protected final COPSPepOSDataProcess _process;
+    protected final COPSPepOSDataProcess _thisProcess;
 
     /**
         COPS message transceiver used to send COPS messages
      */
-    protected transient COPSPepOSMsgSender _sender;
-
-    /**
-     * Sync state
-     */
-    protected transient boolean _syncState;
+    protected transient COPSPepOSMsgSender _thisSender;
 
     /**
      * Creates a state request manager
@@ -43,40 +38,23 @@ public class COPSPepOSReqStateMan extends COPSPepReqStateMan {
     public COPSPepOSReqStateMan(final short clientType, final COPSHandle clientHandle, final COPSPepOSDataProcess process,
                                 final Collection<COPSClientSI> clientSIs) {
         super(clientType, clientHandle, process);
-        this._process = process;
+        this._thisProcess = process;
         this._clientSIs = new HashSet<>(clientSIs);
-        _syncState = true;
     }
 
     @Override
     protected void initRequestState(final Socket sock) throws COPSException {
         // Inits an object for sending COPS messages to the PDP
-        _sender = new COPSPepOSMsgSender(_clientType, _handle, sock);
+        _thisSender = new COPSPepOSMsgSender(_clientType, _handle, sock);
+        _sender = _thisSender;
 
-        // If an object exists for retrieving the PEP features,
-        // use it for retrieving them.
-        /*      Hashtable clientSIs;
-                if (_process != null)
-                    clientSIs = _process.getClientData(this);
-                else
-                    clientSIs = null;*/
-
-        // Semd the request
-        _sender.sendRequest(_clientSIs);
+        // Send the request
+        _thisSender.sendRequest(_clientSIs);
 
         // Initial state
         _status = Status.ST_INIT;
     }
 
-    /**
-     * Deletes the request state
-     * @throws COPSPepException
-     */
-    protected void finalizeRequestState() throws COPSException {
-        _sender.sendDeleteRequest();
-        _status = Status.ST_FINAL;
-    }
-
     /**
      * Processes the decision message
      * @param    dMsg Decision message from the PDP
@@ -84,18 +62,18 @@ public class COPSPepOSReqStateMan extends COPSPepReqStateMan {
      */
     protected void processDecision(final COPSDecisionMsg dMsg) throws COPSException {
         //** Applies decisions to the configuration
-        //_process.setDecisions(this, removeDecs, installDecs, errorDecs);
+        //_thisProcess.setDecisions(this, removeDecs, installDecs, errorDecs);
         // second param changed to dMsg so that the data processor
         // can check the 'solicited' flag
-        final boolean isFailReport = _process.setDecisions(this, dMsg);
+        final boolean isFailReport = _thisProcess.setDecisions(this, dMsg);
         _status = Status.ST_DECS;
 
         if (isFailReport) {
             logger.info("Sending FAIL Report");
-            _sender.sendFailReport(_process.getReportData(this));
+            _thisSender.sendFailReport(_thisProcess.getReportData(this));
         } else {
             logger.info("Sending SUCCESS Report");
-            _sender.sendSuccessReport(_process.getReportData(this));
+            _thisSender.sendSuccessReport(_thisProcess.getReportData(this));
         }
         _status = Status.ST_REPORT;
 
@@ -106,74 +84,25 @@ public class COPSPepOSReqStateMan extends COPSPepReqStateMan {
         }
     }
 
-
-    /**
-     * Processes a COPS delete message
-     * @param dMsg  <tt>COPSDeleteMsg</tt> received from the PDP
-     * @throws COPSPepException
-     */
-    protected void processDeleteRequestState(final COPSDecisionMsg dMsg) throws COPSPepException {
-        if (_process != null)
-            _process.closeRequestState(this);
-
-        _status = Status.ST_DEL;
-    }
-
-    /**
-     * Processes the message SycnStateRequest.
-     * The message SycnStateRequest indicates that the remote PDP
-     * wishes the client (which appears in the common header)
-     * to re-send its state.
-     *
-     * @param    ssMsg               The sync request from the PDP
-     *
-     * @throws   COPSPepException
-     *
-     */
+    @Override
     protected void processSyncStateRequest(final COPSSyncStateMsg ssMsg) throws COPSException {
         _syncState = false;
         // If an object exists for retrieving the PEP features,
         // use it for retrieving them.
 
         // Send the request
-        _sender.sendRequest(_clientSIs);
+        _thisSender.sendRequest(_clientSIs);
 
         _status = Status.ST_SYNC;
     }
 
-    /**
-     * Called when connection is closed
-     * @param error Reason
-     * @throws COPSPepException
-     */
-    protected void processClosedConnection(final COPSError error) throws COPSPepException {
-        if (_process != null)
-            _process.notifyClosedConnection(this, error);
-
-        _status = Status.ST_CCONN;
-    }
-
-    /**
-     * Called when no keep-alive is received
-     * @throws COPSPepException
-     */
-    protected void processNoKAConnection() throws COPSPepException {
-        if (_process != null)
-            _process.notifyNoKAliveReceived(this);
-
-        _status = Status.ST_NOKA;
-    }
-
-    /**
-     * Processes the accounting report
-     * @throws COPSPepException
-     */
-    protected void processAcctReport() throws COPSPepException {
+    @Override
+    public void processAcctReport() throws COPSPepException {
         final List<COPSClientSI> report;
-        if (_process != null) report = new ArrayList<>(_process.getAcctData(this));
+        if (_thisProcess != null) report = new ArrayList<>(_thisProcess.getAcctData(this));
         else report = new ArrayList<>();
 
-        _sender.sendAcctReport(report);
+        _thisSender.sendAcctReport(report);
 
         _status = Status.ST_ACCT;
     }
index 0c8024fbf0a3d90f119d22af7320b60cb8745db2..6cbe8a1063e740087ed226b6610475f897411c7f 100644 (file)
@@ -106,7 +106,7 @@ public class COPSPepReqStateMan extends COPSStateMan {
      * @throws   COPSPepException
      *
      */
-    protected void finalizeRequestState() throws COPSException {
+    public void finalizeRequestState() throws COPSException {
         _sender.sendDeleteRequest();
         _status = Status.ST_FINAL;
     }
@@ -260,7 +260,7 @@ public class COPSPepReqStateMan extends COPSStateMan {
      * @throws   COPSPepException
      *
      */
-    protected void processDeleteRequestState(final COPSDecisionMsg dMsg) throws COPSException {
+    protected void processDeleteRequestState(final COPSDecisionMsg dMsg) throws COPSPepException {
         if (_process != null)
             _process.closeRequestState(this);
 
@@ -295,21 +295,21 @@ public class COPSPepReqStateMan extends COPSStateMan {
         _status = Status.ST_SYNC;
     }
 
-    protected void processClosedConnection(final COPSError error) throws COPSException {
+    public void processClosedConnection(final COPSError error) throws COPSPepException {
         if (_process != null)
             _process.notifyClosedConnection(this, error);
 
         _status = Status.ST_CCONN;
     }
 
-    protected void processNoKAConnection() throws COPSException {
+    public void processNoKAConnection() throws COPSException {
         if (_process != null)
             _process.notifyNoKAliveReceived(this);
 
         _status = Status.ST_NOKA;
     }
 
-    protected void processAcctReport() throws COPSException {
+    public void processAcctReport() throws COPSException {
         final Map<String, String> report;
         if (_process != null) report = _process.getAcctData(this);
         else report = new HashMap<>();