示例#1
0
 @Override
 public void sendError(int statusCode, String msg) throws IOException {
   // FIXME response should be returned at this time.
   setStatus(statusCode);
   resetBuffer();
   if (msg != null) {
     play.Logger.error(msg);
     getWriter().write(msg);
     response.setHeader(Http.HeaderNames.CONTENT_TYPE, "text/plain");
   } else {
     response.getHeaders().remove(Http.HeaderNames.CONTENT_TYPE);
   }
 }
示例#2
0
  private void compruebaUsuarioParticipacion(String user, String name, String email) {
    if (user == null) {
      play.Logger.info("No se comprueba la participación, porque el usuario es: " + user);
      return;
    }
    Participacion p =
        Participacion.find(
                "select participacion from Participacion participacion where participacion.agente.username=? and participacion.solicitud.id=?",
                user,
                this.id)
            .first();
    if (p == null) {
      Agente agente =
          Agente.find("select agente from Agente agente where agente.username=?", user).first();

      if (agente == null) {
        agente = new Agente();
        agente.username = user;
        agente.name = name;
        agente.email = email;
        agente.roles = new HashSet<String>();
        agente.roles.add("usuario");
        agente.rolActivo = "usuario";
        agente.save();
        play.Logger.info("Creado el agente %s", user);
      }

      p = new Participacion();
      p.agente = agente;
      p.solicitud = this;
      p.tipo = "solicitante";
      p.save();
      play.Logger.info(
          "Asignada la participación del agente %s en la solicitud %s", agente.username, this.id);
    }
  }