Skip to content

Instantly share code, notes, and snippets.

@ddbj-repo
Created December 14, 2017 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddbj-repo/4a1ea26e46bebac37cf595eae77e384a to your computer and use it in GitHub Desktop.
Save ddbj-repo/4a1ea26e46bebac37cf595eae77e384a to your computer and use it in GitHub Desktop.
import java.util.LinkedHashMap;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.HttpClientErrorException;
import net.arnx.jsonic.JSON;
/*
* (中略)
*/
/*
* 覚えておいた Request ID を使って GET する。
*/
String requestId = "wabi_blast_1111-1111-1111-11-111-111111";
MultiValueMap<String, String> parts = new LinkedMultiValueMap<String, String>();
parts.add("info", "status");
parts.add("format", "json");
try {
RestTemplate rest = new RestTemplate();
String response = rest.getForObject("http://ddbj.nig.ac.jp/wabi/blast/" + requestId, String.class, parts);
/*
---- response の例 (ここから) --------------------------------
{
"request-ID": "wabi_blast_1111-1111-1111-11-111-111111",
"status": "finished",
"current-time": "2013-01-01 12:34:56",
"system-info": "stdout"
}
---- response の例 (ここまで) --------------------------------
*/
LinkedHashMap<String, String> result = JSON.decode(response, LinkedHashMap.class);
String status = result.get("status");
/*
* ジョブの状態は status の値。 例: "waiting", "running", "finished"
*/
} catch (HttpClientErrorException e) {
/*
* 入力値エラー等。
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment