/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
* $Id: GetIndexerConfiguration.java 595817 2007-11-16 20:49:03Z vgritsenko $
*/
package org.apache.xindice.server.rpc.messages;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.indexer.Indexer;
import org.apache.xindice.server.rpc.RPCDefaultMessage;
import java.util.HashMap;
import java.util.Map;
/**
* Check if an indexer in a particular collection exists...
*
* Warning: this message is not used at all by the current XML-RPC client...
*
* @version $Revision: 595817 $, $Date: 2007-11-16 15:49:03 -0500 (Fri, 16 Nov 2007) $
*/
public class GetIndexerConfiguration extends RPCDefaultMessage {
public Map execute(Map message) throws Exception {
if (!message.containsKey(COLLECTION)) {
throw new Exception(MISSING_COLLECTION_PARAM);
}
Map result = new HashMap(3);
try {
Collection col = getCollection((String) message.get(COLLECTION));
if (col == null) {
// No such collection
result.put(RESULT, "no");
} else {
Indexer idx = col.getIndexer((String) message.get(NAME));
if (idx != null) {
result.put(RESULT, "yes");
} else {
result.put(RESULT, "no");
}
}
} catch (Exception e) {
// FIXME Error handling
result.put(RESULT, "no");
}
return result;
}
}