/** objectid will be one of following table: ad_listuiconf, ad_listdataconf, ad_objuiconf */
  public ValueHolder execute(DefaultWebEvent event) throws RemoteException, NDSException {
    User usr = helper.getOperator(event);
    TableManager manager = TableManager.getInstance();
    int columnId = Tools.getInt(event.getParameterValue("columnid", true), -1);
    Table table = manager.getColumn(columnId).getTable();
    int tableId = table.getId();
    int objectId = Tools.getInt(event.getParameterValue("objectid", true), -1);
    int type;
    if (tableId == manager.getTable("ad_listdataconf").getId()) {
      type = PortletConfig.TYPE_LIST_DATA;
    } else if (tableId == manager.getTable("ad_listuiconf").getId()) {
      type = PortletConfig.TYPE_LIST_UI;
    } else if (tableId == manager.getTable("ad_objuiconf").getId()) {
      type = PortletConfig.TYPE_OBJECT_UI;
    } else {
      throw new NDSException("Internal Error: table is not supported for PortletConfig:" + table);
    }
    PortletConfigManager pcManager =
        (PortletConfigManager)
            WebUtils.getServletContextManager().getActor(nds.util.WebKeys.PORTLETCONFIG_MANAGER);
    pcManager.removePortletConfig(objectId, type);
    // also try to clear config of specified name
    String name =
        (String)
            nds.query.QueryEngine.getInstance()
                .doQueryOne("select name from " + table.getName() + " where id=" + objectId);
    logger.debug("name=" + name);
    pcManager.removePortletConfig(name, type);

    ValueHolder holder = new ValueHolder();
    holder.put("message", "@complete@(cache size:" + pcManager.getCacheSize() + ")");
    holder.put("code", "0");
    return holder;
  }
  // 获取第三方平台accesstoken		//synchronized
  public JSONObject getAccessToken(WxPublicpartyControl wppc) {
    WePublicparty wpp = wppc.getWePublicparty();
    JSONObject accesstokeninfo = new JSONObject();
    JSONObject param = new JSONObject();
    if (wpp == null
        || nds.util.Validator.isNull(wpp.getAppid())
        || nds.util.Validator.isNull(wpp.getAppsecret())) {
      logger.debug("WePublicparty error->");
      return accesstokeninfo;
    }

    try {
      param.put("component_appid", wpp.getAppid());
      param.put("component_appsecret", wpp.getAppsecret());
      param.put("component_verify_ticket", wpp.getComponent_verify_ticket());
    } catch (Exception e) {

    }

    ValueHolder vh = null;
    logger.debug("get publicparty access token");

    try {
      vh = RestUtils.sendRequest_buff(weixingetpublicpartyaccesstoken, param.toString(), "POST");
      String result = (String) vh.get("message");
      logger.debug("get publicparty access token result->" + result);

      JSONObject tjo = new JSONObject(result);
      String returns = "获取授权码失败!";
      if (tjo != null && tjo.has("component_access_token")) {

        accesstokeninfo.put("code", 0);
        accesstokeninfo.put("message", "获取成功");
        accesstokeninfo.put("data", tjo);
      } else {
        accesstokeninfo.put("code", -1);
        accesstokeninfo.put("message", returns);
      }
    } catch (Exception e) {
      logger.debug("get publicparty access token error->" + e.getLocalizedMessage());
      e.printStackTrace();
      try {
        accesstokeninfo.put("code", -1);
        accesstokeninfo.put("message", "获取授权码失败!");
      } catch (JSONException e1) {

      }
    }

    return accesstokeninfo;
  }
Ejemplo n.º 3
0
 /**
  * 修改单据以下内容: status= JNDINames.STATUS_AUDITING auditorId=null, auditNote=null,
  * modifierid=Operator.UserId() modifieddate=sysdate
  */
 public ValueHolder execute(DefaultWebEvent event) throws NDSException, RemoteException {
   Integer pid = new Integer(Tools.getInt(event.getParameterValue("id"), -1));
   int userId = helper.getOperator(event).getId().intValue();
   String spName = (String) event.getParameterValue("spName");
   String tableName = spName.substring(0, spName.indexOf("Audit"));
   QueryEngine engine = QueryEngine.getInstance();
   int status = engine.getSheetStatus(tableName, pid.intValue());
   if (status == JNDINames.STATUS_AUDITING || status == JNDINames.STATUS_PERMIT) {
     throw new NDSEventException("该请求已经被提交过了!");
   }
   Vector sqls = new Vector();
   sqls.addElement(
       "update "
           + tableName
           + " set status="
           + JNDINames.STATUS_AUDITING
           + ",auditorId=null,auditNote=null,modifierid="
           + userId
           + ", modifieddate=sysdate where id="
           + pid);
   try {
     engine.doUpdate(sqls);
     // Notify
     java.sql.Connection con = null;
     try {
       con = engine.getConnection();
       helper.Notify(
           TableManager.getInstance().getTable(tableName),
           pid.intValue(),
           helper.getOperator(event).getDescription(),
           JNDINames.STATUS_AUDITING,
           con);
     } catch (Exception eee) {
     } finally {
       try {
         if (con != null) con.close();
       } catch (Exception eee) {
       }
     }
     ValueHolder v = new ValueHolder();
     v.put("message", "请求进入审核状态!");
     return v;
   } catch (Exception e) {
     throw new NDSEventException(e.getMessage());
   }
 }
