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/05/14 16:15:51 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method ReportMethod.java
juergen 02/05/14 07:15:51
Modified: src/webdav/server/org/apache/slide/webdav/method
ReportMethod.java
Log:
added principal-search-report and principal-search-property-set report
Revision Changes Path
1.25 +392 -90 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.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ReportMethod.java 30 Apr 2002 12:39:19 -0000 1.24
+++ ReportMethod.java 14 May 2002 14:15:51 -0000 1.25
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v 1.24 2002/04/30 12:39:19 pnever Exp $
- * $Revision: 1.24 $
- * $Date: 2002/04/30 12:39:19 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v 1.25 2002/05/14 14:15:51 juergen Exp $
+ * $Revision: 1.25 $
+ * $Date: 2002/05/14 14:15:51 $
*
* ====================================================================
*
@@ -77,6 +77,7 @@
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
import java.util.HashSet;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -104,6 +105,7 @@
import org.apache.slide.webdav.util.DeltavConstants;
import org.apache.slide.webdav.util.AclConstants;
import org.apache.slide.webdav.util.PropertyHelper;
+import org.apache.slide.webdav.util.PropertySearchSetProperty;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.LinkedObjectNotFoundException;
@@ -119,6 +121,7 @@
import org.apache.slide.content.RevisionContentNotFoundException;
import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.content.RevisionNotFoundException;
+import org.apache.slide.macro.ForbiddenException;
import org.apache.slide.security.AccessDeniedException;
@@ -152,6 +155,7 @@
import org.apache.slide.authenticate.CredentialsToken;
import org.jdom.Element;
+import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Namespace;
import org.jdom.JDOMException;
@@ -164,7 +168,7 @@
/**
* An implementation of the DeltaV <code>REPORT</code> method.
*
- * @version $Revision: 1.24 $
+ * @version $Revision: 1.25 $
*
* @author <a href="mailto:ralf.stuckert@softwareag.com">Ralf Stuckert</a>
*/
@@ -210,7 +214,10 @@
*/
protected static final int INFINITY = Integer.MAX_VALUE;
-
+ /**
+ * 'seach requirements' of a principal-property-search request
+ */
+ protected Set propertySearchSet = null;
/**
* The path of the target resource.
@@ -327,6 +334,13 @@
requestedReport = R_PRINCIPAL_MATCH;
parsePrincipalMatchRequest(element);
}
+ else if (element.getName().equalsIgnoreCase(R_PRINCIPAL_PROPERTY_SEARCH)){
+ requestedReport = R_PRINCIPAL_PROPERTY_SEARCH;
+ parsePrincipalSearchRequest(element);
+ }
+ else if (element.getName().equalsIgnoreCase(R_PRINCIPAL_SEARCH_PROPERTY_SET)){
+ requestedReport = R_PRINCIPAL_SEARCH_PROPERTY_SET;
+ }
else if (element.getName().equalsIgnoreCase(R_LOCATE_BY_HISTORY)){
requestedReport = R_LOCATE_BY_HISTORY;
parseLocateByHistoryRequest(element);
@@ -416,7 +430,7 @@
}
/**
- * Parses the <code><acl-principal></code> request.
+ * Parses the <code><principalMatch></code> request.
*
* @param aclElement the <code><acl></code>
* Element.
@@ -459,6 +473,43 @@
}
/**
+ * Parses the <code><principalSearch></code> request.
+ *
+ * @param aclElement the <code><acl></code>
+ * Element.
+ *
+ * @throws WebdavException if parsing fails for any reason.
+ */
+ protected void parsePrincipalSearchRequest(Element aclElement) throws WebdavException {
+
+ List childrenList = aclElement.getChildren();
+ Iterator childListIter = null;
+ if (childrenList.size() == 0) {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+
+ childListIter = childrenList.iterator();
+
+ while (childListIter.hasNext()) {
+ Element element = (Element)childListIter.next();
+
+ if ((E_PROPERTY_SEARCH.equals(element.getName())) && (principalProperty == null)) {
+ if (propertySearchSet == null) propertySearchSet = new HashSet();
+ propertySearchSet.add(element);
+
+ } else if ((E_ALLPROP.equals(element.getName()) || E_PROP.equals(element.getName())) && (requestedProperties == null)) {
+ requestedProperties = new RequestedPropertiesImpl(element);
+ } else {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ }
+ if ((propertySearchSet == null)||(requestedProperties == null)) {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ }
+
+
+ /**
* Parses the <code><expand-property></code> request.
*
* @param expandPropertyElement the <code><expand-property></code>
@@ -525,31 +576,46 @@
// content type must be set BEFORE calling getWriter()
getResponse().setContentType(TEXT_XML + "; charset=" + ENCODING);
-
- Element multistatusElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
-
- getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
-
-
-
+ Element resultElement = null;
try {
if (R_VERSION_TREE.equals(requestedReport)) {
- executeVersionTreeReport(requestUri, multistatusElement, getDepth());
+ resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
+ executeVersionTreeReport(requestUri, resultElement, getDepth());
}
else if (R_EXPAND_PROPERTY.equals(requestedReport)) {
- executeExpandPropertyReport(requestUri, multistatusElement, getDepth());
+ resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
+ executeExpandPropertyReport(requestUri, resultElement, getDepth());
}
else if (R_ACL_PRINCIPAL_PROPS.equals(requestedReport)) {
- executeAclPrincipalReport(requestUri, multistatusElement, getDepth());
+ resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
+ executeAclPrincipalReport(requestUri, resultElement, getDepth());
}
else if (R_PRINCIPAL_MATCH.equals(requestedReport)) {
- executeAclMatchReport (multistatusElement, getDepth());
+ resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
+ executeAclMatchReport (resultElement, getDepth());
+ }
+ else if (R_PRINCIPAL_SEARCH_PROPERTY_SET.equals(requestedReport)) {
+ resultElement = new Element(R_PRINCIPAL_SEARCH_PROPERTY_SET, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_OK);
+ executePrincipalSearchPropertySetReport (requestUri, resultElement);
+ }
+ else if (R_PRINCIPAL_PROPERTY_SEARCH.equals(requestedReport)) {
+ //resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_OK);
+ resultElement = executePrincipalSearchPropertyReport (getDepth());
+
}
else if (R_LOCATE_BY_HISTORY.equals(requestedReport)) {
- executeLocateByHistoryReport(requestUri, multistatusElement, getDepth());
+ resultElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
+ executeLocateByHistoryReport(requestUri, resultElement, getDepth());
}
- new XMLOutputter().output(multistatusElement, getResponse().getWriter());
+ new XMLOutputter().output(resultElement, getResponse().getWriter());
}
catch (PreconditionViolationException e) {
sendPreconditionViolation(e);
@@ -912,6 +978,60 @@
}
/**
+ * Executes the passed search query and returns the search result
+ *
+ * @param searchDocument DASEL XML search document
+ * @param depth search depth
+ *
+ * @throws WebdavException
+ * @throws SlideException
+ * @throws JDOMException
+ */
+ protected SearchQueryResult searchPrincipal(String searchDocument, int depth) throws WebdavException, SlideException, JDOMException {
+ org.w3c.dom.Element rootElement = null;
+ org.w3c.dom.Document parseDoc = null;
+ org.w3c.dom.Element queryElement = null;
+ org.w3c.dom.NodeList nl = null;
+ Search searchHelper = null;
+ String grammarNamespace = null;
+ SearchQuery searchQuery = null;
+ SearchQueryResult queryResult = null;
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ parseDoc = builder.parse(new InputSource(new StringReader(searchDocument)));
+ } catch (Exception e) {
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+
+ rootElement = parseDoc.getDocumentElement();
+ nl = rootElement.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++) {
+ if (nl.item (i) instanceof org.w3c.dom.Element)
+ queryElement = (org.w3c.dom.Element)nl.item(i);
+ }
+
+ // create search query for principals
+ grammarNamespace = queryElement.getNamespaceURI();
+ searchHelper = token.getSearchHelper();
+ try {
+ searchQuery = searchHelper.createSearchQuery
+ (grammarNamespace, queryElement, slideToken, depth, req.getRequestURI());
+ } catch (BadQueryException e) {
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ e.printStackTrace();
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ queryResult = searchHelper.search (slideToken, searchQuery);
+ // Search for Principals
+ return (queryResult);
+ }
+
+
+ /**
* Executes a requested <code>acl-match</code> report.
*
* @param requestUri the URI of the requested resource.
@@ -924,27 +1044,18 @@
*/
protected void executeAclMatchReport(Element parentElement, int depth) throws WebdavException, SlideException, JDOMException {
- List propstatList = null;
String currentUri = null;
String userID = null;
String userpath = token.getNamespaceConfig().getUsersPath();
String searchDocument = null;
- org.w3c.dom.Document parseDoc = null;
- org.w3c.dom.Element rootElement = null;
- org.w3c.dom.NodeList nl = null;
- org.w3c.dom.Element queryElement = null;
int maxDepth = 0;
- SearchQuery searchQuery = null;
- Search searchHelper = null;
- String grammarNamespace = null;
SearchQueryResult queryResult = null;
- PropertyRetriever retriever = null;
- List propList = null;
char seperator = '/';
boolean self = false;
+ currentUri = req.getRequestURI();
// check if self or principal-property is searched
- if ((principalProperty.getName()).equalsIgnoreCase("self")) {
+ if ((principalProperty.getName()).equalsIgnoreCase(E_SELF)) {
self = true;
}
@@ -956,38 +1067,6 @@
}
String currentUser = new String (userpath + userID);
- // get matched user
-
-
- currentUri = req.getRequestURI();
-
- if (self) {
- // build query for self
- searchDocument = C_MATCH_REPORT_SEARCH1 + C_MATCH_REPORT_ALLPROP +
- C_MATCH_REPORT_SEARCH2 + currentUri + C_MATCH_REPORT_SEARCH_SELF;
- } else {
- searchDocument = C_MATCH_REPORT_SEARCH1 + C_MATCH_REPORT_ALLPROP +
- C_MATCH_REPORT_SEARCH2 + currentUri + C_MATCH_REPORT_SEARCH_PROP1;
- }
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- parseDoc = builder.parse(new InputSource(new StringReader(searchDocument)));
- } catch (Exception e) {
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
-
- rootElement = parseDoc.getDocumentElement();
- nl = rootElement.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- if (nl.item (i) instanceof org.w3c.dom.Element)
- queryElement = (org.w3c.dom.Element)nl.item(i);
- }
-
// get search depth
if (self) {
for (int i = 0; i < currentUser.length(); i++) {
@@ -999,25 +1078,21 @@
maxDepth = depth;
}
- // create search query for principals
- grammarNamespace = queryElement.getNamespaceURI();
- searchHelper = token.getSearchHelper();
- try {
- searchQuery = searchHelper.createSearchQuery
- (grammarNamespace, queryElement, slideToken, maxDepth, req.getRequestURI());
- } catch (BadQueryException e) {
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ if (self) {
+ // build query for self
+ searchDocument = C_SEARCHREQUEST_OPEN + C_SELECT_OPEN + C_PROP_DISPLAYNAME +
+ C_SELECT_CLOSE + C_FROM_SCOPE_OPEN + currentUri + C_FROM_SCOPE_CLOSE +
+ C_WHERE_ISPRINCIPAL + C_SEARCHREQUEST_CLOSE;
+ } else {
+ searchDocument = C_SEARCHREQUEST_OPEN + C_SELECT_OPEN + C_PROP_DISPLAYNAME +
+ C_SELECT_CLOSE + C_FROM_SCOPE_OPEN + currentUri + C_FROM_SCOPE_CLOSE +
+ C_SEARCHREQUEST_CLOSE;
}
// Search for Principals
- queryResult = searchHelper.search (slideToken, searchQuery);
- retriever = new PropertyRetrieverImpl(token, slideToken);
-
- org.jdom.Namespace namespace = org.jdom.Namespace.getNamespace ("D", "DAV:");
+ queryResult = searchPrincipal(searchDocument, maxDepth);
Iterator it = queryResult.iterator();
- String serverURL = "http://" + req.getServerName()+ ":" + req.getServerPort();
while (it.hasNext()) {
String uri = null;
@@ -1026,7 +1101,7 @@
uri = resource.getInternalHref();
if (!self) {
try {
- uri = (String) resource.getThisValue("owner", WebdavConstants.DEFAULT_NAMESPACE);
+ uri = (String) resource.getThisValue("owner", DEFAULT_NAMESPACE);
if (uri != null) {
if (!(userpath.endsWith("/"))) userpath = userpath + "/";
uri = new String (userpath + uri);
@@ -1039,21 +1114,207 @@
// remove not matching principals
if ((uri != null)) {
if (currentUser.startsWith(uri)) {
- org.jdom.Element responseElement =
- new org.jdom.Element (WebdavConstants.E_RESPONSE, namespace);
+ if (currentUser.startsWith(uri)) {
+ getPropertiesForResponse(currentIntUrl, parentElement);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Executes a requested <code>principal-search-property</code> report.
+ *
+ * @param requestUri the URI of the requested resource.
+ * @param parentElement the parent Element to append the
+ * <response></code> to.
+ *
+ * @throws WebdavException
+ * @throws SlideException
+ * @throws JDOMException
+ */
+ protected Element executePrincipalSearchPropertyReport(int depth) throws WebdavException, SlideException, JDOMException {
+
+ Element parentElement = new Element(E_MULTISTATUS, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ SearchQueryResult queryResult = null;
+ Iterator searchPropIter = null;
+ Element currentSearchProperty = null;
+ String currentUri = req.getRequestURI();
+ searchPropIter = propertySearchSet.iterator();
+ org.jdom.Namespace namespace = org.jdom.Namespace.getNamespace (DEFAULT_PREFIX, DEFAULT_NAMESPACE);
+ Set principalCollectionSet = new HashSet();
+ String searchReq = null;
+ String whereElement = null;
+ // build dasel search query
+
+ // do propfind principal-collection-set element, parse through the answere
+ // and add the found principal-collection-sets to the principalCollectionSet Set instance
+ Element principalCollectionSetElement = new Element(E_PROP, namespace);
+ principalCollectionSetElement.addContent(new Element(E_PRINCIPAL_COLLECTION_SET, namespace));
+ RequestedProperties collectionSetProp = new RequestedPropertiesImpl(principalCollectionSetElement);
+ List collectionSets = retrieveProperties(requestUri, collectionSetProp);
+ Iterator collectionSetsIter = collectionSets.iterator();
+
+ while (collectionSetsIter.hasNext()) {
+ Element currentPrincipalCollection = (Element)collectionSetsIter.next();
+ List currentProps = currentPrincipalCollection.getChildren();
+ Iterator currentPropsIter = currentProps.iterator();
+ while (currentPropsIter.hasNext()) {
+ Element currentProp = (Element)currentPropsIter.next();
+ if (currentProp.getName() == "prop") {
+ List currentCollectioSets = currentProp.getChildren();
+ if (currentCollectioSets.size() == 1) {
+ Element currentCollectioSet = (Element)currentCollectioSets.get(0);
+ List currentHrefs = currentCollectioSet.getChildren();
+ Iterator currentHrefsIter = currentHrefs.iterator();
+ while (currentHrefsIter.hasNext()) {
+ Element currentHref = (Element) currentHrefsIter.next();
+ principalCollectionSet.add(C_FROM_SCOPE_OPEN + currentHref.getText() + C_FROM_SCOPE_CLOSE);
+ }
+ } else {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ }
+ }
+ }
+
+ // get the search requrements
+ whereElement = C_WHERE_OPEN;
+ while (searchPropIter.hasNext()) {
+ String currentSearchPropertyName = null;
+ String currentSearchPropertyNamespace = null;
+ String currentSearchLiteral = null;
+ currentSearchProperty = (Element)searchPropIter.next();
+ List currentPropertyChildren = currentSearchProperty.getChildren();
+ Iterator currentChildListIter = currentPropertyChildren.iterator();
+
+ // get search property and caseless-substring
+ while (currentChildListIter.hasNext()) {
+ Element element = (Element)currentChildListIter.next();
+
+ if ((E_PROP.equals(element.getName())) && (currentSearchPropertyName == null)) {
+ List props = element.getChildren();
+ if (props.size() != 1) {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ Element currentPropertyElement = (Element) props.get(0);
+ currentSearchPropertyNamespace = (currentPropertyElement.getNamespace()).getURI();
+ // set Namespace for property in query
+ if (currentSearchPropertyNamespace.equals(DEFAULT_NAMESPACE)) {
+ currentSearchPropertyName = C_PROP_OPEN + "<" + DEFAULT_PREFIX + ":" + currentPropertyElement.getName() + "/>" + C_PROP_CLOSE;
+ } else {
+ currentSearchPropertyName = C_PROP_OPEN_NS_OPEN + currentSearchPropertyNamespace +
+ C_PROP_OPEN_NS_CLOSE + "<" + C_X_PREFIX + currentPropertyElement.getName() + "/>" + C_PROP_CLOSE;
+ }
+ if (!(PropertySearchSetProperty.inSearchPropertySet(currentPropertyElement.getName(), currentSearchPropertyNamespace))) {
+ parentElement = new Element(E_NON_SEARCHABLE_PROPERTY, Namespace.getNamespace(DEFAULT_NAMESPACE));
+ parentElement.addContent((Element)element.clone());
+ resp.setStatus(WebdavStatus.SC_FORBIDDEN);
+ return parentElement;
+ }
+ }
+ else if (E_ALLPROP.equals(element.getName())) {
+ parentElement = new Element("non-searchable-property", Namespace.getNamespace(DEFAULT_NAMESPACE));
+ parentElement.addContent((Element)element.clone());
+ resp.setStatus(WebdavStatus.SC_FORBIDDEN);
+ return parentElement;
+ }
+ else if (E_CASELESS_SUBSTRING.equals(element.getName())) {
+ currentSearchLiteral = C_LITERAL_OPEN + element.getText() + C_LITERAL_CLOSE;
+ }
+ else {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ }
+ }
+
+ // test if the search requirements for the property are complete
+ if ((currentSearchLiteral == null) || (currentSearchPropertyName == null)) {
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ } else {
+ whereElement = whereElement + C_PROPCONTAINS_OPEN + currentSearchPropertyName + currentSearchLiteral + C_PROPCONTAINS_CLOSE;
+ }
+
+ }
+ whereElement = whereElement + C_WHERE_CLOSE;
+
+ // Search for Principals
+ Iterator principalCollectionSetIter = principalCollectionSet.iterator();
+ // run through all possible principal collection in the principal-collection-set
+ while (principalCollectionSetIter.hasNext()) {
+ // build dasel query
+ String searchDocument = C_SEARCHREQUEST_OPEN + C_SELECT_OPEN
+ + C_PROP_DISPLAYNAME + C_SELECT_CLOSE + (String)principalCollectionSetIter.next()
+ + whereElement + C_SEARCHREQUEST_CLOSE;
+ queryResult = searchPrincipal(searchDocument, depth);
+ Iterator it = queryResult.iterator();
+ // build response element
+ while (it.hasNext()) {
+ String uri = null;
+ RequestedResource resource = (RequestedResource)it.next();
+ String currentIntUrl = resource.getInternalHref();
+ uri = resource.getInternalHref();
+ // remove not matching principals
+ if ((uri != null)) {
+ getPropertiesForResponse(currentIntUrl, parentElement);
+ }
+ }
+ }
+ return parentElement;
+ }
+
- parentElement.addContent (responseElement);
- org.jdom.Element hrefElement =
- new org.jdom.Element (WebdavConstants.E_HREF, namespace);
+ /**
+ * executes the propfind method for the 'requestedProperties and adds the result to the parentElement.
+ *
+ * @param currentIntUrl the URI of the requested resource.
+ * @param parentElement the parent Element to append the
+ * <response></code> to.
+ *
+ * @throws WebdavException
+ * @throws SlideException
+ * @throws JDOMException
+ */
+ protected void getPropertiesForResponse(String currentIntUrl, Element parentElement) throws WebdavException, SlideException, JDOMException {
+
+ List propList = null;
+ String serverURL = "http://" + req.getServerName()+ ":" + req.getServerPort();
+ PropertyRetriever retriever = new PropertyRetrieverImpl(token, slideToken);
+ org.jdom.Namespace namespace = org.jdom.Namespace.getNamespace (DEFAULT_PREFIX, DEFAULT_NAMESPACE);
+ org.jdom.Element responseElement = new org.jdom.Element (E_RESPONSE, namespace);
+ parentElement.addContent (responseElement);
+ org.jdom.Element hrefElement = new org.jdom.Element (E_HREF, namespace);
hrefElement.addContent(PropertyHelper.getAbsoluteURL(serverURL, req.getContextPath(), currentIntUrl));
responseElement.addContent (hrefElement);
// get properties, if any defined
if (requestedProperties != null) {
+ propList = retrieveProperties(currentIntUrl, requestedProperties);
+ Iterator iterator = propList.iterator();
+ while (iterator.hasNext()) {
+ responseElement.addContent((org.jdom.Element)iterator.next());
+ }
+ }
+ }
+
+ /**
+ * executes the propfind method for the 'reqProperties'.
+ *
+ * @param currentIntUrl the URI of the requested resource.
+ * @param reqProperties, searched resource properties.
+ * @return List of found property values
+ *
+ * @throws WebdavException
+ * @throws SlideException
+ * @throws JDOMException
+ */
+ protected List retrieveProperties (String currentIntUrl, RequestedProperties reqProperties) throws WebdavException, SlideException, JDOMException{
+ List propList = null;
+ String serverURL = "http://" + req.getServerName()+ ":" + req.getServerPort();
+ PropertyRetriever retriever = new PropertyRetrieverImpl(token, slideToken);
try {
- propList = retriever.getPropertiesOfObject (requestedProperties,
+ propList = retriever.getPropertiesOfObject (reqProperties,
currentIntUrl,
req.getContextPath(),
serverURL,
@@ -1063,14 +1324,48 @@
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
+ return propList;
+ }
+
+ /**
+ * Executes a requested <code>principal-search-property-set</code> report.
+ *
+ * @param requestUri the URI of the requested resource.
+ * @param parentElement the parent Element to append the
+ * <response></code> to.
+ * @param principalSearchPropertySet the List of <code><property></code>
+ * elements which are requested.
+ *
+ * @throws WebdavException
+ * @throws ObjectLockedException
+ * @throws RevisionDescriptorNotFoundException
+ * @throws ServiceAccessException
+ * @throws LinkedObjectNotFoundException
+ * @throws AccessDeniedException
+ * @throws ObjectNotFoundException
+ * @throws JDOMException
+ */
+ protected void executePrincipalSearchPropertySetReport(String requestUri, Element parentElement) throws WebdavException, ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, JDOMException {
- Iterator iterator = propList.iterator();
- while (iterator.hasNext()) {
- responseElement.addContent((org.jdom.Element)iterator.next());
- }
- }
- }
- }
+ // get principal-property-set
+ Iterator propertiesIter = PropertySearchSetProperty.getPropertySetIterator();
+ PropertySearchSetProperty currentProperty = null;
+
+ // write result
+ while (propertiesIter.hasNext()) {
+ currentProperty = (PropertySearchSetProperty) propertiesIter.next();
+ Element searchProp = new Element(E_PRINCIPAL_SEARCH_PROPERTY,DEFAULT_NAMESPACE );
+ Element prop = new Element (E_PROP,DEFAULT_NAMESPACE );
+ Element propContent = new Element (currentProperty.getPropertyName(),currentProperty.getNamespace());
+ Element description = new Element (E_DESCRIPTION,DEFAULT_NAMESPACE );
+ Attribute lang = new Attribute ("xml:lang","en");
+// Element descContent = new Element (currentDesc, WebdavConstants.DEFAULT_NAMESPACE);
+ description.setAttribute(lang);
+ description.addContent(currentProperty.getDescription());
+ prop.addContent(propContent);
+ searchProp.addContent(prop);
+ searchProp.addContent(description);
+ parentElement.addContent(searchProp);
}
}
@@ -1440,6 +1735,7 @@
/**
* Returns the servlet request.
+
*
* @return the servlet request.
*/
@@ -1534,6 +1830,12 @@
+
+
+
+
+
+
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>