コード例 #1
0
  private void updateDefaultOrganizationId(User user, String portalOrganizationId)
      throws Exception {
    BasicHttpContext ctx = new BasicHttpContext();
    ctx.setAttribute(ClientContext.AUTH_CACHE, authCache);

    HttpPost post = new HttpPost("/user/update-organizations");
    List<NameValuePair> params = new ArrayList<NameValuePair>();

    JSONSerializer serializer = new JSONSerializer();
    String orgIds = serializer.serialize(new String[] {portalOrganizationId});

    params.add(new BasicNameValuePair("userId", Long.toString(user.getUserId())));
    params.add(new BasicNameValuePair("organizationIds", orgIds));
    params.add(new BasicNameValuePair("serviceContext", null));

    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
    post.setEntity(entity);

    HttpResponse resp = httpclient.execute(targetHost, post, ctx);
    System.out.println("updateDefaultOrganizationId Status:[" + resp.getStatusLine() + "]");

    String response = null;
    if (resp.getEntity() != null) {
      response = EntityUtils.toString(resp.getEntity());
    }
    System.out.println("getOrganizationByName Resp:[" + response + "]");

    EntityUtils.consume(resp.getEntity());
  }
コード例 #2
0
ファイル: Usuarios.java プロジェクト: Ral008/salas
 public static void activarAlUsuario(Long id) {
   ServiceUsuarios.updateUserById(id);
   Map result = new HashMap();
   result.put("status", 1);
   result.put("message", "El usuario fue activado");
   JSONSerializer mapeo = new JSONSerializer();
   renderJSON(mapeo.serialize(result));
 }
コード例 #3
0
  public String get() {
    ProcessModule processModule = (ProcessModule) this.processModuleService.get(this.moduleid);

    JSONSerializer json = JsonUtil.getJSONSerializer(new String[] {"createtime"});

    StringBuffer sb = new StringBuffer("{success:true,data:");
    sb.append(json.serialize(processModule));
    sb.append("}");
    setJsonString(sb.toString());

    return "success";
  }
コード例 #4
0
  public String get() {
    ArchTemplate archTemplate = (ArchTemplate) this.archTemplateService.get(this.templateId);

    JSONSerializer jsonSerializer = JsonUtil.getJSONSerializer();

    StringBuffer sb = new StringBuffer("{success:true,data:");
    sb.append(jsonSerializer.serialize(archTemplate));
    sb.append("}");
    setJsonString(sb.toString());

    return "success";
  }
コード例 #5
0
  @Override
  public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
    int clientId;
    HashMap<String, HashMap<String, String>> returnMap =
        new HashMap<String, HashMap<String, String>>();
    HashMap<String, String> returnKeyValues = new HashMap<String, String>();
    String strClientId;

    if (!doHTTPAuthentication(vhost, req, resp) || req.getMethod().equalsIgnoreCase("get")) return;

    req.parseBodyForParams();
    strClientId = req.getParameter("clientId");
    returnKeyValues.put("type", null);
    returnKeyValues.put("msg", "Request unsuccessful");
    returnKeyValues.put("isPublic", "true");
    returnMap.put("error", returnKeyValues);

    if (strClientId != null) {
      WMSLoggerFactory.getLogger(null)
          .info("*** Attempting to stop stream with clientId " + strClientId);
      try {
        clientId = Integer.parseInt(strClientId);
        IClient client = vhost.getClient(clientId);
        if (client != null) {
          client.setShutdownClient(true);
          returnMap.remove("error");
          returnKeyValues.remove("type");
          returnKeyValues.remove("msg");
          returnKeyValues.remove("isPublic");
          returnKeyValues.put("result", "Id " + clientId + " killed");
          returnMap.put("success", returnKeyValues);
        }
      } catch (NumberFormatException e) {
        WMSLoggerFactory.getLogger(null).error("******* NaN: " + strClientId);
        returnKeyValues.put("type", "NumberFormatException");
        returnKeyValues.put("msg", "NaN: " + strClientId);
        returnKeyValues.put("isPublic", "true");
        returnMap.put("error", returnKeyValues);
      }
    }

    JSONSerializer serializer = new JSONSerializer().exclude("*.class");
    String returnJSONStr = serializer.serialize(returnMap);

    try {
      resp.setHeader("Content-Type", "application/json");
      OutputStream out = resp.getOutputStream();
      byte[] outBytes = returnJSONStr.getBytes();
      out.write(outBytes);
    } catch (Exception e) {
      WMSLoggerFactory.getLogger(null).error("*** HTTPProvider failed: " + e.toString());
    }
  }
