// datasource
DataSource ds = config.getDataSource(storage,null);
if(ds!=null) {
if(ds.isStorage())return storage;
throw new ApplicationException("datasource ["+storage+"] is not enabled to be used as session/client storage");
}
// cache
CacheConnection cc = Util.getCacheConnection(config, storage,null);
if(cc!=null) {
if(cc.isStorage())return storage;
throw new ApplicationException("cache ["+storage+"] is not enabled to be used as session/client storage");
}
String sdx=StringUtil.soundex(storage);
// check if a datasource has a similar name
DataSource[] sources = config.getDataSources();
for(int i=0;i<sources.length;i++){
if(StringUtil.soundex(sources[i].getName()).equals(sdx))
throw new ApplicationException("no matching storage for ["+storage+"] found, did you mean ["+sources[i].getName()+"]");
}
// check if a cache has a similar name
Iterator<String> it = config.getCacheConnections().keySet().iterator();
String name;
while(it.hasNext()){
name=it.next();
if(StringUtil.soundex(name).equals(sdx))
throw new ApplicationException( "no matching storage for ["+storage+"] found, did you mean ["+name+"]");
}
throw new ApplicationException("no matching storage for ["+storage+"] found");
}