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 String copy() {
   /* 177 */ String historyId = getRequest().getParameter("historyId");
   /* 178 */ DocHistory docHistory = (DocHistory) this.docHistoryService.get(new Long(historyId));
   /* 179 */ DocHistory newHistory = new DocHistory();
   /*     */
   /* 181 */ this.archivesDoc = docHistory.getArchivesDoc();
   /*     */
   /* 183 */ newHistory.setDocName(docHistory.getDocName());
   /* 184 */ newHistory.setFileAttach(docHistory.getFileAttach());
   /*     */
   /* 186 */ newHistory.setMender(ContextUtil.getCurrentUser().getFullname());
   /* 187 */ newHistory.setPath(docHistory.getPath());
   /* 188 */ newHistory.setUpdatetime(new Date());
   /* 189 */ newHistory.setVersion(
       Integer.valueOf(this.archivesDoc.getCurVersion().intValue() + 1));
   /* 190 */ newHistory.setArchivesDoc(this.archivesDoc);
   /* 191 */ this.docHistoryService.save(newHistory);
   /*     */
   /* 193 */ this.archivesDoc.setCurVersion(newHistory.getVersion());
   /* 194 */ this.archivesDoc.setDocPath(newHistory.getPath());
   /* 195 */ this.archivesDoc.setFileAttach(newHistory.getFileAttach());
   /*     */
   /* 197 */ this.archivesDocService.save(this.archivesDoc);
   /*     */
   /* 199 */ StringBuffer buff = new StringBuffer("{success:true,data:");
   /* 200 */ JSONSerializer json = new JSONSerializer();
   /* 201 */ buff.append(
       json.exclude(new String[] {"class", "docHistorys"}).serialize(this.archivesDoc));
   /* 202 */ buff.append("}");
   /*     */
   /* 204 */ setJsonString(buff.toString());
   /* 205 */ return "success";
   /*     */ }
  @POST
  @Path("/addPcuLabTestRequest")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public String addPcuLabTestRequest(JSONObject pJson) {

    try {

      PcuLabTestRequest request = new PcuLabTestRequest();

      int testID = pJson.getInt("ftest_ID");

      int labID = pJson.getInt("flab_ID");
      int admissionID = pJson.getInt("admintionID");
      int userid = pJson.getInt("ftest_RequestPerson");

      request.setComment(pJson.getString("comment").toString());
      request.setPriority(pJson.getString("priority").toString());
      request.setStatus(pJson.getString("status").toString());
      request.setTest_RequestDate(new Date());
      request.setTest_DueDate(new Date());

      requestDBDriver.addNewLabTestRequest(request, testID, admissionID, labID, userid);

      JSONSerializer jsonSerializer = new JSONSerializer();
      return jsonSerializer.include("pcu_lab_test_request_id").serialize(request);
    } catch (Exception e) {
      System.out.println(e.getMessage());

      return null;
    }
  }
  @GET
  @Path("/getAllPcuLabTestRequests")
  @Produces(MediaType.APPLICATION_JSON)
  public String getAllTestRequests() {

    List<PcuLabTestRequest> testRequestsList = requestDBDriver.getTestRequestsList();
    JSONSerializer serializer = new JSONSerializer();
    return serializer
        .include(
            "admintionID.admitionId",
            "ftest_ID.test_ID",
            "ftest_ID.test_IDName",
            "ftest_ID.test_Name",
            "admintionID.patientId.patientID",
            "admintionID.patientId.patientFullName",
            "fspecimen_ID.specimen_ID.*",
            "flab_ID.lab_ID.*",
            "flab_ID.lab_Name.*",
            "ftest_RequestPerson.userID.*",
            "ftest_RequestPerson.userName.*",
            "fsample_CenterID.sampleCenter_ID.*",
            "fsample_CenterID.sampleCenter_Name.*")
        .exclude(
            "*.class",
            "fspecimen_ID.*",
            "flab_ID.*",
            "ftest_RequestPerson.*",
            "fsample_CenterID.*",
            "admintionID.*",
            "ftest_ID.*",
            "ftest_RequestPerson.*")
        .transform(new DateTransformer("yyyy-MM-dd"), "test_RequestDate", "test_DueDate")
        .serialize(testRequestsList);
  }
 @GET
 @Path("/getMaxParentID")
 @Produces(MediaType.APPLICATION_JSON)
 public String GetMAxParentID() {
   String MaxID = parentfieldDBDriver.getMaxParentID();
   JSONSerializer serializer = new JSONSerializer();
   return serializer.exclude("*.class").serialize(MaxID);
 }
