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/09/16 14:26:23 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util VersioningHelper.java
wam 2002/09/16 05:26:23
Modified: src/share/org/apache/slide/search/basic
BasicQueryEnvelope.java
src/webdav/server/org/apache/slide/webdav/method
MoveMethod.java SearchMethod.java
src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
bugfix in SEARCH, context versionning: uri was corrupted
Revision Changes Path
1.3 +6 -5 jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryEnvelope.java
Index: BasicQueryEnvelope.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryEnvelope.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BasicQueryEnvelope.java 22 Aug 2002 11:53:32 -0000 1.2
+++ BasicQueryEnvelope.java 16 Sep 2002 12:26:22 -0000 1.3
@@ -283,7 +283,8 @@
AbstractStore store = (AbstractStore)uri.getStore();
- String className = (String)store.getParameter ("basicQueryClass"); // muss defined werden
+ String className = (String)store.getParameter
+ (BasicSearchLanguage.BASIC_QUERY_CLASS);
if (className != null) {
try {
1.52 +4 -4 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java
Index: MoveMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- MoveMethod.java 23 Aug 2002 12:13:34 -0000 1.51
+++ MoveMethod.java 16 Sep 2002 12:26:23 -0000 1.52
@@ -443,7 +443,7 @@
basicSearch,
new SlideTokenWrapper(slideToken, false),
Integer.MAX_VALUE,
- req.getContextPath());
+ req.getRequestURI());
SearchQueryResult queryResult = searchHelper.search(new SlideTokenWrapper(slideToken, false), searchQuery);
1.28 +64 -18 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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- SearchMethod.java 4 Jul 2002 15:22:27 -0000 1.27
+++ SearchMethod.java 16 Sep 2002 12:26:23 -0000 1.28
@@ -71,22 +71,25 @@
import org.apache.slide.common.SlideException;
import org.apache.slide.util.Configuration;
import org.apache.slide.common.Uri;
+import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.webdav.util.WebdavUtils;
import org.apache.slide.search.SearchQuery;
+import org.apache.slide.security.AccessDeniedException;
import org.apache.slide.search.RequestedResource;
import org.apache.slide.search.SearchQueryResult;
import org.apache.slide.search.Search;
import org.apache.slide.search.SearchLanguage;
import org.apache.slide.search.BadQueryException;
import org.apache.slide.search.InvalidQueryException;
+import org.apache.slide.search.InvalidScopeException;
import org.apache.slide.search.BadGatewayException;
import org.apache.slide.search.PropertyProvider;
import org.apache.slide.search.QueryScope;
-import org.apache.slide.search.basic.BasicQueryImpl;
+import org.apache.slide.search.basic.IBasicQuery;
//import org.apache.slide.lock.LockException;
//import org.apache.slide.lock.LockTokenNotFoundException;
@@ -134,13 +137,15 @@
private RequestedProperties requestedProperties = null;
private PropertyRetriever retriever;
+ /** if true, an ALL_PROP request will include computed props */
+ protected boolean allpropIncludesDeltav = false;
// ----------------------------------------------------------- Constructors
/**
* Constructor.
- *
+ *
* @param token the token for accessing the namespace
* @param config configuration of the WebDAV servlet
*/
@@ -158,12 +163,15 @@
searchHelper = token.getSearchHelper();
retriever = new PropertyRetrieverImpl(token, slideToken);
+ String slidePath = null;
+
+ allpropIncludesDeltav = getBooleanInitParameter( "allpropIncludesDeltav" );
+
if (Configuration.useSearch ()) {
try {
Element queryElement = getQueryElement();
String grammarNamespace = queryElement.getNamespaceURI();
-
// SearchLanguage language = searchHelper.getLanguage (grammarNamespace);
int maxDepth = getConfig().getDepthLimit();
@@ -171,21 +179,21 @@
searchQuery = searchHelper.createSearchQuery
(grammarNamespace, queryElement, slideToken, maxDepth,
- new ComputedPropertyProvider(token, slideToken, req.getContextPath(), serverURL),
- req.getRequestURI());
+ new ComputedPropertyProvider(token, slideToken, req.getContextPath (), serverURL),
+ req.getRequestURI ());
requestedProperties = searchQuery.requestedProperties ();
- if (searchQuery instanceof BasicQueryImpl) {
- QueryScope scope = ((BasicQueryImpl)searchQuery).getScope();
-
+ if (searchQuery instanceof IBasicQuery)
+ {
+ QueryScope scope = ((IBasicQuery)searchQuery).getScope();
+ slidePath = ((IBasicQuery)searchQuery).getSlidePath();
+
+ // check, if scope is accessible (ACL)
+ token.getContentHelper().retrieve(slideToken, slidePath);
- String slidePath = ((BasicQueryImpl)searchQuery).getSlidePath();
-
-
scope.setIsCollection (
WebdavUtils.isCollection (token, slideToken, slidePath));
-
}
}
catch (JDOMException e) {
@@ -209,6 +217,14 @@
e.getMessage());
throw new WebdavException(WebdavStatus.SC_BAD_GATEWAY);
}
+ catch (InvalidScopeException e) {
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ resp.setContentType (TEXT_XML);
+ createErrorResult (SearchQueryResult.STATUS_INVALID_SCOPE,
+ e.getMessage());
+
+ throw new WebdavException (WebdavStatus.SC_BAD_REQUEST);
+ }
catch (BadQueryException e) {
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
resp.setContentType (TEXT_XML);
@@ -216,6 +232,31 @@
e.getMessage());
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
+ catch (AccessDeniedException e) {
+
+ String contextPath = req.getContextPath() ;
+ AccessDeniedException ade = new AccessDeniedException
+ (contextPath + e.getObjectUri(),
+ contextPath + e.getSubjectUri(),
+ contextPath + e.getActionUri());
+
+ String msg = ade.getMessage();
+ resp.setStatus(WebdavStatus.SC_FORBIDDEN);
+ resp.setContentType (TEXT_XML);
+ createErrorResult (SearchQueryResult.STATUS_FORBIDDEN, msg);
+ throw new WebdavException(WebdavStatus.SC_FORBIDDEN);
+ }
+ catch (ObjectNotFoundException e) {
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ resp.setContentType (TEXT_XML);
+ createErrorResult (SearchQueryResult.STATUS_INVALID_SCOPE,
+ "scope " + slidePath + " is invalid");
+
+ throw new WebdavException (WebdavStatus.SC_BAD_REQUEST);
+ }
+ catch (SlideException e) {
+ e.printStackTrace();
+ }
}
else {
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
@@ -257,7 +298,7 @@
}
throw new WebdavException(WebdavStatus.SC_NOT_FOUND);
} catch (Exception e) {
-
+ // e.printStackTrace();
resp.setStatus(getErrorCode(e)); // no special handling needed
throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
}
@@ -416,7 +457,7 @@
RequestedResource resource = (RequestedResource)it.next();
String internalUri = resource.getUri();
-
+
//String absUri = resource.getExternalHref();
String absUri = PropertyHelper.getAbsoluteURL
(serverURL, req.getContextPath(), internalUri);
@@ -428,7 +469,7 @@
resource,
req.getContextPath(),
serverURL,
- true);
+ allpropIncludesDeltav);
Iterator iterator = propstatList.iterator();
while (iterator.hasNext()) {
responseElement.addContent((org.jdom.Element)iterator.next());
@@ -465,6 +506,11 @@
case SearchQueryResult.STATUS_BAD_GATEWAY:
errorStatus = WebdavStatus.SC_BAD_GATEWAY;
+ href = queryResult.getHref();
+ break;
+
+ case SearchQueryResult.STATUS_FORBIDDEN:
+ errorStatus = WebdavStatus.SC_FORBIDDEN;
href = queryResult.getHref();
break;
1.76 +11 -7 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
Index: VersioningHelper.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- VersioningHelper.java 23 Aug 2002 12:35:22 -0000 1.75
+++ VersioningHelper.java 16 Sep 2002 12:26:23 -0000 1.76
@@ -106,6 +106,7 @@
import org.apache.slide.search.SearchQuery;
import org.apache.slide.search.SearchQueryResult;
import org.apache.slide.search.BadQueryException;
+import org.apache.slide.search.SlideUri;
import org.apache.slide.search.basic.Literals;
@@ -509,11 +510,14 @@
protected SearchQueryResult searchResourcesWithGivenHistory(String historyPath, String scope, int maxDepth) throws ServiceAccessException, BadQueryException {
// make it a relative scope
- if (scope.startsWith("/")) {
- scope = scope.substring (1);
- }
+// if (scope.startsWith("/")) {
+// scope = scope.substring (1);
+// }
+
+ SlideUri slideUri = new SlideUri (req.getRequestURI());
+ String absPath = slideUri.getContextPath (scope);
- Element basicSearch = getResourcesWithVersionHistoryQueryElement(scope,
+ Element basicSearch = getResourcesWithVersionHistoryQueryElement(absPath,
historyPath);
String grammarNamespace = basicSearch.getNamespaceURI();
Search searchHelper = nsaToken.getSearchHelper();
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>