|
4 | 4 |
|
5 | 5 | package com.windowsazure.messaging; |
6 | 6 |
|
| 7 | +import org.apache.commons.digester3.Digester; |
| 8 | +import org.xml.sax.SAXException; |
| 9 | + |
7 | 10 | import java.io.ByteArrayInputStream; |
8 | 11 | import java.io.IOException; |
9 | 12 | import java.io.InputStream; |
10 | | -import java.io.UnsupportedEncodingException; |
11 | | -import java.net.URLEncoder; |
12 | | -import java.nio.charset.StandardCharsets; |
13 | | -import java.util.Date; |
14 | | -import java.util.HashMap; |
15 | | -import java.util.LinkedList; |
16 | | -import java.util.List; |
17 | | -import java.util.Map; |
18 | | - |
19 | | -import org.apache.commons.digester3.Digester; |
20 | | -import org.xml.sax.SAXException; |
| 13 | +import java.util.*; |
21 | 14 |
|
22 | 15 | /** |
23 | 16 | * This class represents an Azure Notification Hubs job. |
24 | 17 | */ |
25 | 18 | public class NotificationHubJob { |
26 | 19 | private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"utf-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"><content type=\"application/atom+xml;type=entry;charset=utf-8\"><NotificationHubJob xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\">"; |
27 | 20 | private static final String XML_FOOTER = "</NotificationHubJob></content></entry>"; |
| 21 | + private static final String CDATA_PATTERN = "<!\\[CDATA\\[.*?\\]\\]>"; |
28 | 22 |
|
29 | 23 | private String jobId; |
30 | 24 | private double progress; |
@@ -140,7 +134,12 @@ public NotificationHubJobStatus getJobStatus() { |
140 | 134 | * Sets the Azure Notification Hubs job output container URI. |
141 | 135 | * @param value The Azure Notification Hubs job output container URI value to set. |
142 | 136 | */ |
143 | | - public void setOutputContainerUri(String value) { outputContainerUri = value; } |
| 137 | + public void setOutputContainerUri(String value) { |
| 138 | + if (value.matches(CDATA_PATTERN)) { |
| 139 | + value = value.replaceAll(CDATA_PATTERN, ""); |
| 140 | + } |
| 141 | + outputContainerUri = value; |
| 142 | + } |
144 | 143 |
|
145 | 144 | /** |
146 | 145 | * Gets the Azure Notification Hubs job file import URI. |
@@ -239,7 +238,11 @@ public String getXml() { |
239 | 238 | buf.append("<Type>").append(this.jobType.name()).append("</Type>"); |
240 | 239 | } |
241 | 240 | if (this.outputContainerUri != null) { |
242 | | - buf.append("<OutputContainerUri><![CDATA[").append(this.outputContainerUri).append("]]></OutputContainerUri>"); |
| 241 | + String outputContainerUri = this.outputContainerUri; |
| 242 | + if (!outputContainerUri.matches(CDATA_PATTERN)) { |
| 243 | + outputContainerUri = "<![CDATA[" + outputContainerUri + "]]>"; |
| 244 | + } |
| 245 | + buf.append("<OutputContainerUri>").append(outputContainerUri).append("</OutputContainerUri>"); |
243 | 246 | } |
244 | 247 | if (this.importFileUri != null) { |
245 | 248 | buf.append("<ImportFileUri>").append(this.importFileUri).append("</ImportFileUri>"); |
|
0 commit comments