private void parseProperties(ITransaction transaction,
HttpServletRequest req, XMLWriter generatedXML, String path,
int type, List<String> propertiesVector, String mimeType)
throws WebdavException {
StoredObject so = _store.getStoredObject(transaction, path);
boolean isFolder = so.isFolder();
String creationdate = CREATION_DATE_FORMAT.format(so.getCreationDate());
String lastModified = LAST_MODIFIED_DATE_FORMAT.format(so
.getLastModified());
String resourceLength = String.valueOf(so.getResourceLength());
// ResourceInfo resourceInfo = new ResourceInfo(path, resources);
generatedXML.writeElement("DAV::response", XMLWriter.OPENING);
String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " "
+ WebdavStatus.getStatusText(WebdavStatus.SC_OK));
// Generating href element
generatedXML.writeElement("DAV::href", XMLWriter.OPENING);
String href = req.getContextPath();
String servletPath = req.getServletPath();
if (servletPath != null) {
if ((href.endsWith("/")) && (servletPath.startsWith("/")))
href += servletPath.substring(1);
else
href += servletPath;
}
if ((href.endsWith("/")) && (path.startsWith("/")))
href += path.substring(1);
else
href += path;
if ((isFolder) && (!href.endsWith("/")))
href += "/";
generatedXML.writeText(rewriteUrl(href));
generatedXML.writeElement("DAV::href", XMLWriter.CLOSING);
String resourceName = path;
int lastSlash = path.lastIndexOf('/');
if (lastSlash != -1)
resourceName = resourceName.substring(lastSlash + 1);
switch (type) {
case FIND_ALL_PROP:
generatedXML.writeElement("DAV::propstat", XMLWriter.OPENING);
generatedXML.writeElement("DAV::prop", XMLWriter.OPENING);
generatedXML.writeProperty("DAV::creationdate", creationdate);
generatedXML.writeElement("DAV::displayname", XMLWriter.OPENING);
generatedXML.writeData(resourceName);
generatedXML.writeElement("DAV::displayname", XMLWriter.CLOSING);
if (!isFolder) {
generatedXML
.writeProperty("DAV::getlastmodified", lastModified);
generatedXML.writeProperty("DAV::getcontentlength",
resourceLength);
String contentType = mimeType;
if (contentType != null) {
generatedXML.writeProperty("DAV::getcontenttype",
contentType);
}
generatedXML.writeProperty("DAV::getetag", getETag(so));
generatedXML.writeElement("DAV::resourcetype",
XMLWriter.NO_CONTENT);
} else {
generatedXML.writeElement("DAV::resourcetype",
XMLWriter.OPENING);
generatedXML.writeElement("DAV::collection",
XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::resourcetype",
XMLWriter.CLOSING);
}
writeSupportedLockElements(transaction, generatedXML, path);
writeLockDiscoveryElements(transaction, generatedXML, path);
generatedXML.writeProperty("DAV::source", "");
generatedXML.writeElement("DAV::prop", XMLWriter.CLOSING);
generatedXML.writeElement("DAV::status", XMLWriter.OPENING);
generatedXML.writeText(status);
generatedXML.writeElement("DAV::status", XMLWriter.CLOSING);
generatedXML.writeElement("DAV::propstat", XMLWriter.CLOSING);
break;
case FIND_PROPERTY_NAMES:
generatedXML.writeElement("DAV::propstat", XMLWriter.OPENING);
generatedXML.writeElement("DAV::prop", XMLWriter.OPENING);
generatedXML
.writeElement("DAV::creationdate", XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::displayname", XMLWriter.NO_CONTENT);
if (!isFolder) {
generatedXML.writeElement("DAV::getcontentlanguage",
XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::getcontentlength",
XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::getcontenttype",
XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::getetag", XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::getlastmodified",
XMLWriter.NO_CONTENT);
}
generatedXML
.writeElement("DAV::resourcetype", XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::supportedlock",
XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::source", XMLWriter.NO_CONTENT);
generatedXML.writeElement("DAV::prop", XMLWriter.CLOSING);
generatedXML.writeElement("DAV::status", XMLWriter.OPENING);
generatedXML.writeText(status);
generatedXML.writeElement("DAV::status", XMLWriter.CLOSING);
generatedXML.writeElement("DAV::propstat", XMLWriter.CLOSING);
break;
case FIND_BY_PROPERTY:
List<String> propertiesNotFound = new ArrayList<String>();
// Parse the list of properties
generatedXML.writeElement("DAV::propstat", XMLWriter.OPENING);
generatedXML.writeElement("DAV::prop", XMLWriter.OPENING);
Iterator<String> properties = propertiesVector.iterator();
while (properties.hasNext()) {
String property = properties.next();
if (property.equals("DAV::creationdate")) {
generatedXML.writeProperty("DAV::creationdate",
creationdate);
} else if (property.equals("DAV::displayname")) {
generatedXML.writeElement("DAV::displayname",
XMLWriter.OPENING);
generatedXML.writeData(resourceName);
generatedXML.writeElement("DAV::displayname",
XMLWriter.CLOSING);
} else if (property.equals("DAV::getcontentlanguage")) {
if (isFolder) {
propertiesNotFound.add(property);
} else {
generatedXML.writeElement("DAV::getcontentlanguage",
XMLWriter.NO_CONTENT);
}
} else if (property.equals("DAV::getcontentlength")) {
if (isFolder) {
propertiesNotFound.add(property);
} else {
generatedXML.writeProperty("DAV::getcontentlength",
resourceLength);
}
} else if (property.equals("DAV::getcontenttype")) {
if (isFolder) {
propertiesNotFound.add(property);
} else {
generatedXML.writeProperty("DAV::getcontenttype",
mimeType);
}
} else if (property.equals("DAV::getetag")) {
if (isFolder || so.isNullResource()) {
propertiesNotFound.add(property);
} else {
generatedXML.writeProperty("DAV::getetag", getETag(so));
}
} else if (property.equals("DAV::getlastmodified")) {