Package play.mvc.results

Examples of play.mvc.results.Error


      JsonObject contentElement = element.getAsJsonObject();
      String type = contentElement.get("type").getAsString();
      String source = contentElement.get("source").getAsString();
      Long id = contentElement.get("id") != null ? contentElement.get("id").getAsLong() : null;
      if(type==null) {
        Error error = new Error("Type field is empty.");
        error.apply(request, response);
        return;
      }
      Content.ContentType contentType = Content.ContentType.valueOf(type.toUpperCase());
      if(contentType == null) {
        Error error = new Error(type + " is not a correct type value.");
        error.apply(request, response);
        return;
      }
      if(source==null) {
        Error error = new Error("Source field is empty");
        error.apply(request, response);
        return;
      }
      // Se comenta esto para permitir contenido externo
      /*if(id==null) {
        Error error = new Error("Id field is empty");
        error.apply(request, response);
        return;
      }*/
     
      SharedContent sharedContent = new Message().new SharedContent();
      sharedContent.type = contentType;
      sharedContent.id = id;
      sharedContent.source = source;
      sharedContents.add(sharedContent);
    }
   
    ArrayList<User> receivers = new ArrayList<User>();
    for(JsonElement element : body.get("receivers").getAsJsonArray()) {
      JsonObject toElement = element.getAsJsonObject();
      Long userId = toElement.get("id").getAsLong();
      String firstName = toElement.get("firstName").getAsString();
      if(userId == null) {
        Error error = new Error("The id field of " + firstName + " is empty.");
        error.apply(request, response);
        return;
      }
      User to = User.findById(userId);
      if(to == null) {
        Error error = new Error(firstName + " is not a registered user.");
        error.apply(request, response);
        return;
      }
     
      receivers.add(to);
    }
View Full Code Here


     * Send a 5xx Error response
     * @param status The exact status code
     * @param reason The reason
     */
    protected static void error(int status, String reason) {
        throw new Error(status, reason);
    }
View Full Code Here

    /**
     * Send a 500 Error response
     * @param reason The reason
     */
    protected static void error(String reason) {
        throw new Error(reason);
    }
View Full Code Here

     * Send a 500 Error response
     * @param reason The reason
     */
    protected static void error(Exception reason) {
        Logger.error(reason, "error()");
        throw new Error(reason.toString());
    }
View Full Code Here

    /**
     * Send a 500 Error response
     */
    protected static void error() {
        throw new Error("Internal Error");
    }
View Full Code Here

     * Send a 5xx Error response
     * @param status The exact status code
     * @param reason The reason
     */
    protected static void error(int status, String reason) {
        throw new Error(status, reason);
    }
View Full Code Here

    /**
     * Send a 500 Error response
     * @param reason The reason
     */
    protected static void error(String reason) {
        throw new Error(reason);
    }
View Full Code Here

     * Send a 500 Error response
     * @param reason The reason
     */
    protected static void error(Exception reason) {
        Logger.error(reason, "error()");
        throw new Error(reason.toString());
    }
View Full Code Here

    /**
     * Send a 500 Error response
     */
    protected static void error() {
        throw new Error("Internal Error");
    }
View Full Code Here

     * Send a 5xx Error response
     * @param status The exact status code
     * @param reason The reason
     */
    protected static void error(int status, String reason) {
        throw new Error(status, reason);
    }
View Full Code Here

TOP

Related Classes of play.mvc.results.Error

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.