当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponseCodes.SC_OK属性代码示例

本文整理汇总了Java中org.jboss.resteasy.util.HttpResponseCodes.SC_OK属性的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseCodes.SC_OK属性的具体用法?Java HttpResponseCodes.SC_OK怎么用?Java HttpResponseCodes.SC_OK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.jboss.resteasy.util.HttpResponseCodes的用法示例。


在下文中一共展示了HttpResponseCodes.SC_OK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMessages

public void getMessages() 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverGetURL);
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "OpenId " + SubscriberOpenIdIdentifier);
   Response response = builder.post(null);
   response.close();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      throw new RuntimeException("Messages can not be received");
   }
   String message = response.readEntity(String.class);
   if (!"Hello !".equals(message))
   {
      throw new RuntimeException("Wrong Message");
   }
   System.out.println("Success : " + message);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:18,代码来源:Subscriber.java

示例2: registerMessagingServiceCallback

public void registerMessagingServiceCallback(String consumerKey, String callback)
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   Invocation.Builder builder = target.request();
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
      }
   }
   catch (Exception ex) {
      throw new RuntimeException("Callback Registration failed");
   }
   finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:22,代码来源:SubscriberReceiver.java

示例3: produceMessages

public void produceMessages()
{
  WebTarget target = ClientBuilder.newClient().target(MessagingServiceMessagesURL);
  Invocation.Builder builder = target.request();
  String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
  builder.header("Authorization", "Basic " + base64Credentials);
  Response response = null;
  try {
     response = builder.post(Entity.entity("Hello2 !", MediaType.TEXT_PLAIN_TYPE));
     if (HttpResponseCodes.SC_OK != response.getStatus()) {
        throw new RuntimeException("Messages can not be sent");
     }
  }
  catch (Exception ex) {
     throw new RuntimeException("Messages can not be sent");
  }
  finally {
     response.close();
  }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:20,代码来源:SubscriberReceiver.java

示例4: registerMessagingService

public String registerMessagingService(String consumerKey) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   
   Entity<Form> formEntity = Entity.form(new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey));
   Response response = null;
   try {
      response = builder.post(formEntity);
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Registration failed");
      }
      // check that we got all tokens
      Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
      String secret = tokens.get("xoauth_consumer_secret");
      if (secret == null) {
          throw new RuntimeException("No secret available");
      }
      return secret;
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:25,代码来源:Subscriber.java

示例5: registerMessagingServiceScopes

public void registerMessagingServiceScopes(String consumerKey, String scope) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(ConsumerScopesRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
   form.param("xoauth_scope", scope);
   form.param("xoauth_permission", "sendMessages");
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Scopes can not be registered");
      }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:19,代码来源:Subscriber.java

示例6: registerMessagingServiceCallback

public void registerMessagingServiceCallback(String consumerKey, String consumerSecret, String callback) 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("consumer_secret", consumerSecret);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
     }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:20,代码来源:Subscriber.java

示例7: produceMessages

public void produceMessages() 
   throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceMessagesURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.post(Entity.entity("Hello", MediaType.TEXT_PLAIN_TYPE));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be sent");
      }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:17,代码来源:Subscriber.java

示例8: getMessages

public void getMessages() 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverGetURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.get();
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be received");
      }
      String message = response.readEntity(String.class);
      if (!"Hello !".equals(message))
      {
         throw new RuntimeException("Wrong Message");
      }
      System.out.println("Success : " + message);
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:23,代码来源:Subscriber.java

示例9: getMessagesFromSubscriberReceiver

public void getMessagesFromSubscriberReceiver() throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverSubscriberGetURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.get();
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be received");
      }
      String message = response.readEntity(String.class);
      if (!"Hello2 !".equals(message))
      {
         throw new RuntimeException("Wrong Message");
      }
      System.out.println("Message from the subscriber-receiver : " + message);
   } finally {
      response.close();
   }
 }
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:22,代码来源:Subscriber.java

示例10: accessEndUserResource

