Package org.butor.json

Examples of org.butor.json.JsonHelper


    int ePos = sqlCall.lastIndexOf(")");
    if (ePos == -1) {
      ApplicationException.exception(CommonMessageID.INVALID_ARG.getMessage("sqlCall"));
    }
    String jsonArgs = sqlCall.substring(pos+1, ePos);
    Map<String, Object> args = new JsonHelper().deserialize(jsonArgs, Map.class);
    String sql = sqlQueryGenerator.generateQuery(procName, args);
    if (Strings.isNullOrEmpty(sql)) {
      rh.addMessage(new Message(0, MessageType.WARNING, "procedure " +procName +" either it does not exists or it was not invoked yet!"));
    }
    rh.addRow(sql);
View Full Code Here


          methodsMap.put(key, m);
        }
      }
    }

    final JsonHelper jsh = new JsonHelper();

    InvocationHandler ih = new InvocationHandler() {
      //private Logger logger = LoggerFactory.getLogger(this.getClass());
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        AjaxContext actx = (AjaxContext)args[0];
        try {
          String key = buildKey(method.getName(), args.length);
          Method target = methodsMap.get(key);
          if (target == null) {
            //TODO
            return null;
          }

          Context ctx = scf.getContext(actx.getRequest().getUserId(),
              actx.getRequest().getSessionId(),
              actx.getRequest().getLang(), actx.getResponseHandler());

          Object[] serviceArgs = new Object[args.length];
          serviceArgs[0] = ctx;
          for (int ii=1; ii<args.length;ii++)
            serviceArgs[ii] = args[ii];

          JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
          String sargs = jsh.serialize(serviceArgs);
          //logger.info("calling service {} with args {}", method.getName(), sargs);
          jsr.setService(method.getName());
          jsr.setServiceArgsJson(sargs);

          return target.invoke(serviceCaller, serviceArgs);
View Full Code Here

          methodsMap.put(key, m);
        }
      }
    }

    final JsonHelper jsh = new JsonHelper();

    InvocationHandler ih = new InvocationHandler() {
      //private Logger logger = LoggerFactory.getLogger(this.getClass());
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        AjaxContext actx = (AjaxContext)args[0];
        try {
          String key = buildKey(method.getName(), args.length);
          Method target = methodsMap.get(key);
          if (target == null) {
            //TODO
            return null;
          }

          Context ctx = scf.getContext(actx.getRequest().getUserId(),
              actx.getRequest().getSessionId(),
              actx.getRequest().getLang(), actx.getResponseHandler());

          Object[] serviceArgs = new Object[args.length];
          serviceArgs[0] = ctx;
          for (int ii=1; ii<args.length;ii++)
            serviceArgs[ii] = args[ii];

          JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
          String sargs = jsh.serialize(serviceArgs);
          //logger.info("calling service {} with args {}", method.getName(), sargs);
          jsr.setService(method.getName());
          jsr.setServiceArgsJson(sargs);

          return target.invoke(serviceCaller, serviceArgs);
View Full Code Here

    authDataCrit.setDataTypes(SecurityConstants.SEC_DATA_TYPE_FIRM);
    authDataCrit.setMode((crit.getMode() != null ? crit.getMode() : AccessMode.READ).value());
    authDataCrit.setMember(cra.getUserId());

    List<FirmWithAccessMode> fl = queryList(PROC_LIST_FIRM, listSql, FirmWithAccessMode.class, crit, cra, authDataCrit);
    JsonHelper jsh = new JsonHelper();
    for (FirmWithAccessMode f : fl) {
      if (f.getAttributesMap() != null) {
        f.setAttributes(jsh.serialize(f.getAttributesMap()));
      }
    }
    return fl;
  }
View Full Code Here

    setMode(mode == null ? AccessMode.READ.value() : mode.value()).
    setMember(cra.getUserId());

    Firm firm = queryFirst(PROC_READ_FIRM, readSql, Firm.class, args, cra, authDataCrit);
    if (firm != null && !Strings.isNullOrEmpty(firm.getAttributes())) {
      JsonHelper jsh = new JsonHelper();
      firm.setAttributesMap(jsh.deserialize(firm.getAttributes(), Map.class));
    }
    return firm;
  }
View Full Code Here

    firm.setStamp(new Date());
    firm.setCreationDate(firm.getStamp());
    firm.setRevNo(0);

    if (firm.getAttributesMap() != null) {
      JsonHelper jsh = new JsonHelper();
      firm.setAttributes(jsh.serialize(firm.getAttributesMap()));
    }

    UpdateResult ur = insert(PROC_INSERT_FIRM, insertSql, firm, cra);
    if (ur.numberOfRowAffected == 0) {
      ApplicationException.exception(DAOMessageID.UNAUTHORIZED.getMessage());
View Full Code Here

  public FirmKey updateFirm(Firm firm, CommonRequestArgs cra) {
    if (!authDao.hasAccess(SecurityConstants.SYSTEM_ID, SecurityConstants.SEC_FUNC_FIRMS, AccessMode.WRITE, cra)) {
      ApplicationException.exception(DAOMessageID.UNAUTHORIZED.getMessage());
    }
    if (firm.getAttributesMap() != null) {
      JsonHelper jsh = new JsonHelper();
      firm.setAttributes(jsh.serialize(firm.getAttributesMap()));
    }
    UpdateResult ur = update(PROC_UPDATE_FIRM, updateSql, firm, cra);
    if (ur.numberOfRowAffected == 0) {
      Firm ef = readFirm(firm.getFirmId(), cra);
      if (ef == null || ef.getRevNo() != firm.getRevNo()) {
View Full Code Here

          methodsMap.put(key, m);
        }
      }
    }

    final JsonHelper jsh = new JsonHelper();

    InvocationHandler ih = new InvocationHandler() {
      //private Logger logger = LoggerFactory.getLogger(this.getClass());
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        AjaxContext actx = (AjaxContext)args[0];
        try {
          String key = buildKey(method.getName(), args.length);
          Method target = methodsMap.get(key);
          if (target == null) {
            //TODO
            return null;
          }

          Context ctx = scf.getContext(actx.getRequest().getUserId(),
              actx.getRequest().getSessionId(), actx.getRequest().getReqId(),
              actx.getRequest().getLang(), actx.getResponseHandler());

          Object[] serviceArgs = new Object[args.length];
          serviceArgs[0] = ctx;
          for (int ii=1; ii<args.length;ii++)
            serviceArgs[ii] = args[ii];

          JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
          String sargs = jsh.serialize(serviceArgs);
          //logger.info("calling service {} with args {}", method.getName(), sargs);
          jsr.setService(method.getName());
          jsr.setServiceArgsJson(sargs);

          return target.invoke(serviceCaller, serviceArgs);
View Full Code Here

        return commonRequestArgs;
      }
    };
  }
  public static CommonRequestArgs getCommonRequestArgs(String commonRequestJSON) {
    CommonRequestArgs commonRequestArgs = new JsonHelper().deserialize(commonRequestJSON, CommonRequestArgs.class);
    return commonRequestArgs;
  }
View Full Code Here

        }
      }
    }
  }
  public static JsonHelper getJsonHelperWithLocalTimeFormatter() {
    return new JsonHelper("yyyy-MM-dd HH:mm:ss.SSS");
  }
View Full Code Here

TOP

Related Classes of org.butor.json.JsonHelper

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.