Revision c520990d
Added by Andreas Kohlbecker over 7 years ago
src/main/java/org/bgbm/utis/controller/UtisController.java | ||
---|---|---|
27 | 27 |
import org.cybertaxonomy.utis.checklist.BaseChecklistClient; |
28 | 28 |
import org.cybertaxonomy.utis.checklist.BgbmEditClient; |
29 | 29 |
import org.cybertaxonomy.utis.checklist.DRFChecklistException; |
30 |
import org.cybertaxonomy.utis.checklist.EEA_BDC_Client; |
|
30 | 31 |
import org.cybertaxonomy.utis.checklist.PESIClient; |
31 | 32 |
import org.cybertaxonomy.utis.checklist.SearchMode; |
32 | 33 |
import org.cybertaxonomy.utis.checklist.WoRMSClient; |
33 | 34 |
import org.cybertaxonomy.utis.client.AbstractClient; |
35 |
import org.cybertaxonomy.utis.client.ClientFactory; |
|
34 | 36 |
import org.cybertaxonomy.utis.client.ServiceProviderInfo; |
35 | 37 |
import org.cybertaxonomy.utis.tnr.msg.Query; |
36 | 38 |
import org.cybertaxonomy.utis.tnr.msg.Query.ClientStatus; |
... | ... | |
68 | 70 |
private Map<String, ServiceProviderInfo> serviceProviderInfoMap; |
69 | 71 |
private Map<String, Class<? extends BaseChecklistClient>> clientClassMap; |
70 | 72 |
|
73 |
private final ClientFactory clientFactory = new ClientFactory(); |
|
74 |
|
|
71 | 75 |
private final List<ServiceProviderInfo> defaultProviders = new ArrayList<ServiceProviderInfo>(); |
72 | 76 |
|
73 | 77 |
public UtisController() throws ClassNotFoundException { |
... | ... | |
123 | 127 |
} |
124 | 128 |
|
125 | 129 |
defaultProviders.add(serviceProviderInfoMap.get(PESIClient.ID)); |
130 |
defaultProviders.add(serviceProviderInfoMap.get(EEA_BDC_Client.ID)); |
|
126 | 131 |
defaultProviders.add(serviceProviderInfoMap.get(BgbmEditClient.ID)); |
127 | 132 |
defaultProviders.add(serviceProviderInfoMap.get(WoRMSClient.ID)); |
128 | 133 |
} |
... | ... | |
186 | 191 |
} |
187 | 192 |
|
188 | 193 |
|
189 |
private BaseChecklistClient newClientFor(String id) { |
|
190 |
|
|
191 |
BaseChecklistClient instance = null; |
|
192 |
|
|
193 |
if(!clientClassMap.containsKey(id)){ |
|
194 |
logger.error("Unsupported Client ID: "+ id); |
|
195 |
|
|
196 |
} else { |
|
197 |
try { |
|
198 |
instance = clientClassMap.get(id).newInstance(); |
|
199 |
} catch (InstantiationException e) { |
|
200 |
// TODO Auto-generated catch block |
|
201 |
e.printStackTrace(); |
|
202 |
} catch (IllegalAccessException e) { |
|
203 |
// TODO Auto-generated catch block |
|
204 |
e.printStackTrace(); |
|
205 |
} |
|
206 |
} |
|
207 | 194 |
|
208 |
return instance; |
|
209 |
} |
|
210 | 195 |
|
211 | 196 |
@RequestMapping(method = { RequestMethod.GET }, value = "/capabilities") |
212 | 197 |
public @ResponseBody List<ServiceProviderInfo> capabilities(HttpServletRequest request, HttpServletResponse response) { |
... | ... | |
287 | 272 |
// query all providers |
288 | 273 |
List<ChecklistClientRunner> runners = new ArrayList<ChecklistClientRunner>(providerList.size()); |
289 | 274 |
for (ServiceProviderInfo info : providerList) { |
290 |
BaseChecklistClient client = newClientFor(info.getId());
|
|
275 |
BaseChecklistClient client = clientFactory.newClient(clientClassMap.get(info.getId()));
|
|
291 | 276 |
if(client != null){ |
292 | 277 |
logger.debug("sending query to " + info.getId()); |
293 | 278 |
ChecklistClientRunner runner = new ChecklistClientRunner(client, tnrMsg); |
Also available in: Unified diff
following the changes in utis-core, using now the ClientFactory