/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* CVS $Id: GetCollectionMeta.java,v 1.6 2004/02/08 02:54:17 vgritsenko Exp $
*/
package org.apache.xindice.server.rpc.messages;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.meta.MetaData;
import org.apache.xindice.server.rpc.RPCDefaultMessage;
import org.apache.xindice.xml.TextWriter;
import org.apache.xindice.xml.dom.DocumentImpl;
import org.w3c.dom.Document;
import java.util.Hashtable;
/**
* XML-RPC message to fetch the meta data associated with a document
*
* @author <a href="mailto:dviner@apache.org">Dave Viner</a>
* @version CVS $Revision: 1.6 $, $Date: 2004/02/08 02:54:17 $
*/
public class GetCollectionMeta extends RPCDefaultMessage {
/**
* Return the MetaData object for the requested collection.
*
* This method expects the Hashtable to contain the name of the collection
* in the RPCDefaultMessage.COLLECTION key. It will return an XML
* representation of the MetaData object associated with this collection.
* The XML will be stored in the RPCDefaultMessage.RESULT key.
*
* @param message the parameters passed to the xmlrpc method.
* @return Hashtable containing the XML for the requested MetaData object.
*/
public Hashtable execute(Hashtable message) throws Exception {
Collection col = getCollection((String) message.get(COLLECTION));
Hashtable result = new Hashtable();
if (!col.isMetaEnabled()) {
// meta information is not enabled !
throw new Exception(MISSING_META_CONFIGURATION);
}
MetaData meta = col.getCollectionMeta();
Document doc = new DocumentImpl();
doc.appendChild(meta.streamToXML(doc, true));
result.put(RESULT, TextWriter.toString(doc));
return result;
}
}