Пример #1
0
  public static void parse(String xml) {
    Document doc = null;
    try {
      doc = DocumentHelper.parseText(xml); // 将字符串转为XML

      Element rootElt = doc.getRootElement(); // 获取根节点smsReport

      Iterator iters = rootElt.elementIterator("sendResp"); // 获取根节点下的子节点sms

      while (iters.hasNext()) {
        Element recordEle1 = (Element) iters.next();
        Iterator iter = recordEle1.elementIterator("sms");
        int i = 0;
        // 遍历sms节点

        while (iter.hasNext()) {
          Element recordEle = (Element) iter.next();
          String phone = recordEle.elementTextTrim("phone"); // 拿到sms节点下的子节点stat值

          String smsID = recordEle.elementTextTrim("smsID"); // 拿到sms节点下的子节点stat值

          System.out.println(phone + "===" + smsID);
        }
      }
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 /**
  * Processes the Dojo configuration from the supplied {@link Element}
  *
  * @param configElement WebFrameworkConfigElement
  * @param elem Element
  */
 public static void processDojoConfiguration(
     WebFrameworkConfigElement configElement, Element elem) {
   Element dojoConfig = elem.element(DOJO_CONFIG);
   if (dojoConfig != null) {
     String dojoEnabled = dojoConfig.elementTextTrim(DOJO_ENABLED);
     if (dojoEnabled != null) {
       configElement.dojoEnabled = Boolean.valueOf(dojoEnabled);
     }
     String loaderTraceEnabled = dojoConfig.elementTextTrim(DOJO_LOADER_TRACE_ENABLED);
     if (loaderTraceEnabled != null) {
       configElement.dojoLoaderTraceEnabled = Boolean.valueOf(loaderTraceEnabled);
     }
     String bootstrapFile = dojoConfig.elementTextTrim(DOJO_BOOTSTRAP_FILE);
     if (bootstrapFile != null) {
       configElement.dojoBootstrapFile = bootstrapFile;
     }
     String pageWidget = dojoConfig.elementTextTrim(DOJO_PAGE_WIDGETS);
     if (pageWidget != null) {
       configElement.dojoPageWidget = pageWidget;
     }
     String baseUrl = dojoConfig.elementTextTrim(DOJO_BASE_URL);
     if (baseUrl != null) {
       configElement.dojoBaseUrl = baseUrl;
     }
     String messagesObject = dojoConfig.elementTextTrim(DOJO_MESSAGES_OBJECT);
     if (messagesObject != null) {
       configElement.dojoMessagesObject = messagesObject;
     }
     String messagesDefaultScope = dojoConfig.elementTextTrim(DOJO_MESSAGES_DEFAULT_SCOPE);
     if (messagesDefaultScope != null) {
       configElement.dojoMessagesDefaultScope = messagesDefaultScope;
     }
     String defaultLessConfig = dojoConfig.elementTextTrim(DOJO_DEFAULT_LESS_CONFIG);
     if (defaultLessConfig != null) {
       configElement.dojoDefaultLessConfig = defaultLessConfig;
     }
     String aikauVersion = dojoConfig.elementTextTrim(AIKAU_VERSION);
     if (aikauVersion != null) {
       configElement.aikauVersion = aikauVersion;
     }
     Element packages = dojoConfig.element(DOJO_PACKAGES);
     if (packages != null) {
       @SuppressWarnings("unchecked")
       List<Element> packageList = packages.elements(DOJO_PACKAGE);
       if (packageList != null) {
         for (Element packageEntry : packageList) {
           String name = packageEntry.attributeValue(DOJO_PACKAGE_NAME);
           String location = packageEntry.attributeValue(DOJO_PACKAGE_LOCATION);
           if (name != null && location != null) {
             configElement.dojoPackages.put(name, location);
             String main = packageEntry.attributeValue(DOJO_PACKAGE_MAIN);
             if (main != null) {
               configElement.dojoPackagesMain.put(name, main);
             }
           }
         }
       }
     }
   }
 }
Пример #3
0
  /**
   * Handles the IQ packet sent by an owner of the room. Possible actions are:
   *
   * <ul>
   *   <li>Return the list of owners
   *   <li>Return the list of admins
   *   <li>Change user's affiliation to owner
   *   <li>Change user's affiliation to admin
   *   <li>Change user's affiliation to member
   *   <li>Change user's affiliation to none
   *   <li>Destroy the room
   *   <li>Return the room configuration within a dataform
   *   <li>Update the room configuration based on the sent dataform
   * </ul>
   *
   * @param packet the IQ packet sent by an owner of the room.
   * @param role the role of the user that sent the packet.
   * @throws ForbiddenException if the user does not have enough permissions (ie. is not an owner).
   * @throws ConflictException If the room was going to lose all of its owners.
   */
  @SuppressWarnings("unchecked")
  public void handleIQ(IQ packet, MUCRole role)
      throws ForbiddenException, ConflictException, CannotBeInvitedException {
    // Only owners can send packets with the namespace "http://jabber.org/protocol/muc#owner"
    if (MUCRole.Affiliation.owner != role.getAffiliation()) {
      throw new ForbiddenException();
    }

    IQ reply = IQ.createResultIQ(packet);
    Element element = packet.getChildElement();

    // Analyze the action to perform based on the included element
    Element formElement = element.element(QName.get("x", "jabber:x:data"));
    if (formElement != null) {
      handleDataFormElement(role, formElement);
    } else {
      Element destroyElement = element.element("destroy");
      if (destroyElement != null) {
        if (((MultiUserChatServiceImpl) room.getMUCService()).getMUCDelegate() != null) {
          if (!((MultiUserChatServiceImpl) room.getMUCService())
              .getMUCDelegate()
              .destroyingRoom(room.getName(), role.getUserAddress())) {
            // Delegate said no, reject destroy request.
            throw new ForbiddenException();
          }
        }

        JID alternateJID = null;
        final String jid = destroyElement.attributeValue("jid");
        if (jid != null) {
          alternateJID = new JID(jid);
        }
        room.destroyRoom(alternateJID, destroyElement.elementTextTrim("reason"));
      } else {
        // If no element was included in the query element then answer the
        // configuration form
        if (!element.elementIterator().hasNext()) {
          refreshConfigurationFormValues();
          reply.setChildElement(probeResult.createCopy());
        }
        // An unknown and possibly incorrect element was included in the query
        // element so answer a BAD_REQUEST error
        else {
          reply.setChildElement(packet.getChildElement().createCopy());
          reply.setError(PacketError.Condition.bad_request);
        }
      }
    }
    if (reply.getTo() != null) {
      // Send a reply only if the sender of the original packet was from a real JID. (i.e. not
      // a packet generated locally)
      router.route(reply);
    }
  }
Пример #4
0
  /**
   * 初始化数据
   *
   * @param args
   * @throws Exception
   * @throws DocumentException
   */
  @SuppressWarnings("rawtypes")
  public static void init(String[] args) throws Exception {
    try {
      //			 读取配置文件
      Element root = getConfiguration(args);

      //			初始化
      config = getNameMap(root.element("config"));

      //			任务
      Element jobssElement = root.element("jobs");
      if (jobssElement != null && jobssElement.hasContent()) {
        List<?> jobList = jobssElement.elements("job");
        if (jobList != null && jobList.size() > 0) {
          for (Object element : jobList) {
            Element jobElement = (Element) element;
            // 任务属性
            if (!Boolean.parseBoolean(jobElement.attributeValue("enable"))) continue;
            JobInfo jobInfo = new JobInfo();
            JobDetail jobDetail = new JobDetail();
            jobDetail.setName(jobElement.attributeValue("name"));
            jobDetail.setGroup(jobElement.attributeValue("group"));
            jobDetail.setDescription(jobElement.attributeValue("description"));
            String classStr = jobElement.elementTextTrim("class");
            Class clazz = Class.forName(classStr);
            jobDetail.setJobClass(clazz);
            jobInfo.setJobDetail(jobDetail);
            CronTrigger cronTrigger = new CronTrigger();
            cronTrigger.setName(jobElement.attributeValue("name"));
            cronTrigger.setJobGroup(jobElement.attributeValue("group"));
            cronTrigger.setCronExpression(jobElement.elementTextTrim("cron"));
            jobInfo.setCronTrigger(cronTrigger);
            jobs.add(jobInfo);
          }
        }
      }
    } catch (Exception e1) {
      log.error("初始化数据异常:" + e1.getMessage(), e1);
      throw new Exception("初始化数据异常! Init Error!");
    }
  }
Пример #5
0
 @Override
 public void parseEspecial(Element element) {
   if (this.getEvent().equals(WechatEvent.CLICK)) {
     if (element != null) {
       this.setEventKey(element.elementTextTrim("EventKey"));
     }
   } else {
     throw new MsgParseException(
         "微信信息格式解析错误,不能由"
             + this.getEvent().labelOf()
             + "解析成  "
             + WechatEvent.CLICK.labelOf()
             + " 类型");
   }
 }
  @SuppressWarnings("unchecked")
  public Set<String> updateScheduleById(String scheduleId, Set<String> set) {
    try {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      logger.info("根据id更新赛事,id=" + scheduleId);
      if (StringUtils.isBlank(scheduleId)) {
        return set;
      }
      String param = "id=" + scheduleId;
      String data = httpUtil.getResponse(scheduleByIdUrl, HttpUtil.GET, HttpUtil.UTF8, param);
      if (StringUtils.isBlank(data)) {
        logger.info("根据id更新赛事,获取数据为空,id=" + scheduleId);
        return set;
      }
      Document doc = DocumentHelper.parseText(data);
      List<Element> matches = doc.getRootElement().elements("match");

      Schedule schedule = Schedule.findById(Integer.parseInt(scheduleId), false);
      Date matchTime = schedule.getMatchTime(); // 比赛时间
      if (matches == null || matches.size() == 0) { // 删除赛事
        boolean zqEventEmpty = CommonUtil.isZqEventEmpty(schedule);
        if (schedule != null && zqEventEmpty) {
          schedule.remove();
          logger.info("足球赛事删除,id=" + scheduleId);
          if (matchTime != null) {
            set.add(sdf.format(matchTime));
          }
          return set;
        }
      } else if (matches.size() == 1) { // 更新赛事
        Element match = matches.get(0);
        doProcess(match, true);
        if (matchTime != null) { // 之前的比赛时间
          set.add(sdf.format(matchTime));
        }
        String d = match.elementTextTrim("d"); // 现在的比赛时间
        Date time = DateUtil.parse("yyyy/MM/dd HH:mm:ss", d);
        if (time != null) {
          set.add(sdf.format(time));
        }
        return set;
      }
    } catch (Exception e) {
      logger.error("根据id更新赛事发生异常,id=" + scheduleId, e);
    }
    return set;
  }
Пример #7
0
  /*
   * (non-Javadoc)
   *
   * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
   */
  public void init(FilterConfig filterConfig) throws ServletException {
    FileInputStream in = null;

    try {
      xSendFileKey = filterConfig.getInitParameter("xSendFileKey");
      if (StringUtils.isBlank(xSendFileKey)) {
        xSendFileKey = "X-Accel-Redirect";
      }
      if ("web".equals(xSendFileKey)) {
        pagesLocation = filterConfig.getServletContext().getRealPath("/");
        pagesLocation = pagesLocation.replace(File.separatorChar, '/');
        prefix = filterConfig.getInitParameter("pagesLocation");
        if (StringUtils.isBlank(prefix)) {
          prefix = "/p";
          pagesLocation += "p";
        } else {
          if (prefix.startsWith("/")) {
            pagesLocation += prefix.substring(1);
          } else {
            pagesLocation += prefix;
            prefix = "/" + prefix;
          }
        }
      } else {
        pagesLocation = filterConfig.getInitParameter("pagesLocation");
        if (StringUtils.isBlank(pagesLocation)) {
          throw new ServletException("静态化页面存放位置没有配置");
        }
        if (pagesLocation.endsWith("/")) {
          pagesLocation = pagesLocation.substring(0, pagesLocation.length() - 1);
        }
        int idx = pagesLocation.lastIndexOf('/');
        if (idx != -1) {
          prefix = pagesLocation.substring(idx);
        }
      }

      defaultHost = filterConfig.getInitParameter("defaultHost");
      if (StringUtils.isBlank(defaultHost)) {
        defaultHost = "localhost";
      }

      in = new FileInputStream(filterConfig.getServletContext().getRealPath(pageMappingFile));
      SAXReader reader = new SAXReader();
      reader.setValidation(false);
      Document doc = reader.read(in);
      Element root = doc.getRootElement();

      if (root != null) {
        Element element = null;
        Page page = null;
        int beginIndex = 0;
        int endIndex = 0;
        String paramName = null;
        Iterator<Element> it = root.elementIterator();

        while (it.hasNext()) {
          beginIndex = 0;
          endIndex = 0;
          page = new Page();
          element = it.next();
          page.url = element.elementTextTrim("url");
          page.path = element.elementTextTrim("path");
          page.paramNames = new LinkedList<String>();

          while (true) {
            beginIndex = page.path.indexOf("${", beginIndex);

            if (beginIndex < 0) {
              break;
            }

            endIndex = page.path.indexOf("}", beginIndex);

            if (endIndex < 0) {
              break;
            }

            paramName = page.path.substring(beginIndex + 2, endIndex);
            page.paramNames.add(paramName);
            page.path =
                page.path.replace("${" + paramName + "}", "%" + page.paramNames.size() + "$s");
          }

          try {
            page.cronExpression = new CronExpression(element.elementTextTrim("cronExpression"));
          } catch (Exception ex) {
          }
          try {
            page.refreshInterval =
                Long.parseLong(element.elementTextTrim("refreshInterval")) * 1000;
          } catch (Exception ex) {
            page.refreshInterval = Long.MAX_VALUE;
          }

          page.description = element.elementTextTrim("description");
          pageMappings.put(page.url, page);
        }
      }
    } catch (Exception ex) {
      throw new ServletException(ex);
    } finally {
      if (in != null) {
        try {
          in.close();
        } catch (Exception ex) {
        }
      }
    }
  }
  /** Initiates this helper. */
  private void init() {
    logger.info("SRM system configuration: to load ...");

    try {
      String sResource = ClassResourceUtil.mapFullPath(XML_BINDER, true);
      Element xml = XMLUtil.fileToElement(sResource);
      this.setVersion(xml.elementTextTrim("version"));
      this.setEdition(xml.elementTextTrim("edition"));

      if (m_bUniversityEdition) {
        // to load university configuration
        m_universityConfig = new UniversityConfig();
        m_universityConfig.fromXML(xml.element("university"));

        // to validate serial no
        String[] args;
        try {
          args = SNDecoder.decode(m_universityConfig.getSerialNo(), 5);
        } catch (Exception ex) {
          throw new Exception("您当前使用的版本尚未注册!请与www.pureinfo.com.cn联系!");
        }
        if (!m_universityConfig.getCode().equals(args[0])
            || !m_universityConfig.getName().equals(args[1])) {
          throw new Exception("您当前使用的版本尚未注册!请与www.pureinfo.com.cn联系!");
        }

        m_lRegisterExpiredTime = Long.parseLong(args[4]);
        if (System.currentTimeMillis() >= m_lRegisterExpiredTime) {
          throw new Exception("您当前使用的版本已过期!请与www.pureinfo.com.cn联系!");
        }
      } else {
        // to load edu-office configuration
        m_eduOfficeConfig = new EduOfficeConfig();
        m_eduOfficeConfig.fromXML(xml.element("edu-office"));

        // to validate serial no
        String[] args;
        try {
          args = SNDecoder.decode(m_eduOfficeConfig.getSerialNo(), 5);
        } catch (Exception ex) {
          throw new Exception("您当前使用的版本尚未注册!请与www.pureinfo.com.cn联系!");
        }
        if (!m_eduOfficeConfig.getCode().equals(args[0])
            || !m_eduOfficeConfig.getName().equals(args[1])) {
          throw new Exception("您当前使用的版本尚未注册!请与www.pureinfo.com.cn联系!");
        }
        m_lRegisterExpiredTime = Long.parseLong(args[4]);
        if (System.currentTimeMillis() >= m_lRegisterExpiredTime) {
          throw new Exception("您当前使用的版本已过期!请与www.pureinfo.com.cn联系!");
        }
      } // endif

      // to load the modules config
      m_modulesConfig = new ModulesConfig(m_universityConfig.getCode());
      m_modulesConfig.fromXML(xml.element("modules"));

      // OK!
      m_bRegistered = true;
      logger.info("SRM system configuration: loaded and registered");
    } catch (Exception ex) {
      throw new PureRuntimeException(SRMExceptionTypes.CONFIG_LOAD, XML_BINDER, ex);
    }
  }
Пример #9
0
  public void readStringXml(String xml) {
    Document doc = null;
    try {

      // 读取并解析XML文档

      // SAXReader就是一个管道,用一个流的方式,把xml文件读出来

      // SAXReader reader = new SAXReader(); //User.hbm.xml表示你要解析的xml文档

      // Document document = reader.read(new File("User.hbm.xml"));

      // 下面的是通过解析xml字符串的

      doc = DocumentHelper.parseText(xml); // 将字符串转为XML

      Element rootElt = doc.getRootElement(); // 获取根节点

      System.out.println("根节点:" + rootElt.getName()); // 拿到根节点的名称

      Iterator iter = rootElt.elementIterator("head"); // 获取根节点下的子节点head

      // 遍历head节点

      while (iter.hasNext()) {

        Element recordEle = (Element) iter.next();
        String title = recordEle.elementTextTrim("title"); // 拿到head节点下的子节点title值

        System.out.println("title:" + title);

        Iterator iters = recordEle.elementIterator("script"); // 获取子节点head下的子节点script

        // 遍历Header节点下的Response节点

        while (iters.hasNext()) {

          Element itemEle = (Element) iters.next();

          String username = itemEle.elementTextTrim("username"); // 拿到head下的子节点script下的字节点username的值

          String password = itemEle.elementTextTrim("password");

          System.out.println("username:"******"password:"******"body"); // /获取根节点下的子节点body

      // 遍历body节点

      while (iterss.hasNext()) {

        Element recordEless = (Element) iterss.next();
        String result = recordEless.elementTextTrim("result"); // 拿到body节点下的子节点result值

        System.out.println("result:" + result);

        Iterator itersElIterator = recordEless.elementIterator("form"); // 获取子节点body下的子节点form

        // 遍历Header节点下的Response节点

        while (itersElIterator.hasNext()) {

          Element itemEle = (Element) itersElIterator.next();

          String banlce = itemEle.elementTextTrim("banlce"); // 拿到body下的子节点form下的字节点banlce的值

          String subID = itemEle.elementTextTrim("subID");

          System.out.println("banlce:" + banlce);
          System.out.println("subID:" + subID);
        }
      }
    } catch (DocumentException e) {
      e.printStackTrace();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #10
0
  /**
   * @description 将xml字符串转换成map
   * @param xml
   * @return Map
   */
  public static Map readStringXmlOut(String xml) {
    Map map = new HashMap();
    Document doc = null;
    try {
      doc = DocumentHelper.parseText(xml); // 将字符串转为XML

      Element rootElt = doc.getRootElement(); // 获取根节点

      System.out.println("根节点:" + rootElt.getName()); // 拿到根节点的名称

      Iterator iter = rootElt.elementIterator("head"); // 获取根节点下的子节点head

      // 遍历head节点

      while (iter.hasNext()) {

        Element recordEle = (Element) iter.next();
        String title = recordEle.elementTextTrim("title"); // 拿到head节点下的子节点title值

        System.out.println("title:" + title);
        map.put("title", title);

        Iterator iters = recordEle.elementIterator("script"); // 获取子节点head下的子节点script

        // 遍历Header节点下的Response节点

        while (iters.hasNext()) {

          Element itemEle = (Element) iters.next();

          String username = itemEle.elementTextTrim("username"); // 拿到head下的子节点script下的字节点username的值

          String password = itemEle.elementTextTrim("password");

          System.out.println("username:"******"password:"******"username", username);
          map.put("password", password);
        }
      }

      Iterator iterss = rootElt.elementIterator("body"); // /获取根节点下的子节点body

      // 遍历body节点

      while (iterss.hasNext()) {
        Element recordEless = (Element) iterss.next();
        String result = recordEless.elementTextTrim("result"); // 拿到body节点下的子节点result值

        System.out.println("result:" + result);

        Iterator itersElIterator = recordEless.elementIterator("form"); // 获取子节点body下的子节点form

        // 遍历Header节点下的Response节点

        while (itersElIterator.hasNext()) {

          Element itemEle = (Element) itersElIterator.next();

          String banlce = itemEle.elementTextTrim("banlce"); // 拿到body下的子节点form下的字节点banlce的值

          String subID = itemEle.elementTextTrim("subID");

          System.out.println("banlce:" + banlce);
          System.out.println("subID:" + subID);
          map.put("result", result);
          map.put("banlce", banlce);
          map.put("subID", subID);
        }
      }
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return map;
  }
Пример #11
0
  /** 组装actionModel */
  @Override
  public void parse() throws Exception {
    // 读取对应的配置文件
    XmlUtils xmlUtils = new XmlUtils();
    xmlUtils.createXml(((Action) this.model).getConfig());

    // Action生成的动态文件模型
    DynamicActionFileModel fileModel = new DynamicActionFileModel(((Action) model));

    // Action生成的动态执行方法模型
    DynamicActionExecuteMethodModel execute = new DynamicActionExecuteMethodModel();
    execute.setReturnType("void");

    // Action调用逻辑的代码片段
    StringBuffer sb = new StringBuffer("");

    Parse parse = new Parse(new ParseEngineFactory());

    /** 解析对象池定义放入Action对象中的poolVariable */
    if (xmlUtils.getNodeList("//action/pool/object").size() != 0) {
      List<Element> objectList = xmlUtils.getNodeList("//action/pool/object");
      List<String[]> pool = new ArrayList<String[]>();
      for (Element e : objectList) {
        pool.add(new String[] {e.elementTextTrim("name"), e.elementTextTrim("type")});
      }
      ((Action) model).setPoolVariable(pool);
    }

    /** 解析handle */
    int order = 0;
    List<Element> handlesList = xmlUtils.getNodeList("//action/handles/content");
    for (int i = 0; handlesList != null && handlesList.size() > 0 && i < handlesList.size(); i++) {
      Element handleConfig = handlesList.get(i);

      Handle handle = new Handle();
      handle.setAction((Action) model);
      handle.setExecuteOrder(Integer.parseInt(handleConfig.attributeValue("execute-order")));
      handle.setHandleType(handleConfig.attributeValue("type"));
      handle.setHandle(handleConfig.asXML());

      parse.parse(handle);

      sb.append("\n\t\t\t" + handle.getMethod().getCodeSegment());
      execute.appendImports(handle.getMethod().getImports());
      execute.appendGlobalVariables(handle.getMethod().getGlobalVariables());

      order++;
    }

    // 全局变量
    fileModel.appendGlobalVariable(
        "DataProcessEngine dataProcessEngine = new DataProcessEngine();");
    // 引入包
    fileModel.appendImport(" com.dhcc.itsm.form.runtime.FormContext");
    fileModel.appendImport("java.util.*");
    fileModel.appendImport("com.dhcc.itsm.form.engine.core.parseEngine.DataProcessEngine");
    fileModel.appendImport("com.dhcc.itsm.form.runtime.webapp.action.RuntimeAction");
    // 为execute方法设置代码片段
    execute.setCodeSegment(sb.toString());
    // 为Action生成的动态文件模型添加execute方法
    fileModel.addMethod(execute);

    ((Action) model).setFile(fileModel);
  }
  private void doProcess(Element match, boolean updateRanking) {
    try {
      String a = match.elementTextTrim("a"); // 比赛ID
      String c = match.elementTextTrim("c"); // 联赛国语名,联赛繁体名,联赛英文名,联赛ID
      String d = match.elementTextTrim("d"); // 比赛时间
      String f = match.elementTextTrim("f"); // 比赛状态
      String h = match.elementTextTrim("h"); // 主队国语名, 主队繁体名, 主队英文名, 主队ID
      String i = match.elementTextTrim("i"); // 客队国语名, 客队繁体名, 客队英文名, 客队ID
      String j = match.elementTextTrim("j"); // 主队比分
      String k = match.elementTextTrim("k"); // 客队比分
      String l = match.elementTextTrim("l"); // 主队半场比分
      String m = match.elementTextTrim("m"); // 客队半场比分
      String n = match.elementTextTrim("n"); // 主队红牌
      String o = match.elementTextTrim("o"); // 客队红牌
      String p = match.elementTextTrim("p"); // 主队排名
      String q = match.elementTextTrim("q"); // 客队排名
      String r = match.elementTextTrim("r"); // <![CDATA[赛事说明]]>
      String s = match.elementTextTrim("s"); // 轮次/分组名,例如 4/8强/准决赛
      String t = match.elementTextTrim("t"); // 比赛地点
      String u = match.elementTextTrim("u"); // 天气图标
      String v = match.elementTextTrim("v"); // 天气
      String w = match.elementTextTrim("w"); // 温度
      String x = match.elementTextTrim("x"); // 赛季
      String y = match.elementTextTrim("y"); // 小组分组
      String z = match.elementTextTrim("z"); // 是否中立场

      Integer neutrality = StringUtils.equals(z, "True") ? 1 : 0; // 是否是中立场(1:是;0:否)
      String[] homeInfos = h.split("\\,"); // 主队信息
      String homeTeam = homeInfos[0]; // 主队名称
      int homeTeamID = Integer.parseInt(homeInfos[3]); // 主队编号
      String[] guestInfos = i.split("\\,"); // 客队信息
      String guestTeam = guestInfos[0]; // 客队名称
      int guestTeamID = Integer.parseInt(guestInfos[3]); // 客队编号
      Integer scheduleId = Integer.parseInt(a); // 比赛id
      String[] sclassInfos = c.split("\\,"); // 联赛信息
      Integer sclassId = Integer.parseInt(sclassInfos[3]); // 联赛ID
      Date matchTime = DateUtil.parse("yyyy/MM/dd HH:mm:ss", d); // 比赛时间
      Integer matchState = Integer.parseInt(f); // 比赛状态
      Integer homeScore = NumberUtil.parseInt(j, 0); // 主队比分
      Integer guestScore = NumberUtil.parseInt(k, 0); // 客队比分
      Integer homeHalfScore = NumberUtil.parseInt(l, 0); // 主队半场比分
      Integer guestHalsScore = NumberUtil.parseInt(m, 0); // 客队半场比分
      Integer homeRed = NumberUtil.parseInt(n, 0); // 主队红牌
      Integer guestRed = NumberUtil.parseInt(o, 0); // 客队红牌
      Integer round = NumberUtil.parseInt(s, 0); // 轮次
      Integer weatherIcon = NumberUtil.parseInt(u, 0); // 天气图标
      if (sclassId == 95
          && StringUtils.isBlank(y)) { // 如果亞洲杯赛程对应的分组名为空,则取对应的轮次/分组名数据,修复round数据不准确的问题
        y = s;
      }

      Schedule schedule = Schedule.findScheduleWOBuild(scheduleId);
      if (schedule == null) {
        schedule = new Schedule();
        schedule.setScheduleID(scheduleId);
        schedule.setSclassID(sclassId);
        schedule.setMatchTime(matchTime);
        schedule.setMatchState(matchState);
        schedule.setHomeTeam(homeTeam);
        schedule.setHomeTeamID(homeTeamID);
        schedule.setGuestTeam(guestTeam);
        schedule.setGuestTeamID(guestTeamID);
        schedule.setHomeScore(homeScore);
        schedule.setGuestScore(guestScore);
        schedule.setHomeHalfScore(homeHalfScore);
        schedule.setGuestHalfScore(guestHalsScore);
        schedule.setHome_Red(homeRed);
        schedule.setGuest_Red(guestRed);
        schedule.setHome_Order(p);
        schedule.setGuest_Order(q);
        schedule.setExplain(r);
        schedule.setRound(round);
        schedule.setLocation(t);
        schedule.setWeatherIcon(weatherIcon);
        schedule.setWeather(v);
        schedule.setTemperature(w);
        schedule.setMatchSeason(x);
        schedule.setGrouping(y);
        schedule.setNeutrality(neutrality);
        schedule.persist();
        updateRanking(schedule.getScheduleID(), updateRanking);
      } else {
        boolean ismod = false;
        boolean scoreModify = false;
        if (StringUtils.isNotBlank(d)) {
          String pattern = "yyyy/MM/dd HH:mm:ss";
          Date dDate = DateUtil.parse(pattern, d);
          String dDateStr = DateUtil.format(pattern, dDate);
          String matchTimeOldStr = DateUtil.format(pattern, schedule.getMatchTime());
          if (!StringUtils.equals(dDateStr, matchTimeOldStr)) {
            ismod = true;
            schedule.setMatchTime(dDate);
          }
        }
        if (!StringUtils.equals(schedule.getHomeTeam(), homeTeam)) {
          ismod = true;
          schedule.setHomeTeam(homeTeam);
        }
        if (schedule.getHomeTeamID() != homeTeamID) {
          ismod = true;
          schedule.setHomeTeamID(homeTeamID);
        }
        if (!StringUtils.equals(schedule.getGuestTeam(), guestTeam)) {
          ismod = true;
          schedule.setGuestTeam(guestTeam);
        }
        if (schedule.getGuestTeamID() != guestTeamID) {
          ismod = true;
          schedule.setGuestTeamID(guestTeamID);
        }
        Integer oldMatchState = schedule.getMatchState();
        if (matchState != oldMatchState) {
          ismod = true;
          schedule.setMatchState(matchState);
        }
        if (homeScore != schedule.getHomeScore()) {
          ismod = true;
          scoreModify = true;
          schedule.setHomeScore(homeScore);
        }
        if (guestScore != schedule.getGuestScore()) {
          ismod = true;
          scoreModify = true;
          schedule.setGuestScore(guestScore);
        }
        if (homeHalfScore != schedule.getHomeHalfScore()) {
          ismod = true;
          scoreModify = true;
          schedule.setHomeHalfScore(homeHalfScore);
        }
        if (guestHalsScore != schedule.getGuestHalfScore()) {
          ismod = true;
          scoreModify = true;
          schedule.setGuestHalfScore(guestHalsScore);
        }
        if (homeRed != schedule.getHome_Red()) {
          ismod = true;
          schedule.setHome_Red(homeRed);
        }
        if (guestRed != schedule.getGuest_Red()) {
          ismod = true;
          schedule.setGuest_Red(guestRed);
        }
        if (null != p && !p.equals(schedule.getHome_Order())) {
          ismod = true;
          schedule.setHome_Order(p);
        }
        if (null != q && !q.equals(schedule.getGuest_Order())) {
          ismod = true;
          schedule.setGuest_Order(q);
        }
        if (weatherIcon != schedule.getWeatherIcon()) {
          ismod = true;
          schedule.setWeatherIcon(weatherIcon);
        }
        if (v != null && !v.equals(schedule.getWeather())) {
          ismod = true;
          schedule.setWeather(v);
        }
        if (w != null && !w.equals(schedule.getTemperature())) {
          ismod = true;
          schedule.setTemperature(w);
        }
        if (neutrality != schedule.getNeutrality()) {
          ismod = true;
          schedule.setNeutrality(neutrality);
        }
        if (ismod) {
          schedule.merge();
          int wanChangS = MatchState.WANCHANG.value; // 完场状态
          if (wanChangS == schedule.getMatchState()) { // 已完场
            if (wanChangS != oldMatchState) { // 之前的状态不是完场
              commonUtil.sendScheduleFinishJms(schedule); // 发送完场的Jms
              updateRanking(schedule.getScheduleID(), updateRanking); // 更新排名
            }
            // 处理完场后比分发生变化的情况(球探网的比分错误,之后人工修改正确)
            if (wanChangS == oldMatchState && scoreModify) { // 之前的状态是完场
              commonUtil.sendScoreModifyJms(schedule); // 发送比分变化的Jms
              updateRanking(schedule.getScheduleID(), updateRanking); // 更新排名
            }
          }
          if (wanChangS == oldMatchState && wanChangS != schedule.getMatchState()) {
            logger.info(
                "比赛状态由完场变为其他状态,matchState:"
                    + schedule.getMatchState()
                    + ",scheduleId:"
                    + schedule.getScheduleID());
          }
          // 发送赛事缓存更新的Jms
          jmsZqUtil.schedulesCacheUpdate(schedule.getScheduleID());
          jmsZqUtil.schedulesByEventCacheUpdate(schedule.getEvent());
        }
      }
    } catch (Exception e) {
      logger.error("足球处理赛程赛果发生异常", e);
    }
  }
Пример #13
0
  @SuppressWarnings("unchecked")
  protected static WebFrameworkConfigElement newInstance(Element elem) {
    WebFrameworkConfigElement configElement = new WebFrameworkConfigElement();

    // formats
    List<Element> formats = elem.elements("format");
    for (Element el : formats) {
      FormatDescriptor descriptor = new FormatDescriptor(el);
      configElement.formats.put(descriptor.getId(), descriptor);
    }

    // error handlers
    List<Element> errorHandlers = elem.elements("error-handler");
    for (Element el : errorHandlers) {
      ErrorHandlerDescriptor descriptor = new ErrorHandlerDescriptor(el);
      configElement.errorHandlers.put(descriptor.getId(), descriptor);
    }

    // system pages
    List<Element> systemPages = elem.elements("system-page");
    for (Element el : systemPages) {
      SystemPageDescriptor descriptor = new SystemPageDescriptor(el);
      configElement.systemPages.put(descriptor.getId(), descriptor);
    }

    // tag libraries
    List<Element> tagLibraries = elem.elements("tag-library");
    for (Element el : tagLibraries) {
      TagLibraryDescriptor descriptor = new TagLibraryDescriptor(el);
      configElement.tagLibraries.put(descriptor.getId(), descriptor);
    }

    // defaults
    Element defaults = elem.element("defaults");
    if (defaults != null) {
      /** SERVICES * */
      String _requestContextFactoryId = defaults.elementTextTrim("request-context-factory");
      if (_requestContextFactoryId != null) {
        configElement.defaultRequestContextFactoryId = _requestContextFactoryId;
      }
      String _linkBuilderFactoryId = defaults.elementTextTrim("link-builder-factory");
      if (_linkBuilderFactoryId != null) {
        configElement.defaultLinkBuilderFactoryId = _linkBuilderFactoryId;
      }
      String _userFactoryId = defaults.elementTextTrim("user-factory");
      if (_userFactoryId != null) {
        configElement.defaultUserFactoryId = _userFactoryId;
      }

      /** SETTINGS * */
      String _format = defaults.elementTextTrim("format");
      if (_format != null) {
        configElement.defaultFormatId = _format;
      }
      String _regionChrome = defaults.elementTextTrim("region-chrome");
      if (_regionChrome != null) {
        configElement.defaultRegionChrome = _regionChrome;
      }
      String _componentChrome = defaults.elementTextTrim("component-chrome");
      if (_componentChrome != null) {
        configElement.defaultComponentChrome = _componentChrome;
      }

      String _subComponentChrome = defaults.elementTextTrim("sub-component-chrome");
      if (_subComponentChrome != null) {
        configElement.defaultSubComponentChrome = _subComponentChrome;
      }

      String _surfBug = defaults.elementTextTrim("surfbug");
      if (_surfBug != null) {
        configElement.surfBug = _surfBug;
      }

      String _loginCookiesEnabled = defaults.elementTextTrim("login-cookies-enabled");
      if (_loginCookiesEnabled != null) {
        configElement.loginCookiesEnabled = Boolean.valueOf(_loginCookiesEnabled);
      }

      String _theme = defaults.elementTextTrim("theme");
      if (_theme != null && _theme.length() != 0) {
        configElement.defaultTheme = _theme;
      }
      List<Element> pageTypes = defaults.elements("page-type");
      for (Element pageType : pageTypes) {
        String pageTypeId = pageType.elementTextTrim("id");
        String pageTypeInstanceId = pageType.elementTextTrim("page-instance-id");
        configElement.pageTypes.put(pageTypeId, pageTypeInstanceId);
      }
      String _siteConfiguration = defaults.elementTextTrim("site-configuration");
      if (_siteConfiguration != null) {
        configElement.defaultSiteConfiguration = _siteConfiguration;
      }

      /** DEFAULT PERSISTER SETTING * */
      String _defaultPersisterId = defaults.elementText("persister");
      if (_defaultPersisterId != null) {
        configElement.defaultPersisterId = _defaultPersisterId;
      }
    }

    //////////////////////////////////////////////////////
    // Debug Timer
    //////////////////////////////////////////////////////

    Element debugElement = elem.element("debug");
    if (debugElement != null) {
      String _isTimerEnabled = debugElement.elementTextTrim("timer");
      if (_isTimerEnabled != null) {
        configElement.isTimerEnabled = Boolean.parseBoolean(_isTimerEnabled);
      }
    }

    //////////////////////////////////////////////////////
    // Type Specific Things
    //////////////////////////////////////////////////////

    List<Element> objectTypes = elem.elements("object-type");
    for (Element el : objectTypes) {
      TypeDescriptor descriptor = new TypeDescriptor(el);
      if (descriptor.useDefaultPerister() && configElement.getDefaultPersisterId() != null) {
        descriptor.setPersisterId(configElement.getDefaultPersisterId());
      }

      configElement.types.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Resource Loaders
    //////////////////////////////////////////////////////

    List<Element> loaders = elem.elements("resource-loader");
    for (Element el : loaders) {
      ResourceLoaderDescriptor descriptor = new ResourceLoaderDescriptor(el);
      configElement.resourceLoaders.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Resource Resolvers
    //////////////////////////////////////////////////////

    List<Element> resolvers = elem.elements("resource-resolver");
    for (Element el : resolvers) {
      ResourceResolverDescriptor descriptor = new ResourceResolverDescriptor(el);
      configElement.resourceResolvers.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Runtime Configuration
    //////////////////////////////////////////////////////
    List<Element> runtimeConfigElements = elem.elements("runtime-config");
    for (Element el : runtimeConfigElements) {
      RuntimeConfigDescriptor descriptor = new RuntimeConfigDescriptor(el);
      configElement.runtimeConfigs.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Autowire Configuration
    //////////////////////////////////////////////////////
    Element autowireConfigElement = elem.element("autowire");
    if (autowireConfigElement != null) {
      String _autowireModeId = autowireConfigElement.elementTextTrim("mode");
      if (_autowireModeId != null) {
        configElement.autowireModeId = _autowireModeId;
      }
      String _autowireRuntimeId = autowireConfigElement.elementTextTrim("runtime");
      if (_autowireRuntimeId != null) {
        configElement.autowireRuntimeId = _autowireRuntimeId;
      }
    }

    //////////////////////////////////////////////////////
    // Persister Config Descriptor
    //////////////////////////////////////////////////////
    Element persisterConfigElement = elem.element("persisters");
    if (persisterConfigElement != null) {
      configElement.persisterConfigDescriptor =
          new PersisterConfigDescriptor(persisterConfigElement);
    }

    // Module Deployment mode...
    Element moduleDeploymentElement = elem.element("module-deployment");
    if (moduleDeploymentElement != null) {
      String _moduleDeploymentMode = moduleDeploymentElement.elementTextTrim("mode");
      if (_moduleDeploymentMode != null) {
        configElement.moduleDeploymentMode = _moduleDeploymentMode;
      }

      String _enableAutoDeployModules =
          moduleDeploymentElement.elementTextTrim("enable-auto-deploy-modules");
      if (_enableAutoDeployModules != null) {
        configElement.enableAutoDeployModules = Boolean.valueOf(_enableAutoDeployModules);
      }
    }

    // MNT-12724 case, externally specify paths that should be denied by ResourceController
    Element denyAccessPathsElement = elem.element("deny-access-resource-paths");
    if (denyAccessPathsElement != null) {
      List<Element> paths = denyAccessPathsElement.elements("resource-path-pattern");

      for (Element path : paths) {
        configElement.resourcesDeniedPaths.add(Pattern.compile(path.getTextTrim()));
      }
    }

    // When "use-checksum-dependencies" is set to true the JavaScriptDependencyDirective and
    // CssDependencyDirectives will be made available to FreeMarker templates...
    String useChecksumDependencies = elem.elementTextTrim("use-checksum-dependencies");
    if (useChecksumDependencies != null) {
      configElement.useChecksumDependencies = Boolean.valueOf(useChecksumDependencies);
    }

    String generateCssDataImages = elem.elementTextTrim("generate-css-data-images");
    if (generateCssDataImages != null) {
      configElement.generateCssDataImages = Boolean.valueOf(generateCssDataImages);
    }

    String aggregateDependencies = elem.elementTextTrim("aggregate-dependencies");
    if (aggregateDependencies != null) {
      configElement.aggregateDependencies = Boolean.valueOf(aggregateDependencies);
    }

    String calculateWebScriptDependencies =
        elem.elementTextTrim("calculate-webscript-dependencies");
    if (calculateWebScriptDependencies != null) {
      configElement.calculateWebScriptDependencies =
          Boolean.valueOf(calculateWebScriptDependencies);
    }

    String enableRemoteResources = elem.elementTextTrim("enable-remote-resource-resolving");
    if (enableRemoteResources != null) {
      configElement.enableRemoteResourceHandling = Boolean.valueOf(enableRemoteResources);
    }

    String enableGuestPageExtensionModules =
        elem.elementTextTrim("enable-guest-page-extension-modules");
    if (enableGuestPageExtensionModules != null) {
      configElement.enableExtensionModulesOnGuestPages =
          Boolean.valueOf(enableGuestPageExtensionModules);
    }

    String enableDynamicExtensionModules = elem.elementTextTrim("enable-dynamic-extension-modules");
    if (enableDynamicExtensionModules != null) {
      configElement.enableDynamicExtensions = Boolean.valueOf(enableDynamicExtensionModules);
    }

    String disableResourceCaching = elem.elementTextTrim("disable-resource-caching");
    if (disableResourceCaching != null) {
      configElement.disableResourceCaching = Boolean.valueOf(disableResourceCaching);
    }

    // Process any Dojo configuration...
    processDojoConfiguration(configElement, elem);

    return configElement;
  }