Differences between revisions 8 and 9
Revision 8 as of 2004-11-05 00:39:29
Size: 3643
Editor: BrianLee
Comment:
Revision 9 as of 2009-09-20 22:02:35
Size: 3645
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
 1.Enabling binding for a store is simple. It is done by referencing the [http://jakarta.apache.org/slide/javadoc-2.1/javadoc/org/apache/slide/store/BindingStore.html org.apache.slide.store.BindingStore] implementation through the classname attribute of the store element when configuring the store in Domain.xml:  1.Enabling binding for a store is simple. It is done by referencing the [[http://jakarta.apache.org/slide/javadoc-2.1/javadoc/org/apache/slide/store/BindingStore.html|org.apache.slide.store.BindingStore]] implementation through the classname attribute of the store element when configuring the store in Domain.xml:

Binding Demo

Setup:

  • 1.Enabling binding for a store is simple. It is done by referencing the org.apache.slide.store.BindingStore implementation through the classname attribute of the store element when configuring the store in Domain.xml:

<store name="mystore" classname="org.apache.slide.store.BindingStore">
    <nodestore classname=...>
        ...
    </nodestore>
    ...
</store>

For more information on the domain.xml file see DomainConfig.

  • 2.Set org.apache.slide.binding=true in the configuration file slide.properties.

"The properties file is in one of the slide server jars (the slide kernel jar?). So if you want to change the slide.properties then extract it from the archive and put it into the slide/WEB-INF/classes dir so that it overrides the properties in the jar."

For more information on the slide.properties file see SlidePropertiesFile.

IMPORTANT NOTE: Under no circumstances the binding configuration of a store should be changed from disabled to enabled, or vice-versa, while the store contains data, as no migration of the data will take place!

Thanks to Warwick Burrows and Neil Padgen (or whoever first posted the example below in the mailing list)

Example

package testing;

import javax.ejb.EJBException;

import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpURL;
import org.apache.webdav.lib.WebdavResource;

public class PutSomethingInSlide {

    public static void main(String[] args) throws Exception
    {
        WebdavResource container = null;
        HttpURL url = new HttpURL("http://localhost:8080/slide/files/");
        url.setUserinfo("root", "root");
        container = new WebdavResource(url);
        if (container == null)
        {
            throw new Exception("Container WebdavResource is null!");
        }
        container.putMethod("/slide/files/hello.txt", "Hello world\n");
        url = new HttpURL("http://localhost:8080/slide/files/hello.txt");
        url.setUserinfo("root", "root");
        WebdavResource item = new WebdavResource(url);
        if (item == null)
        {
            throw new Exception("Item WebdavResource is null!");
        }

        // now let's try binding it to another name
        boolean result = item.bindMethod("/slide/files/helloagain.txt");
        System.out.println("bindMethod result: " + result);
        url = new HttpURL("http://localhost:8080/slide/files/helloagain.txt");
        url.setUserinfo("root", "root");
        try
        {
            WebdavResource boundItem = new WebdavResource(url);
            System.out.println("boundItem existence: " + boundItem.getExistence());
        }
        catch (HttpException e)
        {
            System.out.println("no boundItem: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

Display

You should now be able to see a hello.txt and helloagain.txt under files from your WebDAV client software.

Useful Notes: Based on my limited experience (someone please correct me if I'm wrong), you can only bind file resources to a binding that points to an existing directory. For example, if your Slide directory structure is:

files/items files/stuff

Inside the 'files' directory is 'blah.txt'. You can bind 'blah.txt' as 'files/items/cools.txt' or 'files/stuff/cools.txt', but not as 'files/brian/cools.txt' because the 'brian' folder does not exist.

BindingDemo (last edited 2009-09-20 22:02:35 by localhost)