コード例 #6
0
ファイル: NewsAction.java プロジェクト: 909910149/ehsuite
 /*     */ public String get() /*     */ {
   /*  94 */ News news = (News) this.newsService.get(this.newsId);
   /*     */
   /*  96 */ JSONSerializer json =
       JsonUtil.getJSONSerializer(new String[] {"createtime", "expTime", "updateTime"});
   /*     */
   /*  98 */ StringBuffer sb = new StringBuffer("{success:true,data:");
   /*  99 */ sb.append(json.serialize(news));
   /* 100 */ sb.append("}");
   /* 101 */ setJsonString(sb.toString());
   /*     */
   /* 103 */ return "success";
   /*     */ }
コード例 #7
0
 public static String eliminar(Long id, String usuario) {
   Map result = new HashMap();
   VmdbProductoCompuesto productoCompuesto = VmdbProductoCompuesto.findById(id);
   if (productoCompuesto != null) {
     productoCompuesto.setStProductoCompuesto('0');
     productoCompuesto.setCoUsuarioModificacion(usuario);
     productoCompuesto.setDaFechaModificacion(new Date());
     productoCompuesto.save();
     result.put("status", 1);
     result.put("message", "El producto compuesto fue eliminado correctamente!");
   } else {
     result.put("status", 0);
     result.put("message", "No puede ser eliminado");
   }
   JSONSerializer mapeo = new JSONSerializer();
   return mapeo.serialize(result);
 }
コード例 #8
0
  public String list() {
    QueryFilter filter = new QueryFilter(getRequest());
    List list = this.processModuleService.getAll(filter);

    StringBuffer buff =
        new StringBuffer("{success:true,'totalCounts':")
            .append(filter.getPagingBean().getTotalItems())
            .append(",result:");

    JSONSerializer json = JsonUtil.getJSONSerializer(new String[] {"createtime"});
    buff.append(json.serialize(list));
    buff.append("}");

    this.jsonString = buff.toString();

    return "success";
  }
コード例 #9
0
ファイル: NewsAction.java プロジェクト: 909910149/ehsuite
 /*     */ public String list() /*     */ {
   /*  57 */ QueryFilter filter = new QueryFilter(getRequest());
   /*  58 */ List list = this.newsService.getAll(filter);
   /*     */
   /*  61 */ StringBuffer buff =
       new StringBuffer("{success:true,'totalCounts':")
           /*  62 */ .append(filter.getPagingBean().getTotalItems())
           .append(",result:");
   /*  63 */ JSONSerializer json =
       JsonUtil.getJSONSerializer(new String[] {"createtime", "expTime", "updateTime"});
   /*  64 */ buff.append(json.serialize(list));
   /*  65 */ buff.append("}");
   /*     */
   /*  67 */ this.jsonString = buff.toString();
   /*     */
   /*  69 */ return "success";
   /*     */ }
コード例 #10
0
ファイル: Usuarios.java プロジェクト: Ral008/salas
 public static void cambiarContrasenia() {
   String clave = params.get("clave");
   Long coUsuario = Long.parseLong(params.get("coUsuario"));
   Map result = new HashMap();
   String deUsuario = session.get("usuario");
   VmdbUsuario usuario = VmdbUsuario.find("coUsuario = ? and stUsuario = '1'", coUsuario).first();
   usuario.setDeClave(clave);
   usuario.setDaFechaModificacion(new Date());
   usuario.setCoUsuarioModificacion(deUsuario);
   usuario.save();
   /** Actualizar clave en Persona * */
   VmdbPersona objPersona = VmdbPersona.findById(usuario.getVmdbPersona().getCoPersona());
   objPersona.setDeClave(clave);
   objPersona.setCoUsuarioModificacion(deUsuario);
   objPersona.setDaFechaModificacion(new Date());
   objPersona.save();
   /** -----------------------------* */
   result.put("status", 1);
   result.put("message", "Su clave fue actualizado correctamente");
   JSONSerializer mapeo = new JSONSerializer();
   renderJSON(mapeo.serialize(result));
 }