Beispiel #6
0
 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));
 }
 @GET
 @Path("/getAllParenTestFields/{ID}")
 @Produces(MediaType.APPLICATION_JSON)
 public String getAllParenTestFieldsByID(@PathParam("ID") int TestID) {
   List<ParentTestFields> parentTestFIeldsList = parentfieldDBDriver.getParentField(TestID);
   JSONSerializer serializer = new JSONSerializer();
   return serializer.exclude("*.class").serialize(parentTestFIeldsList);
 }
  private void listMessages(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setCharacterEncoding("UTF-8");
    if (!IrssiNotifier.versionCheck(req.getParameter("version"))) {
      IrssiNotifier.printError(resp.getWriter(), new OldVersionException());
      return;
    }
    String id = req.getParameter("apiToken");
    String guid = req.getParameter("guid");

    if (id == null || guid == null || id.equals("") || guid.equals("")) {
      IrssiNotifier.printError(resp.getWriter(), "Virheellinen pyyntö");
      return;
    }

    ObjectifyDAO dao = new ObjectifyDAO();
    try {
      IrssiNotifierUser user = IrssiNotifier.getUser(dao, id);
      Query<Message> messages =
          dao.ofy().query(Message.class).order("-timestamp").ancestor(user).limit(LIMIT + 1);
      String starting = req.getParameter("starting");
      if (starting != null) {
        try {
          long startingTimestamp = Long.parseLong(starting);
          messages = messages.filter("timestamp <=", startingTimestamp);
        } catch (NumberFormatException e) {
        }
      }

      Message next = null;
      if (messages.count() == LIMIT + 1) {
        IrssiNotifier.log.info("Lisää viestejä on saatavilla");
        next = messages.list().get(LIMIT);
      } else {
        IrssiNotifier.log.info("Sisältää viestihistorian viimeiset viestit");
      }

      MessageListResponse response = new MessageListResponse(messages.limit(LIMIT));
      response.nextMessage = next;
      response.isNextFetch = starting != null;

      JSONSerializer serializer = new JSONSerializer();
      String jsonObject =
          serializer
              .include("messages")
              .transform(new CustomTimeTransformer(), "messages.timestamp")
              .transform(new CustomTimeTransformer(), "nextMessage.timestamp")
              .exclude("*.class")
              .serialize(response);
      resp.setHeader("Content-Type", "application/json");
      resp.getWriter().println(jsonObject);
      resp.getWriter().close();
    } catch (UserNotFoundException e) {
      IrssiNotifier.printError(resp.getWriter(), e);
    }
  }
 /*     */ public String save() /*     */ {
   /* 123 */ AppUser curUser = ContextUtil.getCurrentUser();
   /* 124 */ if (this.archivesDoc.getDocId() == null)
   /*     */ {
     /* 126 */ this.archivesDoc.initUsers(curUser);
     /* 127 */ this.archivesDoc.setDocStatus(Short.valueOf(ArchivesDoc.STATUS_MODIFY));
     /* 128 */ this.archivesDoc.setUpdatetime(new Date());
     /* 129 */ this.archivesDoc.setCreatetime(new Date());
     /* 130 */ this.archivesDoc.setCurVersion(Integer.valueOf(ArchivesDoc.ORI_VERSION));
     /* 131 */ this.archivesDoc.setFileAttach(
         this.fileAttachService.getByPath(this.archivesDoc.getDocPath()));
     /* 132 */ this.archivesDocService.save(this.archivesDoc);
     /*     */ }
   /*     */ else {
     /* 135 */ ArchivesDoc oldVersion =
         (ArchivesDoc) this.archivesDocService.get(this.archivesDoc.getDocId());
     /* 136 */ this.archivesDoc.setCreatetime(oldVersion.getCreatetime());
     /* 137 */ this.archivesDoc.setArchives(oldVersion.getArchives());
     /* 138 */ this.archivesDoc.setCreatorId(oldVersion.getCreatorId());
     /* 139 */ this.archivesDoc.setFileAttach(
         this.fileAttachService.getByPath(this.archivesDoc.getDocPath()));
     /* 140 */ this.archivesDoc.setCreator(oldVersion.getCreator());
     /* 141 */ this.archivesDoc.setDocStatus(Short.valueOf(ArchivesDoc.STATUS_MODIFY));
     /* 142 */ this.archivesDoc.setUpdatetime(new Date());
     /* 143 */ this.archivesDoc.setCurVersion(
         Integer.valueOf(oldVersion.getCurVersion().intValue() + 1));
     /* 144 */ this.archivesDoc.setMender(curUser.getFullname());
     /* 145 */ this.archivesDoc.setMenderId(curUser.getUserId());
     /* 146 */ this.archivesDoc.setDocHistorys(oldVersion.getDocHistorys());
     /* 147 */ this.archivesDoc.setFileAttach(
         this.fileAttachService.getByPath(this.archivesDoc.getDocPath()));
     /* 148 */ this.archivesDocService.merge(this.archivesDoc);
     /*     */ }
   /*     */
   /* 152 */ DocHistory docHistory = new DocHistory();
   /* 153 */ docHistory.setArchivesDoc(this.archivesDoc);
   /* 154 */ docHistory.setFileAttach(
       this.fileAttachService.getByPath(this.archivesDoc.getDocPath()));
   /* 155 */ docHistory.setDocName(this.archivesDoc.getDocName());
   /* 156 */ docHistory.setPath(this.archivesDoc.getDocPath());
   /* 157 */ docHistory.setVersion(this.archivesDoc.getCurVersion());
   /* 158 */ docHistory.setUpdatetime(new Date());
   /* 159 */ docHistory.setMender(curUser.getFullname());
   /* 160 */ this.docHistoryService.save(docHistory);
   /*     */
   /* 165 */ StringBuffer buff = new StringBuffer("{success:true,data:");
   /*     */
   /* 167 */ JSONSerializer json = new JSONSerializer();
   /* 168 */ buff.append(
       json.exclude(new String[] {"class", "docHistorys"}).serialize(this.archivesDoc));
   /*     */
   /* 170 */ buff.append("}");
   /*     */
   /* 172 */ setJsonString(buff.toString());
   /* 173 */ return "success";
   /*     */ }
 @GET
 @Path("/getAllParenTestFields")
 @Produces(MediaType.APPLICATION_JSON)
 public String getAllParenTestFields() {
   List<ParentTestFields> parentTestFIeldsList = parentfieldDBDriver.getParentTeatFieldsList();
   JSONSerializer serializer = new JSONSerializer();
   return serializer
       .include("fTest_NameID.test_Name")
       .exclude("*.class", "fTest_NameID.*")
       .serialize(parentTestFIeldsList);
 }
  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";
  }
  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";
  }
  @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() {
    /* 113 */ ArchRecType archRecType = (ArchRecType) this.archRecTypeService.get(this.recTypeId);

    /* 117 */ StringBuffer sb = new StringBuffer("{success:true,data:");

    /* 119 */ JSONSerializer serializer = new JSONSerializer();
    /* 120 */ sb.append(
        serializer.exclude(new String[] {"class", "department.class"}).serialize(archRecType));
    /* 121 */ sb.append("}");
    /* 122 */ setJsonString(sb.toString());

    /* 124 */ return "success";
  }
