Wouter de Vaal wrote:
----- Original Message ----- From: "Alexander DEJANOVSKI" <[EMAIL PROTECTED]>
To: <xindice-users@xml.apache.org>
Sent: Friday, August 27, 2004 5:09 PM
Subject: Re: Renaming a collection
Wouter de Vaal wrote:
Is it possible to rename a collection that already exists and is filled with data ?
No. The trick we used in our project is to put a presentable name of the collection in MetaData and then let the collection real name be a generated unique one.
Regards, Wouter
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 ?