Exemplo n.º 1
0
  /**
   * Analyze if testcase FAILED or PASSED base on running results of all steps.
   *
   * @throws Exception
   */
  public void logEnd() throws Exception {
    String rs = new String();

    int a = oi.logList.toArray().length;

    for (String s : oi.logList) {
      if (!StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + init.logTcStart)
          && !StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + init.logTcEnd)) {
        if (!StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + "true")) {
          rs = "FALSE";
          break;
        }
      }
    }

    String tmpStepLog = "";
    tmpStepLog = "," + init.currentStep + " of " + init.sumStep;

    if (rs == "FALSE") {
      oi.logList.add(oi.logRunningTC + "," + init.logFailed + tmpStepLog);
    } else {
      oi.logList.add(oi.logRunningTC + "," + init.logPassed + tmpStepLog);
    }

    System.out.println("END of THIS TC: " + oi.logList.get(oi.logList.size() - 1));
    oi.logList.add(oi.logRunningTC + "," + init.logTcEnd);
    // checkForVerificationErrors(); and insert a FAILED line into loglist
    logToFile();
  }
  public List<String> getSpecialLessons(String grade, String year) {
    List<String> lessons = new ArrayList<String>();
    lessons.addAll(standardSpecialLessons());

    if (StringUtils.equalsIgnoreCase(grade, SIXTH_GRADE)
        || StringUtils.equalsIgnoreCase(grade, FIFTH_GRADE)) {
      List<LessonPost> posts = postDAO.getByYearGradeLessonKeyword(year, grade, null);
      for (LessonPost post : posts) {
        String uuid = post.getUuid();
        if (StringUtils.containsIgnoreCase(uuid, SPECIAL_TAG)) {
          boolean contains = false;
          for (String special : standardSpecialLessons()) {
            if (StringUtils.containsIgnoreCase(uuid, special)) {
              contains = true;
            }
          }

          if (!contains) {
            int index = uuid.indexOf(SPECIAL_TAG) + SPECIAL_TAG.length() + 1;
            String name = uuid.substring(index);

            lessons.add(name);
          }
        }
      }
    }
    return lessons;
  }
Exemplo n.º 3
0
 public String getGroup() {
   if (StringUtils.isNotBlank(group) && !StringUtils.containsIgnoreCase(group, "group by")) {
     if (!StringUtils.containsIgnoreCase(group, ".")) {
       group = "o." + group;
     } // TODO:如果有分组条件但没有指定是哪个则默认为自己。
     return " group by " + group;
   }
   return group == null ? "" : group;
 }
Exemplo n.º 4
0
 @Override
 public void characters(final char[] chars, final int start, final int length)
     throws SAXException {
   if (currentElement.equals("title")) {
     String s = new String(chars, start, length);
     if (StringUtils.containsIgnoreCase(s, plugin.getName())
         && !StringUtils.containsIgnoreCase(s, "bleeding")) {
       versionTitle = s;
     }
   }
 }
Exemplo n.º 5
0
 @Override
 public void startElement(
     final String uri, final String localName, final String qName, final Attributes attributes)
     throws SAXException {
   currentElement = qName;
   if (currentElement.equals("link")) {
     String link = attributes.getValue("href");
     if (StringUtils.containsIgnoreCase(link, plugin.getName())
         && !StringUtils.containsIgnoreCase(link, "bleeding")) {
       versionLink = link;
     }
   }
 }
Exemplo n.º 6
0
  /** Test method for {@link org.jajuk.util.filters.AudioFilter#getDescription()} . */
  public void testGetDescription() {
    StartupCollectionService.registerTypes();

    assertTrue(
        AudioFilter.getInstance().getDescription(),
        StringUtils.containsIgnoreCase(AudioFilter.getInstance().getDescription(), "mp3"));
    assertTrue(
        AudioFilter.getInstance().getDescription(),
        StringUtils.containsIgnoreCase(AudioFilter.getInstance().getDescription(), "ogg"));

    // try removing all types
    TypeManager.getInstance().clear();
    assertEquals("", AudioFilter.getInstance().getDescription());
  }
