/** * Get the named properties for this resource and (potentially) its children. * * @param names an arrary of property names to retrieve * @return a MultiStatus of PropertyResponses * @exception com.ibm.webdav.WebDAVException */ public MultiStatus getProperties(PropertyName[] names) throws WebDAVException { MultiStatus multiStatus = resource.getProperties(resource.getContext()); MultiStatus newMultiStatus = new MultiStatus(); Enumeration responses = multiStatus.getResponses(); while (responses.hasMoreElements()) { PropertyResponse response = (PropertyResponse) responses.nextElement(); PropertyResponse newResponse = new PropertyResponse(response.getResource()); newResponse.setDescription(response.getDescription()); newMultiStatus.addResponse(newResponse); Hashtable properties = (Hashtable) response.getPropertiesByPropName(); // Hashtable newProperties = (Hashtable) newResponse.getProperties(); for (int i = 0; i < names.length; i++) { if (properties.containsKey(names[i])) { PropertyValue srcval = response.getProperty(names[i]); newResponse.setProperty(names[i], srcval); // newProperties.put(names[i], properties.get(names[i])); } else { Document factory = null; try { factory = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (Exception e) { throw new WebDAVException(WebDAVStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } // we'll create an xml element with no value because that's // what webdav will need to return for most methods... even if the // property doesn't exist. That's because the // distinction between a propertyname and propertyvalue // is fuzzy in WebDAV xml. A property name is // essentially an empty property value because // all property values have their property // name stuck on. // if we decide to set reviewStatus to null instead (as // we did previously, then the code for MultiStatus.asXML() // needs to be updated to expect null values. // (jlc 990520) Element elTm = factory.createElementNS("X", "X:" + names[i].getLocal()); elTm.setAttribute("xmlns:X", names[i].getNamespace()); newResponse.addProperty(names[i], elTm, WebDAVStatus.SC_NOT_FOUND); } } } return newMultiStatus; }
/** * Get the names of all properties for this resource. This implementation reads all the properties * and then extracts their names. * * @return a MultiStatus of PropertyResponses (PropertyValue.value is always null, * PropertyValue.status contains the status) * @exception com.ibm.webdav.WebDAVException */ public MultiStatus getPropertyNames() throws WebDAVException { MultiStatus multiStatus = resource.getProperties(resource.getContext()); Enumeration responses = multiStatus.getResponses(); // we have the result, but all of the properties in our structure contain // values. We don't want to include values. Just names. The following // code strips out the content of these elements. while (responses.hasMoreElements()) { PropertyResponse response = (PropertyResponse) responses.nextElement(); Dictionary properties = response.getPropertiesByPropName(); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { PropertyName key = (PropertyName) keys.nextElement(); Element value = (Element) response.getProperty(key).getValue(); response.setProperty( key, new PropertyValue((Element) value.cloneNode(false), WebDAVStatus.SC_OK)); } } return multiStatus; }