Gbenga Bello wrote:

Hello List

Please I would need some help on how to implement the versioning capability of the Webdav using Slide.

I will gracefully appreciate links to webpages or sample codes that could give a simple insight on how to navigate my way successfully.

I thank you all in advance

COGI

Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam



to get the version history of a resource:


public static String getCurrentVersion(String resourceUrl) throws Exception
{
HttpURL httpUrl = new HttpURL(slideHostPort + slideAppContext + resourceUrl);
log.info("getting history for url: [" + httpUrl + "]");
Vector properties = new Vector();
Enumeration report = getCollection().reportMethod(httpUrl, properties, 2);
List versions = new ArrayList();
while (report.hasMoreElements())
{
String version = (String)report.nextElement();
log.debug("version: [" + version + "]");
versions.add(version);
}
//sort the versions
Collections.sort(versions, new VersionComparator());
return (String)versions.get(versions.size() - 1);
}
public static WebdavResource getCollection() throws Exception
{
String resourceUrl = slideHostPort + slideAppContext + getDavDocumentPath();
HttpURL url = new HttpURL(resourceUrl);
url.setUserInfo(slideUser, slidePassword);
return new WebdavResource(url);
}


to update the version:

public static String updateVersion(DocumentForm form) throws Exception
{
FormFile file = form.getFile();
String path = slideAppContext + form.getDocUrl();
boolean succeeded = false;
WebdavResource resource = getCollection();
log.info("Version Controlling: " + path + " in resource: " + resource.getPath());
//will issue a versioncontrol each time, just in case the resource would not be version controlled.
//hope this will not be a problem.
succeeded = resource.versionControlMethod(path);
throwIfNot(succeeded, resource.getStatusMessage());
//checkout
succeeded = resource.checkoutMethod(path);
throwIfNot(succeeded, resource.getStatusMessage());
//update
succeeded = resource.putMethod(path, file.getInputStream());
throwIfNot(succeeded, resource.getStatusMessage());
//checkin
succeeded = resource.checkinMethod(path);
throwIfNot(succeeded, resource.getStatusMessage());
return getCurrentVersion(form.getDocUrl());
}


hope this helps

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to