List of usage examples for org.apache.commons.vfs FileContent getAttributeNames
String[] getAttributeNames() throws FileSystemException;
From source file:com.thinkberg.webdav.data.AbstractDavResource.java
/** * Get property values. This method expects one of either <allprop>, <propnames> or * <prop>. If the element is <prop> it will go through the list of it's children * and request the values. For <allprop> it will get values of all known properties and * <propnames> will return the names of all known properties. * * @param root the root of the result document * @param propertyEl the prop, propname or allprop element * @return the root of the result document *//*from ww w . ja v a 2 s .c o m*/ public Element getPropertyValues(Element root, Element propertyEl) { // initialize the <propstat> for 200 Element okPropStatEl = root.addElement(TAG_PROPSTAT); Element okPropEl = okPropStatEl.addElement(TAG_PROP); // initialize the <propstat> element for 404 Element failPropStatEl = root.addElement(TAG_PROPSTAT); Element failPropEl = failPropStatEl.addElement(TAG_PROP); if (TAG_ALLPROP.equalsIgnoreCase(propertyEl.getName()) || TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName())) { boolean ignoreValue = TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName()); // get all known standard properties for (String propName : ALL_PROPERTIES) { if (!getPropertyValue(okPropEl, propName, ignoreValue)) { failPropEl.addElement(propName); } } // additionally try to add all the custom properties try { FileContent objectContent = object.getContent(); for (String attributeName : objectContent.getAttributeNames()) { if (!getPropertyValue(okPropEl, attributeName, ignoreValue)) { failPropEl.addElement(attributeName); } } } catch (FileSystemException e) { LogFactory.getLog(getClass()) .error(String.format("can't read attribute properties from '%s'", object.getName()), e); } } else { List requestedProperties = propertyEl.elements(); for (Object propertyElObject : requestedProperties) { Element propEl = (Element) propertyElObject; final String nameSpace = propEl.getNamespaceURI(); if (!getPropertyValue(okPropEl, getFQName(nameSpace, propEl.getName()), false)) { failPropEl.addElement(propEl.getQName()); } } } // only add the OK section, if there is content if (okPropEl.elements().size() > 0) { okPropStatEl.addElement(TAG_STATUS).addText(STATUS_200); } else { okPropStatEl.detach(); } // only add the failed section, if there is content if (failPropEl.elements().size() > 0) { failPropStatEl.addElement(TAG_STATUS).addText(STATUS_404); } else { failPropStatEl.detach(); } return root; }
From source file:org.efaps.webdav4vfs.data.AbstractDavResource.java
/** * Get property values. This method expects one of either <allprop>, * <propnames> or <prop>. If the element is <prop> it * will go through the list of it's children and request the values. For * <allprop> it will get values of all known properties and * <propnames> will return the names of all known properties. * * @param root the root of the result document * @param propertyEl the prop, propname or allprop element * @return the root of the result document *//* w ww .jav a 2 s.com*/ public Element getPropertyValues(final Element root, final Element propertyEl) { // initialize the <propstat> for 200 final Element okPropStatEl = root.addElement(TAG_PROPSTAT); final Element okPropEl = okPropStatEl.addElement(TAG_PROP); // initialize the <propstat> element for 404 final Element failPropStatEl = root.addElement(TAG_PROPSTAT); final Element failPropEl = failPropStatEl.addElement(TAG_PROP); if (TAG_ALLPROP.equalsIgnoreCase(propertyEl.getName()) || TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName())) { boolean ignoreValue = TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName()); // get all known standard properties for (String propName : ALL_PROPERTIES) { if (!getPropertyValue(okPropEl, propName, ignoreValue)) { failPropEl.addElement(propName); } } // additionally try to add all the custom properties try { final FileContent objectContent = object.getContent(); for (String attributeName : objectContent.getAttributeNames()) { if (!getPropertyValue(okPropEl, attributeName, ignoreValue)) { failPropEl.addElement(attributeName); } } } catch (final FileSystemException e) { LogFactory.getLog(getClass()) .error(String.format("can't read attribute properties from '%s'", object.getName()), e); } } else { final List<?> requestedProperties = propertyEl.elements(); for (Object propertyElObject : requestedProperties) { final Element propEl = (Element) propertyElObject; final String nameSpace = propEl.getNamespaceURI(); if (!getPropertyValue(okPropEl, getFQName(nameSpace, propEl.getName()), false)) { failPropEl.addElement(propEl.getQName()); } } } // only add the OK section, if there is content if (okPropEl.elements().size() > 0) { okPropStatEl.addElement(TAG_STATUS).addText(STATUS_200); } else { okPropStatEl.detach(); } // only add the failed section, if there is content if (failPropEl.elements().size() > 0) { failPropStatEl.addElement(TAG_STATUS).addText(STATUS_404); } else { failPropStatEl.detach(); } return root; }