/** 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;
  }
예제 #2
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());
   }
 }
예제 #3
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) {
      }
    }
  }
  @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;
  }