Beispiel #15
0
  /**
   * 显示详细信息
   *
   * @return
   */
  public String get() {
    CarApply carApply = carApplyService.get(applyId);
    StringBuffer sb = new StringBuffer("{success:true,data:");
    JSONSerializer serializer = new JSONSerializer();
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "applyDate");
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "startTime");
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "endTime");
    sb.append(serializer.exclude(new String[] {"class"}).prettyPrint(carApply));
    sb.append("}");
    setJsonString(sb.toString());

    return SUCCESS;
  }
Beispiel #16
0
 /*     */ 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 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 void saveNamespace(String name, Map<String, List> desc) throws Exception {
   StoreDesc sdesc = StoreDesc.getGlobalData();
   m_gitService.putContent(
       sdesc.getRepository(),
       format(NAMESPACE_PATH, name),
       NAMESPACE_TYPE,
       m_js.deepSerialize(desc));
 }
Beispiel #19
0
 /*     */ 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 String list() {
    /*  55 */ QueryFilter filter = new QueryFilter(getRequest());
    /*  56 */ List list = this.archRecTypeService.getAll(filter);

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

    /*  64 */ JSONSerializer serializer = new JSONSerializer();
    /*  65 */ buff.append(serializer.exclude(new String[] {"class"}).serialize(list));
    /*  66 */ buff.append("}");

    /*  68 */ this.jsonString = buff.toString();

    /*  70 */ return "success";
  }
