Package org.restlet.resource

Examples of org.restlet.resource.StringRepresentation


               
                resp.getOutputStream().flush();
            }
            else {
                resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                new StringRepresentation( e.getMessage() ).write( resp.getOutputStream() );
                resp.getOutputStream().flush();
            }
        }
           
        return null;
View Full Code Here


     * @param stat The Status to report to the client
     * @param e The actual Exception that occurred
     */
    public RestletException(String s, Status stat, Exception e){
      super(e);
        init(new StringRepresentation(s + ":" + e.getMessage(), MediaType.TEXT_PLAIN), stat);
    }
View Full Code Here

    /**
     * @param s The message to report this error to the user (will report mimetype as text/plain)
     * @param stat The Status to report to the client
     */   
    public RestletException(String s, Status stat){
        init(new StringRepresentation(s, MediaType.TEXT_PLAIN), stat);
    }
View Full Code Here

      getResponse().setEntity(myRequestFormat.makeRepresentation(details));
       
          if ((myRequestFormat == null) | (details == null)) {
            LOG.info("Failed MapResource request; format: " + myRequestFormat + "; details: " + details);
           
            throw new RestletException(new StringRepresentation(
                "Could not find requested resource; format=" + formatName
                + "; resource type is: " + MediaType.TEXT_PLAIN
                ),
                Status.CLIENT_ERROR_NOT_FOUND
            );
View Full Code Here

            myRequestFormat = (DataFormat)myFormatMap.get(getRequest().getAttributes().get("type"));

            Object details = myRequestFormat.readRepresentation(getRequest().getEntity());

            if ((myRequestFormat == null) || (details == null)) {
                throw new RestletException(new StringRepresentation("Could not find  requested resource",
                        MediaType.TEXT_PLAIN),
                        Status.CLIENT_ERROR_NOT_FOUND
                );
            }
View Full Code Here

  private ExceptionThrowingMapResource myResource;
 
  public void setUpInternal() throws Exception{
    super.setUpInternal();
    myResource = new ExceptionThrowingMapResource(
        new StringRepresentation("Error"),
        Status.CLIENT_ERROR_BAD_REQUEST);
  }
View Full Code Here

        if (details != null) {
            try {
                myUserService.deleteUser(username);
                getResponse()
                    .setEntity(new StringRepresentation(username + " deleted",
                        MediaType.TEXT_PLAIN));
            } catch (Exception e) {
                e.printStackTrace();
                getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
            }
View Full Code Here

        message += ("Base ref: " + request.getResourceRef().getBaseRef() + "<br>");

        message += request.getMethod().getName();

        message += "</body></html>";
        response.setEntity(new StringRepresentation(message, MediaType.TEXT_HTML));
    }
View Full Code Here

            } catch (Exception e) {
                e.printStackTrace();
                roles = "failure";
            }

            response.setEntity(new StringRepresentation(roles, MediaType.TEXT_PLAIN));
        } else if (request.getMethod().equals(Method.GET)) {
            response.setEntity(new StringRepresentation(fetchDetailsByUserName(username),
                    MediaType.TEXT_PLAIN));
        } else if (request.getMethod().equals(Method.DELETE)) {
            String message;

            try {
                myUserService.deleteUser(username);
                message = username + " deleted";
            } catch (Exception e) {
                message = "couldn't delete " + username;
            }

            response.setEntity(new StringRepresentation(message, MediaType.TEXT_PLAIN));
        } else {
            response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
        }
    }
View Full Code Here

                Integer i = Integer.valueOf(page);
                Document d = buildPagedSitemap(layerName, fti, i);
                response.setEntity(new JDOMRepresentation(d));
            } catch (NumberFormatException e) {
                response.setEntity(
                        new StringRepresentation(e.toString(),
                            MediaType.TEXT_PLAIN
                            )
                        );
                response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            }
View Full Code Here

TOP

Related Classes of org.restlet.resource.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.