PageRenderTime 27ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/servers/jain-slee/resources/diameter-gq/events/src/main/java/org/mobicents/slee/resource/diameter/gq/events/GqAARequestImpl.java

http://mobicents.googlecode.com/
Java | 504 lines | 206 code | 49 blank | 249 comment | 4 complexity | b4bb486993ca34d14e7cb30a964791ed MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.slee.resource.diameter.gq.events;
  23. import net.java.slee.resource.diameter.base.events.avp.DiameterAvpCodes;
  24. import net.java.slee.resource.diameter.gq.events.GqAARequest;
  25. import net.java.slee.resource.diameter.gq.events.avp.BindingInformation;
  26. import net.java.slee.resource.diameter.gq.events.avp.FlowGrouping;
  27. import net.java.slee.resource.diameter.gq.events.avp.GloballyUniqueAddress;
  28. import net.java.slee.resource.diameter.gq.events.avp.LatchingIndication;
  29. import net.java.slee.resource.diameter.gq.events.avp.MediaComponentDescription;
  30. import net.java.slee.resource.diameter.gq.events.avp.OverbookingIndicator;
  31. import net.java.slee.resource.diameter.gq.events.avp.ReservationPriority;
  32. import net.java.slee.resource.diameter.gq.events.avp.SIPForkingIndication;
  33. import net.java.slee.resource.diameter.gq.events.avp.SpecificAction;
  34. import org.jdiameter.api.Message;
  35. import org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl;
  36. import org.mobicents.slee.resource.diameter.gq.events.avp.BindingInformationImpl;
  37. import org.mobicents.slee.resource.diameter.gq.events.avp.DiameterGqAvpCodes;
  38. import org.mobicents.slee.resource.diameter.gq.events.avp.FlowGroupingImpl;
  39. import org.mobicents.slee.resource.diameter.gq.events.avp.GloballyUniqueAddressImpl;
  40. import org.mobicents.slee.resource.diameter.gq.events.avp.MediaComponentDescriptionImpl;
  41. /**
  42. * <pre>
  43. * <b>7.1.1 AA-Request(AAR) command</b>
  44. * The AAR command, indicated by the Command-Code field set to 265 and the "R" bit set in the Command Flags field,
  45. * is sent by an AF to the SPDF in order to request the authorization for the bearer usage for the AF session.
  46. * Message Format:
  47. * &lt;AA-Request&gt; ::= < Diameter Header: 265, REQ, PXY >
  48. * < Session-Id >
  49. * { Auth-Application-Id }
  50. * { Origin-Host }
  51. * { Origin-Realm }
  52. * { Destination-Realm }
  53. * *[ Media-Component-Description ]
  54. * *[ Flow-Grouping ]
  55. * [ AF-Charging-Identifier ]
  56. * [ SIP-Forking-Indication ]
  57. * *[ Specific-Action ]
  58. * [ User-Name ]
  59. * [ Binding-Information ]
  60. * [ Latching-Indication ]
  61. * [ Reservation-Priority ]
  62. * [ Globally-Unique-Address ]
  63. * [ Service-Class ]
  64. * [ Authorization-Lifetime ]
  65. * *[ Proxy-Info ]
  66. * *[ Route-Record ]
  67. * [ Overbooking-Indicator ]
  68. * *[ Authorization-Package-Id ]
  69. * *[ AVP ]
  70. * </pre>
  71. *
  72. * @author <a href="mailto:webdev@web-ukraine.info"> Yulian Oifa </a>
  73. */
  74. public class GqAARequestImpl extends DiameterMessageImpl implements GqAARequest {
  75. public GqAARequestImpl(Message message) {
  76. super(message);
  77. }
  78. @Override
  79. /*
  80. * (non-Javadoc)
  81. *
  82. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getAuthorizationLifetime
  83. */
  84. public long getAuthorizationLifetime() {
  85. return getAvpAsUnsigned32(DiameterAvpCodes.AUTHORIZATION_LIFETIME);
  86. }
  87. @Override
  88. /*
  89. * (non-Javadoc)
  90. *
  91. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setAuthorizationLifetime
  92. */
  93. public void setAuthorizationLifetime(long authorizationLifetime) throws IllegalStateException {
  94. addAvp(DiameterAvpCodes.AUTHORIZATION_LIFETIME, authorizationLifetime);
  95. }
  96. @Override
  97. /*
  98. * (non-Javadoc)
  99. *
  100. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasAuthorizationLifetime
  101. */
  102. public boolean hasAuthorizationLifetime() {
  103. return hasAvp(DiameterAvpCodes.AUTHORIZATION_LIFETIME);
  104. }
  105. @Override
  106. /*
  107. * (non-Javadoc)
  108. *
  109. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getMediaComponentDescriptions
  110. */
  111. public MediaComponentDescription[] getMediaComponentDescriptions() {
  112. return (MediaComponentDescription[]) getAvpsAsCustom(DiameterGqAvpCodes.TGPP_MEDIA_COMPONENT_DESCRIPTION,
  113. DiameterGqAvpCodes.TGPP_VENDOR_ID, MediaComponentDescriptionImpl.class);
  114. }
  115. @Override
  116. /*
  117. * (non-Javadoc)
  118. *
  119. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setMediaComponentDescription
  120. */
  121. public void setMediaComponentDescription(MediaComponentDescription mediaComponentDescription) throws IllegalStateException {
  122. addAvp(DiameterGqAvpCodes.TGPP_MEDIA_COMPONENT_DESCRIPTION, DiameterGqAvpCodes.TGPP_VENDOR_ID,
  123. mediaComponentDescription.byteArrayValue());
  124. }
  125. @Override
  126. /*
  127. * (non-Javadoc)
  128. *
  129. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setMediaComponentDescriptions
  130. */
  131. public void setMediaComponentDescriptions(MediaComponentDescription[] mediaComponentDescriptions) throws IllegalStateException {
  132. for (MediaComponentDescription mediaComponentDescription : mediaComponentDescriptions) {
  133. setMediaComponentDescription(mediaComponentDescription);
  134. }
  135. }
  136. @Override
  137. /*
  138. * (non-Javadoc)
  139. *
  140. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getFlowGrouping
  141. */
  142. public FlowGrouping[] getFlowGroupings() {
  143. return (FlowGrouping[]) getAvpsAsCustom(DiameterGqAvpCodes.TGPP_FLOW_GROUPING, DiameterGqAvpCodes.TGPP_VENDOR_ID,
  144. FlowGroupingImpl.class);
  145. }
  146. @Override
  147. /*
  148. * (non-Javadoc)
  149. *
  150. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setFlowGrouping
  151. */
  152. public void setFlowGrouping(FlowGrouping flowGrouping) throws IllegalStateException {
  153. addAvp(DiameterGqAvpCodes.TGPP_FLOW_GROUPING, DiameterGqAvpCodes.TGPP_VENDOR_ID, flowGrouping.byteArrayValue());
  154. }
  155. @Override
  156. /*
  157. * (non-Javadoc)
  158. *
  159. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setFlowGroupings
  160. */
  161. public void setFlowGroupings(FlowGrouping[] flowGroupings) throws IllegalStateException {
  162. for (FlowGrouping flowGrouping : flowGroupings) {
  163. setFlowGrouping(flowGrouping);
  164. }
  165. }
  166. @Override
  167. /*
  168. * (non-Javadoc)
  169. *
  170. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getAFChargingIdentifier
  171. */
  172. public byte[] getAFChargingIdentifier() {
  173. return getAvpAsOctetString(DiameterGqAvpCodes.TGPP_AF_CHARGING_IDENTIFIER, DiameterGqAvpCodes.TGPP_VENDOR_ID);
  174. }
  175. @Override
  176. /*
  177. * (non-Javadoc)
  178. *
  179. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setAFChargingIdentifier
  180. */
  181. public void setAFChargingIdentifier(byte[] AFChargingIdentifier) {
  182. addAvp(DiameterGqAvpCodes.TGPP_AF_CHARGING_IDENTIFIER, DiameterGqAvpCodes.TGPP_VENDOR_ID, AFChargingIdentifier);
  183. }
  184. @Override
  185. /*
  186. * (non-Javadoc)
  187. *
  188. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasAFChargingIdentifier
  189. */
  190. public boolean hasAFChargingIdentifier() {
  191. return hasAvp(DiameterGqAvpCodes.TGPP_AF_CHARGING_IDENTIFIER, DiameterGqAvpCodes.TGPP_VENDOR_ID);
  192. }
  193. @Override
  194. /*
  195. * (non-Javadoc)
  196. *
  197. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getSIPForkingIndication
  198. */
  199. public SIPForkingIndication getSIPForkingIndication() {
  200. return (SIPForkingIndication) getAvpAsEnumerated(DiameterGqAvpCodes.TGPP_SIP_FORKING_INDICATION, DiameterGqAvpCodes.TGPP_VENDOR_ID,
  201. SIPForkingIndication.class);
  202. }
  203. @Override
  204. /*
  205. * (non-Javadoc)
  206. *
  207. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setSIPForkingIndication
  208. */
  209. public void setSIPForkingIndication(SIPForkingIndication SIPForkingIndication) {
  210. addAvp(DiameterGqAvpCodes.TGPP_SIP_FORKING_INDICATION, DiameterGqAvpCodes.TGPP_VENDOR_ID, SIPForkingIndication.getValue());
  211. }
  212. @Override
  213. /*
  214. * (non-Javadoc)
  215. *
  216. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasSIPForkingIndication
  217. */
  218. public boolean hasSIPForkingIndication() {
  219. return hasAvp(DiameterGqAvpCodes.TGPP_SIP_FORKING_INDICATION, DiameterGqAvpCodes.TGPP_VENDOR_ID);
  220. }
  221. @Override
  222. /*
  223. * (non-Javadoc)
  224. *
  225. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getSpecificAction
  226. */
  227. public SpecificAction[] getSpecificActions() {
  228. return (SpecificAction[]) getAvpsAsEnumerated(DiameterGqAvpCodes.TGPP_SPECIFIC_ACTION, DiameterGqAvpCodes.TGPP_VENDOR_ID,
  229. SpecificAction.class);
  230. }
  231. @Override
  232. /*
  233. * (non-Javadoc)
  234. *
  235. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setSpecificAction
  236. */
  237. public void setSpecificAction(SpecificAction specificAction) throws IllegalStateException {
  238. addAvp(DiameterGqAvpCodes.TGPP_SPECIFIC_ACTION, DiameterGqAvpCodes.TGPP_VENDOR_ID, specificAction.getValue());
  239. }
  240. @Override
  241. /*
  242. * (non-Javadoc)
  243. *
  244. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setSpecificActions
  245. */
  246. public void setSpecificActions(SpecificAction[] specificActions) throws IllegalStateException {
  247. for (SpecificAction specificAction : specificActions) {
  248. setSpecificAction(specificAction);
  249. }
  250. }
  251. @Override
  252. /*
  253. * (non-Javadoc)
  254. *
  255. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getBindingInformation
  256. */
  257. public BindingInformation getBindingInformation() {
  258. return (BindingInformation) getAvpAsCustom(DiameterGqAvpCodes.ETSI_BINDING_INFORMATION, DiameterGqAvpCodes.ETSI_VENDOR_ID,
  259. BindingInformationImpl.class);
  260. }
  261. @Override
  262. /*
  263. * (non-Javadoc)
  264. *
  265. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setBindingInformation
  266. */
  267. public void setBindingInformation(BindingInformation bindingInformation) throws IllegalStateException {
  268. addAvp(DiameterGqAvpCodes.ETSI_BINDING_INFORMATION, DiameterGqAvpCodes.ETSI_VENDOR_ID, bindingInformation.byteArrayValue());
  269. }
  270. @Override
  271. /*
  272. * (non-Javadoc)
  273. *
  274. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasBindingInformation
  275. */
  276. public boolean hasBindingInformation() {
  277. return hasAvp(DiameterGqAvpCodes.ETSI_BINDING_INFORMATION, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  278. }
  279. @Override
  280. /*
  281. * (non-Javadoc)
  282. *
  283. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getLatchingIndication
  284. */
  285. public LatchingIndication getLatchingIndication() {
  286. return (LatchingIndication) getAvpAsEnumerated(DiameterGqAvpCodes.ETSI_LATCHING_INDICATION, DiameterGqAvpCodes.ETSI_VENDOR_ID,
  287. LatchingIndication.class);
  288. }
  289. @Override
  290. /*
  291. * (non-Javadoc)
  292. *
  293. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setLatchingIndication
  294. */
  295. public void setLatchingIndication(LatchingIndication latchingIndication) throws IllegalStateException {
  296. addAvp(DiameterGqAvpCodes.ETSI_LATCHING_INDICATION, DiameterGqAvpCodes.ETSI_VENDOR_ID, latchingIndication.getValue());
  297. }
  298. @Override
  299. /*
  300. * (non-Javadoc)
  301. *
  302. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasLatchingIndication
  303. */
  304. public boolean hasLatchingIndication() {
  305. return hasAvp(DiameterGqAvpCodes.ETSI_LATCHING_INDICATION, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  306. }
  307. @Override
  308. /*
  309. * (non-Javadoc)
  310. *
  311. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getReservationPriority
  312. */
  313. public ReservationPriority getReservationPriority() {
  314. return (ReservationPriority) getAvpAsEnumerated(DiameterGqAvpCodes.ETSI_RESERVATION_PRIORITY, DiameterGqAvpCodes.ETSI_VENDOR_ID,
  315. ReservationPriority.class);
  316. }
  317. @Override
  318. /*
  319. * (non-Javadoc)
  320. *
  321. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setReservationPriority
  322. */
  323. public void setReservationPriority(ReservationPriority reservationPriority) throws IllegalStateException {
  324. addAvp(DiameterGqAvpCodes.ETSI_RESERVATION_PRIORITY, DiameterGqAvpCodes.ETSI_VENDOR_ID, reservationPriority.getValue());
  325. }
  326. @Override
  327. /*
  328. * (non-Javadoc)
  329. *
  330. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasReservationPriority
  331. */
  332. public boolean hasReservationPriority() {
  333. return hasAvp(DiameterGqAvpCodes.ETSI_RESERVATION_PRIORITY, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  334. }
  335. @Override
  336. /*
  337. * (non-Javadoc)
  338. *
  339. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getGloballyUniqueAddress
  340. */
  341. public GloballyUniqueAddress getGloballyUniqueAddress() {
  342. return (GloballyUniqueAddress) getAvpAsCustom(DiameterGqAvpCodes.ETSI_GLOBALLY_UNIQUE_ADDRESS, DiameterGqAvpCodes.ETSI_VENDOR_ID,
  343. GloballyUniqueAddressImpl.class);
  344. }
  345. @Override
  346. /*
  347. * (non-Javadoc)
  348. *
  349. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setGloballyUniqueAddress
  350. */
  351. public void setGloballyUniqueAddress(GloballyUniqueAddress globallyUniqueAddress) throws IllegalStateException {
  352. addAvp(DiameterGqAvpCodes.ETSI_GLOBALLY_UNIQUE_ADDRESS, DiameterGqAvpCodes.ETSI_VENDOR_ID, globallyUniqueAddress.byteArrayValue());
  353. }
  354. @Override
  355. /*
  356. * (non-Javadoc)
  357. *
  358. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasGloballyUniqueAddress
  359. */
  360. public boolean hasGloballyUniqueAddress() {
  361. return hasAvp(DiameterGqAvpCodes.ETSI_GLOBALLY_UNIQUE_ADDRESS, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  362. }
  363. @Override
  364. /*
  365. * (non-Javadoc)
  366. *
  367. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasServiceClass
  368. */
  369. public boolean hasServiceClass() {
  370. return hasAvp(DiameterGqAvpCodes.ETSI_SERVICE_CLASS, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  371. }
  372. @Override
  373. /*
  374. * (non-Javadoc)
  375. *
  376. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getServiceClass
  377. */
  378. public String getServiceClass() {
  379. return getAvpAsUTF8String(DiameterGqAvpCodes.ETSI_SERVICE_CLASS, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  380. }
  381. @Override
  382. /*
  383. * (non-Javadoc)
  384. *
  385. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setServiceClass
  386. */
  387. public void setServiceClass(String serviceClass) {
  388. addAvp(DiameterGqAvpCodes.ETSI_SERVICE_CLASS, DiameterGqAvpCodes.ETSI_VENDOR_ID, serviceClass);
  389. }
  390. @Override
  391. /*
  392. * (non-Javadoc)
  393. *
  394. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getOverbookingIndicator
  395. */
  396. public OverbookingIndicator getOverbookingIndicator() {
  397. return (OverbookingIndicator) getAvpAsEnumerated(DiameterGqAvpCodes.ETSI_OVERBOOKING_INDICATOR, DiameterGqAvpCodes.ETSI_VENDOR_ID,
  398. OverbookingIndicator.class);
  399. }
  400. @Override
  401. /*
  402. * (non-Javadoc)
  403. *
  404. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setOverbookingIndicator
  405. */
  406. public void setOverbookingIndicator(OverbookingIndicator overbookingIndicator) throws IllegalStateException {
  407. addAvp(DiameterGqAvpCodes.ETSI_OVERBOOKING_INDICATOR, DiameterGqAvpCodes.ETSI_VENDOR_ID, overbookingIndicator.getValue());
  408. }
  409. @Override
  410. /*
  411. * (non-Javadoc)
  412. *
  413. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#hasOverbookingIndicator
  414. */
  415. public boolean hasOverbookingIndicator() {
  416. return hasAvp(DiameterGqAvpCodes.ETSI_OVERBOOKING_INDICATOR, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  417. }
  418. @Override
  419. /*
  420. * (non-Javadoc)
  421. *
  422. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#getAuthorizationPackageId
  423. */
  424. public String[] getAuthorizationPackageIds() {
  425. return getAvpsAsUTF8String(DiameterGqAvpCodes.ETSI_AUTHORIZATION_PACKAGE_ID, DiameterGqAvpCodes.ETSI_VENDOR_ID);
  426. }
  427. @Override
  428. /*
  429. * (non-Javadoc)
  430. *
  431. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setAuthorizationPackageId
  432. */
  433. public void setAuthorizationPackageId(String authorizationPackageId) throws IllegalStateException {
  434. addAvp(DiameterGqAvpCodes.ETSI_AUTHORIZATION_PACKAGE_ID, DiameterGqAvpCodes.ETSI_VENDOR_ID, authorizationPackageId);
  435. }
  436. @Override
  437. /*
  438. * (non-Javadoc)
  439. *
  440. * @see net.java.slee.resource.diameter.gq.events.GqAARequest#setAuthorizationPackageIds
  441. */
  442. public void setAuthorizationPackageIds(String[] authorizationPackageIds) throws IllegalStateException {
  443. for (String authorizationPackageId : authorizationPackageIds) {
  444. setAuthorizationPackageId(authorizationPackageId);
  445. }
  446. }
  447. @Override
  448. public String getLongName() {
  449. return "AA-Request";
  450. }
  451. @Override
  452. public String getShortName() {
  453. return "AAR";
  454. }
  455. }