You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Gbenga Bello <rg...@yahoo.com> on 2004/03/16 17:11:44 UTC

Can Someone give me help on implementating the Document Versioning capability of the WebDav using Slide

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

Re: Can Someone give me help on implementating the Document Versioning capability of the WebDav using Slide

Posted by Gbenga Bello <rg...@yahoo.com>.
Hello Stan,
 
I thank you so much for this million us dollar help.
 
I will try out the code and feed you back soon
 
once again I thank you greatly.
 
Your friend,
 
Cogi

Stan Pinte <st...@axone.be> wrote:
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: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org

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

Re: Can Someone give me help on implementating the Document Versioning capability of the WebDav using Slide

Posted by Stan Pinte <st...@axone.be>.
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: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org