本文整理汇总了Java中org.jboss.resteasy.client.ClientResponse.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse.getStatus方法的具体用法?Java ClientResponse.getStatus怎么用?Java ClientResponse.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.resteasy.client.ClientResponse
的用法示例。
在下文中一共展示了ClientResponse.getStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NubankImportador
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public NubankImportador(){
ClientConnectionManager cm = new ThreadSafeClientConnManager();
DefaultHttpClient httpClient = new DefaultHttpClient(cm);
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
authApi = ProxyFactory.create(NubankAPI.class, "https://prod-auth.nubank.com.br", executor);
costumersApi = ProxyFactory.create(NubankAPI.class, "https://prod-customers.nubank.com.br", executor);
accountsApi = ProxyFactory.create(NubankAPI.class, "https://prod-accounts.nubank.com.br", executor);
ClientResponse<RegistrationResp> resp = authApi.register(RegistrationReq.asNubank());
if(resp.getStatus() != RegistrationResp.SUCCESS_CODE){
throw new RuntimeException("Erro registrando api. Status code = "+resp.getStatus());
// System.out.println(resp.getEntity().getClient_id());
// System.out.println(resp.getEntity().getClient_secret());
}
this.regResp = resp.getEntity();
// api.token(TokenReq.create(resp.getEntity()));
}
示例2: initialize
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
protected void initialize() throws Exception {
super.start();
initialized = true;
initAuthentication();
ClientRequest request = executor.createRequest(registration.getTarget().getHref());
for (XmlHttpHeader header : registration.getHeaders()) {
request.header(header.getName(), header.getValue());
}
ClientResponse<?> res = request.head();
if (res.getStatus() != 200) {
throw new RuntimeException("Failed to query REST destination for init information. Status: " + res.getStatus());
}
String url = (String) res.getHeaders().getFirst("msg-create-with-id");
if (url == null) {
if (res.getLinkHeader() == null) {
throw new RuntimeException("Could not find create-with-id URL");
}
Link link = res.getLinkHeader().getLinkByTitle("create-with-id");
if (link == null) {
throw new RuntimeException("Could not find create-with-id URL");
}
url = link.getHref();
}
targetUri = ResteasyUriBuilder.fromTemplate(url);
}
示例3: main
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length < 1 || args[0] == null)
throw new RuntimeException("You must pass in a parameter");
// first get the create URL for the shipping queue
ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
ClientResponse res = request.head();
Link create = res.getHeaderAsLink("msg-create-with-id");
Order order = new Order();
order.setName(args[0]);
order.setItem("iPhone4");
order.setAmount("$199.99");
res = create.request().pathParameter("id", args[0]).body("application/xml", order).post();
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
System.out.println("Sent order " + args[0]);
}
示例4: main
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// first get the create URL for the shipping queue
ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
ClientResponse res = request.head();
Link pullConsumers = res.getHeaderAsLink("msg-pull-consumers");
res.releaseConnection();
res = pullConsumers.request().post();
Link consumeNext = res.getHeaderAsLink("msg-consume-next");
res.releaseConnection();
while (true) {
System.out.println("Waiting...");
res = consumeNext.request().header("Accept-Wait", "10").post();
if (res.getStatus() == 503) {
System.out.println("Timeout...");
consumeNext = res.getHeaderAsLink("msg-consume-next");
} else if (res.getStatus() == 200) {
Order order = (Order) res.getEntity(Order.class);
System.out.println(order);
consumeNext = res.getHeaderAsLink("msg-consume-next");
} else {
throw new RuntimeException("Failure! " + res.getStatus());
}
res.releaseConnection();
}
}
示例5: main
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// first get the create URL for the shipping queue
ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
ClientResponse res = request.head();
Link create = res.getHeaderAsLink("msg-create");
System.out.println("Send order...");
Order order = new Order();
order.setName("Bill");
order.setItem("iPhone4");
order.setAmount("$199.99");
res = create.request().body("application/xml", order).post();
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
}
示例6: main
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// first get the create URL for the shipping queue
ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
ClientResponse res = request.head();
Link pullConsumers = res.getHeaderAsLink("msg-pull-consumers");
res = pullConsumers.request().formParameter("autoAck", "false").post();
Link ackNext = res.getHeaderAsLink("msg-acknowledge-next");
res.releaseConnection();
while (true) {
System.out.println("Waiting...");
res = ackNext.request().header("Accept-Wait", "10").header("Accept", "application/xml").post();
if (res.getStatus() == 503) {
System.out.println("Timeout...");
ackNext = res.getHeaderAsLink("msg-acknowledge-next");
} else if (res.getStatus() == 200) {
Order order = (Order) res.getEntity(Order.class);
System.out.println(order);
Link ack = res.getHeaderAsLink("msg-acknowledgement");
res = ack.request().formParameter("acknowledge", "true").post();
ackNext = res.getHeaderAsLink("msg-acknowledge-next");
} else {
throw new RuntimeException("Failure! " + res.getStatus());
}
res.releaseConnection();
}
}
示例7: login
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public boolean login(String username, String password) {
ClientResponse<TokenResp> resp = authApi.token(new TokenReq(regResp,username,password));
if(resp.getStatus() == 403){
return false;
}
if(resp.getStatus() != TokenResp.SUCCESS_CODE){
throw new RuntimeException("Erro fazendo login. Status code = "+resp.getStatus());
}
this.token = resp.getEntity();
this.authBearer = token.getToken_type().substring(0, 1).toUpperCase()+token.getToken_type().substring(1).toLowerCase()+" "+token.getAccess_token();
this.costumer = null;
return true;
}
示例8: handleResponse
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
protected void handleResponse(ClientResponse response) {
if (response != null) {
int status = response.getStatus();
response.releaseConnection();
if (status >= 400) {
throw new OperationFailedException(status,
"Operation failed. See server log messages.");
}
}
}
示例9: main
import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// first get the create URL for the shipping queue
ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
ClientResponse res = request.head();
Link create = res.getHeaderAsLink("msg-create");
System.out.println("Send Bill's order...");
Order order = new Order();
order.setName("Bill");
order.setItem("iPhone4");
order.setAmount("$199.99");
res = create.request().body("application/xml", order).post();
if (res.getStatus() == 307) {
Link redirect = res.getLocationLink();
res.releaseConnection();
res = redirect.request().body("application/xml", order).post();
}
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
create = res.getHeaderAsLink("msg-create-next");
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
System.out.println("Send Monica's order...");
order.setName("Monica");
res.releaseConnection();
res = create.request().body("application/xml", order).post();
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
System.out.println("Resend Monica's order over same create-next link...");
res.releaseConnection();
res = create.request().body("application/xml", order).post();
if (res.getStatus() != 201)
throw new RuntimeException("Failed to post");
}