> >>So according to what I understand, it would be possible to change the > >>presentable name of the collection by changing it in the metadata ? > >>Since the name used to access the collection is the one stored in the > >>metadata, I want to change this one. > >>If it is indeed possible, would you mind showing me a piece of code that > >>does it ? > >> > >>Thanks, that would really help out here !! > >> > >> > >> > >> > >> > >this is basically all you need to do: > > > > //get name: > > CollectionImpl xindiceCol = > >(CollectionImpl)DatabaseManager.getCollection(collectionURI, username, > >password); > > > > MetaData metaData = xindiceCol.getMetaData(resource); > > String name = metaData.getAttribute("REALNAME"); > > > > //change name: > > name = "foo"; > > metaData.setType(MetaData.COLLECTION); > > metaData.setAttribute("REALNAME", name); > > > > > > xindiceCol.setMetaData(resource, metaData); > > > > > > > > > I tried that but can't make it work, and here's why : > > The collection I want to change the name of, is right under the /db > collection (its name is HausseTarifaire2004). > When I try to perform a : > > (CollectionImpl)DatabaseManager.getCollection("xmldb:xindice://myUrl/db", > username,password) > MetaData metaData = xindiceCol.getMetaData('HausseTarifaire2004'); > > I get the following exception : > > org.xmldb.api.base.XMLDBException: > org.xmldb.api.base.XMLDBException: :This Collection 'db' cannot store > Documents > > When I use "HausseTarifaire2004" as current collection , I don't know > how to access its metadata (since you must put the resource name as > parameter of the getMetaData method call). > > It seems (according to the javadocs) that metadata are accessible for > resources (XML files) but not (or at least not easily) for collections. > > Any idea here ? > > Ok I pasted some generic code of us that gets and sets meta data on both resources and collections, so I guess that's not entirely clear.
You should use: MetaData metaData = xindiceCol.getMetaData(null); instead of MetaData metaData = xindiceCol.getMetaData('HausseTarifaire2004'); and vice versa for setting metadata. xindiceCol.setMetaData(null, metaData); Wouter