use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class VersionItemCollection method getProperty.
@Override
public DavProperty<?> getProperty(DavPropertyName name) {
DavProperty prop = super.getProperty(name);
if (prop == null && exists()) {
Version v = (Version) item;
try {
if (VERSION_NAME.equals(name)) {
// required, protected DAV:version-name property
prop = new DefaultDavProperty<String>(VERSION_NAME, v.getName(), true);
} else if (VERSION_HISTORY.equals(name)) {
// required DAV:version-history (computed) property
String vhHref = getLocatorFromItem(getVersionHistoryItem()).getHref(true);
prop = new HrefProperty(VERSION_HISTORY, vhHref, true);
} else if (PREDECESSOR_SET.equals(name)) {
// required DAV:predecessor-set (protected) property
prop = getHrefProperty(VersionResource.PREDECESSOR_SET, v.getPredecessors(), true);
} else if (SUCCESSOR_SET.equals(name)) {
// required DAV:successor-set (computed) property
prop = getHrefProperty(SUCCESSOR_SET, v.getSuccessors(), true);
} else if (LABEL_NAME_SET.equals(name)) {
// required, protected DAV:label-name-set property
String[] labels = getVersionHistoryItem().getVersionLabels(v);
prop = new LabelSetProperty(labels);
} else if (CHECKOUT_SET.equals(name)) {
// required DAV:checkout-set (computed) property
PropertyIterator it = v.getReferences();
List<Node> nodeList = new ArrayList<Node>();
while (it.hasNext()) {
Property p = it.nextProperty();
if (JcrConstants.JCR_BASEVERSION.equals(p.getName())) {
Node n = p.getParent();
if (n.isCheckedOut()) {
nodeList.add(n);
}
}
}
prop = getHrefProperty(CHECKOUT_SET, nodeList.toArray(new Node[nodeList.size()]), true);
}
} catch (RepositoryException e) {
log.error(e.getMessage());
}
}
return prop;
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class VersionHistoryItemCollection method getProperty.
@Override
public DavProperty<?> getProperty(DavPropertyName name) {
DavProperty prop = super.getProperty(name);
if (prop == null) {
// required, protected version-set property for version-history resource
try {
if (ROOT_VERSION.equals(name)) {
// required root-version property for version-history resource
String rootVersionHref = getLocatorFromItem(((VersionHistory) item).getRootVersion()).getHref(true);
prop = new HrefProperty(ROOT_VERSION, rootVersionHref, true);
} else if (VERSION_SET.equals(name)) {
VersionIterator vIter = ((VersionHistory) item).getAllVersions();
prop = getHrefProperty(VERSION_SET, vIter, true);
}
} catch (RepositoryException e) {
log.error(e.getMessage());
}
}
return prop;
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class DavResourceImpl method initProperties.
/**
* Fill the set of properties
*/
protected void initProperties() {
if (!exists() || propsInitialized) {
return;
}
try {
config.getPropertyManager().exportProperties(getPropertyExportContext(), isCollection());
} catch (RepositoryException e) {
log.warn("Error while accessing resource properties", e);
}
// set (or reset) fundamental properties
if (getDisplayName() != null) {
properties.add(new DefaultDavProperty<String>(DavPropertyName.DISPLAYNAME, getDisplayName()));
}
if (isCollection()) {
properties.add(new ResourceType(ResourceType.COLLECTION));
// Windows XP support
properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "1"));
} else {
properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
// Windows XP support
properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "0"));
}
if (rfc4122Uri != null) {
properties.add(new HrefProperty(BindConstants.RESOURCEID, rfc4122Uri, true));
}
Set<ParentElement> parentElements = getParentElements();
if (!parentElements.isEmpty()) {
properties.add(new ParentSet(parentElements));
}
/* set current lock information. If no lock is set to this resource,
an empty lock discovery will be returned in the response. */
properties.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE)));
/* lock support information: all locks are lockable. */
SupportedLock supportedLock = new SupportedLock();
supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
properties.add(supportedLock);
propsInitialized = true;
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class DeltaVResourceImpl method getReferenceResources.
/**
* Return an array of <code>DavResource</code> objects that are referenced
* by the property with the specified name.
*
* @param hrefPropertyName
* @return array of <code>DavResource</code>s
* @throws DavException
* @see DeltaVResource#getReferenceResources(org.apache.jackrabbit.webdav.property.DavPropertyName)
*/
public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException {
DavProperty<?> prop = getProperty(hrefPropertyName);
List<DavResource> resources = new ArrayList<DavResource>();
if (prop != null && prop instanceof HrefProperty) {
HrefProperty hp = (HrefProperty) prop;
// process list of hrefs
for (String href : hp.getHrefs()) {
DavResourceLocator locator = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), href);
resources.add(createResourceFromLocator(locator));
}
} else {
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
}
return resources.toArray(new DavResource[resources.size()]);
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class AbstractItemResource method initProperties.
/**
* Fill the property set for this resource.
*/
@Override
protected void initProperties() {
super.initProperties();
if (exists()) {
try {
properties.add(new DefaultDavProperty<String>(JCR_NAME, item.getName()));
properties.add(new DefaultDavProperty<String>(JCR_PATH, item.getPath()));
int depth = item.getDepth();
properties.add(new DefaultDavProperty<String>(JCR_DEPTH, String.valueOf(depth)));
// add href-property for the items parent unless its the root item
if (depth > 0) {
String parentHref = getLocatorFromItem(item.getParent()).getHref(true);
properties.add(new HrefProperty(JCR_PARENT, parentHref, false));
}
} catch (RepositoryException e) {
// should not get here
log.error("Error while accessing jcr properties: " + e.getMessage());
}
}
}
Aggregations