org.restlet.data.Response.getStatus()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.restlet.data.Response.getStatus方法的一些代码示例,展示了Response.getStatus的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getStatus方法的具体详情如下:
包路径:org.restlet.data.Response
类名称:Response
方法名:getStatus

Response.getStatus介绍

[英]Returns the status.
[中]

代码示例

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

/**
 * Extract status from response
 */
public Status extractStatus(final Response response)
  throws IOException
{
 Status status = response.getStatus();
 assertThat(status, notNullValue());
 return status;
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

@Override
protected boolean matchesSafely(Response item) {
 Status status = item.getStatus();
 assertThat(status, notNullValue());
 return status.isRedirection();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-utils

@Override
protected boolean matchesSafely( Response item )
{
  return item.getStatus().getCode() == expectedStatusCode;
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-utils

@Override
protected boolean matchesSafely( Response resp )
{
  return resp.getStatus().isError();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static Status run( String taskId )
  throws IOException
{
  String serviceURI = "service/local/schedule_run/" + taskId;
  Response response = RequestFacade.doGetRequest( serviceURI );
  return response.getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-utils

@Override
protected boolean matchesSafely( Response item )
{
  Status status = item.getStatus();
  assertThat( status, notNullValue() );
  return status.isRedirection();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public RoleResource getRole( String roleId )
  throws IOException
{
  Response response = this.sendMessage( Method.GET, null, roleId );
  if ( !response.getStatus().isSuccess() )
  {
    Assert.fail( "Could not find role: " + roleId + " got: " + response.getStatus() );
  }
  // get the Resource object
  return this.getResourceFromResponse( response );
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public List<PrivilegeStatusResource> createPrivileges( PrivilegeResource resource ) throws IOException
{
  Response response = this.sendMessage( Method.POST, resource );
  if ( !response.getStatus().isSuccess() )
  {
    Assert.fail( "Could not create privilege: " + response.getStatus() );
  }
  // get the Resource object
  List<PrivilegeStatusResource> statusResources = this.getResourceListFromResponse( response );
  SecurityConfigUtil.verifyPrivileges( statusResources );
  return statusResources;
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

/**
 * Use {@link #getResourceFromText(String)} instead.
 */
@Deprecated
public RepositoryRouteResource getResourceFromResponse(Response response)
  throws IOException
{
 String responseString = response.getEntity().getText();
 LOG.debug("responseText: " + responseString);
 Assert.assertTrue(response.getStatus() + "\n" + responseString, response.getStatus().isSuccess());
 return getResourceFromText(responseString);
}

代码示例来源:origin: org.restlet/org.restlet.ext.atom

/**
 * Updates a resource representation.
 * 
 * @param uri
 *            The resource URI.
 * @return The resource representation.
 */
public Status updateResource(String uri,
    Representation updatedRepresentation) {
  return getClientDispatcher().put(uri, updatedRepresentation)
      .getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public List<PrivilegeStatusResource> getList(  ) throws IOException
{
  Response response = this.sendMessage( Method.GET, null );
  if ( !response.getStatus().isSuccess() )
  {
    Assert.fail( "Could not get Privilege: " + response.getStatus() +"\n" + response.getEntity().getText());
  }
  return this.getResourceListFromResponse( response );
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public RoleResource findRole( String roleId )
  throws IOException
{
  Response response = this.sendMessage( Method.GET, null, roleId );
  if ( !response.getStatus().isSuccess() )
  {
    return null;
  }
  // get the Resource object
  return this.getResourceFromResponse( response );
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

public Status recoverUsername(String email)
  throws Exception
{
 String serviceURI = "service/local/users_forgotid/" + email;
 XStreamRepresentation representation = new XStreamRepresentation(xstream, "", MediaType.APPLICATION_XML);
 representation.setPayload(null);
 return RequestFacade.sendMessage(serviceURI, Method.POST, representation).getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static void removeAllTarget()
  throws IOException
{
  List<RepositoryTargetListResource> targets = getList();
  for ( RepositoryTargetListResource target : targets )
  {
    Status status =
      RequestFacade.sendMessage( "service/local/repo_targets/" + target.getId(), Method.DELETE ).getStatus();
    Assert.assertTrue( "Failt to delete: " + status.getDescription(), status.isSuccess() );
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static void removeAllRoutes()
  throws IOException
{
  List<RepositoryRouteListResource> routes = getList();
  for ( RepositoryRouteListResource route : routes )
  {
    Status status = delete( route.getResourceURI() ).getStatus();
    Assert.assertTrue( "Unable to delete route: '" + route.getResourceURI() + "', due to: "
      + status.getDescription(), status.isSuccess() );
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static Status save( GlobalConfigurationResource globalConfig )
  throws IOException
{
  String serviceURI = "service/local/global_settings/current";
  GlobalConfigurationResourceResponse configResponse = new GlobalConfigurationResourceResponse();
  configResponse.setData( globalConfig );
  XStreamRepresentation representation = new XStreamRepresentation( xstream, "", MediaType.APPLICATION_XML );
  representation.setPayload( configResponse );
  Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation );
  return response.getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static Status update( ScheduledServiceBaseResource task )
  throws IOException
{
  ScheduledServiceResourceResponse request = new ScheduledServiceResourceResponse();
  request.setData( task );
  XStreamRepresentation representation = new XStreamRepresentation( xstream, "", MediaType.APPLICATION_XML );
  representation.setPayload( request );
  String serviceURI = "service/local/schedules/" + task.getId();
  Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation );
  return response.getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

public static void removeAllTarget()
  throws IOException
{
 List<RepositoryTargetListResource> targets = getList();
 for (RepositoryTargetListResource target : targets) {
  Status status =
    RequestFacade.sendMessage("service/local/repo_targets/" + target.getId(), Method.DELETE).getStatus();
  Assert.assertTrue("Failt to delete: " + status.getDescription(), status.isSuccess());
 }
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base

public static Status update( RoleResource role )
  throws IOException
{
  RoleResourceRequest request = new RoleResourceRequest();
  request.setData( role );
  XStreamRepresentation representation = new XStreamRepresentation( xStream, "", MediaType.APPLICATION_XML );
  representation.setPayload( request );
  String serviceURI = "service/local/roles/" + role.getId();
  Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation );
  return response.getStatus();
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

public static void removeAllRoutes()
  throws IOException
{
 List<RepositoryRouteListResource> routes = getList();
 for (RepositoryRouteListResource route : routes) {
  Status status = delete(route.getResourceURI()).getStatus();
  Assert.assertTrue("Unable to delete route: '" + route.getResourceURI() + "', due to: "
    + status.getDescription(), status.isSuccess());
 }
}

相关文章