You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by wa...@apache.org on 2002/03/08 11:14:04 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method SearchMethod.java
wam 02/03/08 02:14:04
Modified: src/webdav/server/org/apache/slide/webdav/method
SearchMethod.java
Log:
adjust tab settings
Revision Changes Path
1.6 +150 -150 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java
Index: SearchMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SearchMethod.java 22 Feb 2002 17:21:33 -0000 1.5
+++ SearchMethod.java 8 Mar 2002 10:14:04 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v 1.5 2002/02/22 17:21:33 pnever Exp $
- * $Revision: 1.5 $
- * $Date: 2002/02/22 17:21:33 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v 1.6 2002/03/08 10:14:04 wam Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/03/08 10:14:04 $
*
* ====================================================================
*
@@ -122,164 +122,164 @@
private SearchQuery searchQuery = null;
private Search searchHelper = null;
-
- private RequestedProperties requestedProperties = null;
-
- // ----------------------------------------------------------- Constructors
+
+ private RequestedProperties requestedProperties = null;
+
+ // ----------------------------------------------------------- Constructors
public SearchMethod (NamespaceAccessToken token, HttpServletRequest req,
- HttpServletResponse resp, WebdavServletConfig config) {
- super(token, req, resp, config);
- searchHelper = token.getSearchHelper();
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
+ searchHelper = token.getSearchHelper();
}
/**
- * Method parseRequest
- *
- * @throws WebdavException
- * @throws IOException
- */
+ * Method parseRequest
+ *
+ * @throws WebdavException
+ * @throws IOException
+ */
protected void parseRequest() throws WebdavException {
-
- Element queryElement = getQueryElement();
- String grammarNamespace = queryElement.getNamespaceURI();
-
- try {
- // SearchLanguage language = searchHelper.getLanguage (grammarNamespace);
- int maxDepth = getConfig().getDepthLimit();
-
- searchQuery = searchHelper.getSearchQuery
- (grammarNamespace, queryElement, slideToken, maxDepth);
-
- requestedProperties = searchQuery.requestedProperties ();
- }
- catch (InvalidQueryException e) {
- resp.setStatus(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
- throw new WebdavException(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
- }
- catch (BadQueryException e) {
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
-
+
+ Element queryElement = getQueryElement();
+ String grammarNamespace = queryElement.getNamespaceURI();
+
+ try {
+ // SearchLanguage language = searchHelper.getLanguage (grammarNamespace);
+ int maxDepth = getConfig().getDepthLimit();
+
+ searchQuery = searchHelper.getSearchQuery
+ (grammarNamespace, queryElement, slideToken, maxDepth);
+
+ requestedProperties = searchQuery.requestedProperties ();
+ }
+ catch (InvalidQueryException e) {
+ resp.setStatus(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
+ throw new WebdavException(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
+ }
+ catch (BadQueryException e) {
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+
}
/**
- * Method executeRequest
- *
- * @throws WebdavException
- *
- * @version 12/28/2001
- */
+ * Method executeRequest
+ *
+ * @throws WebdavException
+ *
+ * @version 12/28/2001
+ */
protected void executeRequest() throws WebdavException {
-
- SearchQueryResult result = null;
- try {
- result = searchHelper.search (slideToken, searchQuery);
- sendResult (result);
- }
-
- catch (StructureException e) {
- try {
- resp.sendError
- (WebdavStatus.SC_NOT_FOUND,
- WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND));
- } catch(IOException ex) {
- ex.printStackTrace();
- }
- throw new WebdavException(WebdavStatus.SC_NOT_FOUND);
- } catch (Exception e) {
- resp.setStatus(getErrorCode(e)); // no special handling needed
- throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
- }
- resp.setStatus (WebdavStatus.SC_OK);
- }
-
- /**
- * Method getSearchRequestElement
- *
- * @return an Element
- *
- * @throws WebdavException
- *
- * @version 12/28/2001
- */
- private Element getQueryElement() throws WebdavException {
- Element queryElement = null;
- try
- {
- Document document = parseRequestContent();
- Element rootElement = document.getDocumentElement();
- NodeList nl = rootElement.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- if (nl.item (i) instanceof Element)
- queryElement = (Element)nl.item(i);
- }
- return queryElement;
-
- } catch (SAXException e) {
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- } catch (ParserConfigurationException e) {
- System.err.println(e.getMessage());
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException
- (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- } catch (IOException e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException
- (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- }
-
- private void sendResult (SearchQueryResult result) throws
- SlideException, org.jdom.JDOMException, IOException
- {
-
- resp.setContentType (ReportMethod.TEXT_XML + "; charset=" +
- ReportMethod.ENCODING);
-
-
- org.jdom.Namespace namespace = org.jdom.Namespace.getNamespace ("D", "DAV:");
- org.jdom.Element element =
- new org.jdom.Element (WebdavConstants.E_MULTISTATUS, namespace);
-
- org.jdom.Document responseDoc = new org.jdom.Document (element);
-
- resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
-
- PropertyRetriever retriever = new PropertyRetrieverImpl
- (token, slideToken);
-
- Iterator it = result.iterator();
- while (it.hasNext()) {
-
- org.jdom.Element responseElement =
- new org.jdom.Element (WebdavConstants.E_RESPONSE, namespace);
-
- element.addContent (responseElement);
- org.jdom.Element hrefElement =
- new org.jdom.Element (WebdavConstants.E_HREF, namespace);
-
- RequestedResource resource = (RequestedResource)it.next();
- String uri = resource.getHref();
- hrefElement.addContent(uri);
- responseElement.addContent (hrefElement);
- responseElement.addContent (
- retriever.getPropertiesOfObject (requestedProperties,
- uri,
- req.getContextPath(),
- true)
- );
- }
-
- XMLOutputter xmlWriter = new XMLOutputter (" ", true);
- xmlWriter.output (responseDoc, resp.getWriter());
- }
-
+
+ SearchQueryResult result = null;
+ try {
+ result = searchHelper.search (slideToken, searchQuery);
+ sendResult (result);
+ }
+
+ catch (StructureException e) {
+ try {
+ resp.sendError
+ (WebdavStatus.SC_NOT_FOUND,
+ WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND));
+ } catch(IOException ex) {
+ ex.printStackTrace();
+ }
+ throw new WebdavException(WebdavStatus.SC_NOT_FOUND);
+ } catch (Exception e) {
+ resp.setStatus(getErrorCode(e)); // no special handling needed
+ throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
+ }
+ resp.setStatus (WebdavStatus.SC_OK);
+ }
+
+ /**
+ * Method getSearchRequestElement
+ *
+ * @return an Element
+ *
+ * @throws WebdavException
+ *
+ * @version 12/28/2001
+ */
+ private Element getQueryElement() throws WebdavException {
+ Element queryElement = null;
+ try
+ {
+ Document document = parseRequestContent();
+ Element rootElement = document.getDocumentElement();
+ NodeList nl = rootElement.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++) {
+ if (nl.item (i) instanceof Element)
+ queryElement = (Element)nl.item(i);
+ }
+ return queryElement;
+
+ } catch (SAXException e) {
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ } catch (ParserConfigurationException e) {
+ System.err.println(e.getMessage());
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ throw new WebdavException
+ (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ } catch (IOException e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ throw new WebdavException
+ (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ private void sendResult (SearchQueryResult result) throws
+ SlideException, org.jdom.JDOMException, IOException
+ {
+
+ resp.setContentType (ReportMethod.TEXT_XML + "; charset=" +
+ ReportMethod.ENCODING);
+
+
+ org.jdom.Namespace namespace = org.jdom.Namespace.getNamespace ("D", "DAV:");
+ org.jdom.Element element =
+ new org.jdom.Element (WebdavConstants.E_MULTISTATUS, namespace);
+
+ org.jdom.Document responseDoc = new org.jdom.Document (element);
+
+ resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
+
+ PropertyRetriever retriever = new PropertyRetrieverImpl
+ (token, slideToken);
+
+ Iterator it = result.iterator();
+ while (it.hasNext()) {
+
+ org.jdom.Element responseElement =
+ new org.jdom.Element (WebdavConstants.E_RESPONSE, namespace);
+
+ element.addContent (responseElement);
+ org.jdom.Element hrefElement =
+ new org.jdom.Element (WebdavConstants.E_HREF, namespace);
+
+ RequestedResource resource = (RequestedResource)it.next();
+ String uri = resource.getHref();
+ hrefElement.addContent(uri);
+ responseElement.addContent (hrefElement);
+ responseElement.addContent (
+ retriever.getPropertiesOfObject (requestedProperties,
+ uri,
+ req.getContextPath(),
+ true)
+ );
+ }
+
+ XMLOutputter xmlWriter = new XMLOutputter (" ", true);
+ xmlWriter.output (responseDoc, resp.getWriter());
+ }
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>