Beispiel #21
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);
 }
  private void readAll(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    final AccessLevelManager accessLevelManager =
        new AccessLevelManager(HibernateUtil.getCurrentSession());
    final List<AccessLevel> accessLevels = accessLevelManager.readAll();
    JSONSerializer serializer = new JSONSerializer();
    final StringBuilder jsonLayersBuilder = new StringBuilder();

    serializer
        .rootName("objects")
        .include("layers")
        .exclude("*.class")
        .serialize(accessLevels, jsonLayersBuilder);

    response.setContentType("application/json");
    response.getWriter().println(jsonLayersBuilder.toString());
    response.getWriter().flush();
  }
Beispiel #23
0
  /** 显示列表 */
  public String list() {

    QueryFilter filter = new QueryFilter(getRequest());
    List<CarApply> list = carApplyService.getAll(filter);
    StringBuffer buff =
        new StringBuffer("{success:true,'totalCounts':")
            .append(filter.getPagingBean().getTotalItems())
            .append(",result:");

    JSONSerializer serializer = new JSONSerializer();
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "applyDate");
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "startTime");
    serializer.transform(new DateTransformer("yyyy-MM-dd HH:mm:ss"), "endTime");
    buff.append(serializer.exclude(new String[] {"class"}).prettyPrint(list));
    buff.append("}");

    jsonString = buff.toString();

    return SUCCESS;
  }