Exemplo n.º 7
0
  /**
   * 根据条件查询公司
   *
   * @return
   */
  @RequestMapping(value = "/queryCompanyByConditions.htm", produces = "application/json")
  @ResponseBody
  public JsonResult queryCompanyByConditions(TravelCompanyQuery query, Integer limit) {
    List<TravelCompanyDO> list = companyService.listQuery(query);

    List<Map<String, ?>> mapList = CollectionUtils.toMapList(list, "cId", "cName", "cSpell");
    // StringBuilder sb = new StringBuilder();
    String cond = query.getQ() == null ? StringUtils.EMPTY : query.getQ();
    cond = cond.toLowerCase();
    // String temp;
    int maxSize = getLimit(limit);
    int size = 0;
    List<Map<String, ?>> result = new LinkedList<Map<String, ?>>();
    String property = cond.matches("[a-zA-Z]+") ? "cSpell" : "cName";
    for (Map<String, ?> map : mapList) {
      Object cName = null;
      for (Entry<String, ?> entry : map.entrySet()) {
        if (StringUtils.equals(entry.getKey(), property)) {
          cName = entry.getValue();
        }
      }
      if (cond.matches("[a-zA-Z]+")
          ? StringUtils.startsWith((String) cName, cond)
          : StringUtils.containsIgnoreCase((String) cName, cond)) {
        result.add(map);
        size++;
        if (size > maxSize) {
          break;
        }
      }
    }
    return JsonResultUtils.success(result);
  }
  public List<String> getLessons(String grade, String year) {
    List<String> lessons = new ArrayList<String>();

    if (StringUtils.equalsIgnoreCase(grade, SIXTH_GRADE)) {
      int hi_friends = 2;

      for (String lesson : sixthGradeLessons()) {
        lessons.add(HI_FRIENDS_PREFIX + hi_friends + CONJUNCTION + lesson);
      }
    } else if (StringUtils.equalsIgnoreCase(grade, FIFTH_GRADE)) {
      int hi_friends = 1;

      for (String lesson : fifthGradeLessons()) {
        lessons.add(HI_FRIENDS_PREFIX + hi_friends + CONJUNCTION + lesson);
      }
    } else {
      List<String> grades = Arrays.asList(StringUtils.split(grade, CONJUNCTION));
      List<LessonPost> posts = postDAO.getByYearGradeLessonKeyword(year, grades, null);

      for (LessonPost post : posts) {
        String uuid = post.getUuid();
        if (StringUtils.containsIgnoreCase(uuid, LESSONS_PREFIX)) {
          int index = uuid.lastIndexOf(LESSONS_PREFIX) + LESSONS_PREFIX.length();
          String name = uuid.substring(index);

          lessons.add(name);
        }
      }
    }
    return lessons;
  }
