34d086a46e1419589a50e36de0664a289a3385b6
[packetcable.git] / packetcable-driver / src / main / java / org / pcmm / PCMMPdpDataProcess.java
1 /**
2  @header@
3  */
4
5 package org.pcmm;
6
7 import org.pcmm.gates.ITransactionID;
8 import org.pcmm.gates.impl.PCMMGateReq;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11 import org.umu.cops.stack.COPSError;
12
13 import java.util.Hashtable;
14
15
16 public class PCMMPdpDataProcess { // extends COPSPdpDataProcess
17
18     public final static Logger logger = LoggerFactory.getLogger(PCMMPdpAgent.class);
19
20     private Hashtable installPolicy;
21     private Hashtable removePolicy;
22
23     public PCMMPdpDataProcess() {
24     }
25
26     /**
27      * PDPAgent gets the policies to delete from PEP
28      *
29      * @param man
30      * @return
31      */
32     public Hashtable getRemovePolicy(PCMMPdpReqStateMan man) {
33         return removePolicy;
34     }
35
36     /**
37      * PDPAgent gets the policies to be installed in PEP
38      *
39      * @param man
40      * @return
41      */
42     public Hashtable getInstallPolicy(PCMMPdpReqStateMan man) {
43         return installPolicy;
44     }
45
46     /**
47      * PEP configuration items for sending inside the request
48      *
49      * @param man
50      * @param reqSIs
51      */
52     public void setClientData(PCMMPdpReqStateMan man, Hashtable reqSIs) {
53
54         logger.info("Request Info");
55         /*
56                 for (Enumeration e = reqSIs.keys() ; e.hasMoreElements() ;) {
57                     String strprid = (String) e.nextElement();
58                     String strepd = (String) reqSIs.get(strprid);
59
60                     // Check PRID-EPD
61                     // ....
62                     System.out.println(getClass().getName() + ": " + "PRID: " + strprid);
63                     System.out.println(getClass().getName() + ": " + "EPD: " + strepd);
64                 }
65
66                 // Create policies to be deleted
67                 // ....
68
69                 // Create policies to be installed
70                 String prid = new String("<XPath>");
71                 String epd = new String("<?xml this is an XML policy>");
72                 installPolicy.put(prid, epd);
73         */
74     }
75
76     /**
77      * Fail report received
78      *
79      * @param man
80      * @param gateMsg
81      */
82     public void failReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
83
84         logger.info("Fail Report notified with error - " + gateMsg.getError().toString());
85         /*
86
87                 System.out.println(getClass().getName() + ": " + "Report Info");
88                 for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
89                     String strprid = (String) e.nextElement();
90                     String strepd = (String) reportSIs.get(strprid);
91
92                     // Check PRID-EPD
93                     // ....
94                     System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
95                     System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
96                 }
97         */
98     }
99
100     /**
101      * Positive report received
102      *
103      * @param man
104      * @param gateMsg
105      */
106     public void successReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
107         logger.info("Success Report notified.");
108
109         if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateDeleteAck ) {
110             logger.info("GateDeleteAck: GateID = " + gateMsg.getGateID().getGateID());
111             if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID1())
112                 PCMMGlobalConfig.setGateID1(0);
113             if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID2())
114                 PCMMGlobalConfig.setGateID2(0);
115
116         }
117         if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck ) {
118             logger.info("GateSetAck : GateID = " + gateMsg.getGateID().getGateID());
119             if (0 == PCMMGlobalConfig.getGateID1())
120                 PCMMGlobalConfig.setGateID1(gateMsg.getGateID().getGateID());
121             if (0 == PCMMGlobalConfig.getGateID2())
122                 PCMMGlobalConfig.setGateID2(gateMsg.getGateID().getGateID());
123         }
124
125         /*
126                 System.out.println(getClass().getName()+ ": " + "Report Info");
127                 for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
128                     String strprid = (String) e.nextElement();
129                     String strepd = (String) reportSIs.get(strprid);
130
131                     // Check PRID-EPD
132                     // ....
133                     System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
134                     System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
135                 }
136         */
137
138     }
139
140     /**
141      * Accounting report received
142      *
143      * @param man
144      * @param gateMsg
145      */
146     public void acctReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
147         logger.info("Acct Report notified.");
148
149         /*
150                 System.out.println(getClass().getName()+ ": " + "Report Info");
151                 for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
152                     String strprid = (String) e.nextElement();
153                     String strepd = (String) reportSIs.get(strprid);
154
155                     // Check PRID-EPD
156                     // ....
157                     System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
158                     System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
159                 }
160         */
161     }
162
163     /**
164      * Notifies that an Accounting report is missing
165      *
166      * @param man
167      */
168     public void notifyNoAcctReport(PCMMPdpReqStateMan man) {
169         //To change body of implemented methods use File | Settings | File Templates.
170     }
171
172     /**
173      * Notifies that a KeepAlive message is missing
174      *
175      * @param man
176      */
177     public void notifyNoKAliveReceived(PCMMPdpReqStateMan man) {
178         //To change body of implemented methods use File | Settings | File Templates.
179     }
180
181     /**
182      * PEP closed the connection
183      *
184      * @param man
185      * @param error
186      */
187     public void notifyClosedConnection(PCMMPdpReqStateMan man, COPSError error) {
188         logger.info("Connection was closed by PEP");
189     }
190
191     /**
192      * Delete request state received
193      *
194      * @param man
195      */
196     public void notifyDeleteRequestState(PCMMPdpReqStateMan man) {
197         //To change body of implemented methods use File | Settings | File Templates.
198     }
199
200     /**
201      * Closes request state
202      *
203      * @param man
204      */
205     public void closeRequestState(PCMMPdpReqStateMan man) {
206         //To change body of implemented methods use File | Settings | File Templates.
207     }
208 }