예제 #1
0
 /**
  * Writes an XML string representing the rule info instance. 
  * 
  * @param XMLWriter $xmlWriter The XML writer. 
  * 
  * @return none
  */
 public function writeXml($xmlWriter)
 {
     $content = null;
     if (!is_null($this->_ruleDescription)) {
         $content = new Content();
         $content->setText(XmlSerializer::objectSerialize($this->_ruleDescription, 'RuleDescription'));
     }
     $this->_entry->setContent($content);
     $this->_entry->writeXml($xmlWriter);
 }
예제 #2
0
 /**
  * Returns a XML string based on ATOM ENTRY schema. 
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  *
  * @return none
  */
 public function writeXml($xmlWriter)
 {
     $content = null;
     if (!is_null($this->_queueDescription)) {
         $content = new Content();
         $content->setText(XmlSerializer::objectSerialize($this->_queueDescription, 'QueueDescription'));
         $content->setType(Resources::XML_CONTENT_TYPE);
     }
     $this->_entry->setContent($content);
     $this->_entry->writeXml($xmlWriter);
 }
 /**
  * Creates a rule. 
  *
  * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780774
  * 
  * @param string   $topicPath        The path of the topic.
  * @param string   $subscriptionName The name of the subscription. 
  * @param RuleInfo $ruleInfo         The information of the rule.
  *
  * @return RuleInfo
  */
 public function createRule($topicPath, $subscriptionName, $ruleInfo)
 {
     $httpCallContext = new HttpCallContext();
     $httpCallContext->setMethod(Resources::HTTP_PUT);
     $httpCallContext->addStatusCode(Resources::STATUS_CREATED);
     $httpCallContext->addHeader(Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE);
     $rulePath = sprintf(Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleInfo->getTitle());
     $ruleDescriptionXml = XmlSerializer::objectSerialize($ruleInfo->getRuleDescription(), 'RuleDescription');
     $entry = new Entry();
     $content = new Content($ruleDescriptionXml);
     $content->setType(Resources::XML_CONTENT_TYPE);
     $entry->setContent($content);
     $entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE);
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $entry->writeXml($xmlWriter);
     $httpCallContext->setBody($xmlWriter->outputMemory());
     $httpCallContext->setPath($rulePath);
     $response = $this->sendContext($httpCallContext);
     $ruleInfo = new ruleInfo();
     $ruleInfo->parseXml($response->getBody());
     return $ruleInfo;
 }
 /**
  * Wraps media services entity with Atom entry
  *
  * @param object $entity Media services entity
  * @param array  $links  AtomLinks to other media services entities
  *
  * @return XML string representing Atom Entry
  */
 protected function wrapAtomEntry($entity, $links = null)
 {
     Validate::notNull($entity, 'entity');
     $content = new Content();
     $content->setType(Resources::XML_CONTENT_TYPE);
     $content->setText(ContentPropertiesSerializer::serialize($entity));
     $atomEntry = new Entry();
     $atomEntry->setContent($content);
     if ($links) {
         Validate::isArray($links, 'links');
         $atomEntry->setLink($links);
     }
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $atomEntry->writeXml($xmlWriter);
     return $xmlWriter->outputMemory();
 }
예제 #5
0
 /**
  * @covers WindowsAzure\Common\Internal\Atom\Entry::getContent
  * @covers WindowsAzure\Common\Internal\Atom\Entry::setContent
  */
 public function testGetSetContent()
 {
     // Setup
     $expected = 'testContent';
     $entry = new Entry();
     // Test
     $entry->setContent($expected);
     $actual = $entry->getContent();
     // Assert
     $this->assertEquals($expected, $actual);
 }