/*
* 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: RemoveCollection.java,v 1.10 2004/02/19 03:06:44 vgritsenko Exp $
*/
package org.apache.xindice.server.rpc.messages;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.FaultCodes;
import org.apache.xindice.server.rpc.RPCDefaultMessage;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.base.ErrorCodes;
import java.util.Hashtable;
/**
*
* @version CVS $Revision: 1.10 $, $Date: 2004/02/19 03:06:44 $
*/
public class RemoveCollection extends RPCDefaultMessage {
public Hashtable execute(Hashtable message) throws Exception {
final String parentName = (String) message.get(COLLECTION);
if (parentName == null) {
throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
FaultCodes.COL_COLLECTION_NOT_FOUND,
MISSING_COLLECTION_PARAM);
}
final String childName = (String) message.get(NAME);
if (childName == null || childName.length() == 0) {
throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
FaultCodes.COL_COLLECTION_NOT_FOUND,
MISSING_NAME_PARAM);
}
final Collection col = getCollection((String) message.get(COLLECTION));
if (col == null) {
// No such collection
throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
FaultCodes.COL_COLLECTION_NOT_FOUND,
"Cannot remove child collection '" + childName + "': Parent collection '" + parentName + "' not found.");
}
final Hashtable result = new Hashtable();
col.dropCollection(col.getCollection(childName));
result.put(RESULT, "yes");
return result;
}
}