public HierarchicalProperty getProperty(QName name) throws PathNotFoundException, AccessDeniedException,
RepositoryException
{
if (name.equals(DISPLAYNAME))
{
return new HierarchicalProperty(name, node.getName());
}
else if (name.equals(CREATIONDATE))
{
Calendar created = node.getProperty("jcr:created").getDate();
HierarchicalProperty creationDate = new HierarchicalProperty(name, created, CREATION_PATTERN);
creationDate.setAttribute("b:dt", "dateTime.tz");
return creationDate;
}
else if (name.equals(CHILDCOUNT))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(GETCONTENTLENGTH))
{
return new HierarchicalProperty(name, String.valueOf(dataProperty().getLength()));
}
else if (name.equals(GETCONTENTTYPE))
{
return new HierarchicalProperty(name, contentNode().getProperty("jcr:mimeType").getString());
}
else if (name.equals(GETLASTMODIFIED))
{
Calendar modified;
try
{
modified = contentNode().getProperty("jcr:lastModified").getDate();
}
catch (PathNotFoundException e)
{
modified = node.getProperty("jcr:created").getDate();
}
HierarchicalProperty lastModified = new HierarchicalProperty(name, modified, MODIFICATION_PATTERN);
lastModified.setAttribute("b:dt", "dateTime.rfc1123");
return lastModified;
}
else if (name.equals(HASCHILDREN))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(ISCOLLECTION))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(ISFOLDER))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(ISROOT))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(PARENTNAME))
{
return new HierarchicalProperty(name, node.getParent().getName());
}
else if (name.equals(RESOURCETYPE))
{
return new HierarchicalProperty(name);
}
else if (name.equals(SUPPORTEDLOCK))
{
if (!node.canAddMixin("mix:lockable"))
{
throw new PathNotFoundException();
}
return supportedLock();
}
else if (name.equals(LOCKDISCOVERY))
{
if (node.isLocked())
{
String token = node.getLock().getLockToken();
String owner = node.getLock().getLockOwner();
return lockDiscovery(token, owner, "86400");
}
else
{
throw new PathNotFoundException();
}
}
else if (name.equals(ISVERSIONED))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(SUPPORTEDMETHODSET))
{
return supportedMethodSet();
}
else
{
try
{
Property property = node.getProperty(WebDavNamespaceContext.createName(name));
String propertyValue;
if (property.getDefinition().isMultiple())
{
if (property.getValues().length == 0)
{
throw new PathNotFoundException();
}
propertyValue = property.getValues()[0].getString();
}
else
{
propertyValue = property.getString();
}
return new HierarchicalProperty(name, propertyValue);
}
catch (PathNotFoundException e)
{
Property property = contentNode().getProperty(WebDavNamespaceContext.createName(name));
String propertyValue;
if (property.getDefinition().isMultiple())
{
if (property.getValues().length >= 1)
{
propertyValue = property.getValues()[0].getString();
}
else
{
// this means that we return empty value, because according to WebDAV spec:
// this is a property whose semantics and syntax are not enforced by the server
// the server only records the value of a dead property;
// the client is responsible for maintaining the consistency of the syntax and semantics of a dead property.
propertyValue = "";
}
}
else
{
propertyValue = property.getString();
}
return new HierarchicalProperty(name, propertyValue);
}
}
}