Exemplo n.º 9
0
  public static void readHead() {
    String url = "http://www.2177s.com";
    try {
      Document doc = Jsoup.connect(url).timeout(10000).get();
      String title = doc.title();
      System.out.printf("title:%s\n", title);

      //			Elements eles = doc.select("meta[name~=(?i)keywords|(?i)description]");

      Elements eles = doc.select("meta");
      System.out.println(eles.size());
      for (Element ele : eles) {
        if (StringUtils.containsIgnoreCase(url, title)) ;
        if (ele.toString().matches(".*(?i)keywords.*")) {
          System.out.println(ele.attr("content"));
        }
        //				System.out.println(ele.attr("content"));
      }

      //			Elements eles = doc.getElementsByTag("meta");
      //			for (Element ele : eles) {
      //				System.out.printf("keys:%s\n", ele.attr("keywords"));
      //				System.out.printf("desc:%s\n", ele.attr("description"));
      //				System.out.println("----------------");
      //			}
      doc = null;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 10
0
 public String getWhere() {
   if (!whereFlag) {
     int i = 0;
     if (whereBuilder.length() > 0) {
       i++;
     }
     if (queryGroup != null
         && (queryGroup.getGroups().size() > 0 || queryGroup.getRules().size() > 0)) {
       if (StringUtils.isBlank(queryGroup.getGroupOp())) {
         queryGroup.setGroupOp(QueryGroup.AND);
       }
       if (i > 0) {
         whereBuilder.append(" ").append(queryGroup.getGroupOp()).append(" ");
       }
       whereBuilder.append(queryGroup2Where(queryGroup));
     }
     if (whereBuilder.toString().trim().length() > 0) {
       if (!StringUtils.containsIgnoreCase(baseHql, "where")
           && whereBuilder.indexOf("where") == -1) {
         whereBuilder.insert(0, " where ");
       }
     }
     whereFlag = true;
   }
   System.out.println("getWhere: " + whereBuilder.toString());
   return whereBuilder.toString();
 }
Exemplo n.º 11
0
 private boolean containsBoringString(String className) {
   for (String ignoreString : ignoredStrings) {
     if (StringUtils.containsIgnoreCase(className, ignoreString)) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 12
0
 public String getHaving() {
   if (StringUtils.isNotBlank(having) && !StringUtils.containsIgnoreCase(having, "having")) {
     // if(!StringUtils.containsIgnoreCase(having, "o.")){
     // having="o."+having;
     // }
     return " having " + having;
   }
   return having == null ? "" : having;
 }
Exemplo n.º 13
0
 @Override
 public void destroy(ConnectionResource mr) throws Throwable {
   if (!isCreated()) return;
   try {
     // drop the group
     mr.execute("drop persistent group " + name);
     // and also drop all the sites
     for (int i = 0; i < nsites; i++) mr.execute("drop persistent site " + siteKern + i);
     clearCreated();
   } catch (PEException e) {
     if (!throwDropGroupInUseException
         && (StringUtils.containsIgnoreCase(e.getMessage(), "Unable to drop persistent group")
             && StringUtils.containsIgnoreCase(e.getMessage(), "because used by database"))) {
       // eat the exception
     } else {
       throw e;
     }
   }
 }
Exemplo n.º 14
0
 /**
  * Checks if the NameIDFormat is of the following formats below, if not, the name is changed to
  * the value of the first matching usernameAttribute.
  */
 private void identifyNameIDFormat() {
   if (!((StringUtils.containsIgnoreCase(nameIDFormat, SAML2Constants.NAMEID_FORMAT_PERSISTENT)
           || StringUtils.containsIgnoreCase(
               nameIDFormat, SAML2Constants.NAMEID_FORMAT_X509_SUBJECT_NAME)
           || StringUtils.containsIgnoreCase(nameIDFormat, SAML2Constants.NAMEID_FORMAT_KERBEROS)
           || StringUtils.containsIgnoreCase(
               nameIDFormat, SAML2Constants.NAMEID_FORMAT_UNSPECIFIED))
       && !name.equals(""))) {
     for (AttributeStatement attributeStatementList : getAttributeStatements()) {
       List<Attribute> attributeList = attributeStatementList.getAttributes();
       for (Attribute attribute : attributeList) {
         if (listContainsIgnoreCase(usernameAttributeList, attribute.getName())) {
           name = ((XMLString) attribute.getAttributeValues().get(0)).getValue();
           return;
         }
       }
     }
   }
 }
  /*
   * Add authenticated users to the group defined in dspace.cfg by
   * the authentication-ldap.login.groupmap.* key.
   */
  private void assignGroups(String dn, String group, Context context) {
    if (StringUtils.isNotBlank(dn)) {
      System.out.println("dn:" + dn);
      int i = 1;
      String groupMap =
          ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + i);

      boolean cmp;

      while (groupMap != null) {
        String t[] = groupMap.split(":");
        String ldapSearchString = t[0];
        String dspaceGroupName = t[1];

        if (group == null) {
          cmp = StringUtils.containsIgnoreCase(dn, ldapSearchString + ",");
        } else {
          cmp = StringUtils.equalsIgnoreCase(group, ldapSearchString);
        }

        if (cmp) {
          // assign user to this group
          try {
            Group ldapGroup = groupService.findByName(context, dspaceGroupName);
            if (ldapGroup != null) {
              groupService.addMember(context, ldapGroup, context.getCurrentUser());
              groupService.update(context, ldapGroup);
            } else {
              // The group does not exist
              log.warn(
                  LogManager.getHeader(
                      context,
                      "ldap_assignGroupsBasedOnLdapDn",
                      "Group defined in authentication-ldap.login.groupmap."
                          + i
                          + " does not exist :: "
                          + dspaceGroupName));
            }
          } catch (AuthorizeException ae) {
            log.debug(
                LogManager.getHeader(
                    context,
                    "assignGroupsBasedOnLdapDn could not authorize addition to group",
                    dspaceGroupName));
          } catch (SQLException e) {
            log.debug(
                LogManager.getHeader(
                    context, "assignGroupsBasedOnLdapDn could not find group", dspaceGroupName));
          }
        }

        groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + ++i);
      }
    }
  }
Exemplo n.º 16
0
  public DBTable getTableDescription(String dbPool, String schema, String table) {
    DBTable retObj = new DBTable(schema, table);

    if (StringUtils.isBlank(table)) {
      Logger.error(null, this, "getTableDescription", "Table name is empty!");
      return retObj;
    }

    Connection db = null;
    Statement st = null;
    ResultSet rs = null;
    try {
      if (StringUtils.isBlank(dbPool)) {
        db = Utils.getDataSource().getConnection();
      } else {
        db = Utils.getUserDataSource(dbPool).getConnection();
      }
      st = db.createStatement();
      if (StringUtils.isNotBlank(schema)) {
        table = schema + "." + table;
      }
      String query = "DESC " + table;
      if (Logger.isDebugEnabled()) {
        Logger.debug(null, this, "getTableDescription", "QUERY=" + query);
      }
      rs = st.executeQuery(query);
      DBTableHelper.clearCache();
      while (rs.next()) {
        ResultSetMetaData data = rs.getMetaData();
        for (int i = 1; i <= data.getColumnCount(); i++) {
          String name = data.getColumnName(i);
          String value = rs.getString(i);
          if (StringUtils.isBlank(value)) {
            value = "";
          }
          DBTableHelper.addItem(retObj, name, value, -1);
        }
      }
      if (retObj.getFields() != null) {
        List<String> conds = new ArrayList<String>();
        for (int i = 0; i < retObj.getFields().size(); i++) {
          String sKey = DBTableHelper.getListValue(retObj.getKeys(), i);
          boolean bCond = Utils.string2bool(DBTableHelper.getListValue(retObj.getConds(), i));
          conds.add(((bCond || StringUtils.containsIgnoreCase(sKey, "PRI")) ? "1" : "0"));
        }
        retObj.setConds(conds);
      }
      DBTableHelper.clearCache();
    } catch (SQLException e) {
      Logger.error(null, this, "getTableDescription", "SQLException caught: ", e);
    } finally {
      DatabaseInterface.closeResources(db, st, rs);
    }
    return retObj;
  }
Exemplo n.º 17
0
 /** SSF-13 HttpOnly flag SSF-16 Secure flag */
 private void checkCookieFlags(HttpsURLConnection connection) {
   List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
   boolean foundSessionCookie = false;
   for (String cookie : cookies) {
     if (StringUtils.containsIgnoreCase(cookie, "JSESSIONID")) {
       foundSessionCookie = true;
       assertThat(cookie).containsIgnoringCase("Secure").containsIgnoringCase("HttpOnly");
     }
   }
   if (!foundSessionCookie) {
     fail("Session cookie not found");
   }
 }
Exemplo n.º 18
0
  @Override
  public void onApplicationEvent(ApplicationEvent event) {

    // shop key unknow
    String k =
        (String)
            servletContext.getAttribute("Z" + "G" + "S" + "H" + "O" + "P" + "_" + "K" + "E" + "Y");
    String shopkey = EncryptUtils.dencrypt(k);
    if (!StringUtils.containsIgnoreCase(shopkey, "z" + "g" + "s" + "h" + "o" + "p")) {
      throw new RuntimeException();
    }

    // 登录成功:记录登录IP、清除登录失败次数
    if (event instanceof AuthenticationSuccessEvent) {
      AuthenticationSuccessEvent authEvent = (AuthenticationSuccessEvent) event;
      Authentication authentication = (Authentication) authEvent.getSource();
      String loginIp = ((WebAuthenticationDetails) authentication.getDetails()).getRemoteAddress();
      Admin admin = (Admin) authentication.getPrincipal();
      admin.setLoginIp(loginIp);
      admin.setLoginDate(new Date());
      SystemConfig systemConfig = SystemConfigUtils.getSystemConfig();
      if (systemConfig.getIsLoginFailureLock() == false) {
        return;
      }
      admin.setLoginFailureCount(0);
      adminService.update(admin);
    }

    // 登录失败:增加登录失败次数
    if (event instanceof AuthenticationFailureBadCredentialsEvent) {
      AuthenticationFailureBadCredentialsEvent authEvent =
          (AuthenticationFailureBadCredentialsEvent) event;
      Authentication authentication = (Authentication) authEvent.getSource();
      String loginUsername = authentication.getName();
      SystemConfig systemConfig = SystemConfigUtils.getSystemConfig();
      if (systemConfig.getIsLoginFailureLock() == false) {
        return;
      }
      Admin admin = adminService.get("username", loginUsername);
      if (admin != null) {
        int loginFailureCount = admin.getLoginFailureCount() + 1;
        if (loginFailureCount >= systemConfig.getLoginFailureLockCount()) {
          admin.setIsAccountLocked(true);
          admin.setLockedDate(new Date());
        }
        admin.setLoginFailureCount(loginFailureCount);
        adminService.update(admin);
      }
    }
  }
  public String getLesson(String grade, String year, String... parameters) {
    List<String> lessons = new ArrayList<String>();
    lessons.addAll(getLessons(grade, year));
    lessons.addAll(getSpecialLessons(grade, year));
    lessons.addAll(getYearlyItems(grade));

    for (String l : lessons) {
      for (String p : parameters) {
        if (StringUtils.containsIgnoreCase(l, p)) {
          return l;
        }
      }
    }
    return "";
  }
  protected boolean before(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    //        L.trace("begin before");
    resp.setHeader("Access-Control-Allow-Origin", "*");
    resp.setCharacterEncoding(Charsets.DEFAULT);
    String ua = req.getHeader("User-Agent");
    L.trace("----" + StringUtils.trimToEmpty(ua));
    if (StringUtils.isNotBlank(ua) && StringUtils.containsIgnoreCase(ua, "Sogou web spider")) {
      //            L.trace("end before");
      return false;
    }
    //        L.trace("end before");

    return true;
  }
Exemplo n.º 21
0
  /**
   * Verify strings. Using for comparing displayed text.
   *
   * @param exp
   * @param obs
   * @param pro
   * @return [boolean]
   * @throws Exception
   */
  public boolean QVerify(String exp, String obs, int pro) throws Exception {
    /*
     * pro:
     * 0:Expected is Equal	(e.g: return TRUE if a=a);
     * 1:Expected is NOT equal. (e.g: return TRUE if a=a)
     */
    try {
      // handle logging text START
      String logExp, logObs;
      if (exp.length() > 50) {
        logExp = StringUtils.mid(exp, 0, 50) + "...";
      } else {
        logExp = StringUtils.mid(exp, 0, exp.length());
      } // Cut expected string for Reporting
      if (exp.length() > 50) {
        logObs = StringUtils.mid(obs, 0, 50) + "...";
      } else {
        logObs = StringUtils.mid(obs, 0, obs.length());
      } // Cut observed string for Reporting
      if (StringUtils.indexOf(logObs, "\n") > 0) {
        logObs = StringUtils.mid(logObs, 0, StringUtils.indexOf(obs, "\n"));
      }
      ; // Again cut observed string for Reporting

      // handle logging text END

      if (StringUtils.containsIgnoreCase(obs.trim(), exp.trim()) == true) {
        if (pro == 0) {
          logStep("", "TRUE", "Expectation: " + logExp + " , " + "Observation: " + logObs);
          return true;
        } else {
          logStep("", "FALSE", "Expectation: " + logExp + " , " + "Observation: " + logObs);
          return false;
        }
      } else {
        if (pro == 0) {
          logStep("", "FALSE", "Expectation: " + logExp + " , " + "Observation: " + logObs);
          return false;
        } else {
          logStep("", "TRUE", "Expectation: " + logExp + " , " + "Observation: " + logObs);
          return true;
        }
      }
    } catch (Exception e) {
      logStep("", "FALSE", "Expectation: " + exp.trim() + " , " + "Observation: " + obs.trim());
      return false;
    }
  }
Exemplo n.º 22
0
  @Override
  public Set<Principal> getPrincipals() {
    Set<Principal> principals = new HashSet<>();
    Principal primary = getPrincipal();
    principals.add(primary);
    principals.add(new RolePrincipal(primary.getName()));
    for (AttributeStatement attributeStatement : getAttributeStatements()) {
      for (Attribute attr : attributeStatement.getAttributes()) {
        if (StringUtils.containsIgnoreCase(attr.getName(), "role")) {
          for (final XMLObject obj : attr.getAttributeValues()) {
            principals.add(new RolePrincipal(((XSString) obj).getValue()));
          }
        }
      }
    }

    return principals;
  }
Exemplo n.º 23
0
 // 查看订单跟踪明细信息
 @SuppressWarnings("unchecked")
 public String viewDetail() {
   String userAgent = request.getHeader("User-Agent");
   if (StringUtils.containsIgnoreCase(userAgent, "MSIE")) {
     browseType = BROWSE_TYPE_IE;
   }
   String salordicode = request.getParameter("salordicode");
   // List mainInfo = erpService.findByList("shcb_erp_sql.getOrderBaseInfo", salordicode);
   List shipperInfos = erpService.findByList("shcb_erp_sql.getShipperInfo", salordicode);
   List customers = erpService.findByList("shcb_erp_sql.getCustomInfo", salordicode);
   List shs = erpService.findByList("shcb_erp_sql.getShInfo", salordicode);
   List hks = erpService.findByList("shcb_erp_sql.getHkInfo", salordicode);
   List fys = erpService.findByList("shcb_erp_sql.getFyInfo", salordicode);
   // request.setAttribute("mainInfo", mainInfo);
   request.setAttribute("shippers", shipperInfos);
   request.setAttribute("customers", customers);
   request.setAttribute("shs", shs);
   request.setAttribute("hks", hks);
   request.setAttribute("fys", fys);
   return "order-view-detail";
 }
  private boolean parseSimpleClause(String fieldName, String operator, Object value)
      throws JSONException {

    String hqlOperator = getHqlOperator(operator);
    String strField = fieldName;
    boolean filterIdentifier = false;
    // if (strField.endsWith("$_identifier")) {
    // strField = strField.substring(0, strField.length() - 12);
    // filterIdentifier = true;
    // }
    Object mapValue = recordMap.get(strField);
    if (operator.equals(OPERATOR_NOTNULL)) {
      return mapValue != null;
    } else if (operator.equals(OPERATOR_ISNULL)) {
      return mapValue == null;
    }

    Object localValue = value;
    if (ignoreCase(mapValue, operator)) {
      localValue = localValue.toString().toUpperCase();
    }

    boolean returnVal = mainOperatorIsAnd;

    if ("id".equals(strField)) {
      // ID is always equals
      returnVal = mapValue != JSONObject.NULL && ((String) localValue).equals(mapValue);
    } else if (filterIdentifier) {
      BaseOBObject currentVal = (BaseOBObject) mapValue;
      String strCurrValIdentifier = currentVal.getIdentifier();
      String strCurrentFilter = (String) localValue;
      returnVal = StringUtils.containsIgnoreCase(strCurrValIdentifier, strCurrentFilter);
    } else if (mapValue instanceof Boolean) {
      returnVal = (Boolean) mapValue == (Boolean) localValue;
    } else if (mapValue instanceof BigDecimal) {
      BigDecimal filterValue = new BigDecimal((Integer) localValue);
      int compare = filterValue.compareTo((BigDecimal) mapValue);
      if ("=".equals(hqlOperator)) {
        returnVal = compare == 0;
      } else if ("!=".equals(hqlOperator)) {
        returnVal = compare != 0;
      } else if (">".equals(hqlOperator)) {
        returnVal = compare > 0;
      } else if (">=".equals(hqlOperator)) {
        returnVal = compare >= 0;
      } else if ("<".equals(hqlOperator)) {
        returnVal = compare < 0;
      } else if ("<=".equals(hqlOperator)) {
        returnVal = compare <= 0;
      }

    } else if (mapValue instanceof Date) {
      try {
        Date filterValue;
        try {
          filterValue = simpleDateTimeFormat.parse(localValue.toString());
        } catch (ParseException e) {
          // When a DateTime column is filtered, plan Date values are used
          // See issue https://issues.openbravo.com/view.php?id=23203
          filterValue = simpleDateFormat.parse(localValue.toString());
        }
        final Calendar calendar = Calendar.getInstance();
        calendar.setTime(filterValue);
        // Applies the time zone offset difference of the client
        calendar.add(Calendar.MINUTE, clientUTCMinutesTimeZoneDiff);
        // move the date to the beginning of the day
        if (isGreaterOperator(operator)) {
          calendar.set(Calendar.HOUR, 0);
          calendar.set(Calendar.MINUTE, 0);
          calendar.set(Calendar.SECOND, 0);
          calendar.set(Calendar.MILLISECOND, 0);
        } else if (isLesserOperator(operator)) {
          // move the data to the end of the day
          calendar.set(Calendar.HOUR, 23);
          calendar.set(Calendar.MINUTE, 59);
          calendar.set(Calendar.SECOND, 59);
          calendar.set(Calendar.MILLISECOND, 999);
        }
        // Applies the time zone offset difference of the server
        calendar.add(Calendar.MINUTE, -UTCServerMinutesTimeZoneDiff);
        Date mapDate = (Date) mapValue;
        boolean isBefore = mapDate.before(calendar.getTime());
        boolean isAfter = mapDate.after(calendar.getTime());
        boolean sameDate = mapDate.compareTo(calendar.getTime()) == 0;
        if ("=".equals(hqlOperator)) {
          returnVal = sameDate;
        } else if ("!=".equals(hqlOperator)) {
          returnVal = !sameDate;
        } else if (">".equals(hqlOperator)) {
          returnVal = isAfter;
        } else if (">=".equals(hqlOperator)) {
          returnVal = isAfter || sameDate;
        } else if ("<".equals(hqlOperator)) {
          returnVal = isBefore;
        } else if ("<=".equals(hqlOperator)) {
          returnVal = isBefore || sameDate;
        }
      } catch (Exception e) {
        throw new IllegalArgumentException(e);
      }
    } else if (mapValue instanceof String) {
      String strCurrentValue = (String) mapValue;
      String strCurrentFilter = (String) localValue;
      returnVal = StringUtils.containsIgnoreCase(strCurrentValue, strCurrentFilter);
    }

    if (isNot(operator)) {
      return !returnVal;
    } else {
      return returnVal;
    }
  }
Exemplo n.º 25
0
  private void onUpdate() {
    String searchString = edSearch.getText().trim();

    lsmdl.clear();

    for (Iterator<CCMovie> it = movielist.iteratorMovies(); it.hasNext(); ) {
      CCMovie mov = it.next();

      if ((mov.getLocalID() + "").equals(searchString)) { // $NON-NLS-1$
        addToList(mov);
        continue;
      }

      if (StringUtils.containsIgnoreCase(mov.getTitle(), searchString)) {
        addToList(mov);
        continue;
      }

      if (StringUtils.containsIgnoreCase(mov.getZyklus().getTitle(), searchString)) {
        addToList(mov);
        continue;
      }

      boolean movFound = false;
      for (int i = 0; i < mov.getPartcount(); i++) {
        if (StringUtils.containsIgnoreCase(mov.getAbsolutePart(i), searchString)) {
          movFound = true;
          addToList(mov);
          break;
        }
      }
      if (movFound) {
        continue;
      }
    }

    for (Iterator<CCSeries> it = movielist.iteratorSeries(); it.hasNext(); ) {
      CCSeries ser = it.next();

      for (int i = 0; i < ser.getSeasonCount(); i++) {
        CCSeason sea = ser.getSeason(i);

        for (int j = 0; j < sea.getEpisodeCount(); j++) {
          CCEpisode epi = sea.getEpisode(j);

          if (StringUtils.containsIgnoreCase(epi.getTitle(), searchString)) {
            addToList(epi);
            continue;
          }

          if (StringUtils.containsIgnoreCase(epi.getAbsolutePart(), searchString)) {
            addToList(epi);
            continue;
          }
        }

        if (StringUtils.containsIgnoreCase(sea.getTitle(), searchString)) {
          addToList(sea);
          continue;
        }
      }

      if (StringUtils.containsIgnoreCase(ser.getTitle(), searchString)) {
        addToList(ser);
        continue;
      }
    }
  }
 protected boolean match(String resourceType, String keyword) {
   return StringUtils.containsIgnoreCase(resourceType, keyword);
 }
Exemplo n.º 27
0
  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;

    String contextPath = httpRequest.getContextPath();
    String requestUrl = httpRequest.getRequestURI().replace(contextPath, "");

    // 当遇到不须过滤的直接跳过,/mobile/不作过滤。
    if ("/".equals(requestUrl)
        || requestUrl.contains("//")
        || map.get(StringUtil.parseSuffix(requestUrl, "url")) != null
        || suffixmap.get(StringUtil.parseSuffix(requestUrl, "suffix")) != null) {
      // System.out.println(TimeDateHelper.changeDate2String(new Date(),"yyyy-MM-dd
      // HH:mm:ss")+"----requestUrl==遇到不用过滤的直接跳过=="+requestUrl);
      // 可以跳过
      chain.doFilter(request, response);
      return;
    }

    HttpSession httpSession = httpRequest.getSession(false); // 传 false参数不创建session
    // httpSession.setMaxInactiveInterval(60);
    Object userinfo = httpSession.getAttribute("userinfo");

    if (userinfo == null) {
      String userAgent = httpRequest.getHeader("User-Agent");

      if (userAgent != null
          && (StringUtils.containsIgnoreCase(userAgent, "android")
              || StringUtils.containsIgnoreCase(userAgent, "iphone")
              || StringUtils.containsIgnoreCase(userAgent, "ipad"))) {

        httpSession = httpRequest.getSession();

        // 保存当前请求的信息,用于虚拟登录时恢复
        httpRequest.setAttribute("servletPath", httpRequest.getServletPath());
        httpRequest.setAttribute(
            "pathInfo", httpRequest.getPathInfo() == null ? "" : httpRequest.getPathInfo());
        httpRequest.setAttribute(
            "queryString",
            httpRequest.getQueryString() == null ? "" : httpRequest.getQueryString());

        httpRequest.getRequestDispatcher("/user/sessionTimeout").forward(httpRequest, httpResponse);
      } else {
        httpRequest.getRequestDispatcher("/user/notSupport").forward(httpRequest, httpResponse);
      }
      //            } else {
      //                // web请求转到登录页面
      //                String ajax=httpRequest.getHeader("X-Requested-With");
      //
      //                if(StringUtils.isNotBlank(ajax)){
      //
      // httpRequest.getRequestDispatcher("/user/sessionTimeoutWeb").forward(httpRequest,
      // httpResponse);
      //                } else {
      //
      // httpRequest.getRequestDispatcher("/login/login.jsp").forward(httpRequest, httpResponse);
      //                }
      //            }
      //
    } else {
      chain.doFilter(httpRequest, httpResponse);
    }
  }
Exemplo n.º 28
0
 /**
  * Returns <code>true</code> if a String contains the given substring. Otherwise <code>false
  * </code>.
  *
  * @param ref the {@link String} to test
  * @param substring the substring to look for
  * @param ignoreCase whether the comparison should be case-insensitive
  * @return Returns <code>true</code> iff the String contains the given substring. Otherwise <code>
  *     false</code>.
  */
 public static boolean contains(String ref, String substring, boolean ignoreCase) {
   if (ignoreCase) return StringUtils.containsIgnoreCase(ref, substring);
   return StringUtils.contains(ref, substring);
 }
Exemplo n.º 29
0
  public void run() {
    overallCount = new HashMap<String, Integer>();
    pageCount = new HashMap<String, Map<String, Integer>>();
    jobCount = new HashMap<String, Map<String, Integer>>();

    long startTime = System.currentTimeMillis();

    while (!stop) {
      Map<Thread, StackTraceElement[]> allTraces = Thread.getAllStackTraces();

      for (Thread thread : allTraces.keySet()) {
        String pageName = null;
        String jobName = null;

        Map<String, Integer> classCountForThread = new HashMap<String, Integer>();
        for (StackTraceElement stackElement : allTraces.get(thread)) {
          Class clazz = getStackElementClass(stackElement);
          String className = clazz == null ? stackElement.getClassName() : clazz.getName();

          if (!containsBoringString(className)) {
            String key =
                className
                    + "."
                    + stackElement.getMethodName()
                    + "() line "
                    + stackElement.getLineNumber();

            if (!classCountForThread.containsKey(key)) {
              classCountForThread.put(key, 0);
            }
            classCountForThread.put(key, classCountForThread.get(key) + 1);
          }
          if (clazz != null && StringUtils.containsIgnoreCase(className, ".pages.")) {
            pageName = clazz.getSimpleName();
          }
          if (clazz != null && jobIdentifier.isJob(clazz)) {
            jobName = clazz.getSimpleName();
          }
        }
        if (pageName != null) {
          if (!pageCount.containsKey(pageName)) {
            pageCount.put(pageName, new HashMap<String, Integer>());
          }
          mergeCounts(pageCount.get(pageName), classCountForThread);
        }
        if (jobName != null && !ignoreJobs) {
          if (!jobCount.containsKey(jobName)) {
            jobCount.put(jobName, new HashMap<String, Integer>());
          }
          mergeCounts(jobCount.get(jobName), classCountForThread);
        }
        if (!ignoreJobs || jobName == null) {
          mergeCounts(overallCount, classCountForThread);
        }
      }

      long curTime = System.currentTimeMillis();
      if (curTime - startTime >= (maxThreadRuntime * 60 * 1000)) {
        log.info(
            "Profiler thread has been running for the maximum of {} minutes, quitting",
            maxThreadRuntime);
        stop = true;
      }

      try {
        Thread.sleep(pollingInterval);
      } catch (InterruptedException e) {
      }
    }
  }
Exemplo n.º 30
0
  /**
   * (non-Javadoc)
   *
   * @see
   *     com.santander.supernet.jbServices.MovimientoService#obtenerMovimientosTransferencias(ClienteBean,
   *     OperacionesBitacoraBean, BitacoraBean)
   */
  public List<ConsultaBitacoraBean> obtenerMovimientosTransferencias(
      OperacionesBitacoraBean opBitacora, BitacoraBean bitacora) throws BusinessException {
    SantanderConsultarBitacoraService sbs = new SantanderConsultarBitacoraService();
    boolean sinMovimientos = true;

    sbs.setCuentaFiltro(opBitacora.getCuentaFiltro());
    sbs.setNumeroCliente(opBitacora.getNumeroCliente());
    sbs.setNumeroCuenta(opBitacora.getNumeroCuenta());

    try {
      sbs.setFechaInicio(Utils.sdfSocket.format(Utils.sdf.parse(opBitacora.getFechaInicio())));
      sbs.setFechaFin(Utils.sdfSocket.format(Utils.sdf.parse(opBitacora.getFechaFin())));
    } catch (Exception e) {
      throw new BusinessException("PAR-01");
    }

    sbs.setTipoOperacion("1");
    sbs.setImporteInicial(opBitacora.getImporteInicial());
    sbs.setImporteFinal(opBitacora.getImporteFinal());
    sbs.setTipoEstatus(" ");

    sbs.ejecuta();

    if (sbs.getCodigoEstatus() == 99
        || sbs.getConsultaBita() == null
        || sbs.getConsultaBita().isEmpty()) {
      throw new BusinessException("MOVC-TRNI-1");
    } else if (sbs.getCodigoEstatus() == NO_MOVIMIENTOS) {
      throw new BusinessException("mov-1");
    } else if (sbs.getCodigoEstatus() != 0) {
      throw new BusinessException("ERROR_SERVICIO");
    }

    Iterator registros = sbs.getConsultaBita().iterator();

    List<ConsultaBitacoraBean> bitacoraResp = new ArrayList<ConsultaBitacoraBean>();

    for (Iterator iter = registros; iter.hasNext(); ) {
      String arrTabla[] = (String[]) iter.next();
      if (StringUtils.contains(arrTabla[5], "TEF")
          || StringUtils.contains(arrTabla[5], "SPEI")
          || StringUtils.contains(arrTabla[5], "TRANSFERENCIAS ENTRE CUENTAS INTERBAN")
          || StringUtils.contains(arrTabla[5], "TRANSFERENCIAS TELEFONO MOVIL DE OTROS BANCOS")) {
        if (StringUtils.containsIgnoreCase(arrTabla[18], "RECHAZADA")
            || StringUtils.containsIgnoreCase(arrTabla[18], "ACEPTADA")) {
          ConsultaBitacoraBean bean = new ConsultaBitacoraBean();
          sinMovimientos = false;

          bean.setConcepto(arrTabla[19]);
          bean.setCuentaDestino(arrTabla[11].trim().equals("0000000000000000") ? "" : arrTabla[11]);
          bean.setCuentaOrigen(arrTabla[10].trim().equals("0000000000000000") ? "" : arrTabla[10]);
          bean.setCuentaReferencia(
              arrTabla[4].trim().equals("0000000000000000") ? "" : arrTabla[4]);
          bean.setDescripcionReferencia(arrTabla[5]);
          String estatus = Utils.estatusTranferenciaInterbancaria(arrTabla[18]);
          bean.setEstatus(estatus);
          bean.setFecha(arrTabla[0]);
          bean.setHora(arrTabla[1]);
          bean.setImporte(arrTabla[17]);
          bean.setNumeroReferencia(arrTabla[2]);

          int auxT = arrTabla[19].trim().indexOf("TC0");

          if (auxT >= 0) {
            bean.setTipoCambio(arrTabla[19].trim().substring(auxT + 3, auxT + 8));
          }

          if (arrTabla[3].trim().equals("PGSE")
              || arrTabla[3].trim().equals("PGSP")
              || arrTabla[3].trim().equals("PSTP")) {
            bean.setTipoOperacion(arrTabla[3]);
          }

          String strRefTrans =
              getTranferReference2SPEI(
                      bean.getFecha(), bean.getNumeroReferencia(), opBitacora.getNumeroCliente())
                  .substring(0, 7);
          if (isNumeric(strRefTrans)) {
            ResConTranfer resTrans = getStatus2SPEI(bean.getFecha(), strRefTrans);
            if (resTrans.getEstatus().equals("Error")) {
              bean.setEstatus("NO DISPONIBLE");
              // throw new BusinessException("h-3");
            } else {
              bean.setEstatus(resTrans.getEstatus());
            }
          }

          arrTabla = null;
          bitacoraResp.add(bean);
        }
      }
    }

    if (sinMovimientos) {
      throw new BusinessException("MOVC-TRNI-1");
    }

    // TODO: falta registrar en bitacora.

    return bitacoraResp;
  }