Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 186915 Details for
Bug 319907
[Help] Promote main help servlets to public API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Draft of Public API services
org.eclipse.help.webapp.services.patch.txt (text/plain), 184.36 KB, created by
Snehasish Paul
on 2011-01-17 10:49:08 EST
(
hide
)
Description:
Draft of Public API services
Filename:
MIME Type:
Creator:
Snehasish Paul
Created:
2011-01-17 10:49:08 EST
Size:
184.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.help.webapp >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/META-INF/MANIFEST.MF,v >retrieving revision 1.32 >diff -u -r1.32 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 Jun 2010 22:48:18 -0000 1.32 >+++ META-INF/MANIFEST.MF 17 Jan 2011 15:38:33 -0000 >@@ -14,6 +14,7 @@ > org.eclipse.core.expressions;bundle-version="3.4.200" > Export-Package: org.eclipse.help.internal.webapp;x-friends:="org.eclipse.ua.tests", > org.eclipse.help.internal.webapp.data;x-friends:="org.eclipse.ua.tests", >+ org.eclipse.help.internal.webapp.service;x-friends:="org.eclipse.ua.tests,org.eclipse.ua.tests.doc", > org.eclipse.help.internal.webapp.servlet;x-friends:="org.eclipse.ua.tests,org.eclipse.ua.tests.doc", > org.eclipse.help.webapp > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/plugin.xml,v >retrieving revision 1.39 >diff -u -r1.39 plugin.xml >--- plugin.xml 30 Mar 2010 21:04:49 -0000 1.39 >+++ plugin.xml 17 Jan 2011 15:38:33 -0000 >@@ -5,7 +5,7 @@ > are made available under the terms of the Eclipse Public License v1.0 > which accompanies this distribution, and is available at > http://www.eclipse.org/legal/epl-v10.html >- >+ > Contributors: > IBM Corporation - initial API and implementation > --> >@@ -15,6 +15,7 @@ > <extension-point id="view" name="View" schema="schema/view.exsd"/> > <extension-point id="frame" name="Webapp Frame" schema="schema/frame.exsd"/> > <extension-point id="toolbarButton" name="Toolbar Button" schema="schema/toolbarButton.exsd"/> >+ <extension-point id="secureServlet" name="Security Enhanced Servlet" schema="schema/secureServlet.exsd"/> > <extension > point="org.eclipse.equinox.http.registry.httpcontexts"> > <httpcontext >@@ -125,6 +126,11 @@ > <serviceSelector > filter="(other.info=org.eclipse.help)"> > </serviceSelector> >+ <servlet >+ alias="/ss" >+ class="org.eclipse.help.internal.webapp.servlet.SecureServlet" >+ httpcontextId="help"> >+ </servlet> > </extension> > <extension > id="org.eclipse.help.webapp.remoteStatusProducer" >@@ -134,4 +140,79 @@ > producer="org.eclipse.help.internal.webapp.StatusProducer"> > </contentProducer> > </extension> >+ <extension >+ point="org.eclipse.help.webapp.secureServlet"> >+ <servlet >+ alias="/service/control" >+ class="org.eclipse.help.internal.webapp.service.ControlService"> >+ </servlet> >+ <servlet >+ alias="/service/content" >+ class="org.eclipse.help.internal.webapp.service.ContentService"> >+ </servlet> >+ <servlet >+ alias="/service/topic" >+ class="org.eclipse.help.internal.webapp.service.ContentService"> >+ </servlet> >+ <servlet >+ alias="/service/nftopic" >+ class="org.eclipse.help.internal.webapp.service.ContentService"> >+ </servlet> >+ <servlet >+ alias="/service/ntopic" >+ class="org.eclipse.help.internal.webapp.service.ContentService"> >+ </servlet> >+ <servlet >+ alias="/service/rtopic" >+ class="org.eclipse.help.internal.webapp.service.ContentService"> >+ </servlet> >+ <servlet >+ alias="/service/nav" >+ class="org.eclipse.help.internal.webapp.service.NavService"> >+ </servlet> >+ <servlet >+ alias="/service/livehelp" >+ class="org.eclipse.help.internal.webapp.service.LiveHelpService"> >+ </servlet> >+ <servlet >+ alias="/service/toc" >+ class="org.eclipse.help.internal.webapp.service.TocService"> >+ </servlet> >+ <servlet >+ alias="/service/tocfragment" >+ class="org.eclipse.help.internal.webapp.service.TocFragmentService"> >+ </servlet> >+ <servlet >+ alias="/service/index" >+ class="org.eclipse.help.internal.webapp.service.IndexService"> >+ </servlet> >+ <servlet >+ alias="/service/indexfragment" >+ class="org.eclipse.help.internal.webapp.service.IndexFragmentService"> >+ </servlet> >+ <servlet >+ alias="/service/search" >+ class="org.eclipse.help.internal.webapp.service.SearchService"> >+ </servlet> >+ <servlet >+ alias="/service/simplesearch" >+ class="org.eclipse.help.internal.webapp.service.SimpleSearchService"> >+ </servlet> >+ <servlet >+ alias="/service/context" >+ class="org.eclipse.help.internal.webapp.service.ContextService"> >+ </servlet> >+ <servlet >+ alias="/service/extension" >+ class="org.eclipse.help.internal.webapp.service.ExtensionService"> >+ </servlet> >+ <servlet >+ alias="/service/about.html" >+ class="org.eclipse.help.internal.webapp.service.AboutService"> >+ </servlet> >+ <servlet >+ alias="/service/state" >+ class="org.eclipse.help.internal.webapp.service.SearchStateService"> >+ </servlet> >+ </extension> > </plugin> >Index: schema/secureServlet.exsd >=================================================================== >RCS file: schema/secureServlet.exsd >diff -N schema/secureServlet.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/secureServlet.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.help.webapp" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.help.webapp" id="secureServlet" name="Security Enhanced Servlet"/> >+ </appInfo> >+ <documentation> >+ Allows definition of Servlets and their aliases, with a focus on preventing known security vulernabilites. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <sequence minOccurs="0" maxOccurs="unbounded"> >+ <element ref="servlet"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="servlet"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="javax.servlet.http.HttpServlet:"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="alias" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ [Enter the first release in which this extension point appears.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiinfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ >+</schema> >Index: src/org/eclipse/help/internal/webapp/WebappResources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties,v >retrieving revision 1.81 >diff -u -r1.81 WebappResources.properties >--- src/org/eclipse/help/internal/webapp/WebappResources.properties 10 Jan 2011 23:09:01 -0000 1.81 >+++ src/org/eclipse/help/internal/webapp/WebappResources.properties 17 Jan 2011 15:38:40 -0000 >@@ -211,3 +211,10 @@ > criterionClosed=Criterion closed > criterionOpen=Criterion open > Criteria=Criteria >+ >+# Secure Servlet >+cantCreateServlet=Unable to create servlet: {0} >+ >+# Service API >+StatusServlet_PARAM_MISSING=The "{0}" parameter is missing from the request. >+ >Index: src/org/eclipse/help/internal/webapp/data/SearchData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java,v >retrieving revision 1.14 >diff -u -r1.14 SearchData.java >--- src/org/eclipse/help/internal/webapp/data/SearchData.java 10 Jan 2011 23:09:01 -0000 1.14 >+++ src/org/eclipse/help/internal/webapp/data/SearchData.java 17 Jan 2011 15:38:42 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Sebastian Davids <sdavids@gmx.de> - fix for Bug 182466 >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.data; > >@@ -177,6 +178,10 @@ > public int getResultsCount() { > return hits.length; > } >+ >+ public SearchHit[] getResults() { >+ return hits; >+ } > > public String getSelectedTopicId() { > return selectedTopicId; >@@ -554,12 +559,12 @@ > > public String getScopeActiveMessage() { > String scope = getScope(); >- return NLS.bind(ServletResources.getString("activeScope", request), scope); //$NON-NLS-1$ >+ return NLS.bind(ServletResources.getString("activeScope", request), scope); //$NON-NLS-1$ > } >- >+ > public String getMatchesInScopeMessage() { >- String scope = getScope(); >- return NLS.bind(ServletResources.getString("matchesInScope", request), "" + getResultsCount(), scope); //$NON-NLS-1$ //$NON-NLS-2$ >+ String scope = getScope(); >+ return NLS.bind(ServletResources.getString("matchesInScope", request), "" + getResultsCount(), scope); //$NON-NLS-1$ //$NON-NLS-2$ > } > > /* >Index: src/org/eclipse/help/internal/webapp/parser/ContextParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/ContextParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/ContextParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/ContextParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+ >+public class ContextParser extends ResultParser { >+ >+ private ParseElement element = null; >+ private String currentTag; >+ >+ public ContextParser() { >+ super(JSonHelper.TITLE); >+ } >+ >+ public void startElement(String uri, String lname, String name, Attributes attrs) { >+ >+ currentTag = name; >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_DESCRIPTION)) >+ return; >+ >+ Properties properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, name); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ ParseElement elem = new ParseElement(properties, element); >+ if (element != null) >+ element.addChild(elem); >+ else >+ items.add(elem); >+ >+ element = elem; >+ >+ } >+ >+ public void characters(char[] ch, int start, int length) { >+ >+ if (element != null >+ && currentTag.equalsIgnoreCase( >+ XMLHelper.ELEMENT_DESCRIPTION)) { >+ >+ Properties properties = element.getProps(); >+ if (properties != null) { >+ >+ String content = new String(ch, start, length); >+ >+ String existing = (String) properties.get(currentTag); >+ if (existing == null) >+ existing = ""; //$NON-NLS-1$ >+ >+ content = content.replaceAll("[\\n\\t]", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ properties.put(currentTag, existing + content); >+ element.updateParseElement(properties); >+ } >+ } >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_DESCRIPTION)) >+ return; >+ >+ if (element != null) { >+ element = element.getParent(); >+ } >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/parser/ExtensionParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/ExtensionParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/ExtensionParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/ExtensionParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.xml.sax.Attributes; >+ >+public class ExtensionParser extends ResultParser { >+ >+ private ParseElement element = null; >+ private String currentTag; >+ >+ public ExtensionParser() { >+ super(JSonHelper.TITLE); >+ } >+ >+ public void startElement(String uri, String lname, String name, Attributes attrs) { >+ >+ currentTag = name; >+ >+ Properties properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, name); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ ParseElement elem = new ParseElement(properties, element); >+ if (element != null) >+ element.addChild(elem); >+ else >+ items.add(elem); >+ >+ element = elem; >+ >+ } >+ >+ public void characters(char[] ch, int start, int length) { >+ >+ if (element != null) { >+ >+ Properties properties = element.getProps(); >+ if (properties != null) { >+ >+ String content = new String(ch, start, length); >+ >+ String existing = (String) properties.get(currentTag); >+ if (existing == null) >+ existing = ""; //$NON-NLS-1$ >+ >+ content = content.replaceAll("[\\n\\t]", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ properties.put(currentTag, existing + content); >+ element.updateParseElement(properties); >+ } >+ } >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ >+ if (element != null) { >+ element = element.getParent(); >+ } >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/parser/IndexFragmentParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/IndexFragmentParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/IndexFragmentParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/IndexFragmentParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+ >+public class IndexFragmentParser extends ResultParser{ >+ >+ private ParseElement element = null; >+ >+ public IndexFragmentParser() { >+ super(JSonHelper.TITLE); >+ } >+ >+ public void startElement(String uri, String lname, String name, Attributes attrs) { >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)) >+ { >+ Properties properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, JSonHelper.INDEX); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ ParseElement elem = new ParseElement(properties, element); >+ if (element != null) >+ element.addChild(elem); >+ else >+ items.add(elem); >+ >+ element = elem; >+ } >+ >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ if (element != null >+ && name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)) { >+ element = element.getParent(); >+ } >+ } >+} >Index: src/org/eclipse/help/internal/webapp/parser/IndexParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/IndexParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/IndexParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/IndexParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+ >+public class IndexParser extends ResultParser { >+ >+ private ParseElement element = null; >+ >+ public IndexParser() { >+ super(JSonHelper.TITLE); >+ } >+ >+ public void startElement(String uri, String lname, String name, Attributes attrs) { >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_INDEX_CONTRIBUTIONS) >+ || name.equalsIgnoreCase(XMLHelper.ELEMENT_INDEX)) >+ return; >+ >+ Properties properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, name); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ ParseElement elem = new ParseElement(properties, element); >+ if (element != null) >+ element.addChild(elem); >+ else >+ items.add(elem); >+ >+ element = elem; >+ >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_INDEX_CONTRIBUTIONS) >+ || name.equalsIgnoreCase(XMLHelper.ELEMENT_INDEX)) >+ return; >+ >+ if (element != null) { >+ element = element.getParent(); >+ } >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/parser/ParseElement.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/ParseElement.java >diff -N src/org/eclipse/help/internal/webapp/parser/ParseElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/ParseElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.ArrayList; >+import java.util.Enumeration; >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+ >+public class ParseElement { >+ >+ private Properties props; >+ private ArrayList children = new ArrayList(); >+ private ParseElement parent; >+ >+ public ParseElement(Properties props, ParseElement parent) { >+ this.props = props; >+ this.parent = parent; >+ } >+ >+ public ParseElement(Properties props) { >+ this(props, null); >+ } >+ >+ public void updateParseElement(Properties props) { >+ this.props = props; >+ } >+ >+ public Properties getProps() { >+ return props; >+ } >+ >+ public ParseElement getParent() { >+ return parent; >+ } >+ >+ public String getProperty(String key) { >+ return (props != null) ? props.getProperty(key) : ""; //$NON-NLS-1$ >+ } >+ >+ public String toString() { >+ return (props != null) ? props.toString() : ""; //$NON-NLS-1$ >+ } >+ >+ public void addChild(ParseElement elem) { >+ children.add(elem); >+ } >+ >+ public int getChildrenCount() { >+ return children.size(); >+ } >+ >+ public String toJSON(int level) { >+ >+ StringBuffer buff = new StringBuffer(); >+ >+ String space = JSonHelper.SPACE; >+ for (int s = 0; s < level; s++) { >+ space += JSonHelper.SPACE; >+ } >+ >+ buff.append(JSonHelper.NEWLINE + space); >+ buff.append(JSonHelper.BEGIN_BRACE); >+ >+ if (props != null) { >+ Enumeration enumObj = props.keys(); >+ while (enumObj.hasMoreElements()) { >+ >+ String key = (String) enumObj.nextElement(); >+ String val = props.getProperty(key); >+ >+ buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE); >+ buff.append(key); >+ buff.append(JSonHelper.COLON); >+ buff.append(JSonHelper.getQuotes(val)); >+ buff.append(JSonHelper.COMMA); >+ } >+ } >+ >+ if (children.size() <= 0) { >+ int len = buff.length(); >+ char ch = buff.charAt(len - 1); >+ if (ch == ',') { >+ buff.deleteCharAt(len - 1); >+ buff.append(JSonHelper.NEWLINE + space); >+ } >+ >+ } else { >+ >+ buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE); >+ buff.append(JSonHelper.CHILDREN); >+ buff.append(JSonHelper.COLON); >+ buff.append(JSonHelper.BEGIN_BRACKET); >+ >+ for (int i = 0; i < children.size(); i++) { >+ >+ if (i > 0) >+ buff.append(JSonHelper.COMMA); >+ >+ ParseElement element = (ParseElement) children.get(i); >+ buff.append(element.toJSON(level + 2)); >+ } >+ >+ buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE); >+ >+ buff.append(JSonHelper.END_BRACKET); >+ buff.append(JSonHelper.NEWLINE + space); >+ } >+ >+ buff.append(JSonHelper.END_BRACE); >+ >+ return buff.toString(); >+ } >+} >Index: src/org/eclipse/help/internal/webapp/parser/ResultParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/ResultParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/ResultParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/ResultParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,100 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.net.URL; >+import java.util.ArrayList; >+ >+import javax.xml.parsers.ParserConfigurationException; >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.xml.sax.SAXException; >+import org.xml.sax.helpers.DefaultHandler; >+ >+public class ResultParser extends DefaultHandler { >+ >+ private String label = ""; //$NON-NLS-1$ >+ protected ArrayList items = new ArrayList(); //parser populates the items arrayList withe parsed data. >+ >+ public ResultParser(String label) { >+ this.label = label; >+ } >+ >+ public void parse(URL tocURL) >+ throws ParserConfigurationException, SAXException, IOException >+ { >+ parse(tocURL.openStream()); >+ } >+ >+ public void parse(InputStream in) >+ throws ParserConfigurationException, SAXException, IOException >+ { >+ SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); >+ parser.parse(in, this); >+ } >+ >+ public ArrayList getItems() >+ { >+ return items; >+ } >+ >+ public String toString() >+ { >+ return items.toString(); >+ } >+ >+ public String toJSON() { >+ >+ StringBuffer buf = new StringBuffer(); >+ >+ buf.append(JSonHelper.BEGIN_BRACE); >+ buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE); >+ >+ buf.append(JSonHelper.IDENTIFIER); >+ buf.append(JSonHelper.COLON); >+ buf.append(JSonHelper.getQuotes(JSonHelper.ID)); >+ buf.append(JSonHelper.COMMA); >+ >+ buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE); >+ buf.append(JSonHelper.LABEL); >+ buf.append(JSonHelper.COLON); >+ buf.append(JSonHelper.getQuotes(label)); >+ buf.append(JSonHelper.COMMA); >+ >+ buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE); >+ buf.append(JSonHelper.ITEMS); >+ buf.append(JSonHelper.COLON); >+ buf.append(JSonHelper.BEGIN_BRACKET); >+ >+ for (int i = 0; i < items.size(); i++) { >+ >+ if (i > 0) >+ buf.append(JSonHelper.COMMA); >+ >+ ParseElement element = (ParseElement) items.get(i); >+ buf.append(element.toJSON(1)); >+ } >+ >+ if (items.size() > 0) >+ buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE); >+ >+ buf.append(JSonHelper.END_BRACKET); >+ buf.append(JSonHelper.NEWLINE); >+ buf.append(JSonHelper.END_BRACE); >+ >+ return buf.toString(); >+ } >+} >Index: src/org/eclipse/help/internal/webapp/parser/SearchParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/SearchParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/SearchParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/SearchParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+ >+public class SearchParser extends ResultParser { >+ >+// private ParseElement element; >+ private Properties properties; >+ private String currentTag; >+ >+ public SearchParser() { >+ super(JSonHelper.LABEL); >+ } >+ >+ public void startElement(String uri, >+ String lname, String name, Attributes attrs) { >+ >+ currentTag = name; >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_HIT)) { >+ >+ properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, name); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ String id = "" + items.size(); //$NON-NLS-1$ >+ properties.put(JSonHelper.ID, id); >+ >+ } else if (name.equalsIgnoreCase(XMLHelper.ELEMENT_CATEGORY)) { >+// } else { >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ if (qname.equalsIgnoreCase(XMLHelper.ATTR_HREF)) >+ qname = XMLHelper.CATEGORY_HREF; >+ properties.put(qname, val); >+ } >+ } >+ } >+ >+ public void characters(char[] ch, int start, int length) { >+ >+ if (currentTag.equalsIgnoreCase(XMLHelper.ELEMENT_HIT) >+ || currentTag.equalsIgnoreCase(XMLHelper.ELEMENT_HITS)) >+ return; >+ >+ if (properties != null) >+ { >+ String content = new String(ch, start, length); >+ >+ String existing = (String) properties.get(currentTag); >+ if (existing == null) >+ existing = ""; //$NON-NLS-1$ >+ >+ content = content.replaceAll("[\\n\\t]", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ properties.put(currentTag, existing + content); >+ } >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_HIT)) { >+ ParseElement element = new ParseElement(properties); >+ items.add(element); >+ } >+// } else if (name.equalsIgnoreCase(XMLHelper.ELEMENT_CATEGORY)) { >+ /*} else { >+ if (element != null && properties != null) { >+ ParseElement category = new ParseElement(properties); >+ element.addChild(category); >+ } >+ properties = null; >+ }*/ >+ } >+} >Index: src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/TocFragmentParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.net.URL; >+import java.util.Properties; >+ >+import javax.xml.parsers.ParserConfigurationException; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+import org.xml.sax.SAXException; >+ >+public class TocFragmentParser extends ResultParser { >+ >+ private Properties properties; >+ private String parentId = ""; //$NON-NLS-1$ >+ private int tagLevel = -1; >+ private int level = 0; >+ >+ public TocFragmentParser() { >+ super(JSonHelper.TITLE); >+ } >+ >+ public void parse(URL tocURL, int level) >+ throws ParserConfigurationException, SAXException, IOException >+ { >+ parse(tocURL.openStream(), level); >+ } >+ >+ public void parse(InputStream in, int level) >+ throws ParserConfigurationException, SAXException, IOException >+ { >+ this.level = level; >+ super.parse(in); >+ } >+ >+ public void startElement(String uri, >+ String lname, String name, Attributes attrs) { >+ >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)) >+ { >+ tagLevel++; >+ >+ if (tagLevel == level) { >+ properties = new Properties(); >+ 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); >+ if (qname.equals(XMLHelper.ATTR_ID)) { >+ if (parentId.length() > 0) >+ val = parentId + '$' + val; >+ } >+ properties.put(qname, val); >+ } >+ } else if (parentId.length() <= 0) { >+ for (int i = 0; i < attrs.getLength(); i++) { >+ if (attrs.getQName(i).equals(XMLHelper.ATTR_ID)) >+ parentId = attrs.getValue(i); >+ } >+ } >+ } >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_NODE)) >+ { >+ if (tagLevel == level && properties != null ) { >+ >+ properties.setProperty("type", "toc"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ ParseElement element = new ParseElement(properties); >+ items.add(element); >+ >+ properties = null; >+ } >+ >+ tagLevel--; >+ } >+ } >+} >Index: src/org/eclipse/help/internal/webapp/parser/TocParser.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/parser/TocParser.java >diff -N src/org/eclipse/help/internal/webapp/parser/TocParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/parser/TocParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.parser; >+ >+import java.util.Properties; >+ >+import org.eclipse.help.internal.webapp.utils.JSonHelper; >+import org.eclipse.help.internal.webapp.utils.XMLHelper; >+import org.xml.sax.Attributes; >+ >+public class TocParser extends ResultParser { >+ >+ private ParseElement element = null; >+ >+ public TocParser() { >+ super(JSonHelper.LABEL); >+ } >+ >+ public void startElement(String uri, String lname, String name, Attributes attrs) { >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_TOC_CONTRIBUTIONS)) >+ return; >+ >+ Properties properties = new Properties(); >+ properties.put(JSonHelper.PROPERTY_NAME, name); >+ for (int i = 0; i < attrs.getLength(); i++) { >+ String qname = attrs.getQName(i); >+ String val = attrs.getValue(i); >+ properties.put(qname, val); >+ } >+ >+ ParseElement elem = new ParseElement(properties, element); >+ if (element != null) >+ element.addChild(elem); >+ else >+ items.add(elem); >+ >+ element = elem; >+ >+ } >+ >+ public void endElement(String uri, String lname, String name) { >+ if (name.equalsIgnoreCase(XMLHelper.ELEMENT_TOC_CONTRIBUTIONS)) >+ return; >+ >+ if (element != null) { >+ element = element.getParent(); >+ } >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/AboutService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/AboutService.java >diff -N src/org/eclipse/help/internal/webapp/service/AboutService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/AboutService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import org.eclipse.help.internal.webapp.servlet.AboutServlet; >+ >+public class AboutService extends AboutServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/ContentService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/ContentService.java >diff -N src/org/eclipse/help/internal/webapp/service/ContentService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/ContentService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.IOException; >+import java.io.OutputStream; >+import java.io.OutputStreamWriter; >+import java.io.PrintWriter; >+import java.net.URL; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class ContentService extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ resp.setContentType("text/html; charset=UTF-8"); //$NON-NLS-1$ >+ >+ String servletPath = "/help"; //$NON-NLS-1$ >+ String pathInfo = req.getPathInfo(); >+ if (pathInfo != null) { >+ int index = pathInfo.indexOf("/service"); //$NON-NLS-1$ >+ if (index > -1) >+ pathInfo = pathInfo.substring(index + "/service".length()); //$NON-NLS-1$ >+ if (!pathInfo.equals("")) //$NON-NLS-1$ >+ servletPath += pathInfo.startsWith("/") ? pathInfo : "/" + pathInfo; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ String queryString = req.getQueryString(); >+ if (queryString != null && !queryString.equals("")) { //$NON-NLS-1$ >+ servletPath += "?" + queryString; //$NON-NLS-1$ >+ } >+ >+ URL url = new URL("http", req.getServerName(), //$NON-NLS-1$ >+ req.getServerPort(), servletPath); >+ String response = Utils.convertStreamToString(url.openStream()); >+ >+ OutputStream out = resp.getOutputStream(); >+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); //$NON-NLS-1$ >+ writer.write(response); >+ writer.close(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/ContextService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/ContextService.java >diff -N src/org/eclipse/help/internal/webapp/service/ContextService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/ContextService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.ContextParser; >+import org.eclipse.help.internal.webapp.servlet.ContextServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class ContextService extends ContextServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ if ("400".equals(response)) { //$NON-NLS-1$ >+ resp.sendError(400); // bad request; missing parameter >+ return; >+ } else if ("404".equals(response)) { //$NON-NLS-1$ >+ resp.sendError(404); // Wrong context id; not found >+ return; >+ } >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ ContextParser searchParser = new ContextParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ searchParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return searchParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/ControlService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/ControlService.java >diff -N src/org/eclipse/help/internal/webapp/service/ControlService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/ControlService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import org.eclipse.help.internal.webapp.servlet.ControlServlet; >+ >+public class ControlService extends ControlServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/ExtensionService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/ExtensionService.java >diff -N src/org/eclipse/help/internal/webapp/service/ExtensionService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/ExtensionService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.ExtensionParser; >+import org.eclipse.help.internal.webapp.servlet.ExtensionServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class ExtensionService extends ExtensionServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ ExtensionParser searchParser = new ExtensionParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ searchParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return searchParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/IndexFragmentService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/IndexFragmentService.java >diff -N src/org/eclipse/help/internal/webapp/service/IndexFragmentService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/IndexFragmentService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.IndexFragmentParser; >+import org.eclipse.help.internal.webapp.servlet.IndexFragmentServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+/* >+ * Sends all available keyword index data in XML form. The data is sent as one >+ * large index contribution that includes all merged contributions from the >+ * system. >+ * >+ * This is called on infocenters by client workbenches configured for remote >+ * help in order to gather all the index keywords and assemble them into a >+ * complete index. >+ */ >+public class IndexFragmentService extends IndexFragmentServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ IndexFragmentParser indexParser = new IndexFragmentParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ indexParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return indexParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/IndexService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/IndexService.java >diff -N src/org/eclipse/help/internal/webapp/service/IndexService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/IndexService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.IndexParser; >+import org.eclipse.help.internal.webapp.servlet.IndexServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class IndexService extends IndexServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ IndexParser indexParser = new IndexParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ indexParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return indexParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/LiveHelpService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/LiveHelpService.java >diff -N src/org/eclipse/help/internal/webapp/service/LiveHelpService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/LiveHelpService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import org.eclipse.help.internal.webapp.servlet.LiveHelpServlet; >+ >+public class LiveHelpService extends LiveHelpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/NavService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/NavService.java >diff -N src/org/eclipse/help/internal/webapp/service/NavService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/NavService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.IOException; >+import java.io.OutputStream; >+import java.io.OutputStreamWriter; >+import java.io.PrintWriter; >+import java.net.URL; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class NavService extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ resp.setContentType("text/html; charset=UTF-8"); //$NON-NLS-1$ >+ >+ String servletPath = "/help"; //$NON-NLS-1$ >+ String pathInfo = req.getPathInfo(); >+ if (pathInfo != null) { >+ int index = pathInfo.indexOf("/service"); //$NON-NLS-1$ >+ if (index > -1) >+ pathInfo = pathInfo.substring(index + "/service".length()); //$NON-NLS-1$ >+ if (!pathInfo.equals("")) //$NON-NLS-1$ >+ servletPath += pathInfo.startsWith("/") ? pathInfo : "/" + pathInfo; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ String queryString = req.getQueryString(); >+ if (queryString != null && !queryString.equals("")) { //$NON-NLS-1$ >+ servletPath += "?" + queryString; //$NON-NLS-1$ >+ } >+ >+ URL url = new URL("http", req.getServerName(), //$NON-NLS-1$ >+ req.getServerPort(), servletPath); >+ String response = Utils.convertStreamToString(url.openStream()); >+ >+ OutputStream out = resp.getOutputStream(); >+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); //$NON-NLS-1$ >+ writer.write(response); >+ writer.close(); >+ >+ /*try { >+ HttpServlet servlet = getWebappServlet("NavServlet"); //$NON-NLS-1$ >+ ServletConfig config = getServletConfig(); >+ servlet.init(config); >+ servlet.service(req, resp); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ }*/ >+ } >+ >+ /*private HttpServlet getWebappServlet(String service) >+ throws Exception { >+ Class cls = Class.forName( >+ "org.eclipse.help.internal.webapp.servlet." + service); //$NON-NLS-1$ >+ Constructor constructor = cls.getConstructor(new Class[]{}); >+ return (HttpServlet)constructor.newInstance(new Object[]{}); >+ }*/ >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/SearchService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/SearchService.java >diff -N src/org/eclipse/help/internal/webapp/service/SearchService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/SearchService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletContext; >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.search.SearchHit; >+import org.eclipse.help.internal.search.SearchProgressMonitor; >+import org.eclipse.help.internal.webapp.data.SearchData; >+import org.eclipse.help.internal.webapp.data.UrlUtil; >+import org.eclipse.help.internal.webapp.parser.SearchParser; >+import org.eclipse.help.internal.webapp.utils.Utils; >+import org.eclipse.help.internal.webapp.utils.SearchXMLGenerator; >+ >+/* >+ * Returns the search hits for the query provided in the phrase parameter. >+ * >+ * This is called on infocenters by client workbenches configured for remote >+ * help in order to retrieve search hits from the remote help server. >+ */ >+public class SearchService extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ public static final String XID = "xid"; //$NON-NLS-1$ >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$ >+ >+ ServletContext context = req.getSession().getServletContext(); >+ SearchData searchData = new SearchData(context, req, resp); >+ >+ String noCat = req.getParameter(Utils.NO_CATEGORY); >+ boolean boolIsCategory = (noCat == null >+ || !noCat.equalsIgnoreCase("true")); //$NON-NLS-1$ >+ >+ String locale = UrlUtil.getLocale(req, resp); >+ SearchProgressMonitor pm = SearchProgressMonitor >+ .getProgressMonitor(locale); >+ while (!pm.isDone()) { >+ try { >+ Thread.sleep(500); // Sleep for 0.5 sec >+ } catch(InterruptedException ex) {} >+ } >+ >+ SearchHit[] hits = searchData.getResults(); >+ >+ String response = SearchXMLGenerator.serialize(hits, boolIsCategory); >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ SearchParser searchParser = new SearchParser(); >+ >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ searchParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return searchParser.toJSON(); >+ } >+} >Index: src/org/eclipse/help/internal/webapp/service/SearchStateService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/SearchStateService.java >diff -N src/org/eclipse/help/internal/webapp/service/SearchStateService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/SearchStateService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.IOException; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.search.SearchProgressMonitor; >+import org.eclipse.help.internal.webapp.data.UrlUtil; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+/** >+ * This is the main servlet for WAR Update Actions. It delegates each action to the >+ * appropriate <code>IDelegatorOperation</code> >+ * >+ * @author snehpaul >+ * >+ */ >+public class SearchStateService extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ private final static String STATE = "state"; //$NON-NLS-1$ >+ private final static String PERCENT = "percent"; //$NON-NLS-1$ >+ >+ public void init() throws ServletException { >+ } >+ >+ /** >+ * Called by the server (via the <code>service</code> method) to allow a >+ * Servlet to handle a GET request. >+ */ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ process(req,resp); >+ } >+ >+ /** >+ * >+ * Called by the server (via the <code>service</code> method) to allow a >+ * Servlet to handle a POST request. >+ * >+ * Handle the search requests, >+ * >+ */ >+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ process(req, resp); >+ } >+ >+ >+ /** >+ * Processes all requests to the servlet. >+ * >+ */ >+ private void process(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ //$NON-NLS-2$ >+ resp.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ >+ int indexCompletion = 0; >+ String locale = UrlUtil.getLocale(req, resp); >+ SearchProgressMonitor pm = SearchProgressMonitor >+ .getProgressMonitor(locale); >+ if (pm.isDone()) { >+ indexCompletion = 100; >+ } else { >+ indexCompletion = pm.getPercentage(); >+ if (indexCompletion >= 100) { >+ // 38573 We do not have results, so index cannot be 100 >+ indexCompletion = 100 - 1; >+ } >+ } >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean isXML = Utils.XML.equalsIgnoreCase(returnType); >+ if (isXML) { >+ resp.setContentType("application/xml"); //$NON-NLS-1$ >+ resp.getWriter().write(toXML(indexCompletion)); >+ } else { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ resp.getWriter().write(toString(indexCompletion)); >+ } >+ resp.getWriter().flush(); >+ } >+ >+ public static String toXML(int percent) { >+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; //$NON-NLS-1$ >+ xml += '<'+STATE+">\n"; //$NON-NLS-1$ >+ xml += " <"+PERCENT+'>'+percent+"</"+PERCENT+">\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ xml += "</"+STATE+">"; //$NON-NLS-1$ //$NON-NLS-2$ >+ return xml; >+ } >+ >+ public static String toString(int percent) { >+ return "Percent:" + percent; //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/help/internal/webapp/service/SimpleSearchService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/SimpleSearchService.java >diff -N src/org/eclipse/help/internal/webapp/service/SimpleSearchService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/SimpleSearchService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.SearchParser; >+import org.eclipse.help.internal.webapp.servlet.SearchServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class SimpleSearchService extends SearchServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ if ("".equals(response)) { //$NON-NLS-1$ >+ resp.sendError(400); // bad request; missing parameter >+ return; >+ } >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ SearchParser searchParser = new SearchParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ searchParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return searchParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/service/TocFragmentService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/TocFragmentService.java >diff -N src/org/eclipse/help/internal/webapp/service/TocFragmentService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/TocFragmentService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.TocFragmentParser; >+import org.eclipse.help.internal.webapp.servlet.TocFragmentServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+/* >+ * Sends all toc contributions available on this host in XML form. The toc >+ * is not send in assembled form, but instead fragments, because complete books >+ * may be distributed between remote and local. >+ * >+ */ >+public class TocFragmentService extends TocFragmentServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ String toc = req.getParameter("toc"); //$NON-NLS-1$ >+ String path = req.getParameter("path"); //$NON-NLS-1$ >+ response = getJSONResponse(toc, path, response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String toc, String path, String xmlResource) >+ throws IOException { >+ TocFragmentParser tocParser = new TocFragmentParser(); >+ InputStream is = null; >+ try { >+ if (xmlResource != null) { >+ is = new ByteArrayInputStream(xmlResource.getBytes("UTF-8")); //$NON-NLS-1$ >+ >+ int level = 0; >+ if (toc != null && toc.length() > 0) { >+ level++; >+ >+ >+ if (path != null && path.length() > 0) { >+ String[] pathIdxs = path.split("_"); //$NON-NLS-1$ >+ level += pathIdxs.length; >+ } >+ } >+ >+ tocParser.parse(is, level); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return tocParser.toJSON(); >+ } >+} >Index: src/org/eclipse/help/internal/webapp/service/TocService.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/service/TocService.java >diff -N src/org/eclipse/help/internal/webapp/service/TocService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/service/TocService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.service; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.internal.webapp.parser.TocParser; >+import org.eclipse.help.internal.webapp.servlet.TocServlet; >+import org.eclipse.help.internal.webapp.utils.Utils; >+ >+public class TocService extends TocServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >+ // Set standard HTTP/1.1 no-cache headers. >+ resp.setHeader("Cache-Control", //$NON-NLS-1$ >+ "no-store, no-cache, must-revalidate"); //$NON-NLS-1$ >+ >+ String response = processRequest(req, resp); >+ >+ String returnType = req.getParameter(Utils.RETURN_TYPE); >+ boolean boolIsJSON = (returnType != null >+ && returnType.equalsIgnoreCase(Utils.JSON)); >+ >+ // If JSON output is required >+ if (boolIsJSON) { >+ resp.setContentType("text/plain"); //$NON-NLS-1$ >+ response = getJSONResponse(response); >+ } >+ >+ resp.getWriter().write(response); >+ } >+ >+ protected String getJSONResponse(String response) >+ throws IOException { >+ TocParser tocParser = new TocParser(); >+ InputStream is = null; >+ try { >+ if (response != null) { >+ is = new ByteArrayInputStream(response.getBytes("UTF-8")); //$NON-NLS-1$ >+ tocParser.parse(is); >+ } >+ >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ if (is != null) >+ is.close(); >+ >+ // Call after the catch. >+ // An empty JSON is created if any Exception is thrown >+ // Else returns the complete JSON >+ return tocParser.toJSON(); >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/servlet/ContextServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ContextServlet.java,v >retrieving revision 1.5 >diff -u -r1.5 ContextServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/ContextServlet.java 15 Nov 2010 19:17:24 -0000 1.5 >+++ src/org/eclipse/help/internal/webapp/servlet/ContextServlet.java 17 Jan 2011 15:38:48 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,11 +7,11 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > > import java.io.IOException; >-import java.io.Writer; > > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; >@@ -40,6 +40,17 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ String response = processRequest(req, resp); >+ if ("400".equals(response)) //$NON-NLS-1$ >+ resp.sendError(400); // bad request; missing parameter >+ else if ("404".equals(response)) //$NON-NLS-1$ >+ resp.sendError(404); // Wrong context id; not found >+ else >+ resp.getWriter().write(response); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > BaseHelpSystem.checkMode(); > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >@@ -48,15 +59,13 @@ > if (id != null) { > IContext context = getContext(locale, id); > if (context != null) { >- serialize(context, resp.getWriter()); >+ return serialize(context); > } >- else { >- resp.sendError(404); >- } >- } >- else { >- resp.sendError(400); // bad request; missing parameter >+ // Wrong context id; not found >+ return "404"; //$NON-NLS-1$ > } >+ // bad request; missing parameter >+ return "400"; //$NON-NLS-1$ > } > > protected IContext getContext(String locale, String id) { >@@ -64,32 +73,34 @@ > return context; > } > >- private void serialize(IContext context, Writer out) throws IOException { >- out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ >- out.write('<' + Context.NAME ); >+ private String serialize(IContext context) throws IOException { >+ StringBuffer buff = new StringBuffer(); >+ buff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ >+ buff.append('<' + Context.NAME ); > if (context instanceof IContext2) { > String title = ((IContext2)context).getTitle(); > if (title != null && title.length() > 0) { >- out.write(" title=\"" + title + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ buff.append(" title=\"" + title + "\""); //$NON-NLS-1$ //$NON-NLS-2$ > } > } >- out.write(">\n"); //$NON-NLS-1$ >+ buff.append(">\n"); //$NON-NLS-1$ > String description = context.getText(); > if (description != null) { >- out.write(" <description>" + UrlUtil.htmlEncode(description) + "</description>\n"); //$NON-NLS-1$ //$NON-NLS-2$ >+ buff.append(" <description>" + UrlUtil.htmlEncode(description) + "</description>\n"); //$NON-NLS-1$ //$NON-NLS-2$ > } > > IHelpResource[] topics = context.getRelatedTopics(); > for (int i=0;i<topics.length;++i) { >- out.write(" <" + Topic.NAME); //$NON-NLS-1$ >+ buff.append(" <" + Topic.NAME); //$NON-NLS-1$ > if (topics[i].getLabel() != null) { >- out.write("\n " + Topic.ATTRIBUTE_LABEL + "=\"" + topics[i].getLabel() + '"'); //$NON-NLS-1$ //$NON-NLS-2$ >+ buff.append("\n " + Topic.ATTRIBUTE_LABEL + "=\"" + topics[i].getLabel() + '"'); //$NON-NLS-1$ //$NON-NLS-2$ > } > if (topics[i].getHref() != null) { >- out.write("\n " + Topic.ATTRIBUTE_HREF + "=\"" + topics[i].getHref() + '"'); //$NON-NLS-1$ //$NON-NLS-2$ >+ buff.append("\n " + Topic.ATTRIBUTE_HREF + "=\"" + topics[i].getHref() + '"'); //$NON-NLS-1$ //$NON-NLS-2$ > } >- out.write(">\n </topic>"); //$NON-NLS-1$ >+ buff.append("> </" + Topic.NAME + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$ > } >- out.write("</" + Context.NAME + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$ >+ buff.append("</" + Context.NAME + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return buff.toString(); > } > } >Index: src/org/eclipse/help/internal/webapp/servlet/ExtensionServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ExtensionServlet.java,v >retrieving revision 1.1 >diff -u -r1.1 ExtensionServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/ExtensionServlet.java 15 Mar 2007 15:36:56 -0000 1.1 >+++ src/org/eclipse/help/internal/webapp/servlet/ExtensionServlet.java 17 Jan 2011 15:38:49 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -39,6 +40,11 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ resp.getWriter().write(processRequest(req, resp)); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ > resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$ >@@ -57,7 +63,7 @@ > } > responseByLocale.put(locale, response); > } >- resp.getWriter().write(response); >+ return response; > } > > private String serialize(ContentExtension[] extensions) throws TransformerException { >Index: src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java,v >retrieving revision 1.6 >diff -u -r1.6 IndexFragmentServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java 25 Feb 2010 17:55:34 -0000 1.6 >+++ src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java 17 Jan 2011 15:38:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 IBM Corporation and others. >+ * Copyright (c) 2007, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -68,6 +69,11 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ resp.getWriter().write(processRequest(req, resp)); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > String locale = UrlUtil.getLocale(req, resp); > startParameter = req.getParameter("start"); //$NON-NLS-1$ > if (startParameter != null) { >@@ -112,7 +118,8 @@ > Serializer serializer = new Serializer(locale, scope); > String response = serializer.generateIndexXml(); > locale2Response.put(locale, response); >- resp.getWriter().write(response); >+ >+ return response; > } > > /* >Index: src/org/eclipse/help/internal/webapp/servlet/IndexServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexServlet.java,v >retrieving revision 1.2 >diff -u -r1.2 IndexServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/IndexServlet.java 1 Dec 2009 20:00:08 -0000 1.2 >+++ src/org/eclipse/help/internal/webapp/servlet/IndexServlet.java 17 Jan 2011 15:38:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -44,6 +45,11 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ resp.getWriter().write(processRequest(req, resp)); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > BaseHelpSystem.checkMode(); > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >@@ -63,7 +69,8 @@ > } > responseByLocale.put(locale, response); > } >- resp.getWriter().write(response); >+ >+ return (response != null) ? response : ""; //$NON-NLS-1$ > } > > public String serialize(IndexContribution[] contributions, String locale) throws TransformerException { >Index: src/org/eclipse/help/internal/webapp/servlet/SearchServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/SearchServlet.java,v >retrieving revision 1.7 >diff -u -r1.7 SearchServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/SearchServlet.java 16 Nov 2010 23:39:01 -0000 1.7 >+++ src/org/eclipse/help/internal/webapp/servlet/SearchServlet.java 17 Jan 2011 15:38:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -14,7 +15,6 @@ > import java.util.ArrayList; > import java.util.Collection; > import java.util.Collections; >-import java.util.Iterator; > import java.util.List; > > import javax.servlet.ServletException; >@@ -27,10 +27,10 @@ > import org.eclipse.help.internal.search.ISearchHitCollector; > import org.eclipse.help.internal.search.ISearchQuery; > import org.eclipse.help.internal.search.QueryTooComplexException; >-import org.eclipse.help.internal.search.SearchHit; > import org.eclipse.help.internal.search.SearchQuery; > import org.eclipse.help.internal.util.URLCoder; > import org.eclipse.help.internal.webapp.data.UrlUtil; >+import org.eclipse.help.internal.webapp.utils.SearchXMLGenerator; > > /* > * Returns the search hits for the query provided in the phrase parameter. >@@ -61,65 +61,34 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ String response = processRequest(req, resp); >+ if ("".equals(response)) //$NON-NLS-1$ >+ resp.sendError(400); // bad request; missing parameter >+ else >+ resp.getWriter().write(response); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > BaseHelpSystem.checkMode(); > HitCollector collector = new HitCollector(); > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ > resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$ >- String phrase = req.getParameter(PARAMETER_PHRASE); >+ String phrase = req.getParameter(PARAMETER_PHRASE); > if (phrase != null) { > phrase = URLCoder.decode(phrase); > ISearchQuery query = new SearchQuery(phrase, false, Collections.EMPTY_LIST, locale); > collector.results.clear(); > BaseHelpSystem.getSearchManager().search(query, collector, new NullProgressMonitor()); > if (searchException == null) { >- String response = serialize(collector.results); >- resp.getWriter().write(response); >- return; >+ return serialize(collector.results); > } > } >- >- resp.sendError(400); // bad request; missing parameter >- >+ return ""; //$NON-NLS-1$ > } > > public static String serialize(Collection results) { >- StringBuffer buf = new StringBuffer(); >- buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ >- buf.append("<searchHits>\n"); //$NON-NLS-1$ >- Iterator iter = results.iterator(); >- while (iter.hasNext()) { >- SearchHit hit = (SearchHit)iter.next(); >- serialize(hit, buf, " "); //$NON-NLS-1$ >- } >- buf.append("</searchHits>\n"); //$NON-NLS-1$ >- return buf.toString(); >- } >- >- private static void serialize(SearchHit hit, StringBuffer buf, String indent) { >- buf.append(indent + "<hit"); //$NON-NLS-1$ >- if (hit.getHref() != null) { >- buf.append('\n' + indent + " href=\"" + XMLGenerator.xmlEscape(hit.getHref()) + '"'); //$NON-NLS-1$ >- } >- if (hit.getLabel() != null) { >- buf.append('\n' + indent + " label=\"" + XMLGenerator.xmlEscape(hit.getLabel()) + '"'); //$NON-NLS-1$ >- } >- if (hit.isPotentialHit()) { >- buf.append('\n' + indent + " isPotentialHit=\"true\""); //$NON-NLS-1$ >- } >- buf.append('\n' + indent + " score=\"" + hit.getScore() + '"'); //$NON-NLS-1$ >- buf.append(">\n"); //$NON-NLS-1$ >- >- String summary = hit.getSummary(); >- if (summary != null) { >- serialize(summary, buf, indent + " "); //$NON-NLS-1$ >- } >- buf.append(indent + "</hit>\n"); //$NON-NLS-1$ >- } >- >- private static void serialize(String summary, StringBuffer buf, String indent) { >- buf.append(indent + "<summary>"); //$NON-NLS-1$ >- buf.append(XMLGenerator.xmlEscape(summary)); >- buf.append("</summary>\n"); //$NON-NLS-1$ >+ return SearchXMLGenerator.serialize(results); > } > } >Index: src/org/eclipse/help/internal/webapp/servlet/SecureServlet.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/servlet/SecureServlet.java >diff -N src/org/eclipse/help/internal/webapp/servlet/SecureServlet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/servlet/SecureServlet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,267 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.servlet; >+ >+import java.io.ByteArrayInputStream; >+import java.io.ByteArrayOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.OutputStream; >+import java.io.PrintWriter; >+import java.io.UnsupportedEncodingException; >+import java.util.ArrayList; >+import java.util.Enumeration; >+import java.util.Hashtable; >+import java.util.List; >+import java.util.Locale; >+ >+import javax.servlet.ServletConfig; >+import javax.servlet.ServletException; >+import javax.servlet.ServletOutputStream; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+import javax.servlet.http.HttpServletResponseWrapper; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.help.internal.webapp.HelpWebappPlugin; >+import org.eclipse.help.internal.webapp.WebappResources; >+import org.eclipse.help.internal.webapp.data.UrlUtil; >+ >+/* >+ * Class is responsible for implementing security protection. All servlets >+ * who use the org.eclipse.help.webapp.secureServlet extension point will >+ * will be processed for security failures by this class. >+ * >+ */ >+public class SecureServlet extends HttpServlet { >+ >+ private static final long serialVersionUID = -3783758607845176051L; >+ private Hashtable servletTable = new Hashtable(); >+ >+ protected void process(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException{ >+ >+ String baseURL = req.getRequestURL().toString(); >+ baseURL = baseURL.substring(0, baseURL.indexOf(req.getServletPath())); >+ >+ Locale locale = UrlUtil.getLocaleObj(req,resp); >+ >+ String service = req.getRequestURL().toString().substring( >+ (baseURL).length()+("/ss".length())); //$NON-NLS-1$ >+ >+ try { >+ HttpServletResponseAdv response = new HttpServletResponseAdv(resp); >+ >+ HttpServlet servlet = getServlet(service); >+ ServletConfig config = getServletConfig(); >+ servlet.init(config); >+ servlet.service(req, response); >+ >+ if (isSecure(req, response)) >+ response.commitOutput(); >+ >+ } catch(Exception ex) { >+ >+ String errorMsg = WebappResources.getString("cantCreateServlet", //$NON-NLS-1$ >+ locale, service); >+ HelpWebappPlugin.logError(errorMsg, ex); >+ >+ PrintWriter writer = resp.getWriter(); >+ writer.println(errorMsg); >+ ex.printStackTrace(writer); >+ >+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); >+ } >+ } >+ >+ private HttpServlet getServlet(String name) throws CoreException >+ { >+ HttpServlet servlet = (HttpServlet)servletTable.get(name); >+ >+ if (servlet==null) >+ { >+ IConfigurationElement[] configs = >+ Platform.getExtensionRegistry().getConfigurationElementsFor(HelpWebappPlugin.PLUGIN_ID+".secureServlet"); //$NON-NLS-1$ >+ >+ for (int c=0;c<configs.length;c++) >+ { >+ String alias = configs[c].getAttribute("alias"); //$NON-NLS-1$ >+ if (alias!=null) >+ { >+ if (isMatch(alias,name)) >+ { >+ servlet = (HttpServlet)configs[c].createExecutableExtension("class"); //$NON-NLS-1$ >+ servletTable.put(name, servlet); >+ } >+ } >+ } >+ } >+ return servlet; >+ >+ } >+ >+ private boolean isMatch(String alias,String name) >+ { >+ if (alias.indexOf("*")>-1) //$NON-NLS-1$ >+ alias = replaceAll(alias,'*',".*"); //$NON-NLS-1$ >+ >+ alias+=".*"; //$NON-NLS-1$ >+ >+ return name.matches(alias); >+ } >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ process(req,resp); >+ } >+ >+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ process(req,resp); >+ } >+ >+ public boolean isSecure(HttpServletRequest req,HttpServletResponseAdv resp) throws SecurityException >+ { >+ Enumeration names = req.getParameterNames(); >+ List values = new ArrayList(); >+ List scripts = new ArrayList(); >+ >+ while (names.hasMoreElements()) >+ { >+ String name = (String)names.nextElement(); >+ String val = req.getParameter(name); >+ values.add(val); >+ if (replaceAll(val,'+',"").indexOf("<script")>-1) //$NON-NLS-1$ //$NON-NLS-2$ >+ scripts.add(val); >+ } >+ >+ if(resp.getWriter()!=null) >+ { >+ String data = resp.getString(); >+ for (int s=0;s<scripts.size();s++) >+ if (data.indexOf((String)scripts.get(s))>-1) >+ throw new SecurityException("Potential cross-site scripting detected."); //$NON-NLS-1$ >+ } >+ >+ return true; >+ } >+ >+ public void isScript(List params,OutputStream out) >+ { >+// ByteArrayOutputStream bOut = new ByteArrayOutputStream(out); >+ } >+ >+ >+ public String replaceAll(String str,char remove,String add) >+ { >+ StringBuffer buffer = new StringBuffer(); >+ for (int s=0;s<str.length();s++) >+ { >+ if (str.charAt(s)==remove) >+ buffer.append(add); >+ else >+ buffer.append(str.charAt(s)); >+ } >+ return buffer.toString(); >+ } >+ >+ private class HttpServletResponseAdv extends HttpServletResponseWrapper >+ { >+ private HttpServletResponse response; >+ private ByteArrayOutputStream out; >+ private ServletPrintWriter writer; >+ private SecureServletOutputStream stream; >+ >+ public HttpServletResponseAdv(HttpServletResponse response) { >+ super(response); >+ out = new ByteArrayOutputStream(); >+ this.response = response; >+ } >+ >+ public PrintWriter getWriter() >+ { >+ if (writer==null && stream==null) >+ writer = new ServletPrintWriter(); >+ return writer; >+ } >+ >+ public ServletOutputStream getOutputStream() >+ { >+ if (stream==null && writer==null) >+ stream = new SecureServletOutputStream(out); >+ return stream; >+ } >+ >+ public void commitOutput() throws IOException >+ { >+ OutputStream os = response.getOutputStream(); >+ InputStream is = getInputStream(); >+ >+ int read; >+ byte buffer[] = new byte[1024*8*8]; >+ >+ while ((read = is.read(buffer))>-1) >+ os.write(buffer,0,read); >+ >+ os.flush(); >+ } >+ >+ public InputStream getInputStream() >+ { >+ if (stream!=null) >+ { >+ try { >+ out.flush(); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ return new ByteArrayInputStream(out.toByteArray()); >+ } >+ if (writer!=null) >+ { >+ try { >+ return new ByteArrayInputStream(writer.toString().getBytes(getCharacterEncoding())); >+ } catch (UnsupportedEncodingException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ return null; >+ } >+ >+ public String getString() >+ { >+ if (writer!=null) >+ return writer.toString(); >+ >+ return null; >+ } >+ } >+ >+ >+ private class SecureServletOutputStream extends ServletOutputStream{ >+ >+ private OutputStream out; >+ >+ public SecureServletOutputStream(OutputStream out) >+ { >+ this.out = out; >+ } >+ >+ public void write(int b) throws IOException { >+ out.write(b); >+ } >+ >+ } >+} >Index: src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java >diff -N src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.servlet; >+ >+import java.io.ByteArrayOutputStream; >+import java.io.PrintWriter; >+ >+public class ServletPrintWriter extends PrintWriter{ >+ >+ private StringBuffer buffer; >+ >+ public ServletPrintWriter() { >+ super(new ByteArrayOutputStream()); >+ buffer = new StringBuffer(); >+ } >+ >+ /** >+ * Writes a single character. >+ * @param c int specifying a character to be written. >+ */ >+ public void write(int c) { >+ synchronized (lock) { >+ buffer.append((char)(c)); >+ } >+ } >+ >+ /** >+ * Writes A Portion of an array of characters. >+ * @param buf Array of characters >+ * @param off Offset from which to start writing characters >+ * @param len Number of characters to write >+ */ >+ public void write(char buf[], int off, int len) { >+ synchronized (lock) { >+ buffer.append(buf, off, len); >+ } >+ } >+ >+ /** >+ * Writes an array of characters. This method cannot be inherited from the >+ * Writer class because it must suppress I/O exceptions. >+ * @param buf Array of characters to be written >+ */ >+ public void write(char buf[]) { >+ write(buf, 0, buf.length); >+ } >+ >+ /** >+ * Writes a portion of a string. >+ * @param s A String >+ * @param off Offset from which to start writing characters >+ * @param len Number of characters to write >+ */ >+ public void write(String s, int off, int len) { >+ synchronized (lock) { >+ buffer.append(s.toCharArray(), off, off+len); >+ } >+ } >+ >+ /** >+ * Writes a string. This method cannot be inherited from the Writer class >+ * because it must suppress I/O exceptions. >+ * @param s String to be written >+ */ >+ public void write(String s) { >+ write(s, 0, s.length()); >+ } >+ >+ public String toString() >+ { >+ return buffer.toString(); >+ } >+} >Index: src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java,v >retrieving revision 1.15 >diff -u -r1.15 TocFragmentServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java 17 Feb 2010 17:53:39 -0000 1.15 >+++ src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java 17 Jan 2011 15:38:59 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * Copyright (c) 2006, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -46,6 +47,11 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ resp.getWriter().write(processRequest(req, resp)); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ > resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$ >@@ -60,7 +66,8 @@ > Serializer serializer = new Serializer(data, req.getLocale(), scope); > String response = serializer.generateTreeXml(); > locale2Response.put(locale, response); >- resp.getWriter().write(response); >+ >+ return response; > } > > private void readParameters(HttpServletRequest req) { >Index: src/org/eclipse/help/internal/webapp/servlet/TocServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocServlet.java,v >retrieving revision 1.5 >diff -u -r1.5 TocServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/TocServlet.java 1 Dec 2009 20:00:08 -0000 1.5 >+++ src/org/eclipse/help/internal/webapp/servlet/TocServlet.java 17 Jan 2011 15:39:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.help.internal.webapp.servlet; > >@@ -44,6 +45,11 @@ > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { >+ resp.getWriter().write(processRequest(req, resp)); >+ } >+ >+ protected String processRequest(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { > BaseHelpSystem.checkMode(); > String locale = UrlUtil.getLocale(req, resp); > req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ >@@ -63,7 +69,8 @@ > } > responseByLocale.put(locale, response); > } >- resp.getWriter().write(response); >+ >+ return (response != null) ? response : ""; //$NON-NLS-1$ > } > > protected String serialize(TocContribution[] contributions, String locale) throws TransformerException { >Index: src/org/eclipse/help/internal/webapp/utils/JSonHelper.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/utils/JSonHelper.java >diff -N src/org/eclipse/help/internal/webapp/utils/JSonHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/utils/JSonHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.utils; >+ >+public final class JSonHelper { >+ >+ //JSON Characters >+ public static final String BEGIN_BRACE = "{"; //$NON-NLS-1$ >+ public static final String END_BRACE = "}"; //$NON-NLS-1$ >+ public static final String QUOTE = "\'"; //$NON-NLS-1$ >+ public static final String COLON = ":"; //$NON-NLS-1$ >+ public static final String BEGIN_BRACKET = "["; //$NON-NLS-1$ >+ public static final String END_BRACKET = "]"; //$NON-NLS-1$ >+ public static final String COMMA = ","; //$NON-NLS-1$ >+ public static final String NEWLINE = "\n"; //$NON-NLS-1$ >+ public static final String SPACE = " "; //$NON-NLS-1$ >+ >+ //JSON items >+ public static final String LABEL = "label"; //$NON-NLS-1$ >+ public static final String IDENTIFIER = "identifier"; //$NON-NLS-1$ >+ public static final String URL = "url"; //$NON-NLS-1$ >+ public static final String PROVIDER = "provider"; //$NON-NLS-1$ >+ public static final String ITEMS = "items"; //$NON-NLS-1$ >+ public static final String NAME = "name"; //$NON-NLS-1$ >+ public static final String TITLE = "title"; //$NON-NLS-1$ >+ public static final String ID = "id"; //$NON-NLS-1$ >+ public static final String HREF = "href"; //$NON-NLS-1$ >+ public static final String TYPE = "type"; //$NON-NLS-1$ >+ public static final String CHECKED = "checked"; //$NON-NLS-1$ >+ public static final String CHILDREN = "children"; //$NON-NLS-1$ >+ public static final String REFERENCE = "_reference"; //$NON-NLS-1$ >+ public static final String IS_LEAF = "is_leaf"; //$NON-NLS-1$ >+ public static final String IS_SELECTED = "is_selected"; //$NON-NLS-1$ >+ public static final String IS_HIGHLIGHTED = "is_highlighted"; //$NON-NLS-1$ >+ public static final String TOC = "toc"; //$NON-NLS-1$ >+ public static final String PATH = "path"; //$NON-NLS-1$ >+ public static final String CATEGORY = "category"; //$NON-NLS-1$ >+ public static final String DESCRIPTION = "description"; //$NON-NLS-1$ >+ public static final String CATEGORY_HREF = CATEGORY+"_"+HREF; //$NON-NLS-1$ >+ 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 String getQuotes(String str){ >+ return ((str != null)?QUOTE + str + QUOTE:""); //$NON-NLS-1$ >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/utils/SearchXMLGenerator.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/utils/SearchXMLGenerator.java >diff -N src/org/eclipse/help/internal/webapp/utils/SearchXMLGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/utils/SearchXMLGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.utils; >+ >+import java.util.Collection; >+ >+import org.eclipse.help.HelpSystem; >+import org.eclipse.help.IHelpResource; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.internal.search.SearchHit; >+import org.eclipse.help.internal.webapp.data.UrlUtil; >+import org.eclipse.help.internal.webapp.servlet.XMLGenerator; >+ >+public class SearchXMLGenerator { >+ >+ public static String serialize(Collection results) { >+ return serialize((results != null) ? results.toArray() : null, false); >+ } >+ >+ public static String serialize(Object[] hits, boolean boolIsCategory) { >+ StringBuffer buf = new StringBuffer(); >+ buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ >+ buf.append("<searchHits>\n"); //$NON-NLS-1$ >+ >+ if (hits != null) { >+ for (int i = 0; i < hits.length; i++) { >+ SearchHit hit = (SearchHit) hits[i]; >+ serialize(hit, buf, " ", boolIsCategory); //$NON-NLS-1$ >+ } >+ } >+ >+ buf.append("</searchHits>\n"); //$NON-NLS-1$ >+ >+ return buf.toString(); >+ } >+ >+ private static void serialize(SearchHit hit, StringBuffer buf, >+ String indent, boolean boolIsCategory) { >+ buf.append(indent + "<hit"); //$NON-NLS-1$ >+ if (hit.getHref() != null) { >+ buf.append('\n' + indent + " href=\"" + XMLGenerator.xmlEscape(hit.getHref()) + '"'); //$NON-NLS-1$ >+ } >+ if (hit.getLabel() != null) { >+ buf.append('\n' + indent + " label=\"" + XMLGenerator.xmlEscape(hit.getLabel()) + '"'); //$NON-NLS-1$ >+ } >+ if (hit.isPotentialHit()) { >+ buf.append('\n' + indent + " isPotentialHit=\"true\""); //$NON-NLS-1$ >+ } >+ buf.append('\n' + indent + " score=\"" + hit.getScore() + '"'); //$NON-NLS-1$ >+ buf.append(">\n"); //$NON-NLS-1$ >+ >+ // get Category >+ if (boolIsCategory) { >+ IHelpResource categoryResource = hit.getCategory(); >+ if (categoryResource != null) { >+ serializeCategory(categoryResource, buf, indent + " "); //$NON-NLS-1$ >+ } >+ } >+ >+ // get Summary/Description >+ String summary = hit.getSummary(); >+ if (summary != null) { >+ serialize(summary, buf, indent + " "); //$NON-NLS-1$ >+ } >+ buf.append(indent + "</hit>\n"); //$NON-NLS-1$ >+ } >+ >+ private static void serialize(String summary, StringBuffer buf, String indent) { >+ buf.append(indent + "<summary>"); //$NON-NLS-1$ >+ buf.append(XMLGenerator.xmlEscape(summary)); >+ buf.append("</summary>\n"); //$NON-NLS-1$ >+ } >+ >+ private static void serializeCategory(IHelpResource categoryResource, >+ StringBuffer buf, String indent) { >+ String category = categoryResource.getLabel(); >+ if (category == null) return; >+ >+ buf.append(indent + "<category"); //$NON-NLS-1$ >+ >+ String catHref = getCategoryHref(categoryResource); >+ if (catHref != null) { >+ buf.append('\n' + indent + " href=\"" //$NON-NLS-1$ >+ + XMLGenerator.xmlEscape(catHref) + '"'); >+ } >+ >+ buf.append(">\n"); //$NON-NLS-1$ >+ buf.append(XMLGenerator.xmlEscape(category)); >+ >+ buf.append("</category>\n"); //$NON-NLS-1$ >+ } >+ >+ private static String getCategoryHref(IHelpResource categoryResource) { >+ String tocHref = categoryResource.getHref(); >+ IToc[] tocs = HelpSystem.getTocs(); >+ for (int j=0;j<tocs.length;++j) { >+ if (tocHref.equals(tocs[j].getHref())) { >+ ITopic topic = tocs[j].getTopic(null); >+ String topicHref = topic.getHref(); >+ if (topicHref != null) { >+ return UrlUtil.getHelpURL(topicHref); >+ } >+ return "../nav/" + j; //$NON-NLS-1$ >+ } >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/help/internal/webapp/utils/Utils.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/utils/Utils.java >diff -N src/org/eclipse/help/internal/webapp/utils/Utils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/utils/Utils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.utils; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.io.Reader; >+import java.io.StringWriter; >+import java.io.Writer; >+ >+public class Utils { >+ >+ public static final String RETURN_TYPE = "returnType"; //$NON-NLS-1$ >+ public static final String NO_CATEGORY = "noCategory"; //$NON-NLS-1$ >+ >+ // returnType values: xml (default) | json >+ public static final String XML = "xml"; //$NON-NLS-1$ >+ public static final String JSON = "json"; //$NON-NLS-1$ >+ >+ public static String convertStreamToString(InputStream is) >+ throws IOException { >+ if (is != null) { >+ Writer writer = new StringWriter(); >+ char[] buffer = new char[1024]; >+ try { >+ Reader reader = new BufferedReader( >+ new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$ >+ int n; >+ while ((n = reader.read(buffer)) != -1) { >+ writer.write(buffer, 0, n); >+ } >+ } finally { >+ is.close(); >+ } >+ return writer.toString(); >+ } else { >+ return ""; //$NON-NLS-1$ >+ } >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/utils/XMLHelper.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/utils/XMLHelper.java >diff -N src/org/eclipse/help/internal/webapp/utils/XMLHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/utils/XMLHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.help.internal.webapp.utils; >+ >+public final class XMLHelper { >+ >+ public static final String SESSION_URL = "helpURL"; //$NON-NLS-1$ >+ >+ public static final String URL36_PREFIX = "/advanced"; //$NON-NLS-1$ >+ public static final String TOC_URL = "/tocfragment"; //$NON-NLS-1$ >+ public static final String SEARCH_URL = "/search"; //$NON-NLS-1$ >+ >+ public static final String ATTR_TITLE = "title"; //$NON-NLS-1$ >+ public static final String ATTR_ID = "id"; //$NON-NLS-1$ >+ public static final String ATTR_HREF = "href"; //$NON-NLS-1$ >+ public static final String ATTR_IMAGE = "image"; //$NON-NLS-1$ >+ public static final String ATTR_LABEL = "label"; //$NON-NLS-1$ >+ public static final String ATTR_SCORE = "score"; //$NON-NLS-1$ >+ public static final String ATTR_LOCALE = "locale"; //$NON-NLS-1$ >+ public static final String ATTR_KEYWORD = "keyword"; //$NON-NLS-1$ >+ >+ public static final String ELEMENT_NODE = "node"; //$NON-NLS-1$ >+ public static final String ELEMENT_HIT = "hit"; //$NON-NLS-1$ >+ public static final String ELEMENT_HITS = "searchHits"; //$NON-NLS-1$ >+ public static final String ELEMENT_CATEGORY = "category"; //$NON-NLS-1$ >+ public static final String ELEMENT_SUMMARY = "summary"; //$NON-NLS-1$ >+ public static final String ELEMENT_DESCRIPTION = "description"; //$NON-NLS-1$ >+ 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 CATEGORY_HREF = "categoryHref"; //$NON-NLS-1$ >+} >#P org.eclipse.ua.tests >Index: help/org/eclipse/ua/tests/help/AllHelpTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java,v >retrieving revision 1.13 >diff -u -r1.13 AllHelpTests.java >--- help/org/eclipse/ua/tests/help/AllHelpTests.java 1 Feb 2010 23:40:28 -0000 1.13 >+++ help/org/eclipse/ua/tests/help/AllHelpTests.java 17 Jan 2011 15:39:06 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * Copyright (c) 2006, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -23,6 +23,7 @@ > import org.eclipse.ua.tests.help.search.AllSearchTests; > import org.eclipse.ua.tests.help.toc.AllTocTests; > import org.eclipse.ua.tests.help.webapp.AllWebappTests; >+import org.eclipse.ua.tests.help.webapp.service.AllWebappServiceTests; > > /* > * Tests help functionality (automated). >@@ -50,5 +51,6 @@ > addTest(AllOtherHelpTests.suite()); > addTest(AllRemoteTests.suite()); > addTest(AllScopeTests.suite()); >+ addTest(AllWebappServiceTests.suite()); > } > } >Index: help/org/eclipse/ua/tests/help/remote/ContextServletTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java,v >retrieving revision 1.2 >diff -u -r1.2 ContextServletTest.java >--- help/org/eclipse/ua/tests/help/remote/ContextServletTest.java 7 Jan 2011 21:52:44 -0000 1.2 >+++ help/org/eclipse/ua/tests/help/remote/ContextServletTest.java 17 Jan 2011 15:39:06 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.ua.tests.help.remote; > >@@ -70,14 +71,14 @@ > } > } > >- private Element[] getContextsFromServlet(String phrase) >+ protected Element[] getContextsFromServlet(String phrase) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/context?id=" + URLEncoder.encode(phrase, "UTF-8")); > return makeServletCall(url); > } > >- private Element[] getContextsUsingLocale(String phrase, String locale) >+ protected Element[] getContextsUsingLocale(String phrase, String locale) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/context?id=" >@@ -85,7 +86,7 @@ > return makeServletCall(url); > } > >- private Element[] makeServletCall(URL url) throws IOException, >+ protected Element[] makeServletCall(URL url) throws IOException, > ParserConfigurationException, FactoryConfigurationError, > SAXException { > InputStream is = url.openStream(); >Index: help/org/eclipse/ua/tests/help/remote/IndexServletTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java,v >retrieving revision 1.2 >diff -u -r1.2 IndexServletTest.java >--- help/org/eclipse/ua/tests/help/remote/IndexServletTest.java 7 Jan 2011 21:52:44 -0000 1.2 >+++ help/org/eclipse/ua/tests/help/remote/IndexServletTest.java 17 Jan 2011 15:39:07 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.ua.tests.help.remote; > >@@ -146,7 +147,7 @@ > } > } > >- private Node getIndexContributions( String locale) >+ protected Node getIndexContributions( String locale) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/index?lang=" + locale); >Index: help/org/eclipse/ua/tests/help/remote/SearchServletTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java,v >retrieving revision 1.5 >diff -u -r1.5 SearchServletTest.java >--- help/org/eclipse/ua/tests/help/remote/SearchServletTest.java 7 Jan 2011 21:52:44 -0000 1.5 >+++ help/org/eclipse/ua/tests/help/remote/SearchServletTest.java 17 Jan 2011 15:39:07 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.ua.tests.help.remote; > >@@ -97,14 +98,14 @@ > assertEquals(0, hits.length); > } > >- private Node[] getSearchHitsFromServlet(String phrase) >+ protected Node[] getSearchHitsFromServlet(String phrase) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/search?phrase=" + URLEncoder.encode(phrase, "UTF-8")); > return makeServletCall(url); > } > >- private Node[] getSearchHitsUsingLocale(String phrase, String locale) >+ protected Node[] getSearchHitsUsingLocale(String phrase, String locale) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/search?phrase=" >@@ -112,7 +113,7 @@ > return makeServletCall(url); > } > >- private Node[] makeServletCall(URL url) throws IOException, >+ protected Node[] makeServletCall(URL url) throws IOException, > ParserConfigurationException, FactoryConfigurationError, > SAXException { > InputStream is = url.openStream(); >Index: help/org/eclipse/ua/tests/help/remote/TocServletTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java,v >retrieving revision 1.3 >diff -u -r1.3 TocServletTest.java >--- help/org/eclipse/ua/tests/help/remote/TocServletTest.java 7 Jan 2011 21:52:44 -0000 1.3 >+++ help/org/eclipse/ua/tests/help/remote/TocServletTest.java 17 Jan 2011 15:39:07 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services > *******************************************************************************/ > package org.eclipse.ua.tests.help.remote; > >@@ -110,7 +111,7 @@ > } > > >- private Node getTocContributions( String locale) >+ protected Node getTocContributions( String locale) > throws Exception { > int port = WebappManager.getPort(); > URL url = new URL("http", "localhost", port, "/help/toc?lang=" + locale); >Index: help/org/eclipse/ua/tests/help/util/ServletTester.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/util/ServletTester.java >diff -N help/org/eclipse/ua/tests/help/util/ServletTester.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/util/ServletTester.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,111 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.util; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.net.URL; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.Status; >+import org.xml.sax.ErrorHandler; >+import org.xml.sax.SAXException; >+import org.xml.sax.SAXParseException; >+ >+ >+public class ServletTester { >+ >+ // dtd validation >+ // argument processing / validation >+ // invalid args dont workit >+ >+ public static String callTextServlet(URL url) throws IOException >+ { >+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); >+ >+ String res=""; >+ String line; >+ while ((line = br.readLine())!=null) >+ res+=line+'\n'; >+ >+ br.close(); >+ >+ return res; >+ } >+ >+ public static boolean isXML(URL url) throws IOException >+ { >+ return callTextServlet(url).startsWith("<?xml"); >+// return siteContains(url,"<?xml"); >+ } >+ >+ public static boolean siteContains(URL url,String str) throws IOException >+ { >+ return (callTextServlet(url).indexOf(str) > -1); >+ } >+ >+ public static boolean isDTDValidated(URL url) throws Exception >+ { >+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >+ factory.setValidating(true); >+ >+ DocumentBuilder builder = factory.newDocumentBuilder(); >+ >+ DTDErrorHandler handler = new DTDErrorHandler(); >+ builder.setErrorHandler(handler); >+ builder.parse(url.toString()); >+ >+ return handler.getStatus().getSeverity()!=IStatus.ERROR; >+ } >+ >+ >+ private static class DTDErrorHandler implements ErrorHandler >+ { >+ private MultiStatus status = null; >+ >+ public void warning(SAXParseException exception) throws SAXException { >+ if (status==null) >+ status = new MultiStatus("org.eclipse.ua.tests",IStatus.WARNING,"DTD Processing Warning",exception); >+ else >+ { >+ IStatus tmp = new Status(IStatus.WARNING,"org.eclipse.ua.tests","DTD Processing Warning",exception); >+ status.add(tmp); >+ } >+ } >+ >+ public void error(SAXParseException exception) throws SAXException { >+ if (status==null) >+ status = new MultiStatus("org.eclipse.ua.tests",IStatus.ERROR,"DTD Processing Error",exception); >+ else >+ { >+ IStatus tmp = new Status(IStatus.ERROR,"org.eclipse.ua.tests","DTD Processing Error",exception); >+ status.add(tmp); >+ } >+ } >+ >+ public void fatalError(SAXParseException exception) throws SAXException { >+ error(exception); >+ } >+ >+ public IStatus getStatus() >+ { >+ if (status==null) >+ return Status.OK_STATUS; >+ return status; >+ } >+ >+ } >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+/* >+ * Tests utility classes and servlets used in Web Application >+ */ >+public class AllWebappServiceTests extends TestSuite { >+ >+ /* >+ * Returns the entire test suite. >+ */ >+ public static Test suite() { >+ TestSuite suite = new TestSuite( >+ "org.eclipse.ua.tests.help.AllWebappServiceTests"); >+ //$JUnit-BEGIN$ >+ suite.addTestSuite(ContentServiceTest.class); >+ suite.addTestSuite(ContextServiceTest.class); >+ suite.addTestSuite(IndexFragmentServiceTest.class); >+ suite.addTestSuite(IndexServiceTest.class); >+ suite.addTestSuite(SearchServiceTest.class); >+ suite.addTestSuite(SimpleSearchServiceTest.class); >+ suite.addTestSuite(TocFragmentServiceTest.class); >+ suite.addTestSuite(TocServiceTest.class); >+ //$JUnit-END$ >+ return suite; >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.io.IOException; >+ >+import org.eclipse.ua.tests.help.remote.ContentServletTest; >+ >+public class ContentServiceTest extends ContentServletTest { >+ >+ private static final String UA_TESTS = "org.eclipse.ua.tests"; >+ >+ public void testSimpleContent() throws Exception { >+ final String path = "/data/help/index/topic1.html"; >+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en"); >+ String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path); >+ assertEquals(remoteContent, localContent); >+ } >+ >+ public void testFilteredContent() throws Exception { >+ final String path = "/data/help/manual/filter.xhtml"; >+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en"); >+ String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path); >+ assertEquals(remoteContent, localContent); >+ } >+ >+ public void testContentInEnLocale() throws Exception { >+ final String path = "/data/help/search/testnl1.xhtml"; >+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en"); >+ String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path); >+ assertEquals(remoteContent, localContent); >+ } >+ >+ public void testContentInDeLocale() throws Exception { >+ final String path = "/data/help/search/testnl1.xhtml"; >+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "de"); >+ String enLocalContent = ServicesTestUtils.getLocalContent(UA_TESTS, path); >+ String deLocalContent = ServicesTestUtils.getLocalContent(UA_TESTS, "/nl/de" + path); >+ assertEquals(remoteContent, deLocalContent); >+ assertFalse(remoteContent.equals(enLocalContent)); >+ } >+ >+ public void testRemoteContentNotFound() throws Exception { >+ try { >+ ServicesTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en"); >+ fail("No exception thrown"); >+ } catch (IOException e) { >+ // Exception caught as expected >+ } >+ } >+ >+ >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.net.URL; >+import java.net.URLEncoder; >+ >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.ContextServletTest; >+import org.w3c.dom.Element; >+ >+public class ContextServiceTest extends ContextServletTest { >+ >+ protected Element[] getContextsFromServlet(String phrase) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/context?id=" >+ + URLEncoder.encode(phrase, "UTF-8")); >+ return makeServletCall(url); >+ } >+ >+ protected Element[] getContextsUsingLocale(String phrase, String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/context?id=" >+ + URLEncoder.encode(phrase, "UTF-8") + "&lang=" + locale); >+ return makeServletCall(url); >+ } >+ >+ public void testContextServiceXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/context?id=org.eclipse.ua.tests.test_cheatsheets&lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/context.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testContextServiceJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+ >+import java.io.InputStream; >+import java.net.URL; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.help.internal.base.BaseHelpSystem; >+import org.eclipse.help.internal.entityresolver.LocalEntityResolver; >+import org.eclipse.help.internal.server.WebappManager; >+import org.w3c.dom.Document; >+import org.w3c.dom.Node; >+import org.xml.sax.InputSource; >+ >+public class IndexFragmentServiceTest extends TestCase { >+ >+ private int mode; >+ >+ protected void setUp() throws Exception { >+ BaseHelpSystem.ensureWebappRunning(); >+ mode = BaseHelpSystem.getMode(); >+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); >+ } >+ >+ protected void tearDown() throws Exception { >+ BaseHelpSystem.setMode(mode); >+ } >+ >+ public void testIndexServletEn() throws Exception { >+ getTreeData("en"); >+ } >+ >+ public void testIndexServletDe() throws Exception { >+ getTreeData("de"); >+ } >+ >+ private void getTreeData(String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/indexfragment?lang=" + locale); >+ InputStream is = url.openStream(); >+ InputSource inputSource = new InputSource(is); >+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); >+ documentBuilder.setEntityResolver(new LocalEntityResolver()); >+ Document document = documentBuilder.parse(inputSource); >+ Node root = document.getFirstChild(); >+ is.close(); >+ assertEquals("tree_data", root.getNodeName()); >+ } >+ >+ public void testIndexFragmentServiceXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/indexfragment?lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/indexfragment.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testIndexFragmentServiceJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.io.InputStream; >+import java.net.URL; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ >+import org.eclipse.help.internal.entityresolver.LocalEntityResolver; >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.IndexServletTest; >+import org.w3c.dom.Document; >+import org.w3c.dom.Node; >+import org.xml.sax.InputSource; >+ >+public class IndexServiceTest extends IndexServletTest { >+ >+ protected Node getIndexContributions( String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/index?lang=" + locale); >+ InputStream is = url.openStream(); >+ InputSource inputSource = new InputSource(is); >+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); >+ documentBuilder.setEntityResolver(new LocalEntityResolver()); >+ Document document = documentBuilder.parse(inputSource); >+ Node root = document.getFirstChild(); >+ is.close(); >+ assertEquals("indexContributions", root.getNodeName()); >+ return root; >+ } >+ >+ public void testIndexServiceXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/index?lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/index.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testIndexServiceJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.io.File; >+import java.net.URL; >+ >+import javax.xml.transform.Source; >+import javax.xml.transform.stream.StreamSource; >+import javax.xml.validation.Schema; >+import javax.xml.validation.SchemaFactory; >+import javax.xml.validation.Validator; >+ >+import org.xml.sax.SAXException; >+ >+public class SchemaValidator { >+ >+ public static String testXMLSchema(String uri, String schemaFile) { >+ String msg = ""; //$NON-NLS-1$ >+ try { >+ SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$ >+ Schema schema = null; >+ if (schemaFile.startsWith("http") || schemaFile.startsWith("ftp")) >+ schema = factory.newSchema(new URL(schemaFile)); >+ else >+ schema = factory.newSchema(new File(schemaFile)); >+ >+ Validator validator = schema.newValidator(); >+ Source source = new StreamSource(uri); >+ try { >+ validator.validate(source); >+ msg = "valid"; //$NON-NLS-1$ >+ } catch (SAXException ex) { >+ msg = "not valid. Details: " + ex.getMessage(); //$NON-NLS-1$ >+ } >+ } catch(Exception e) { >+ msg = "Exception e: " + e; //$NON-NLS-1$ >+ } >+ >+ System.out.println(msg); >+ return msg; >+ } >+ >+ public static String testJSONSchema(String uri, String schemaFile) { >+ // TODO: Not yet implemented >+ return ""; //$NON-NLS-1$ >+ } >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+ >+import java.net.URL; >+import java.net.URLEncoder; >+ >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.SearchServletTest; >+import org.w3c.dom.Node; >+ >+public class SearchServiceTest extends SearchServletTest { >+ >+ protected Node[] getSearchHitsFromServlet(String searchWord) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/search?searchWord=" + URLEncoder.encode(searchWord, "UTF-8")); >+ return makeServletCall(url); >+ } >+ >+ protected Node[] getSearchHitsUsingLocale(String searchWord, String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/search?searchWord=" >+ + URLEncoder.encode(searchWord, "UTF-8") + "&lang=" + locale); >+ return makeServletCall(url); >+ } >+ >+ public void testRemoteSearchXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/search?searchWord=" + URLEncoder.encode("jehcyqpfjs vkrhjewiwh", "UTF-8")); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/search.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testRemoteSearchXMLSchemaExactMatchFound() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/search?searchWord=" + URLEncoder.encode("\"jehcyqpfjs vkrhjewiwh\"", "UTF-8")); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/search.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testRemoteSearchJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.net.URL; >+ >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.RemoteTestUtils; >+ >+public class ServicesTestUtils extends RemoteTestUtils { >+ >+ public static String getRemoteContent(String plugin, String path, >+ String locale) throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/rtopic/" + plugin >+ + path + "?lang=" + locale); >+ return readFromURL(url); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/SimpleSearchServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/SimpleSearchServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/SimpleSearchServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/SimpleSearchServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+ >+import java.net.URL; >+import java.net.URLEncoder; >+ >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.SearchServletTest; >+import org.w3c.dom.Node; >+ >+public class SimpleSearchServiceTest extends SearchServletTest { >+ >+ protected Node[] getSearchHitsFromServlet(String phrase) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/simplesearch?phrase=" + URLEncoder.encode(phrase, "UTF-8")); >+ return makeServletCall(url); >+ } >+ >+ protected Node[] getSearchHitsUsingLocale(String phrase, String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/simplesearch?phrase=" >+ + URLEncoder.encode(phrase, "UTF-8") + "&lang=" + locale); >+ return makeServletCall(url); >+ } >+ >+ public void testRemoteSimpleSearchXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/simplesearch?phrase=" + URLEncoder.encode("jehcyqpfjs vkrhjewiwh", "UTF-8")); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/simplesearch.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testRemoteSimpleSearchXMLSchemaExactMatchFound() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/simplesearch?phrase=" + URLEncoder.encode("\"jehcyqpfjs vkrhjewiwh\"", "UTF-8")); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/simplesearch.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testRemoteSimpleSearchJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,164 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.io.InputStream; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.List; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.help.internal.base.BaseHelpSystem; >+import org.eclipse.help.internal.entityresolver.LocalEntityResolver; >+import org.eclipse.help.internal.server.WebappManager; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+import org.xml.sax.InputSource; >+ >+public class TocFragmentServiceTest extends TestCase { >+ >+ private int mode; >+ >+ protected void setUp() throws Exception { >+ BaseHelpSystem.ensureWebappRunning(); >+ mode = BaseHelpSystem.getMode(); >+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); >+ } >+ >+ protected void tearDown() throws Exception { >+ BaseHelpSystem.setMode(mode); >+ } >+ >+ public void testTocFragmentServiceContainsUAToc() throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/tocfragment?lang=en"); >+ Node root = getTreeData(url); >+ Element[] UARoot = findNodeById(root, >+ "/org.eclipse.ua.tests/data/help/toc/root.xml"); >+ assertEquals(1, UARoot.length); >+ } >+ >+ public void testTocFragmentServiceContainsFilteredToc() throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/tocfragment?lang=en&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=2"); >+ Node root = getTreeData(url); >+ Element[] UARoot = findNodeById(root, >+ "/org.eclipse.ua.tests/data/help/toc/root.xml"); >+ assertEquals(1, UARoot.length); >+ Element[] filterNode = findNodeById(UARoot[0], "2"); >+ assertEquals(1, filterNode.length); >+ Element[] results = findChildren(filterNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html"); >+ assertEquals(24, results.length); >+ >+ results = findChildren(filterNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html"); >+ assertEquals(1, results.length); >+ } >+ >+ public void testReadEnToc() throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/tocfragment?lang=en&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=7"); >+ Node root = getTreeData(url); >+ Element[] UARoot = findNodeById(root, >+ "/org.eclipse.ua.tests/data/help/toc/root.xml"); >+ assertEquals(1, UARoot.length); >+ Element[] searchNode = findNodeById(UARoot[0], "7"); >+ assertEquals(1, searchNode.length); >+ Element[] topicEn = findChildren(searchNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/search/test_en.html"); >+ assertEquals(1, topicEn.length); >+ Element[] topicDe = findChildren(searchNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/search/test_de.html"); >+ assertEquals(0, topicDe.length); >+ } >+ >+ public void testReadDeToc() throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, >+ "/help/ss/service/tocfragment?lang=de&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=7"); >+ Node root = getTreeData(url); >+ Element[] UARoot = findNodeById(root, >+ "/org.eclipse.ua.tests/data/help/toc/root.xml"); >+ assertEquals(1, UARoot.length); >+ Element[] searchNode = findNodeById(UARoot[0], "7"); >+ Element[] topicEn = findChildren(searchNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/search/test_en.html"); >+ assertEquals(0, topicEn.length); >+ Element[] topicDe = findChildren(searchNode[0], "node", "href", >+ "../topic/org.eclipse.ua.tests/data/help/search/test_de.html"); >+ assertEquals(1, topicDe.length); >+ } >+ >+ private Element[] findNodeById(Node root, String id) { >+ return findChildren(root, "node", "id", id); >+ } >+ >+ private Element[] findChildren(Node parent, String childKind, >+ String attributeName, String attributeValue) { >+ NodeList nodes = parent.getChildNodes(); >+ List<Node> results = new ArrayList<Node>(); >+ for (int i = 0; i < nodes.getLength(); i++) { >+ Node next = nodes.item(i); >+ if (next instanceof Element) { >+ Element nextElement = (Element)next; >+ if ( childKind.equals(nextElement.getTagName()) >+ && attributeValue.equals(nextElement.getAttribute(attributeName))) { >+ >+ results.add(next); >+ } >+ } >+ } >+ return (Element[]) results.toArray(new Element[results.size()]); >+ } >+ >+ >+ private Node getTreeData(URL url) >+ throws Exception { >+ InputStream is = url.openStream(); >+ InputSource inputSource = new InputSource(is); >+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); >+ documentBuilder.setEntityResolver(new LocalEntityResolver()); >+ Document document = documentBuilder.parse(inputSource); >+ Node root = document.getFirstChild(); >+ is.close(); >+ assertEquals("tree_data", root.getNodeName()); >+ return root; >+ } >+ >+ public void testTocFragmentServiceXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/tocfragment?lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/tocfragment.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testTocFragmentServiceJSONSchema() >+ throws Exception { >+// fail("Not yet implemented."); >+ } >+ >+} >Index: help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java >=================================================================== >RCS file: help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java >diff -N help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services >+ *******************************************************************************/ >+package org.eclipse.ua.tests.help.webapp.service; >+ >+import java.io.InputStream; >+import java.net.URL; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+ >+import org.eclipse.help.internal.entityresolver.LocalEntityResolver; >+import org.eclipse.help.internal.server.WebappManager; >+import org.eclipse.ua.tests.help.remote.TocServletTest; >+import org.w3c.dom.Document; >+import org.w3c.dom.Node; >+import org.xml.sax.InputSource; >+ >+public class TocServiceTest extends TocServletTest { >+ >+ protected Node getTocContributions( String locale) >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/toc?lang=" + locale); >+ InputStream is = url.openStream(); >+ InputSource inputSource = new InputSource(is); >+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); >+ documentBuilder.setEntityResolver(new LocalEntityResolver()); >+ Document document = documentBuilder.parse(inputSource); >+ Node root = document.getFirstChild(); >+ is.close(); >+ assertEquals("tocContributions", root.getNodeName()); >+ return root; >+ } >+ >+ public void testTocServiceXMLSchema() >+ throws Exception { >+ int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/toc?lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/toc.xsd"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testXMLSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result); >+ } >+ >+ public void testTocServiceJSONSchema() >+ throws Exception { >+ /*int port = WebappManager.getPort(); >+ URL url = new URL("http", "localhost", port, "/help/ss/service/toc?lang=en"); >+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/json/toc.json"); >+ String schema = schemaUrl.toString(); >+ String uri = url.toString(); >+ String result = SchemaValidator.testJSONSchema(uri, schema); >+ >+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);*/ >+// fail("Not yet implemented."); >+ } >+ >+} >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ua.tests/plugin.xml,v >retrieving revision 1.62 >diff -u -r1.62 plugin.xml >--- plugin.xml 17 Jun 2010 18:35:47 -0000 1.62 >+++ plugin.xml 17 Jan 2011 15:39:17 -0000 >@@ -545,6 +545,10 @@ > alias="/titlesearch/script" > base-name="/script"> > </resource> >+ <resource >+ alias="/test" >+ base-name="/service"> >+ </resource> > <serviceSelector > filter="(other.info=org.eclipse.help)"> > </serviceSelector> >Index: service/schema/xml/context.xsd >=================================================================== >RCS file: service/schema/xml/context.xsd >diff -N service/schema/xml/context.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/context.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+ >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ >+ <xs:element name="context"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" /> >+ <xs:element ref="topic" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="title" type="xs:string" /> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="topic"> >+ <xs:complexType mixed="true"> >+ <xs:attribute name="label" type="xs:string" /> <!-- attribute for tree_data --> >+ <xs:attribute name="href" type="xs:string" /> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+</xs:schema> >\ No newline at end of file >Index: service/schema/xml/index.xsd >=================================================================== >RCS file: service/schema/xml/index.xsd >diff -N service/schema/xml/index.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/index.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ >+<xs:element name="indexContributions"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="indexContribution" minOccurs="0" >+ maxOccurs="unbounded" /> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ >+ <xs:element name="indexContribution"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="index" minOccurs="1" maxOccurs="1" /> >+ </xs:sequence> >+ <xs:attribute name="id" type="xs:string" use="required"/> <!-- attribute for tree_data --> >+ <xs:attribute name="locale" type="xs:string" use="required"/> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="index"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="entry" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="entry"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="topic" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="entry" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="see" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="keyword" type="xs:string" use="required"/> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="topic"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="href" type="xs:string" /> <!-- attribute for tree_data --> >+ <xs:attribute name="title" type="xs:string" /> <!-- attribute for tree_data --> >+ <xs:attribute name="label" type="xs:string" /> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="see"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="subpath" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="keyword" type="xs:string" use="required"/> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="subpath"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="keyword" type="xs:string" use="required"/> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+</xs:schema> >\ No newline at end of file >Index: service/schema/xml/indexfragment.xsd >=================================================================== >RCS file: service/schema/xml/indexfragment.xsd >diff -N service/schema/xml/indexfragment.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/indexfragment.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ <xs:element name="tree_data"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="node" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="enableNext" type="xs:boolean" use="required" /> <!-- attribute for tree_data --> >+ <xs:attribute name="enablePrevious" type="xs:boolean" use="required" /> <!-- attribute for tree_data --> >+ >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="node" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="node" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ >+ <xs:attribute name="title" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="id" type="xs:ID" use="required" /> <!-- attribute for node --> >+ <xs:attribute name="href" type="xs:string"/> <!-- optional attribute for node --> >+ </xs:complexType> >+ </xs:element> >+ >+</xs:schema> >\ No newline at end of file >Index: service/schema/xml/search.xsd >=================================================================== >RCS file: service/schema/xml/search.xsd >diff -N service/schema/xml/search.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/search.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ <xs:element name="searchHits"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="hit" minOccurs="0" maxOccurs="unbounded" /> <!-- hits result could be zero --> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="hit" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element name="category" minOccurs="1" maxOccurs="1"> >+ <xs:complexType> >+ <xs:simpleContent> >+ <xs:extension base="xs:string"> >+ <xs:attribute name="href" type="xs:string" use="required" /> >+ </xs:extension> >+ </xs:simpleContent> >+ </xs:complexType> >+ </xs:element> >+ <xs:element name="summary" type="xs:string" minOccurs="1" maxOccurs="1" /> >+ </xs:sequence> >+ <xs:attribute name="href" type="xs:string" use="required" /> <!-- attribute for hit --> >+ <xs:attribute name="label" type="xs:string" use="required" /> <!-- attribute for hit --> >+ <xs:attribute name="isPotentialHit" type="xs:boolean" /> <!-- optional attribute for hit --> >+ <xs:attribute name="score" type="xs:double" use="required" /> <!-- attribute for hit --> >+ </xs:complexType> >+ </xs:element> >+ >+</xs:schema> >Index: service/schema/xml/simplesearch.xsd >=================================================================== >RCS file: service/schema/xml/simplesearch.xsd >diff -N service/schema/xml/simplesearch.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/simplesearch.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ <xs:element name="searchHits"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="hit" minOccurs="0" maxOccurs="unbounded" /> <!-- hits result could be zero --> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="hit" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element name="summary" type="xs:string" minOccurs="1" maxOccurs="1" /> >+ </xs:sequence> >+ <xs:attribute name="href" type="xs:string" use="required" /> <!-- attribute for hit --> >+ <xs:attribute name="label" type="xs:string" use="required" /> <!-- attribute for hit --> >+ <xs:attribute name="isPotentialHit" type="xs:boolean" /> <!-- optional attribute for hit --> >+ <xs:attribute name="score" type="xs:double" use="required" /> <!-- attribute for hit --> >+ </xs:complexType> >+ </xs:element> >+ >+</xs:schema> >Index: service/schema/xml/toc.xsd >=================================================================== >RCS file: service/schema/xml/toc.xsd >diff -N service/schema/xml/toc.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/toc.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,101 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ >+ <xs:element name="tocContributions"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="tocContribution" minOccurs="0" >+ maxOccurs="unbounded" /> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ >+ <xs:element name="tocContribution " abstract="false" >+ nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="toc" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="extraDocument" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="categoryId" type="xs:string" /> <!-- attribute for tree_data --> >+ <xs:attribute name="contributorId" type="xs:string" /> <!-- attribute for tree_data --> >+ <xs:attribute name="id" type="xs:string" use="required" /> <!-- attribute for tree_data --> >+ <xs:attribute name="locale" type="xs:string" use="required" /> <!-- attribute for tree_data --> >+ <xs:attribute name="isPrimary" type="xs:boolean" use="required" /> <!-- attribute for tree_data --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="toc" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="anchor" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="topic" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="enablement" minOccurs="0" maxOccurs="1" /> >+ </xs:sequence> >+ >+ <xs:attribute name="label" type="xs:string" use="required" /> <!-- optional attribute for node --> >+ <xs:attribute name="link_to" type="xs:string" /> <!-- attribute for node --> >+ <xs:attribute name="topic" type="xs:string" /> <!-- optional attribute for node --> >+ </xs:complexType> >+ >+ >+ </xs:element> >+ >+ <xs:element name="extraDocument" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="href" type="xs:string" use="required" /> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="topic" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="topic" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="link" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="enablement" minOccurs="0" maxOccurs="1" /> >+ </xs:sequence> >+ >+ <xs:attribute name="label" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="href" type="xs:string" /> <!-- optional attribute for node --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="anchor" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="id" type="xs:string" use="required" /> <!-- optional attribute for node --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="link" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="toc" type="xs:string" use="required" /> <!-- optional attribute for node --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="enablement" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="with" minOccurs="0" maxOccurs="unbounded" /> >+ <xs:element ref="test" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="test" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:attribute name="args" type="xs:string" use="required" /> <!-- optional attribute for node --> >+ <xs:attribute name="property" type="xs:string" use="required" /> <!-- attribute for node --> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="with" abstract="false" nillable="false"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element ref="test" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="variable" type="xs:string" /> <!-- optional attribute for node --> >+ </xs:complexType> >+ </xs:element> >+</xs:schema> >\ No newline at end of file >Index: service/schema/xml/tocfragment.xsd >=================================================================== >RCS file: service/schema/xml/tocfragment.xsd >diff -N service/schema/xml/tocfragment.xsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ service/schema/xml/tocfragment.xsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >+ elementFormDefault="qualified"> >+ <xs:element name="tree_data"> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element name="error" minOccurs="0" /> >+ <xs:element ref="numeric_path" minOccurs="0" maxOccurs="1" /> >+ <xs:element name="node" minOccurs="0" maxOccurs="unbounded"> >+ <!-- >+ toc node, only difference b/w toc and topic level node is of >+ is_leaf attrb and order of attrb >+ --> >+ <xs:complexType mixed="false"> >+ <xs:sequence> >+ <xs:element name="node" type="TopicNode" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ <xs:attribute name="title" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="id" type="xs:string" use="required" /> <!-- attribute for node --> >+ <xs:attribute name="href" type="xs:string" use="required" /> <!-- attribute for node --> >+ <xs:attribute name="openImage" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="closedImage" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="imageAlt" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="image" type="xs:string" default="toc_closed" /> <!-- optional attribute for node --> >+ <xs:attribute name="is_selected" type="xs:boolean" >+ default="true" /> <!-- attribute for node --> >+ <xs:attribute name="is_highlighted" type="xs:boolean" >+ default="true" /> <!-- attribute for node --> >+ >+ </xs:complexType> >+ </xs:element> >+ </xs:sequence> >+ </xs:complexType> >+ </xs:element> >+ >+ <xs:element name="numeric_path"> >+ <xs:complexType> >+ <xs:attribute name="path" type="xs:string" /> >+ </xs:complexType> >+ </xs:element> >+ >+ >+ <xs:complexType name="TopicNode" mixed="false"> >+ <xs:sequence> >+ <xs:element name="node" type="TopicNode" minOccurs="0" maxOccurs="unbounded" /> >+ </xs:sequence> >+ >+ <xs:attribute name="title" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="id" type="xs:string" use="required" /> <!-- attribute for node --> >+ <xs:attribute name="href" type="xs:string" use="required" /> <!-- attribute for node --> >+ <xs:attribute name="is_leaf" type="xs:boolean" default="true" /> <!-- attribute for node --> >+ <xs:attribute name="is_selected" type="xs:boolean" >+ default="true" /> <!-- attribute for node --> >+ <xs:attribute name="is_highlighted" type="xs:boolean" >+ default="true" /> <!-- attribute for node --> >+ <xs:attribute name="openImage" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="closedImage" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="imageAlt" type="xs:string" /> <!-- optional attribute for node --> >+ <xs:attribute name="image" type="xs:string" default="toc_closed" /> <!-- optional attribute for node --> >+ >+ </xs:complexType> >+ >+ >+</xs:schema> >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 319907
:
186915
|
187144
|
187289
|
188265
|
188681
|
190202
|
195192