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 ju...@apache.org on 2002/06/26 07:00:01 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method PropFindMethod.java PropPatchMethod.java ReportMethod.java UpdateMethod.java
juergen 2002/06/25 22:00:01
Modified: src/share/org/apache/slide/common
RequestedPropertiesImpl.java
src/share/org/apache/slide/search/basic BasicQuery.java
src/webdav/server/org/apache/slide/webdav/method
PropFindMethod.java PropPatchMethod.java
ReportMethod.java UpdateMethod.java
Added: src/share/org/apache/slide/common
PropertyParseException.java
Log:
Constructor and method add() of RequestedPropertiesImpl now throws a PropertyParseException.
(ralf)
Revision Changes Path
1.10 +16 -10 jakarta-slide/src/share/org/apache/slide/common/RequestedPropertiesImpl.java
Index: RequestedPropertiesImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/RequestedPropertiesImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RequestedPropertiesImpl.java 19 Jun 2002 11:00:15 -0000 1.9
+++ RequestedPropertiesImpl.java 26 Jun 2002 05:00:00 -0000 1.10
@@ -81,8 +81,8 @@
*/
public class RequestedPropertiesImpl implements RequestedProperties {
- private boolean isAllProp = false;
- private List propertyList = new ArrayList ();
+ protected boolean isAllProp = false;
+ protected List propertyList = new ArrayList ();
/**
* Default constructor
@@ -95,8 +95,10 @@
*
* @param propElement <code><DAV:prop></code> or
* <code><DAV:allprop></code>.
+ *
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- public RequestedPropertiesImpl (Element propElement) {
+ public RequestedPropertiesImpl (Element propElement) throws PropertyParseException {
add(propElement);
}
@@ -107,8 +109,10 @@
*
* @param propElement <code><DAV:prop></code> or
* <code><DAV:allprop></code>.
+ *
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- public void add(Element propElement) {
+ public void add(Element propElement) throws PropertyParseException {
String uri = propElement.getNamespace().getURI();
String name = propElement.getName ();
@@ -148,8 +152,10 @@
* @param children the children of the propery element.
*
* @return the created RequestedProperty.
+ *
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected RequestedProperty createRequestedProperty(String name, String namespacePrefix, String namespaceUri, String text, List children) {
+ protected RequestedProperty createRequestedProperty(String name, String namespacePrefix, String namespaceUri, String text, List children) throws PropertyParseException {
return new RequestedPropertyImpl(name, namespaceUri);
}
@@ -291,7 +297,7 @@
*
* @param prop a SelectedProperty
*/
- private void addProperty (RequestedProperty prop) {
+ protected void addProperty (RequestedProperty prop) {
if (isAllProp == true)
throw new IllegalStateException ();
1.1 jakarta-slide/src/share/org/apache/slide/common/PropertyParseException.java
Index: PropertyParseException.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/PropertyParseException.java,v 1.1 2002/06/26 05:00:00 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/06/26 05:00:00 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Slide", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.common;
// import list
/**
* This exception is thrown if parsing a Property fails for any reason.
*
* @version $Revision: 1.1 $
*
* @author <a href="mailto:ralf.stuckert@softwareag.com">Ralf Stuckert</a>
**/
public class PropertyParseException extends SlideException {
/**
* The exception that was the cause of this exception
* (may be <code>null</code>)
*/
protected Exception cause = null;
/**
* Creates a PropertyParseException.
*
* @param message the message of this exception.
*/
public PropertyParseException(String message) {
this(message, null);
}
/**
* Creates a PropertyParseException.
*
* @param message the message of this exception.
* @param cause the exception that was the cause of this exception.
*/
public PropertyParseException(String message, Exception cause) {
super(message);
this.cause = cause;
}
/**
* Returns the exception that was the cause of this exception
* (may be <code>null</code>).
*
* @return the exception that was the cause of this exception.
*/
public Exception getCause() {
return cause;
}
}
1.13 +12 -5 jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java
Index: BasicQuery.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- BasicQuery.java 21 Jun 2002 13:26:16 -0000 1.12
+++ BasicQuery.java 26 Jun 2002 05:00:00 -0000 1.13
@@ -77,6 +77,7 @@
import org.apache.slide.search.InvalidScopeException;
import org.apache.slide.common.RequestedProperties;
import org.apache.slide.common.RequestedPropertiesImpl;
+import org.apache.slide.common.PropertyParseException;
import org.apache.slide.common.Uri;
import org.apache.slide.store.AbstractStore;
import org.jdom.input.DOMBuilder;
@@ -121,11 +122,12 @@
/**
* Message of a BadQueryException that is thrown if the query element
- * neither contains a <from> nor a <from> element.
+ * neither contains a <prop> nor a <allprop> element.
*/
public static final String PROP_OR_ALLPROP_ELEMENT_MISSING = "Required element <prop> or <allprop> not supplied";
+
/** the element describing this query */
protected Element queryElement;
@@ -309,7 +311,12 @@
throw new BadQueryException(PROP_OR_ALLPROP_ELEMENT_MISSING);
}
+ try {
requestedProperties = new RequestedPropertiesImpl (propElement);
+ }
+ catch (PropertyParseException e) {
+ throw new BadQueryException(e.getMessage(), e);
+ }
scope = new BasicQueryScope (fromElement);
1.75 +10 -3 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- PropFindMethod.java 14 Jun 2002 12:24:05 -0000 1.74
+++ PropFindMethod.java 26 Jun 2002 05:00:00 -0000 1.75
@@ -277,6 +277,13 @@
} catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
+ catch (PropertyParseException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
1.54 +15 -4 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- PropPatchMethod.java 14 Jun 2002 12:24:05 -0000 1.53
+++ PropPatchMethod.java 26 Jun 2002 05:00:00 -0000 1.54
@@ -209,6 +209,15 @@
}
+ catch (PropertyParseException e) {
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ }
+ catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
catch (JDOMException e) {
try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
@@ -644,8 +653,10 @@
*
* @param propElement the <DAV:prop> from which to create the
* List of PropPatchProperty.
+ *
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- public PropPatchProperties (Element propElement) {
+ public PropPatchProperties (Element propElement) throws PropertyParseException {
super(propElement);
}
1.37 +34 -12 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java
Index: ReportMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ReportMethod.java 21 Jun 2002 08:09:11 -0000 1.36
+++ ReportMethod.java 26 Jun 2002 05:00:00 -0000 1.37
@@ -91,6 +91,7 @@
import org.apache.slide.common.RequestedPropertiesImpl;
import org.apache.slide.common.RequestedProperty;
import org.apache.slide.common.RequestedPropertyImpl;
+import org.apache.slide.common.PropertyParseException;
import org.apache.slide.webdav.WebdavException;
import org.apache.slide.webdav.WebdavServletConfig;
@@ -342,6 +343,13 @@
} catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
+ catch (PropertyParseException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
@@ -370,8 +378,9 @@
* Element.
*
* @throws WebdavException if parsing fails for any reason.
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected void parseVersionTreeRequest(Element versionTreeElement) throws WebdavException {
+ protected void parseVersionTreeRequest(Element versionTreeElement) throws WebdavException, PropertyParseException {
List childrenList = versionTreeElement.getChildren();
if (childrenList.size() == 0) {
@@ -395,8 +404,9 @@
* Element.
*
* @throws WebdavException if parsing fails for any reason.
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected void parseACLRequest(Element aclElement) throws WebdavException {
+ protected void parseACLRequest(Element aclElement) throws WebdavException, PropertyParseException {
List childrenList = aclElement.getChildren();
if (childrenList.size() == 0) {
@@ -420,8 +430,9 @@
* Element.
*
* @throws WebdavException if parsing fails for any reason.
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected void parsePrincipalMatchRequest(Element aclElement) throws WebdavException {
+ protected void parsePrincipalMatchRequest(Element aclElement) throws WebdavException, PropertyParseException {
List childrenList = aclElement.getChildren();
Iterator childListIter = null;
@@ -463,8 +474,9 @@
* Element.
*
* @throws WebdavException if parsing fails for any reason.
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected void parsePrincipalSearchRequest(Element aclElement) throws WebdavException {
+ protected void parsePrincipalSearchRequest(Element aclElement) throws WebdavException, PropertyParseException {
List childrenList = aclElement.getChildren();
Iterator childListIter = null;
@@ -501,7 +513,7 @@
*
* @throws WebdavException if parsing fails for any reason.
*/
- protected void parseExpandPropertyRequest(Element expandPropertyElement) throws WebdavException {
+ protected void parseExpandPropertyRequest(Element expandPropertyElement) throws WebdavException, PropertyParseException {
this.expandPropertyElement = expandPropertyElement;
}
@@ -512,8 +524,9 @@
* Element.
*
* @throws WebdavException if parsing fails for any reason.
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- protected void parseLocateByHistoryRequest(Element locateByHistoryElement) throws WebdavException {
+ protected void parseLocateByHistoryRequest(Element locateByHistoryElement) throws WebdavException, PropertyParseException {
List childrenList = locateByHistoryElement.getChildren();
if (childrenList.size() != 2) {
@@ -880,7 +893,13 @@
aclproperty.setAttribute(PARAM_NAME,P_ACL);
Element prop = new Element(E_PROP, NamespaceCache.DEFAULT_NAMESPACE);
prop.addContent(aclproperty);
- RequestedPropertiesImpl reqProperties = new RequestedPropertiesImpl(prop);
+ RequestedPropertiesImpl reqProperties = null;
+ try {
+ reqProperties = new RequestedPropertiesImpl(prop);
+ }
+ catch (PropertyParseException e) {
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
// get NodeRevisionDescriptor
try {
@@ -1591,8 +1610,10 @@
*
* @return A <code>RequestedProperties</code> created from the given
* list of <code><property></code> elements.
+ *
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- private RequestedProperties createRequestedProperties(List propertyElements) {
+ private RequestedProperties createRequestedProperties(List propertyElements) throws PropertyParseException{
Element propertyListElement = new Element(PROPERTY_LIST);
Iterator iterator = propertyElements.iterator();
@@ -1806,6 +1827,7 @@
}
return saxBuilder;
}
+
}
1.10 +13 -4 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java
Index: UpdateMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- UpdateMethod.java 14 Jun 2002 12:24:06 -0000 1.9
+++ UpdateMethod.java 26 Jun 2002 05:00:01 -0000 1.10
@@ -80,6 +80,7 @@
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.RequestedProperties;
import org.apache.slide.common.RequestedPropertiesImpl;
+import org.apache.slide.common.PropertyParseException;
import org.apache.slide.common.SlideException;
import org.apache.slide.structure.SubjectNode;
import org.apache.slide.structure.ObjectNode;
@@ -194,6 +195,13 @@
} catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
+ catch (PropertyParseException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
catch( IOException x ){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
@@ -205,8 +213,9 @@
*
* @throws JDOMException if parsing the request failed for any reason.
* @throws IOException
+ * @throws PropertyParseException if parsing the property fails for any reason.
*/
- private void parseUpdateRequestContent() throws IOException, JDOMException {
+ private void parseUpdateRequestContent() throws IOException, JDOMException, PropertyParseException {
Element ue = parseRequestContent().getRootElement();
Element ve = null;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>