private static void accessEndUserResource(String relativeURI) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(EndUserResourceURL + relativeURI);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   target.request().header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try
   {
      response = target.request().get();
      if ("/invisible".equals(relativeURI)) {
         if (response.getStatus() != 401) {
            throw new RuntimeException("End user can access the invisible resource");
         } else {
            return;
         }
      }
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("End user can not access its own resources");
     }
     System.out.println("End user resource : " + response.getEntity());
   }
   finally
   {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:26,代码来源:EndUser.java

示例11: getSharedSecret

public String getSharedSecret(String consumerKey) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
   Invocation.Builder builder = target.request();
   Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
   Entity<Form> formEntity = Entity.form(form);
   Response response = builder.post(formEntity);
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      response.close();
      throw new RuntimeException("Registration failed");
   }
   // check that we got all tokens
   Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
   String secret = tokens.get("xoauth_consumer_secret");
   if (secret == null) {
      throw new RuntimeException("No secret available");
   }
   return secret;
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:19,代码来源:ConsumerResource.java

示例12: getRequestToken

public Token getRequestToken(String consumerKey, String consumerSecret, 
                             String callbackURI, String scope, String permission) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(getRequestURL(consumerKey, consumerSecret, callbackURI, scope, permission));
   Response response = target.request().get();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      response.close();
      throw new RuntimeException("Request token can not be obtained");
   }
   // check that we got all tokens
   Map<String, String> tokens = getTokens(response.readEntity(String.class));
   if (tokens.size() != 3
         || !tokens.containsKey(OAuth.OAUTH_TOKEN)
         || !(tokens.get(OAuth.OAUTH_TOKEN).length() > 0)
         || !tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET)
         || !(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0)
         || !tokens.containsKey(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM)
         || !tokens.get(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM).equals("true")) {
      throw new RuntimeException("Wrong request token details");
   }

   return new Token(tokens.get(OAuth.OAUTH_TOKEN), tokens.get(OAuth.OAUTH_TOKEN_SECRET));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:23,代码来源:ConsumerResource.java

示例13: getAccessToken

public Token getAccessToken(String consumerKey, String consumerSecret,
        Token requestToken) throws Exception
{
   String url = getAccessURL(consumerKey, consumerSecret, 
                             requestToken.getToken(), requestToken.getSecret(),
                             requestToken.getVerifier());
   WebTarget target = ClientBuilder.newClient().target(url);
   Response response = target.request().get();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      response.close();
      throw new RuntimeException("Request token can not be obtained");
   }
   // check that we got all tokens
   Map<String, String> tokens = getTokens(response.readEntity(String.class));
   if (tokens.size() != 2
         || !tokens.containsKey(OAuth.OAUTH_TOKEN)
         || !(tokens.get(OAuth.OAUTH_TOKEN).length() > 0)
         || !tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET)
         || !(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0)) {
      throw new RuntimeException("Wrong access token details");
   }

   return new Token(tokens.get(OAuth.OAUTH_TOKEN), tokens.get(OAuth.OAUTH_TOKEN_SECRET));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:24,代码来源:ConsumerResource.java

示例14: sendMessage

public void sendMessage(String callbackURI, String messageSenderId, String message) {
   Response response = null;
   try
   {
      WebTarget target = ClientBuilder.newClient().target(getPushMessageURL(callbackURI, messageSenderId));
      response = target.request().post(Entity.entity(message, MediaType.TEXT_PLAIN_TYPE));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Message can not be delivered to subscribers");
      }
   } catch (Exception ex) 
   {
       throw new RuntimeException("Message can not be delivered to subscribers");
   } finally
   {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:17,代码来源:OAuthMessageSender.java

示例15: getResponseContent

public byte[] getResponseContent(HttpResponse httpResponse) throws IOException {
       if ((httpResponse == null) || (httpResponse.getStatusLine().getStatusCode() != HttpResponseCodes.SC_OK)) {
       	return null;
       }

       HttpEntity entity = httpResponse.getEntity();
	byte[] responseBytes = new byte[0];
	if (entity != null) {
		responseBytes = EntityUtils.toByteArray(entity);
	}

   	// Consume response content
	if (entity != null) {
		EntityUtils.consume(entity);
	}

   	return responseBytes;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:18,代码来源:HttpService.java


注:本文中的org.jboss.resteasy.util.HttpResponseCodes.SC_OK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。