Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-05-10 16:37:26 -0400
committerChris Goldthorpe2011-05-10 16:37:26 -0400
commitbffb23c13e365868f834affa60ccf4aad9389a6d (patch)
tree69f26ec7de98ec7c72c4104ed1aeb84376733bc2 /org.eclipse.help.webapp
parenta8d74ef9189a43055208cd19437b8c5d65d9b901 (diff)
downloadeclipse.platform.ua-bffb23c13e365868f834affa60ccf4aad9389a6d.tar.gz
eclipse.platform.ua-bffb23c13e365868f834affa60ccf4aad9389a6d.tar.xz
eclipse.platform.ua-bffb23c13e365868f834affa60ccf4aad9389a6d.zip
Bug 345309 - [Help] Web API JSON format should be encodedv20110510
Diffstat (limited to 'org.eclipse.help.webapp')
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java7
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java23
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java1
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/XMLHelper.java1
5 files changed, 31 insertions, 5 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
index 50438b475..152b714a4 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.help.internal.webapp.parser;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
@@ -81,6 +83,11 @@ public class ParseElement {
buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE);
buff.append(key);
buff.append(JSonHelper.COLON);
+ try {
+ val = URLEncoder.encode(val, "UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
buff.append(JSonHelper.getQuotes(val));
buff.append(JSonHelper.COMMA);
}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
index 945d71d0f..08c7e866e 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
@@ -45,6 +45,10 @@ public class ResultParser extends DefaultHandler {
parser.parse(in, this);
}
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
public ArrayList getItems()
{
return items;
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
index cd2b5c607..cd5cca625 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java
@@ -49,13 +49,20 @@ public class TocFragmentParser extends ResultParser {
public void startElement(String uri,
String lname, String name, Attributes attrs) {
- if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE))
- {
+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)
+ || name.equalsIgnoreCase(XMLHelper.ELEMENT_NUMERIC_PATH)) {
+
tagLevel++;
if (tagLevel == level) {
properties = new Properties();
- properties.put(JSonHelper.PROPERTY_NAME, JSonHelper.TOPIC);
+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NUMERIC_PATH)) {
+ setLabel(""); //$NON-NLS-1$
+ properties.put(JSonHelper.PROPERTY_NAME, JSonHelper.NUMERIC_PATH);
+ }
+ else
+ properties.put(JSonHelper.PROPERTY_NAME, JSonHelper.TOPIC);
+
for (int i = 0; i < attrs.getLength(); i++) {
String qname = attrs.getQName(i);
String val = attrs.getValue(i);
@@ -76,11 +83,17 @@ public class TocFragmentParser extends ResultParser {
public void endElement(String uri, String lname, String name) {
- if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE))
+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)
+ || name.equalsIgnoreCase(XMLHelper.ELEMENT_NUMERIC_PATH))
{
if (tagLevel == level && properties != null ) {
- properties.setProperty("type", "toc"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NUMERIC_PATH)) {
+ properties.setProperty("id", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ properties.setProperty("type", "topic"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else
+ properties.setProperty("type", "toc"); //$NON-NLS-1$ //$NON-NLS-2$
ParseElement element = new ParseElement(properties);
items.add(element);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
index f3f6a65b8..a59ff8bc9 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
@@ -48,6 +48,7 @@ public final class JSonHelper {
public static final String PROPERTY_NAME = "propertyName"; //$NON-NLS-1$
public static final String INDEX = "Index"; //$NON-NLS-1$
public static final String TOPIC = "Topic"; //$NON-NLS-1$
+ public static final String NUMERIC_PATH = "NumericPath"; //$NON-NLS-1$
public static String getQuotes(String str){
return ((str != null)?QUOTE + str + QUOTE:""); //$NON-NLS-1$
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/XMLHelper.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/XMLHelper.java
index 614b701d5..b8513a400 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/XMLHelper.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/XMLHelper.java
@@ -36,6 +36,7 @@ public final class XMLHelper {
public static final String ELEMENT_INDEX = "index"; //$NON-NLS-1$
public static final String ELEMENT_INDEX_CONTRIBUTIONS = "indexContributions"; //$NON-NLS-1$
public static final String ELEMENT_TOC_CONTRIBUTIONS = "tocContributions"; //$NON-NLS-1$
+ public static final String ELEMENT_NUMERIC_PATH = "numeric_path"; //$NON-NLS-1$
public static final String CATEGORY_HREF = "categoryHref"; //$NON-NLS-1$
}

Back to the top