Package org.restlet.representation

Examples of org.restlet.representation.StringRepresentation


      Resource[] contexts = spParams.getContext();
      boolean includeInferred = spParams.isIncludeInferred();

      try {
        long size = connection.sizeMatch(subj, pred, obj, includeInferred, contexts);
        return new StringRepresentation(String.valueOf(size));
      }
      catch (StoreException e) {
        throw new ResourceException(e);
      }
    }
View Full Code Here


public class ErrorHandler extends StatusService {

  @Override
  public Representation getRepresentation(Status status, Request request, Response response) {
    // Return UTF-8 encoded plain text errors
    return new StringRepresentation(status.getDescription(), TEXT_PLAIN, Language.ALL, UTF_8);
  }
View Full Code Here

  @Override
  public Status getStatus(Throwable throwable, Request request, Response response) {
    if (throwable instanceof ErrorInfoException) {
      ErrorInfo errInfo = ((ErrorInfoException)throwable).getErrorInfo();
      response.setEntity(new StringRepresentation(errInfo.toString(), TEXT_PLAIN, Language.ALL, UTF_8));
      return new Status(CLIENT_ERROR_BAD_REQUEST, errInfo.getErrorType().getLabel());
    }
    else {
      return super.getStatus(throwable, request, response);
    }
View Full Code Here

    String pgtIou = queryParams.getFirstValue("pgtIou");
    if (pgtId != null && pgtIou != null) {
      // FIXME: clean up the hash map once in a while
      pgtIouMap.put(pgtIou, pgtId);
      response.setStatus(Status.SUCCESS_OK);
      response.setEntity(new StringRepresentation("bla"));
      return Filter.SKIP;
    }

    Session session = SessionManager.get();
    if (session != null && session.getUsername() != null) {
View Full Code Here

    else {
      session = SessionManager.get();
    }

    if (session != null && session.getUsername() != null) {
      return new StringRepresentation("logged in as '" + session.getUsername() + "'");
    }
    else {
      return new StringRepresentation("not logged in");
    }
  }
View Full Code Here

      if (namespace == null) {
        throw new ResourceException(CLIENT_ERROR_NOT_FOUND, "Undefined prefix: " + prefix);
      }

      if (variant.getMediaType().equals(MediaType.TEXT_PLAIN, true)) {
        return new StringRepresentation(namespace);
      }

      throw new ResourceException(SERVER_ERROR_INTERNAL, "Unsupported media type: "
          + variant.getMediaType());
    }
View Full Code Here

      SessionRegistry registry = SessionRegistry.getFromContext(getContext());
      registry.remove(sessionID);
      SessionUtil.discardSessionID(getResponse());
    }

    return new StringRepresentation("no longer logged in");
  }
View Full Code Here

    setConditional(false);
  }

  @Override
  protected Representation get() {
    return new StringRepresentation(Protocol.VERSION);
  }
View Full Code Here

        stringBuilder.append("</td>");
        stringBuilder.append("</tr>");
        stringBuilder.append("</table>");
        stringBuilder.append("</body>");
        stringBuilder.append("</html>");
        response.setEntity(new StringRepresentation(stringBuilder.toString(), MediaType.TEXT_HTML));
      }
    };
    router.attach("", mainpage);
    return router;
  }
View Full Code Here

    setNegotiated(false);
  }

  @Override
  public Representation get() {
    StringRepresentation presentation = null;
    try {
      String clusterName = (String) getRequest().getAttributes().get("clusterName");
      presentation = getHostedEntitiesRepresentation(clusterName);
    }

    catch (Exception e) {
      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);

      LOG.error("", e);
    }
    return presentation;
  }
View Full Code Here

TOP

Related Classes of org.restlet.representation.StringRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.