Ejemplo n.º 4
0
  public ValueHolder execute(DefaultWebEvent event) throws NDSException, RemoteException {

    manager = helper.getTableManager();

    Table table = manager.findTable(event.getParameterValue("table", true));
    int tableId = table.getId();
    String[] itemidStr = event.getParameterValues("itemid", true);

    User user = helper.getOperator(event);
    String operatorDesc = user.getDescription();
    String tableName = table.getRealTableName();
    String tableDesc = table.getDescription(event.getLocale());

    if (itemidStr == null) itemidStr = new String[0];
    java.sql.Connection con = null;
    QueryEngine engine = QueryEngine.getInstance();
    con = engine.getConnection();
    try {
      // logger.debug(" parent table of " + table + " is " + parent);
      int[] oids = new int[itemidStr.length];
      for (int i = 0; i < oids.length; i++) oids[i] = Integer.parseInt(itemidStr[i]);

      ValueHolder v = new ValueHolder();

      // 由于界面上无法控制所有的对象都具有相同层次的权限,故需要在此进行权限认证
      // check permissions on all objects
      if (!SecurityUtils.hasPermissionOnAll(
          user.getId().intValue(),
          user.getName(),
          table.getName(),
          itemidStr,
          Directory.WRITE,
          event.getQuerySession())) {
        v.put("message", "@no-void-permission-on-all-pls-do-one-by-one@");
        return v;
      }

      String res = "", s;
      int errCount = 0;
      for (int i = 0; i < itemidStr.length; i++) {
        int itemid = Tools.getInt(itemidStr[i], -1);
        s = voidOne(table, itemid, user.getId().intValue(), con);
        if (s != null) {
          res += s + "<br>";
          errCount++;
        } else {
          logger.info(
              "Invalidate table="
                  + table
                  + ", id="
                  + itemid
                  + " by "
                  + user.name
                  + " of id "
                  + user.id);
        }
      }

      String message = null;

      message = itemidStr.length + "@line@ @request-to-void@";
      if (errCount > 0) message += ", @failed-count@:" + errCount + ", @detail-msg@:" + res;
      else message += ",@complete@";
      v.put("message", message);

      return v;
    } catch (Exception t) {
      if (t instanceof NDSException) throw (NDSException) t;
      else {
        logger.error("Failed", t);
        throw new NDSException(t.getMessage(), t);
      }
    } finally {
      try {
        con.close();
      } catch (Exception e) {
      }
    }
  }
Ejemplo n.º 5
0
  @Override
  public ValueHolder execute(DefaultWebEvent event) throws NDSException, RemoteException {
    ValueHolder vh = new ValueHolder();
    User user = this.helper.getOperator(event);

    if (user == null) {
      logger.debug("publish menu error->user logout");
      vh.put("code", "-1");
      vh.put("message", "用户不存在,请重新登陆->");
      return vh;
    }

    JSONObject jo = (JSONObject) event.getParameterValue("jsonObject");
    try {
      jo = new JSONObject(jo.optString("params"));
    } catch (Exception e) {
      logger.debug("get params error->" + e.getLocalizedMessage());
      e.printStackTrace();
    }

    // 获取与接口相关的信息对象
    WeUtils wu = WeUtilsManager.getByAdClientId(user.adClientId);
    if (wu == null) {
      logger.debug(
          "massreply error->not find WeUtils WeUtilsManager.getByAdClientId("
              + user.adClientId
              + ")");
      vh.put("code", "-1");
      vh.put("message", "请到菜单【微信】的【微信接口配置】中设置APPID与APPSECRET并点击【刷新APP】按钮");
      return vh;
    }
    // 判断APPID与APPSECRET是否为空
    if (nds.util.Validator.isNull(wu.getAppId())) {
      logger.debug(
          "massreply error->appid or appsecret is null[appid:"
              + wu.getAppId()
              + "][appsecret:"
              + wu.getAppSecret()
              + "]");
      vh.put("code", "-1");
      vh.put("message", "请到菜单【微信】的【微信接口配置】中设置APPID与APPSECRET并点击【刷新APP】按钮");
      return vh;
    }

    WxPublicControl wc = WxPublicControl.getInstance(wu.getAppId());
    if (wc == null) {
      logger.debug(
          "massreply error->not find WeControl WeControl.getInstance(" + wu.getAppId() + ")");
      vh.put("code", "-1");
      vh.put("message", "请到菜单【微信】的【微信接口配置】中设置APPID与APPSECRET并点击【刷新APP】按钮");
      return vh;
    }

    logger.debug("getAllMaterial");

    // 素材类型
    String type = jo.optString("type"); // "news"

    WeBatchGetMaterial bgm = WeBatchGetMaterial.getInstance(wu.getAppId());
    JSONObject tempjo = null;
    try {
      tempjo = bgm.getAllMaterials(wc, user, type);
      if (tempjo != null) {
        vh.put("code", tempjo.optInt("code", -1));
        vh.put("message", tempjo.optString("message"));
      } else {
        vh.put("code", "-1");
        vh.put("message", "获取素材列表异常!");
      }
    } catch (Exception e) {
      vh.put("code", "-1");
      vh.put("message", wu.getAppId() + " getMaterial error2->" + e.toString());
      e.printStackTrace();
    }

    return vh;
  }