PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/WindowsAzure/ServiceBus/Models/SubscriptionInfo.php

http://github.com/WindowsAzure/azure-sdk-for-php
PHP | 402 lines | 157 code | 32 blank | 213 comment | 4 complexity | be527f168161d6b6121abf7d280b8314 MD5 | raw file
  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package WindowsAzure\ServiceBus\Models
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  22. */
  23. namespace WindowsAzure\ServiceBus\Models;
  24. use WindowsAzure\Common\Internal\Atom\Entry;
  25. use WindowsAzure\Common\Internal\Atom\Content;
  26. use WindowsAzure\Common\Internal\Serialization\XmlSerializer;
  27. use WindowsAzure\Common\Internal\Resources;
  28. use WindowsAzure\Common\Internal\Utilities;
  29. use WindowsAzure\Common\Internal\Validate;
  30. use WindowsAzure\ServiceBus\Models\SubscriptionDescription;
  31. /**
  32. * The information of a subscription.
  33. *
  34. * @category Microsoft
  35. * @package WindowsAzure\ServiceBus\Models
  36. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  37. * @copyright 2012 Microsoft Corporation
  38. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  39. * @version Release: @package_version@
  40. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  41. */
  42. class SubscriptionInfo extends Entry
  43. {
  44. /**
  45. * The entry of the subscription info.
  46. *
  47. * @var Entry
  48. */
  49. private $_entry;
  50. /**
  51. * The description of the subscription.
  52. *
  53. * @var SubscriptionDescription
  54. */
  55. private $_subscriptionDescription;
  56. /**
  57. * Creates a SubscriptionInfo instance with specified parameters.
  58. *
  59. * @param string $title The title of
  60. * the subscription.
  61. * @param SubscriptionDescription $subscriptionDescription The description
  62. * of the subscription.
  63. *
  64. */
  65. public function __construct(
  66. $title = Resources::EMPTY_STRING,
  67. $subscriptionDescription = null
  68. ) {
  69. Validate::isString($title, 'title');
  70. if (is_null($subscriptionDescription)) {
  71. $subscriptionDescription = new SubscriptionDescription();
  72. }
  73. $this->_subscriptionDescription = $subscriptionDescription;
  74. $this->_entry = new Entry();
  75. $this->_entry->setTitle($title);
  76. $this->_entry->setAttribute(
  77. Resources::XMLNS,
  78. Resources::SERVICE_BUS_NAMESPACE
  79. );
  80. }
  81. /**
  82. * Populates the properties of the subscription info instance with a XML string.
  83. *
  84. * @param string $entryXml A XML string representing a subscription
  85. * information instance.
  86. *
  87. * @return none
  88. */
  89. public function parseXml($entryXml)
  90. {
  91. $this->_entry->parseXml($entryXml);
  92. $content = $this->_entry->getContent();
  93. if (is_null($content)) {
  94. $this->_subscriptionDescription = null;
  95. } else {
  96. $this->_subscriptionDescription = SubscriptionDescription::create(
  97. $content->getText()
  98. );
  99. }
  100. }
  101. /**
  102. * Writes XML based on the subscription information.
  103. *
  104. * @param XMLWriter $xmlWriter The XML writer.
  105. *
  106. * @return none
  107. */
  108. public function writeXml($xmlWriter)
  109. {
  110. $content = null;
  111. if (!is_null($this->_subscriptionDescription)) {
  112. $content = new Content();
  113. $content->setText(
  114. XmlSerializer::objectSerialize(
  115. $this->_subscriptionDescription,
  116. 'SubscriptionDescription'
  117. )
  118. );
  119. }
  120. $this->_entry->setContent($content);
  121. $this->_entry->writeXml($xmlWriter);
  122. }
  123. /**
  124. * Gets the entry of the subscription info.
  125. *
  126. * @return Entry
  127. */
  128. public function getEntry()
  129. {
  130. return $this->_entry;
  131. }
  132. /**
  133. * Sets the entry of the subscription info.
  134. *
  135. * @param Entry $entry The entry of the subscription info.
  136. *
  137. * @return none
  138. */
  139. public function setEntry($entry)
  140. {
  141. $this->_entry = $entry;
  142. }
  143. /**
  144. * Gets the title.
  145. *
  146. * @return string
  147. */
  148. public function getTitle()
  149. {
  150. return $this->_entry->getTitle();
  151. }
  152. /**
  153. * Sets the title.
  154. *
  155. * @param string $title The title of the queue info.
  156. *
  157. * @return none
  158. */
  159. public function setTitle($title)
  160. {
  161. $this->_entry->setTitle($title);
  162. }
  163. /**
  164. * Gets the subscription description.
  165. *
  166. * @return none
  167. */
  168. public function getSubscriptionDescription()
  169. {
  170. return $this->_subscriptionDescription;
  171. }
  172. /**
  173. * Sets the subscription description.
  174. *
  175. * @param string $subscriptionDescription The description of
  176. * the subscription.
  177. *
  178. * @return none
  179. */
  180. public function setSubscriptionDescription($subscriptionDescription)
  181. {
  182. $this->_subscriptionDescription = $subscriptionDescription;
  183. }
  184. /**
  185. * Gets the lock duration.
  186. *
  187. * @return integer
  188. */
  189. public function getLockDuration()
  190. {
  191. return $this->_subscriptionDescription->getLockDuration();
  192. }
  193. /**
  194. * Sets the lock duration.
  195. *
  196. * @param string $lockDuration The duration of the lock.
  197. *
  198. * @return none
  199. */
  200. public function setLockDuration($lockDuration)
  201. {
  202. $this->_subscriptionDescription->setlockDuration($lockDuration);
  203. }
  204. /**
  205. * Gets requires session.
  206. *
  207. * @return boolean
  208. */
  209. public function getRequiresSession()
  210. {
  211. return $this->_subscriptionDescription->getRequiresSession();
  212. }
  213. /**
  214. * Sets the requires session.
  215. *
  216. * @param boolean $requiresSession The requires session.
  217. *
  218. * @return none
  219. */
  220. public function setRequiresSession($requiresSession)
  221. {
  222. $this->_subscriptionDescription->setRequiresSession($requiresSession);
  223. }
  224. /**
  225. * Gets default message time to live.
  226. *
  227. * @return string
  228. */
  229. public function getDefaultMessageTimeToLive()
  230. {
  231. return $this->_subscriptionDescription->getDefaultMessageTimeToLive();
  232. }
  233. /**
  234. * Sets default message time to live.
  235. *
  236. * @param string $defaultMessageTimeToLive The default message time to live.
  237. *
  238. * @return none
  239. */
  240. public function setDefaultMessageTimeToLive($defaultMessageTimeToLive)
  241. {
  242. $this->_subscriptionDescription->setDefaultMessageTimeToLive($defaultMessageTimeToLive);
  243. }
  244. /**
  245. * Gets dead lettering on message expiration.
  246. *
  247. * @return string
  248. */
  249. public function getDeadLetteringOnMessageExpiration()
  250. {
  251. return $this->_subscriptionDescription->getDeadLetteringOnMessageExpiration();
  252. }
  253. /**
  254. * Sets dead lettering on message expiration.
  255. *
  256. * @param string $deadLetteringOnMessageExpiration The dead lettering
  257. * on message expiration.
  258. *
  259. * @return none
  260. */
  261. public function setDeadLetteringOnMessageExpiration(
  262. $deadLetteringOnMessageExpiration
  263. ) {
  264. $this->_subscriptionDescription->setDeadLetteringOnMessageExpiration($deadLetteringOnMessageExpiration);
  265. }
  266. /**
  267. * Gets dead lettering on filter evaluation exceptions.
  268. *
  269. * @return string
  270. */
  271. public function getDeadLetteringOnFilterEvaluationExceptions()
  272. {
  273. return $this->_subscriptionDescription->getDeadLetteringOnFilterEvaluationExceptions();
  274. }
  275. /**
  276. * Sets dead lettering on filter evaluation exceptions.
  277. *
  278. * @param string $deadLetteringOnFilterEvaluationExceptions Sets dead lettering
  279. * on filter evaluation exceptions.
  280. *
  281. * @return none
  282. */
  283. public function setDeadLetteringOnFilterEvaluationExceptions(
  284. $deadLetteringOnFilterEvaluationExceptions
  285. ) {
  286. $this->_subscriptionDescription->setdeadLetteringOnFilterEvaluationExceptions(
  287. $deadLetteringOnFilterEvaluationExceptions
  288. );
  289. }
  290. /**
  291. * Gets the default rule description.
  292. *
  293. * @return RuleDescription
  294. */
  295. public function getDefaultRuleDescription()
  296. {
  297. return $this->_subscriptionDescription->getDefaultRuleDescription();
  298. }
  299. /**
  300. * Sets the default rule description.
  301. *
  302. * @param string $defaultRuleDescription The default rule description.
  303. *
  304. * @return none
  305. */
  306. public function setDefaultRuleDescription($defaultRuleDescription)
  307. {
  308. $this->_subscriptionDescription->setDefaultRuleDescription($defaultRuleDescription);
  309. }
  310. /**
  311. * Gets the count of the message.
  312. *
  313. * @return integer
  314. */
  315. public function getMessageCount()
  316. {
  317. return $this->_subscriptionDescription->getMessageCount();
  318. }
  319. /**
  320. * Sets the count of the message.
  321. *
  322. * @param string $messageCount The count of the message.
  323. *
  324. * @return none
  325. */
  326. public function setMessageCount($messageCount)
  327. {
  328. $this->_subscriptionDescription->setMessageCount($messageCount);
  329. }
  330. /**
  331. * Gets maximum delivery count.
  332. *
  333. * @return integer
  334. */
  335. public function getMaxDeliveryCount()
  336. {
  337. return $this->_subscriptionDescription->getMaxDeliveryCount();
  338. }
  339. /**
  340. * Sets maximum delivery count.
  341. *
  342. * @param integer $maxDeliveryCount The maximum delivery count.
  343. *
  344. * @return none
  345. */
  346. public function setMaxDeliveryCount($maxDeliveryCount)
  347. {
  348. $this->_subscriptionDescription->setmaxDeliveryCount($maxDeliveryCount);
  349. }
  350. /**
  351. * Gets enable batched operations.
  352. *
  353. * @return boolean
  354. */
  355. public function getEnableBatchedOperations()
  356. {
  357. return $this->_subscriptionDescription->getEnableBatchedOperations();
  358. }
  359. /**
  360. * Sets enable batched operations.
  361. *
  362. * @param boolean $enableBatchedOperations Enable batched operations.
  363. *
  364. * @return none
  365. */
  366. public function setEnableBatchedOperations($enableBatchedOperations)
  367. {
  368. $this->_subscriptionDescription->setEnableBatchedOperations($enableBatchedOperations);
  369. }
  370. }