Beispiel #24
0
 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));
 }
  public static void main(String[] args) {
    try {
      XPlatUIPrimitiveElement textBox =
          new XPlatUIPrimitiveElement(XPlatUIElementType.TEXT_BOX_SINGLE);
      textBox.setParameter("label", "Name");
      textBox.setParameter("initialValue", "Please supply a gene name");
      XPlatUIElementLayout regLayoutTop =
          new XPlatUIElementLayout(XPlatUIElementLayout.UILayoutType.REGIONAL);
      regLayoutTop.setLayoutParameter("region", "top");
      textBox.setLayout(regLayoutTop);

      JSONSerializer serializer = new JSONSerializer();

      serializer.transform(textBox.new ExcludeNullsTransformer(), void.class);

      System.out.println(serializer.deepSerialize(textBox));
    } catch (Exception e) {

      System.err.println("[ERROR] In DialogElement: " + e);
      e.printStackTrace();
    }
  }
 public void saveBranding(Map<String, String> desc) throws Exception {
   StoreDesc sdesc = StoreDesc.getGlobalData();
   m_gitService.putContent(
       sdesc.getRepository(), BRANDING_PATH, "sw.setting", m_js.deepSerialize(desc));
 }
 public GitMetaDataImpl(GitService gs) {
   m_gitService = gs;
   m_js.prettyPrint(true);
 }
  @PersistenceContext
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();

    // DataManager dm = new DataManager();

    try {
      String req = Utility.getHttpParam("REQUEST", request);
      String filter = Utility.getHttpParam("FILTER", request);
      String[] filterArr = null;
      if (filter != null) {
        filterArr = filter.split(";");
      }
      if (req.equalsIgnoreCase("servicesUrls")) {
        synchronized (this) {
          System.out.println("\nSTART: servicesUrls");
          DataManager dm = new DataManager();
          try {
            List<ServicesUrls> srvUrls = dm.getServicesUrls();

            if (filterArr != null) {
              for (Iterator<ServicesUrls> it = srvUrls.iterator(); it.hasNext(); ) {
                ServicesUrls sur = it.next();
                if (filterArr[0].equalsIgnoreCase("idGrp")) {
                  List<ServicesPermissions> lpr = sur.getSprList();
                  boolean rem = true;
                  for (Iterator<ServicesPermissions> itSpr = lpr.iterator(); itSpr.hasNext(); ) {
                    ServicesPermissions spr = itSpr.next();
                    if (spr.getIdGrpFk().getIdGrp() == Integer.parseInt(filterArr[1])) {
                      rem = false;
                      break;
                    }
                  }
                  if (rem) {
                    it.remove();
                  }
                } else {
                  if (sur.getIdSrvFk().getIdSrv() != Integer.parseInt(filterArr[1])) {
                    // System.out.println("removing idSrv " + sur.getPathSur());
                    it.remove();
                  }
                }
              }
            }

            JSONSerializer json = new JSONSerializer();
            // System.out.println("JSON:\n" + json.exclude("*.class").prettyPrint("servicesUrls",
            // srvUrls));
            out.println(json.exclude("*.class").serialize("servicesUrls", srvUrls));

          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
          System.out.println("END: servicesUrls\n");
        }
      } else if (req.equalsIgnoreCase("wmswfsSurls")) {
        synchronized (this) {
          System.out.println("\nSTART: wmswfsSurls");
          DataManager dm = new DataManager();
          try {
            List<ServicesUrls> srvUrls = dm.getServicesUrls();

            for (Iterator<ServicesUrls> it = srvUrls.iterator(); it.hasNext(); ) {
              ServicesUrls sur = it.next();
              if (sur.getIdSrvFk().getNameSrv().equalsIgnoreCase("SOS")) {
                it.remove();
              }
            }

            if (filterArr != null) {
              for (Iterator<ServicesUrls> it = srvUrls.iterator(); it.hasNext(); ) {
                ServicesUrls sur = it.next();
                if (filterArr[0].equalsIgnoreCase("idGrp")) {
                  List<ServicesPermissions> lpr = sur.getSprList();
                  boolean rem = true;
                  for (Iterator<ServicesPermissions> itSpr = lpr.iterator(); itSpr.hasNext(); ) {
                    ServicesPermissions spr = itSpr.next();
                    if (spr.getIdGrpFk().getIdGrp() == Integer.parseInt(filterArr[1])) {
                      rem = false;
                      break;
                    }
                  }
                  if (rem) {
                    it.remove();
                  }
                } else {
                  if (sur.getIdSrvFk().getIdSrv() != Integer.parseInt(filterArr[1])) {
                    // System.out.println("removing idSrv " + sur.getPathSur());
                    it.remove();
                  }
                }
              }
            }

            JSONSerializer json = new JSONSerializer();
            // System.out.println("JSON:\n" + json.exclude("*.class").prettyPrint("servicesUrls",
            // srvUrls));
            out.println(json.exclude("*.class").serialize("servicesUrls", srvUrls));

          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
          System.out.println("END: wmswfsSurls\n");
        }
      } else if (req.equalsIgnoreCase("sosSurls")) {
        synchronized (this) {
          System.out.println("\nSTART: sosSurls");
          DataManager dm = new DataManager();
          try {
            List<ServicesUrls> srvUrls = dm.getServicesUrls();
            List<ServicesUrls> ret = new ArrayList<ServicesUrls>();
            for (Iterator<ServicesUrls> it = srvUrls.iterator(); it.hasNext(); ) {
              ServicesUrls sur = it.next();
              if (sur.getIdSrvFk().getNameSrv().equalsIgnoreCase("SOS")) {
                ret.add(sur);
              }
            }
            JSONSerializer json = new JSONSerializer();
            // System.out.println("JSON:\n" + json.exclude("*.class").prettyPrint("servicesUrls",
            // srvUrls));
            out.println(json.exclude("*.class").serialize("servicesUrls", ret));
          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
          System.out.println("END: sosSurls\n");
        }
      } else if (req.equalsIgnoreCase("services")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          try {
            List<Services> srv = dm.getServices();
            JSONSerializer json = new JSONSerializer();
            // System.out.println("JSON:\n" + json.exclude("*.class").prettyPrint("services", srv));
            out.println(json.exclude("*.class").serialize("services", srv));
          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("servicesPermissions")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          try {
            List<ServicesPermissions> srvPrm = dm.getServicesPermissions();
            JSONSerializer json = new JSONSerializer();
            // System.out.println("JSON:\n" + json.exclude("*.class", "idReqFk.idSrvFk",
            // "idSurFk.idSrvFk").prettyPrint("servicesPermissions", srvPrm));
            out.println(
                json.exclude("*.class", "idSrvFk").serialize("servicesPermissions", srvPrm));
          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("setServicesPermissions")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          String idGrp = Utility.getHttpParam("idGrp", request);
          String idSur = Utility.getHttpParam("idSur", request);
          String hasSpr = Utility.getHttpParam("hasSpr", request);

          System.out.println("*******************************************");
          System.out.println("Params: ");
          System.out.println("idGrp: " + idGrp);
          System.out.println("idSur: " + idSur);
          System.out.println("hasSpr: " + hasSpr);
          // Check input params

          Groups grp = null;
          ServicesUrls sur = null;
          ServicesPermissions spr = null;

          try {
            // System.out.println("\nChecking..");

            // Check if Group exist
            grp = dm.getGroup(Integer.parseInt(idGrp));
            // System.out.println("Group exist: " + grp.getNameGrp());

            // Check if Sur exist
            sur = dm.getServicesUrls(Integer.parseInt(idSur));
            // System.out.println("Sur exist: " + sur.getPathSur());

            try {
              // Check if isMember
              spr = dm.getServicePermissionBySurGrp(sur.getIdSur(), grp.getIdGrp());
              System.out.println("Membership exist: " + spr.getIdSpr());
              if (!Boolean.parseBoolean(hasSpr)) {
                System.out.println("Removing.");
                dm.remove(spr);
                out.print("{success: true, message: 'Services Permissions removed.'}");
              } else {
                // System.out.println("Error.");
                out.print("{success: false, error: 'Database mismatch, please reload data!'}");
              }
            } catch (NoResultException noResultException) {
              System.out.println("Membership NOT exist.");
              if (Boolean.parseBoolean(hasSpr)) {
                spr = new ServicesPermissions();
                spr.setIdGrpFk(grp);
                spr.setIdSurFk(sur);
                dm.persist(spr);
                out.print(
                    "{success: true, message: 'Services Permissions "
                        + "<br>for group \""
                        + grp.getNameGrp()
                        + "\" added.'}");
              } else {
                out.print("{success: false, error: 'Database mismatch, please reload data!'}");
              }
            }
          } catch (ServiceException ex) {
            out.print("{success: false, error: 'Database error!'}");
          } catch (NoResultException noResultException) {
            out.print("{success: false, " + "error: 'Group or user with given Id are not found'}");
          } catch (Exception ex) {
            System.out.println(ex.getMessage());
            out.print("{success: false, error: 'Database error!'}");
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("setSprReq")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          String idReq = Utility.getHttpParam("idReq", request);
          String idSpr = Utility.getHttpParam("idSpr", request);
          String hasSre = Utility.getHttpParam("hasSre", request);

          Requests reqs = null;
          ServicesPermissions spr = null;
          SprReq sre = null;

          try {

            // Check if Requests exist
            // System.out.println("\nChecking Requests..");
            reqs = dm.getRequestById(Integer.parseInt(idReq));
            // System.out.println("Requests exist: " + reqs.getNameReq());

            // Check if Spr exist
            // System.out.println("\nChecking ServicesPermissions..");
            spr = dm.getServicesPermissionsById(Integer.parseInt(idSpr));
            // System.out.println("Spr exist: " + spr.getIdSpr());

            try {
              // Check if isMember
              sre = dm.getSprReqByIdReqIdSpr(reqs.getIdReq(), spr.getIdSpr());
              // System.out.println("SprReq exist:(" + hasSre + "):" + sre.getIdSre());
              if (!Boolean.parseBoolean(hasSre)) {
                dm.remove(sre);
                out.print(
                    "{success: true, message: 'Services Request \""
                        + reqs.getNameReq()
                        + "\" removed.'}");
              } else {
                out.print("{success: false, error: 'Services request already setted!'}");
              }
            } catch (NoResultException noResultException) {
              // System.out.println("Membership NOT exist. (" + hasSre + ")");
              if (Boolean.parseBoolean(hasSre)) {
                sre = new SprReq();
                sre.setIdReqFk(reqs);
                sre.setIdSprFk(spr);
                dm.persist(sre);
                out.print(
                    "{success: true, message: 'Services Request \""
                        + reqs.getNameReq()
                        + "\" added.'}");
              } else {
                out.print("{success: false, error: 'Services request is already deleted!'}");
              }
            }
          } catch (ServiceException ex) {
            out.print("{success: false, error: 'Database error!'}");
          } catch (NoResultException noResultException) {
            out.print("{success: false, " + "error: 'Group or user with given Id are not found'}");
          } catch (Exception ex) {
            System.out.println(
                "Error: " + ex.getClass().getCanonicalName() + "\n" + ex.getMessage());
            out.print("{success: false, error: 'Database error!'}");
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("insertServiceUrl")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          // check if idSpr exist error!!
          String idSur = Utility.getHttpParam("idSur", request);

          String idSrv = Utility.getHttpParam("idSrv", request);
          String pathSur = Utility.getHttpParam("pathSur", request);
          String urlSur = Utility.getHttpParam("urlSur", request);

          // Check mandatory input params

          ServicesUrls srvUrls = null;
          try {
            srvUrls =
                dm.getServicesUrlsByPathIdSrv(
                    pathSur, dm.getServicesById(Integer.parseInt(idSrv)).getNameSrv());
            out.print(
                "{success: false, "
                    + "error: 'Service with path \""
                    + pathSur
                    + "\" already exist.'}");
          } catch (ServiceException sex) {
            Services srv = null;
            try {
              srv = dm.getServicesById(Integer.parseInt(idSrv));
              srvUrls = null;
              srvUrls = new ServicesUrls();
              srvUrls.setPathSur(pathSur);
              srvUrls.setUrlSur(urlSur);
              srvUrls.setIdSrvFk(srv);
              try {
                dm.persist(srvUrls);
                out.print(
                    "{success: true, message: 'Service \"" + srvUrls.getUrlSur() + "\" added.'}");
              } catch (ServiceException ex) {
                System.out.println("Service ex:\n" + ex.getMessage());
                out.print("{success: false, error: 'Database error!'}");
              }
            } catch (NumberFormatException numberFormatException) {
              out.print("{success: false, error: 'Parameter idSrv not number!'}");
            } catch (NoResultException noResultException) {
              out.print("{success: false, error: 'Service type idSrv not exist!'}");
            }
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("updateServicePermission")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          String idSur = Utility.getHttpParam("idSur", request);
          String idSrv = Utility.getHttpParam("idSrv", request);
          String pathSur = Utility.getHttpParam("pathSur", request);
          String urlSur = Utility.getHttpParam("urlSur", request);
          ServicesUrls srvUrls = null;
          try {
            srvUrls = dm.getServicesUrls(Integer.parseInt(idSur));
            try {
              srvUrls.setIdSrvFk(dm.getServicesById(Integer.parseInt(idSrv)));
              srvUrls.setPathSur(pathSur);
              srvUrls.setUrlSur(urlSur);
              dm.persist(srvUrls);
              out.print(
                  "{success: true, message: 'Service \"" + srvUrls.getUrlSur() + "\" updated.'}");
            } catch (ServiceException ex) {
              out.print("{success: false, error: 'Database error!'}");
            }
          } catch (NoResultException noResultException) {
            out.print(
                "{success: false, " + "error: 'User with id \"" + idSur + "\" does not exist.'}");
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("deleteService")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          String idSur = Utility.getHttpParam("idSur", request);
          ServicesUrls srvUrls = null;
          try {
            srvUrls = dm.getServicesUrls(Integer.parseInt(idSur));
            try {
              String url = srvUrls.getUrlSur();
              dm.remove(srvUrls);
              out.print("{success: true, message: 'Service \"" + url + "\" removed.'}");
            } catch (ServiceException ex) {
              out.print("{success: false, error: 'Database error!'}");
            }
          } catch (NoResultException noResultException) {
            out.print(
                "{success: false, " + "error: 'User with id \"" + idSur + "\" does not exist.'}");
          }
          dm.closeIt();
          dm = null;
        }
      } else if (req.equalsIgnoreCase("requests")) {
        synchronized (this) {
          DataManager dm = new DataManager();
          try {
            List<Requests> reqs = dm.getRequests();
            if (filterArr != null) {
              for (Iterator<Requests> it = reqs.iterator(); it.hasNext(); ) {
                Requests tmp = it.next();
                if (tmp.getIdSrvFk().getIdSrv() != Integer.parseInt(filterArr[1])) {
                  // System.out.println("removing for " + tmp.getIdSrvFk().getNameSrv());
                  it.remove();
                }
              }
            }
            JSONSerializer json = new JSONSerializer();
            out.println(
                json.include("sreList.idSprFk.idSpr")
                    .exclude("idSrvFk", "*.class", "sreList.*")
                    .serialize("requests", reqs));
          } catch (Exception e) {
            out.println(e.toString());
          }
          dm.closeIt();
          dm = null;
        }
      } else {
        out.print("{success: false, error: 'Request parameter unknown!'}");
      }
    } finally {
      out.close();
    }
  }