예제 #1
0
    @Override
    public void before(ActionEvent<List<WebContentEntity>> event) {
      Orm orm = event.getOrm();

      WebCatalogEntity catalog = null;
      String catalogCode = "";

      List<WebContentEntity> list = event.getEntity();
      for (WebContentEntity entity : list) {

        /*
         * 获取栏目编码
         */
        if (catalog == null) {
          catalog = entity.getCatalog();
          catalogCode = catalog.getCode();
          if (StringUtil.isNil(catalogCode)) {
            catalog = (WebCatalogEntity) orm.load(catalog.getClass(), catalog.getId());
            catalogCode = catalog.getCode();
          }
        }

        /** 设置栏目编码(冗余字段) */
        entity.setCatalogCode(catalogCode);
      }
    }
예제 #2
0
  /**
   * 参数:
   *
   * <UL>
   *   <LI>mobiles 手机号码(群发为字符串数组推荐最多为200个手机号码或以内)
   *   <LI>smsContent
   *       短信内容(最多500个汉字或1000个纯英文,emay服务器程序能够自动分割;亿美有多个通道为客户提供服务,所以分割原则采用最短字数的通道为分割短信长度的规则,请客户应用程序不要自己分割短信以免造成混乱)
   *   <LI>addSerial 扩展号 (长度小于15的字符串) 用户可通过扩展号自定义短信类别
   *   <LI>smsPriority 优先级(级别从1到5的正整数,数字越大优先级越高,越先被发送)
   *       <p>返回值:
   *       <UL>
   *         <UL>
   *           <LI>0 成功
   *           <LI>-1 系统异常
   *           <LI>-2 客户端异常
   *           <LI>-9001 序列号格式错误
   *           <LI>-9002 密码格式错误
   *           <LI>-9003 客户端key格式错误
   *           <LI>-9016 发送短信包大小超出范围
   *           <LI>-9017 发送短信内容格式错误
   *           <LI>-9019 发送短信优先级格式错误
   *           <LI>-9020 发送短信手机号格式错误
   *           <LI>-9022 发送短信唯一序列值错误
   *           <LI>-9025 客户端请求sdk5超时
   *           <LI>-101 命令不被支持
   *           <LI>-104 请求超过限制
   *           <LI>-117 发送短信失败
   *           <LI>-126 路由信息失败
   *           <LI>-1104 路由失败,请联系系统管理员
   *           <LI>101 客户端网络故障
   *           <LI>307 目标电话不符合规则,电话号码必须是以0,1开头
   *           <LI>303 由于客户端网络问题导致信息发送超时,该信息是否成功下发无法确定
   *           <LI>305 服务器端返回错误,错误的返回值(返回值不是数字字符串)
   *         </UL>
   */
  @Override
  public String send(String mobiles, String content, String extCode, String time, String rrid) {

    if (emayClient == null) {
      register();
      //
      // Log.info("EmaySmsClient.send: 失败!{emayClient:null}");
      //
      // return null;
    }
    synchronized (emayClient) {
      content = StringUtil.trim(content);

      /*
       * 经过测试:10657可以支持500个字。
       */
      int from = 0;
      int len = content.length();
      int to = Math.min(from + 500, len);

      String[] telArray = StringUtil.toArray(mobiles, ",;,; \r\t\n");
      if (telArray.length == 0) {
        return "307";
      }

      StringBuffer ret = new StringBuffer();
      while (from < to && to <= len) {
        String msg = content.substring(from, to);
        ret.append("," + this.emayClient.sendSMS(telArray, msg, 5));
        from = to + 1;
        to = Math.min(from + 500, len);
      }

      Log.info(
          "EmaySmsClient.send: result=%s {mobiles:%s,  content:%s,  extCode:%s,  time:%s,  rrid:%s}",
          ret, mobiles, content, extCode, time, rrid);

      return ret.length() > 0 ? ret.substring(1) : "";
    }
  }
예제 #3
0
    @Override
    public void before(ActionEvent<WebContentEntity> event) {
      Orm orm = event.getOrm();

      WebContentEntity entity = event.getEntity();

      /*
       * 获取栏目编码
       */
      WebCatalogEntity catalog = entity.getCatalog();
      String catalogCode = catalog.getCode();
      if (StringUtil.isNil(catalogCode)) {
        catalog = (WebCatalogEntity) orm.load(catalog.getClass(), catalog.getId());
        catalogCode = catalog.getCode();
      }

      /** 设置栏目编码(冗余字段) */
      entity.setCatalogCode(catalogCode);
    }
예제 #4
0
    @Override
    public void before(ActionEvent<WebCatalogEntity> event) {
      synchronized (SaveWebCatalog.class) {
        Orm orm = event.getOrm();

        WebCatalogEntity entity = event.getEntity();

        String catalogCode = entity.getCode();
        if (!StringUtil.isNil(catalogCode)) {
          WebCatalogEntity existedCatalog =
              (WebCatalogEntity) orm.get(entity.getClass(), Expr.eq("code", catalogCode));
          if (existedCatalog != null && catalogCode.equals(existedCatalog.getCode())) {
            if (entity.getId() != existedCatalog.getId()) {
              throw new CocException("栏目编码已经被占用!");
            }
          }
        }
      }
    }