import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.json.JSONException;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.ColorResources;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.Resources;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TermParser;
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TerminologyParser;
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch;
@Override
protected IStatus run(IProgressMonitor monitor) {
String response = new RequestTerminologies().request();
- availableOntologies = TerminologyParser.parse(response);
+ try {
+ availableOntologies = TerminologyParser.parse(response);
+ } catch (JSONException e) {
+ MessagingUtils.errorDialog("Loading ontologies failed", this, "Ontologies could not be found", TaxeditorStorePlugin.PLUGIN_ID, e, false);
+ e.printStackTrace();
+ }
return Status.OK_STATUS;
}
};
*
*/
public class TerminologyParser {
- public static Collection<TerminologyWrapper> parse(String response){
+ public static Collection<TerminologyWrapper> parse(String response) throws JSONException{
List<TerminologyWrapper> wrapperList = new ArrayList<>();
- try {
- JSONObject jsonResponse = new JSONObject(response);
- JSONArray responseArray = jsonResponse.getJSONArray("results");
- for(int i=0;i<responseArray.length();i++){
- JSONObject jsonObject = responseArray.getJSONObject(i);
- String name = jsonObject.getString("name");
- String acronym = jsonObject.getString("acronym");
- String description = ParserUtil.parseDescription(jsonObject);
- String uri = ParserUtil.parseUri(jsonObject);
- wrapperList.add(new TerminologyWrapper(name, acronym, description, uri));
- }
- } catch (JSONException e) {
- e.printStackTrace();
+ JSONObject jsonResponse = new JSONObject(response);
+ JSONArray responseArray = jsonResponse.getJSONArray("results");
+ for(int i=0;i<responseArray.length();i++){
+ JSONObject jsonObject = responseArray.getJSONObject(i);
+ String name = jsonObject.getString("name");
+ String acronym = jsonObject.getString("acronym");
+ String description = ParserUtil.parseDescription(jsonObject);
+ String uri = ParserUtil.parseUri(jsonObject);
+ wrapperList.add(new TerminologyWrapper(name, acronym, description, uri));
}
return wrapperList;
}