// BridgeDb,
// An abstraction layer for identifer mapping services, both local and online.
// Copyright 2006-2009 BridgeDb developers
//
// 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.
//
package org.bridgedb.rest;

import java.util.List;

import org.bridgedb.DataSource;
import org.bridgedb.bio.GdbProvider;
import org.bridgedb.bio.Organism;
import org.bridgedb.rdb.IDMapperRdb;
import org.restlet.resource.ServerResource;

/**
 * Base resource implementation that provides methods shared
 * between the idmapper resources (such as access to the IDMapper objects).
 */
public class IDMapperResource extends ServerResource {
	protected DataSource parseDataSource(String dsName) {
		if(dsName == null) return null;
		DataSource ds = DataSource.getBySystemCode(dsName);
		if(ds == null) {
			ds = DataSource.getByFullName(dsName);
		}
		return ds;
	}
	
	protected List<IDMapperRdb> getIDMappers(String orgName) {
		Organism org = Organism.fromLatinName(orgName);
		if(org == null) { //Fallback on code
			org = Organism.fromCode(orgName);
		}
		if(org == null) { //Fallback on shortname
			org = Organism.fromShortName(orgName);
		}
		if(org == null) {
			throw new IllegalArgumentException("Unknown organism: " + orgName);
		}
		return getGdbProvider().getGdbs(org);
	}
	
	private GdbProvider getGdbProvider() {
		return ((IDMapperService)getApplication()).getGdbProvider();
	}
}

@@ -1720,53 +1720,421 @@
 Name
-);%0A%09%09%7D%0A%09%09return getGdbProvider().getGdbs(org)
+ + %22%3Cp%3E%3Cfont size='+1'%3E%3Ci%3EDouble check the spelling. We are expecting an entry like: Human%3C/i%3E%3C/font%3E%3C/p%3E%22);%0A%09%09%7D%0A%09%09List%3CIDMapperRdb%3E mappers = getGdbProvider().getGdbs(org);%0A%09%09if (mappers.isEmpty())%7B%0A%09%09%09throw new IllegalArgumentException(%22No database found for: %22 + orgName +%22%3Cp%3E%3Cfont size='+1'%3E%3Ci%3EVerify that the database is supported and properly referenced in gdb.config.%3C/i%3E%3C/font%3E%3C/p%3E%22);%0A%09%09%7D%0A%09%09return mappers
 ;%0A%09%7D

fix #32