public HierarchicalProperty getProperty(QName name) throws PathNotFoundException, AccessDeniedException,
RepositoryException
{
if (name.equals(DISPLAYNAME))
{
return new HierarchicalProperty(name, node.getName());
}
else if (name.equals(CHILDCOUNT))
{
return new HierarchicalProperty(name, "" + node.getNodes().getSize());
}
else if (name.equals(CREATIONDATE))
{
if (node.isNodeType("nt:hierarchyNode"))
{
Calendar created = node.getProperty("jcr:created").getDate();
HierarchicalProperty creationDate = new HierarchicalProperty(name, created, CREATION_PATTERN);
creationDate.setAttribute("b:dt", "dateTime.tz");
return creationDate;
}
else
{
throw new PathNotFoundException("Property not found " + CREATIONDATE);
}
}
else if (name.equals(HASCHILDREN))
{
if (node.getNodes().getSize() > 0)
{
return new HierarchicalProperty(name, "1");
}
else
{
return new HierarchicalProperty(name, "0");
}
}
else if (name.equals(ISCOLLECTION))
{
return new HierarchicalProperty(name, "1");
}
else if (name.equals(ISFOLDER))
{
return new HierarchicalProperty(name, "1");
}
else if (name.equals(ISROOT))
{
return new HierarchicalProperty(name, (node.getDepth() == 0) ? "1" : "0");
}
else if (name.equals(PARENTNAME))
{
if (node.getDepth() == 0)
{
throw new PathNotFoundException();
}
return new HierarchicalProperty(name, node.getParent().getName());
}
else if (name.equals(RESOURCETYPE))
{
HierarchicalProperty collectionProp = new HierarchicalProperty(new QName("DAV:", "collection"));
HierarchicalProperty resourceType = new HierarchicalProperty(name);
resourceType.addChild(collectionProp);
return resourceType;
}
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");
}
throw new PathNotFoundException();
}
else if (name.equals(ISVERSIONED))
{
return new HierarchicalProperty(name, "0");
}
else if (name.equals(SUPPORTEDMETHODSET))
{
return supportedMethodSet();
}
else if (name.equals(ORDERING_TYPE))
{
if (node.getPrimaryNodeType().hasOrderableChildNodes())
{
HierarchicalProperty orderingType = new HierarchicalProperty(name);
// <D:href>DAV:custom</D:href>
HierarchicalProperty orderHref = orderingType.addChild(new HierarchicalProperty(new QName("DAV:", "href")));
orderHref.setValue("DAV:custom");
return orderingType;
}
throw new PathNotFoundException();
}
else
{
if ("DAV:".equals(name.getNamespaceURI()))
{
throw new PathNotFoundException();
}
Property property = node.getProperty(WebDavNamespaceContext.createName(name));
if (property.getDefinition().isMultiple())
{
Value[] values = property.getValues();
return new HierarchicalProperty(name, values[0].getString());
}
else
{
return new HierarchicalProperty(name, property.getString());
}
}
}