本文整理了Java中org.restlet.data.Status.toString()
方法的一些代码示例,展示了Status.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.toString()
方法的具体详情如下:
包路径:org.restlet.data.Status
类名称:Status
方法名:toString
[英]Returns the reason phrase of the status followed by its HTTP code.
[中]返回状态的原因短语,后跟其HTTP代码。
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Constructor.
*
* @param status
* The status to associate.
* @param cause
* The wrapped cause error or exception.
*/
public ResourceException(Status status, Throwable cause, Resource resource) {
super((status == null) ? null : status.toString(), cause);
this.status = status;
this.resource = resource;
}
代码示例来源:origin: uk.org.mygrid.remotetaverna/taverna-rest-client
public NotSuccessException(Status status) {
super(status.toString());
this.status = status;
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
@Override
protected void describeMismatchSafely(Status status, Description mismatchDescription) {
mismatchDescription.appendText("was ").appendText(status.toString());
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-utils
@Override
protected void describeMismatchSafely( Status status, Description mismatchDescription )
{
mismatchDescription.appendText( "was " ).appendText( status.toString() );
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
@Override
public String toString() {
return getStatus().toString();
}
代码示例来源:origin: org.umlg/runtime-restlet
@Override
public Representation getRepresentation(Status status, Request request, Response response) {
StringBuilder sb = new StringBuilder();
Throwable throwable = status.getThrowable();
if (throwable != null) {
sb.append(throwable.getMessage());
return new StringRepresentation(String.format("Http Status = %s\n + Error = %s", new Object[]{status.toString(), sb.toString()}));
} else {
return new StringRepresentation(String.format("Http Status = %s", new Object[]{status.toString()}));
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-utils
/**
* Holds execution until all tasks of a given type stop running
*
* @param taskType task type
* @param maxAttempts how many times check for tasks being stopped
*/
public void waitForAllTasksToStop( int maxAttempts, String taskType )
throws Exception
{
String uri = "service/local/taskhelper?attempts=" + maxAttempts;
if ( taskType != null )
{
uri += "&taskType=" + taskType;
}
final Status status = nexusRestClient.doGetForStatus( uri );
if ( !status.isSuccess() )
{
throw new IOException( "The taskhelper REST resource reported an error (" + status.toString()
+ "), bailing out!" );
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
/**
* Hold execution until asynchronous events at nexus side stop running
*/
public void waitForCalmPeriod(final long waitMillis)
throws IOException, InterruptedException
{
Thread.yield();
if (waitMillis > 0) {
Thread.sleep(waitMillis);
}
final Status status =
nexusRestClient.doGetForStatus("service/local/eventInspectors/isCalmPeriod?waitForCalm=true");
if (status.getCode() != Status.SUCCESS_OK.getCode()) {
throw new IOException("The isCalmPeriod REST resource reported an error ("
+ status.toString() + "), bailing out!");
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
/**
* Holds execution until all tasks of a given type stop running
*
* @param taskType task type
* @param maxAttempts how many times check for tasks being stopped
*/
public void waitForAllTasksToStop(int maxAttempts, String taskType)
throws Exception
{
String uri = "service/local/taskhelper?attempts=" + maxAttempts;
if (taskType != null) {
uri += "&taskType=" + taskType;
}
final Status status = nexusRestClient.doGetForStatus(uri);
if (!status.isSuccess()) {
throw new IOException("The taskhelper REST resource reported an error (" + status.toString()
+ "), bailing out!");
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-utils
/**
* Hold execution until asynchronous events at nexus side stop running
*/
public void waitForCalmPeriod( final long waitMillis )
throws IOException, InterruptedException
{
Thread.yield();
if ( waitMillis > 0 )
{
Thread.sleep( waitMillis );
}
final Status status =
nexusRestClient.doGetForStatus( "service/local/eventInspectors/isCalmPeriod?waitForCalm=true" );
if ( status.getCode() != Status.SUCCESS_OK.getCode() )
{
throw new IOException( "The isCalmPeriod REST resource reported an error ("
+ status.toString() + "), bailing out!" );
}
}
代码示例来源:origin: ontopia/ontopia
public Error(Status status) {
this.httpcode = status.getCode();
this.message = status.toString();
this.description = status.getDescription();
if (status.getThrowable() != null) {
Throwable t = status.getThrowable();
if (t instanceof OntopiaRestException) {
code = ((OntopiaRestException) t).getOntopiaCode();
}
Set<String> c = new HashSet<>();
while (t.getCause() != null) {
t = t.getCause();
c.add(t.getClass().getName() + ": " + (t.getMessage() != null ? t.getMessage() : ""));
}
if (!c.isEmpty()) {
causes = c.toArray(causes);
}
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
@Override
protected void describeMismatchSafely(Response item, Description mismatchDescription) {
mismatchDescription.appendText(item.getStatus().toString());
// provide some more info if it's validation error
if (item.getStatus().getCode() == 400) {
try {
mismatchDescription.appendText(item.getEntity().getText());
}
catch (IOException e) {
mismatchDescription.appendText("response entity could not be converted to text: " + e.getMessage());
}
}
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
public static void log(String loggerName, String level, String message, String exceptionType,
String exceptionMessage)
throws Exception
{
String uri = "";
if (loggerName != null) {
uri += "&loggerName=" + loggerName;
}
if (level != null) {
uri += "&level=" + level;
}
if (message != null) {
uri += "&message=" + message;
}
if (exceptionType != null) {
uri += "&exceptionType=" + exceptionType;
}
if (exceptionMessage != null) {
uri += "&exceptionMessage=" + exceptionMessage;
}
if (!uri.equals("")) {
uri = uri.substring(1);
}
uri = BASE_URI + "?" + uri;
final Status status = RequestFacade.doGetForStatus(uri);
if (!status.isSuccess()) {
throw new IOException("The loghelper REST resource reported an error (" + status.toString()
+ "), bailing out!");
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-base
public static StatusResourceResponse getNexusStatus()
throws IOException
{
Response response = RequestFacade.doGetRequest( "service/local/status" );
if ( !response.getStatus().isSuccess() )
{
throw new ConnectException( response.getStatus().toString() );
}
XStream xstream = XStreamFactory.getXmlXStream();
String entityText = response.getEntity().getText();
Assert.assertNotNull( "Invalid server response: " + new XStream().toXML( response ), entityText );
StatusResourceResponse status = (StatusResourceResponse) xstream.fromXML( entityText );
return status;
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-utils
@Override
protected void describeMismatchSafely( Response item, Description mismatchDescription )
{
mismatchDescription.appendText( item.getStatus().toString() );
// provide some more info if it's validation error
if ( item.getStatus().getCode() == 400 )
{
try
{
mismatchDescription.appendText( item.getEntity().getText() );
}
catch ( IOException e )
{
mismatchDescription.appendText( "response entity could not be converted to text: " + e.getMessage() );
}
}
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
public void waitForTask(String name, int maxAttempts, boolean failIfNotFinished)
throws Exception
{
if (maxAttempts == 0) {
return;
}
String uri = "service/local/taskhelper?attempts=" + maxAttempts;
if (name != null) {
uri += "&name=" + name;
}
final Status status = nexusRestClient.doGetForStatus(uri);
if (failIfNotFinished) {
if (Status.SUCCESS_NO_CONTENT.equals(status)) {
throw new IOException("The taskhelper REST resource reported that task named '" + name
+ "' still running after '" + maxAttempts + "' cycles! This may indicate a performance issue.");
}
}
else {
if (!status.isSuccess()) {
throw new IOException("The taskhelper REST resource reported an error (" + status.toString()
+ "), bailing out!");
}
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-utils
public void waitForTask( String name, int maxAttempts, boolean failIfNotFinished )
throws Exception
{
if ( maxAttempts == 0 )
{
return;
}
String uri = "service/local/taskhelper?attempts=" + maxAttempts;
if ( name != null )
{
uri += "&name=" + name;
}
final Status status = nexusRestClient.doGetForStatus( uri );
if ( failIfNotFinished )
{
if ( Status.SUCCESS_NO_CONTENT.equals( status ) )
{
throw new IOException( "The taskhelper REST resource reported that task named '" + name
+ "' still running after '" + maxAttempts + "' cycles! This may indicate a performance issue." );
}
}
else
{
if ( !status.isSuccess() )
{
throw new IOException( "The taskhelper REST resource reported an error (" + status.toString()
+ "), bailing out!" );
}
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* Gets authentication result from response entity.
*
* @param clientResource response container
* @return map with user details
* @throws org.jtalks.jcommune.plugin.api.exceptions.NoConnectionException
*
*/
private Map<String, String> getAuthResult(ClientResource clientResource)
throws NoConnectionException, JAXBException, IOException {
if (clientResource.getStatus().getCode() == Status.SUCCESS_OK.getCode()
&& clientResource.getResponseEntity() != null) {
return parseUserDetails(clientResource.getResponseEntity());
} else if (clientResource.getStatus().getCode() == Status.CLIENT_ERROR_NOT_FOUND.getCode()) {
return Collections.emptyMap();
} else {
throw new NoConnectionException(clientResource.getStatus().toString());
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* Gets errors from response if request wasn't successful, otherwise return null.
*
* @param clientResource response container
* @param locale locale
* @return errors
* @throws org.jtalks.jcommune.plugin.api.exceptions.NoConnectionException
*
* @throws java.io.IOException
*/
private Map<String, String> getRegistrationResult(ClientResource clientResource, Locale locale)
throws NoConnectionException, IOException, JAXBException, UnexpectedErrorException {
if (clientResource.getStatus().getCode() == Status.SUCCESS_OK.getCode()
&& clientResource.getResponseEntity() != null) {
return Collections.emptyMap();
} else if (clientResource.getStatus().getCode() == Status.CLIENT_ERROR_BAD_REQUEST.getCode()) {
return parseErrors(clientResource.getResponseEntity(), locale);
} else if (clientResource.getStatus().getCode() == Status.SERVER_ERROR_INTERNAL.getCode()) {
throw new UnexpectedErrorException();
} else {
throw new NoConnectionException(clientResource.getStatus().toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!