use of org.apache.jackrabbit.webdav.DavResourceLocator in project jackrabbit by apache.
the class LatestActivityVersionReport method init.
/**
* Check all the preconditions for this report.
*
* @throws DavException if a precondition is not met.
* @see Report#init(DavResource, ReportInfo)
*/
public void init(DavResource resource, ReportInfo info) throws DavException {
// validate info
if (!getType().isRequestedReportType(info)) {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:latest-activity-version element expected.");
}
// make sure the report is applied to a vh-resource
if (resource != null && (resource instanceof VersionHistoryResource)) {
vhResource = (VersionHistoryResource) resource;
} else {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:latest-activity-version report can only be created for a version history resource.");
}
// make sure the DAV:href element inside the request body points to
// an activity resource (precondition for this report).
String activityHref = DomUtil.getText(info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE));
DavResourceLocator vhLocator = resource.getLocator();
DavResourceLocator activityLocator = vhLocator.getFactory().createResourceLocator(vhLocator.getPrefix(), activityHref);
activity = resource.getFactory().createResource(activityLocator, resource.getSession());
if (!(activity instanceof ActivityResource)) {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:latest-activity-version report: The DAV:href in the request body MUST identify an activity.");
}
}
use of org.apache.jackrabbit.webdav.DavResourceLocator 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.DavResourceLocator in project jackrabbit by apache.
the class DavResourceImpl method getParentElements.
/**
* @see org.apache.jackrabbit.webdav.bind.BindableResource#getParentElements()
*/
public Set<ParentElement> getParentElements() {
try {
if (node.getDepth() > 0) {
Set<ParentElement> ps = new HashSet<ParentElement>();
NodeIterator sharedSetIterator = node.getSharedSet();
while (sharedSetIterator.hasNext()) {
Node sharednode = sharedSetIterator.nextNode();
DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), sharednode.getParent().getPath(), false);
ps.add(new ParentElement(loc.getHref(true), sharednode.getName()));
}
return ps;
}
} catch (UnsupportedRepositoryOperationException e) {
log.debug("unable to calculate parent set", e);
} catch (RepositoryException e) {
log.warn("unable to calculate parent set", e);
}
return Collections.emptySet();
}
use of org.apache.jackrabbit.webdav.DavResourceLocator in project jackrabbit by apache.
the class VersionHistoryItemCollection method getVersions.
//-----------------------------------< VersionHistoryResource interface >---
/**
* Return an array of {@link VersionResource}s representing all versions
* present in the underlying JCR version history.
*
* @return array of {@link VersionResource}s representing all versions
* present in the underlying JCR version history.
* @throws DavException
* @see org.apache.jackrabbit.webdav.version.VersionHistoryResource#getVersions()
*/
public VersionResource[] getVersions() throws DavException {
try {
VersionIterator vIter = ((VersionHistory) item).getAllVersions();
ArrayList<VersionResource> l = new ArrayList<VersionResource>();
while (vIter.hasNext()) {
DavResourceLocator versionLoc = getLocatorFromItem(vIter.nextVersion());
VersionResource vr = (VersionResource) createResourceFromLocator(versionLoc);
l.add(vr);
}
return l.toArray(new VersionResource[l.size()]);
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
use of org.apache.jackrabbit.webdav.DavResourceLocator in project jackrabbit by apache.
the class VersionItemCollection method getVersionHistory.
/**
* Returns the {@link VersionHistory} associated with the repository version.
* Note: in contrast to a versionable node, the version history of a version
* item is always represented by its nearest ancestor.
*
* @return the {@link VersionHistoryResource} associated with this resource.
* @throws org.apache.jackrabbit.webdav.DavException
* @see org.apache.jackrabbit.webdav.version.VersionResource#getVersionHistory()
* @see javax.jcr.Item#getParent()
*/
public VersionHistoryResource getVersionHistory() throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
try {
VersionHistory vh = getVersionHistoryItem();
DavResourceLocator loc = getLocatorFromItem(vh);
return (VersionHistoryResource) createResourceFromLocator(loc);
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
Aggregations