Revision fe281c15
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/specimen/SpecimenProviderSelectionComposite.java | ||
---|---|---|
14 | 14 |
import java.net.HttpURLConnection; |
15 | 15 |
import java.net.URL; |
16 | 16 |
import java.util.ArrayList; |
17 |
import java.util.HashSet; |
|
18 |
import java.util.Set; |
|
17 | 19 |
|
18 | 20 |
import org.eclipse.equinox.internal.p2.ui.misc.StringMatcher; |
19 | 21 |
import org.eclipse.jface.fieldassist.ComboContentAdapter; |
... | ... | |
36 | 38 |
import org.json.JSONException; |
37 | 39 |
import org.json.JSONObject; |
38 | 40 |
|
41 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
42 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
43 |
|
|
39 | 44 |
/** |
40 | 45 |
* @author pplitzner |
41 | 46 |
* @date 22.05.2014 |
... | ... | |
81 | 86 |
toolkit.adapt(btnBioCaseProvider, true, true); |
82 | 87 |
btnBioCaseProvider.setText("BioCASE Provider"); |
83 | 88 |
// txtAccessPoint = new Combo(this, SWT.BORDER); |
84 |
// CdmPreference biocaseProvider = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.BioCaseProvider); |
|
85 |
// if (biocaseProvider != null){ |
|
86 |
// String items[] = biocaseProvider.getValue().split(";"); |
|
87 |
// txtAccessPoint.setItems(items); |
|
88 |
// } |
|
89 |
// |
|
89 | 90 |
|
90 | 91 |
txtAccessPoint = new Combo(this, SWT.BORDER); |
91 |
|
|
92 |
Set<String> itemList = new HashSet<>(); |
|
92 | 93 |
URL url; |
93 | 94 |
String response = null; |
94 | 95 |
try { |
95 |
url = new URL("http://www.biocase.org/whats_biocase/gbif_biocase.cgi"); |
|
96 |
url = new URL("https://www.biocase.org/whats_biocase/gbif_biocase.cgi");
|
|
96 | 97 |
|
97 | 98 |
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
98 | 99 |
conn.setRequestProperty("Accept", "application/json"); |
... | ... | |
100 | 101 |
// conn.setReadTimeout(TIMEOUT*9); |
101 | 102 |
|
102 | 103 |
if (conn.getResponseCode() != 200) { |
103 |
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
|
|
104 |
//TODO
|
|
104 | 105 |
} |
105 | 106 |
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); |
106 | 107 |
|
... | ... | |
122 | 123 |
|
123 | 124 |
int i = 0; |
124 | 125 |
String service_url = null; |
125 |
items = new String[jsonResponseArray.length()]; |
|
126 |
|
|
127 |
// items = new String[jsonResponseArray.length()]; |
|
126 | 128 |
while (i<jsonResponseArray.length()){ |
127 | 129 |
JSONObject object = jsonResponseArray.getJSONObject(i); |
128 | 130 |
service_url = (String) object.get("service_url"); |
129 | 131 |
if (service_url != null){ |
130 |
txtAccessPoint.add(service_url); |
|
131 |
items[i] = service_url; |
|
132 |
if (itemList.add(service_url)){ |
|
133 |
txtAccessPoint.add(service_url); |
|
134 |
} |
|
135 |
// items[i] = service_url; |
|
132 | 136 |
} |
133 | 137 |
i++; |
134 | 138 |
} |
... | ... | |
137 | 141 |
// TODO Auto-generated catch block |
138 | 142 |
e.printStackTrace(); |
139 | 143 |
} |
140 |
|
|
144 |
String biocaseProvider = PreferencesUtil.getStringValue(PreferencePredicate.BioCaseProvider.getKey()); |
|
145 |
if (biocaseProvider != null){ |
|
146 |
String items[] = biocaseProvider.split(";"); |
|
147 |
for (String item: items){ |
|
148 |
if (itemList.add(item)){ |
|
149 |
txtAccessPoint.add(item); |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
items = new String[itemList.size()]; |
|
154 |
items = itemList.toArray(items); |
|
141 | 155 |
|
142 | 156 |
GridData dataProviderUri = new GridData(); |
143 | 157 |
dataProviderUri.horizontalAlignment = GridData.FILL; |
Also available in: Unified diff
ws for biocase provider moved