use of org.apache.jackrabbit.webdav.version.VersionResource in project jackrabbit by apache.
the class VersionHistoryResourceImpl method getVersions.
// ---------------------------------------------< VersionHistoryResource >---
/**
* Return an array of {@link org.apache.jackrabbit.webdav.version.VersionResource}s representing all versions
* present in the underlying JCR version history.
*
* @return array of {@link org.apache.jackrabbit.webdav.version.VersionResource}s representing all versions
* present in the underlying JCR version history.
* @throws org.apache.jackrabbit.webdav.DavException
* @see org.apache.jackrabbit.webdav.version.VersionHistoryResource#getVersions()
*/
public VersionResource[] getVersions() throws DavException {
try {
VersionIterator vIter = ((VersionHistory) getNode()).getAllVersions();
ArrayList<VersionResource> l = new ArrayList<VersionResource>();
while (vIter.hasNext()) {
DavResourceLocator versionLoc = getLocatorFromNode(vIter.nextVersion());
DavResource vr = createResourceFromLocator(versionLoc);
if (vr instanceof VersionResource) {
l.add((VersionResource) vr);
} else {
// severe error since resource factory doesn't behave correctly.
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
return l.toArray(new VersionResource[l.size()]);
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
use of org.apache.jackrabbit.webdav.version.VersionResource 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.version.VersionResource 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.version.VersionResource in project jackrabbit by apache.
the class CompareBaselineReport method toXml.
/**
* @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
*/
public Element toXml(Document document) {
Element el = DomUtil.createElement(document, XML_COMPARE_BASELINE_REPORT, DeltaVConstants.NAMESPACE);
try {
// TODO: check if correct
List<VersionResource> requestVs = new ArrayList<VersionResource>();
getVersions(requestBaseline.getBaselineCollection(), requestVs);
List<VersionResource> compareVs = new ArrayList<VersionResource>();
getVersions(compareBaseline.getBaselineCollection(), compareVs);
for (VersionResource requestV : requestVs) {
if (!compareVs.remove(requestV)) {
// check if another version of the same vh is present (change)
VersionResource changedV = findChangedVersion(requestV, compareVs);
if (changedV != null) {
// found a 'changed-version' entry
Element cv = DomUtil.addChildElement(el, XML_CHANGED_VERSION, DeltaVConstants.NAMESPACE);
cv.appendChild(DomUtil.hrefToXml(requestV.getHref(), document));
cv.appendChild(DomUtil.hrefToXml(changedV.getHref(), document));
} else {
// no corresponding version => 'deleted-version'
Element cv = DomUtil.addChildElement(el, XML_DELETED_VERSION, DeltaVConstants.NAMESPACE);
cv.appendChild(DomUtil.hrefToXml(requestV.getHref(), document));
}
}
// else: both baseline contain a vc-resource with the same checked-in version
}
// to be added-versions.
for (VersionResource addedV : compareVs) {
Element cv = DomUtil.addChildElement(el, XML_ADDED_VERSION, DeltaVConstants.NAMESPACE);
cv.appendChild(DomUtil.hrefToXml(addedV.getHref(), document));
}
} catch (DavException e) {
log.error("Internal error while building report", e);
}
return el;
}
Aggregations