+ * Alternative that uses java.net not apache http client
+ * @param command
+ * @return
+ */
+ protected List<String> sendRestCommandForJS(String command)
+ {
+ List<String> reply = new ArrayList<>();
+ BufferedReader response = null;
+ try
+ {
+ String encoded = URLEncoder.encode(command, "UTF-8");
+ URL url = new URL("http://127.0.0.1:" + this.chimeraRestPort + "/run?command="+encoded);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod(HttpMethod.GET);
+ connection.setDoInput(true);
+ InputStream is = connection.getInputStream();
+ // JalviewJS can't read response without access-control-allow-origin * header
+ if (!Platform.isJS())
+ {
+ response = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ String line = "";
+ while ((line = response.readLine()) != null)
+ {
+ reply.add(line);
+ }
+ }
+ } catch (Exception e)
+ {
+ logger.error("REST call '" + command + "' failed: " + e.getMessage());
+ } finally
+ {
+ if (response != null)
+ {
+ try
+ {
+ response.close();
+ } catch (IOException e)
+ {
+ }
+ }
+ }
+ return reply;
+ }
+
+ /**