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()); }
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)); }
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"; }
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"; }
@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()); } }
/* */ 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"; /* */ }
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); }
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"; }
/* */ 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"; /* */ }
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)); }