use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class VersionControlledItemCollection method initProperties.
/**
* Fill the property set for this resource.
*/
@Override
protected void initProperties() {
super.initProperties();
if (isVersionControlled()) {
Node n = (Node) item;
// workspace property already set in AbstractResource.initProperties()
try {
// DAV:version-history (computed)
String vhHref = getLocatorFromItem(n.getVersionHistory()).getHref(true);
properties.add(new HrefProperty(VERSION_HISTORY, vhHref, true));
// DAV:auto-version property: there is no auto version, explicit CHECKOUT is required.
properties.add(new DefaultDavProperty<String>(AUTO_VERSION, null, false));
String baseVHref = getLocatorFromItem(n.getBaseVersion()).getHref(true);
if (n.isCheckedOut()) {
// DAV:predecessors property
if (n.hasProperty(JcrConstants.JCR_PREDECESSORS)) {
Value[] predec = n.getProperty(JcrConstants.JCR_PREDECESSORS).getValues();
addHrefProperty(PREDECESSOR_SET, predec, false);
}
// being set results in an exception on failure.
if (n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
addHrefProperty(AUTO_MERGE_SET, mergeFailed, false);
}
// todo: checkout-fork, checkin-fork
}
} catch (RepositoryException e) {
log.error(e.getMessage());
}
}
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class CompareBaselineReport method getVersions.
private void getVersions(DavResource collection, List<VersionResource> vList) throws DavException {
DavResourceIterator it = collection.getMembers();
while (it.hasNext()) {
DavResource member = it.nextResource();
if (member instanceof VersionControlledResource) {
String href = new HrefProperty(member.getProperty(VersionControlledResource.CHECKED_IN)).getHrefs().get(0);
DavResourceLocator locator = member.getLocator();
DavResourceLocator vLocator = locator.getFactory().createResourceLocator(locator.getPrefix(), href);
DavResource v = member.getFactory().createResource(vLocator, member.getSession());
if (v instanceof VersionResource) {
vList.add((VersionResource) v);
} else {
log.error("Internal error: DAV:checked-in property must point to a VersionResource.");
}
}
if (member.isCollection()) {
getVersions(member, vList);
}
}
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class ExpandPropertyReport method getResponse.
/**
* Builds a <code>MultiStatusResponse</code> for the given resource respecting
* the properties specified. Any property that represents a {@link HrefProperty}
* is expanded: It's name equals the name of a valid {@link HrefProperty}.
* However the value of that given property (consisting of one or multiple DAV:href elements)
* is replaced by the Xml representation of a separate
* {@link MultiStatusResponse multistatus responses} for the
* resource referenced by the given DAV:href elements. The responses may
* themselves have properties, which are defined by the separate list.
*
* @param res
* @param propertyElements
* @return <code>MultiStatusResponse</code> for the given resource.
* @see ExpandProperty
*/
private MultiStatusResponse getResponse(DavResource res, Iterator<Element> propertyElements) {
MultiStatusResponse resp = new MultiStatusResponse(res.getHref(), null);
while (propertyElements.hasNext()) {
Element propertyElem = propertyElements.next();
// retrieve the localName present in the "name" attribute
String nameAttr = propertyElem.getAttribute(ATTR_NAME);
if (nameAttr == null || "".equals(nameAttr)) {
// NOTE: this is not valid according to the DTD
continue;
}
// retrieve the namespace present in the "namespace" attribute
// NOTE: if this attribute is missing the DAV: namespace represents the default.
String namespaceAttr = propertyElem.getAttribute(ATTR_NAMESPACE);
Namespace namespace = (namespaceAttr != null) ? Namespace.getNamespace(namespaceAttr) : NAMESPACE;
DavPropertyName propName = DavPropertyName.create(nameAttr, namespace);
DavProperty<?> p = res.getProperty(propName);
if (p != null) {
if (p instanceof HrefProperty && res instanceof DeltaVResource) {
ElementIterator it = DomUtil.getChildren(propertyElem, XML_PROPERTY, NAMESPACE);
resp.add(new ExpandProperty((DeltaVResource) res, (HrefProperty) p, it));
} else {
resp.add(p);
}
} else {
resp.add(propName, DavServletResponse.SC_NOT_FOUND);
}
}
return resp;
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class PrincipalSearchReport method init.
/**
* @see Report#init(DavResource, ReportInfo)
*/
@Override
public void init(DavResource resource, ReportInfo info) throws DavException {
super.init(resource, info);
// make sure the request body contains all mandatory elements
if (!info.containsContentElement(XML_PROPERTY_SEARCH, SecurityConstants.NAMESPACE)) {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Request body must contain at least a single DAV:property-search element.");
}
List<Element> psElements = info.getContentElements(XML_PROPERTY_SEARCH, SecurityConstants.NAMESPACE);
searchArguments = new SearchArgument[psElements.size()];
int i = 0;
for (Element psElement : psElements) {
searchArguments[i++] = new SearchArgument(psElement);
}
if (info.containsContentElement(XML_APPLY_TO_PRINCIPAL_COLLECTION_SET, SecurityConstants.NAMESPACE)) {
HrefProperty p = new HrefProperty(resource.getProperty(SecurityConstants.PRINCIPAL_COLLECTION_SET));
searchRoots = p.getHrefs().toArray(new String[0]);
} else {
searchRoots = new String[] { resource.getHref() };
}
}
use of org.apache.jackrabbit.webdav.property.HrefProperty in project jackrabbit by apache.
the class RepositoryServiceImpl method resolveMergeConflict.
@Override
public void resolveMergeConflict(SessionInfo sessionInfo, NodeId nodeId, NodeId[] mergeFailedIds, NodeId[] predecessorIds) throws RepositoryException {
HttpProppatch request = null;
try {
List<HrefProperty> changeList = new ArrayList<HrefProperty>();
String[] mergeFailedHref = new String[mergeFailedIds.length];
for (int i = 0; i < mergeFailedIds.length; i++) {
mergeFailedHref[i] = getItemUri(mergeFailedIds[i], sessionInfo);
}
changeList.add(new HrefProperty(VersionControlledResource.AUTO_MERGE_SET, mergeFailedHref, false));
if (predecessorIds != null && predecessorIds.length > 0) {
String[] pdcHrefs = new String[predecessorIds.length];
for (int i = 0; i < predecessorIds.length; i++) {
pdcHrefs[i] = getItemUri(predecessorIds[i], sessionInfo);
}
changeList.add(new HrefProperty(VersionControlledResource.PREDECESSOR_SET, pdcHrefs, false));
}
request = new HttpProppatch(getItemUri(nodeId, sessionInfo), changeList);
initMethod(request, sessionInfo, !isUnLockMethod(request));
HttpResponse response = executeRequest(sessionInfo, request);
request.checkSuccess(response);
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
Aggregations