Java Code Examples for org.jsoup.helper.StringUtil#isBlank()

The following examples show how to use org.jsoup.helper.StringUtil#isBlank() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
private void checkSourceDestinationTopic(RuleEngineEntity ruleEngineEntity) throws GovernanceException {
    ArrayList<String> list = new ArrayList<>();
    if (!StringUtil.isBlank(ruleEngineEntity.getFromDestination())) {
        list.add(ruleEngineEntity.getFromDestination().trim());
    }

    if (!StringUtil.isBlank(ruleEngineEntity.getToDestination())) {
        list.add(ruleEngineEntity.getToDestination().trim());
    }
    if (!StringUtil.isBlank(ruleEngineEntity.getErrorDestination())) {
        list.add(ruleEngineEntity.getErrorDestination().trim());
    }
    Set<String> topicSet = new HashSet<>(list);
    if (topicSet.size() < list.size()) {
        throw new GovernanceException("source topic 、destination topic and error topic cannot be the same");
    }
}
 
Example 2
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
private void checkField(RuleEngineEntity rule) throws GovernanceException {
    if (rule.getConditionType() == null) {
        log.error("the conditionType is empty");
        throw new GovernanceException("the conditionType is empty");
    }
    boolean flag = ConditionTypeEnum.TOPIC.getCode().equals(rule.getConditionType()) && StringUtil.isBlank(rule.getToDestination());
    if (flag) {
        log.error("the toDestination is empty");
        throw new GovernanceException("the toDestination is empty");
    }
    flag = ConditionTypeEnum.DATABASE.getCode().equals(rule.getConditionType()) && StringUtil.isBlank(rule.getDatabaseUrl());
    if (flag) {
        log.error("the databaseUrl is empty");
        throw new GovernanceException("the databaseUrl is empty");
    }
    if (StringUtil.isBlank(rule.getFromDestination())) {
        log.error("the fromDestination is empty");
        throw new GovernanceException("the fromDestination is empty");
    }
}
 
Example 3
Source File: ForwardBrokerFilter.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    String idStr = req.getParameter("brokerId");
    String brokerUrl = req.getParameter("brokerUrl");
    String originUrl = req.getRequestURI();
    // get tail of brokerEntity url
    String subStrUrl = originUrl.substring(originUrl.indexOf("/weevent-broker/") + "/weevent-broker".length());
    if (!StringUtil.isBlank(idStr) && StringUtil.isBlank(brokerUrl)) {
        Integer id = Integer.parseInt(idStr);
        BrokerEntity brokerEntity = brokerService.getBroker(id);
        brokerUrl = brokerEntity.getBrokerUrl();
    }
    // get complete forward brokerEntity url
    String newUrl = brokerUrl + subStrUrl;
    // get client according url
    CloseableHttpResponse closeResponse = commonService.getCloseResponse(req, newUrl);
    commonService.writeResponse(closeResponse, res);
}
 
Example 4
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
private void checkRule(RuleEngineEntity ruleEngineEntity) throws GovernanceException {
    //Verify ruleName English letters, numbers, underscores, hyphens,length
    if (StringUtil.isBlank(ruleEngineEntity.getRuleName())) {
        throw new GovernanceException("ruleName is empty");
    }

    boolean flag = checkRuleNameRepeat(ruleEngineEntity);
    if (!flag) {
        throw new GovernanceException("ruleName repeat");
    }
    if (ruleEngineEntity.getPayloadMap().isEmpty()) {
        throw new GovernanceException("rule description is empty");
    }
    if (ruleEngineEntity.getPayload() != null && ruleEngineEntity.getPayload().length() > 4096) {
        throw new GovernanceException("rule description length cannot exceed 4096");
    }

}
 
Example 5
Source File: TimerSchedulerService.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
private void setRuleDataBaseUrl(TimerSchedulerEntity timerSchedulerEntity) {
    if (timerSchedulerEntity.getRuleDatabaseId() == null) {
        return;
    }
    RuleDatabaseEntity ruleDataBase = ruleDatabaseRepository.findById(timerSchedulerEntity.getRuleDatabaseId());
    if (ruleDataBase != null) {
        String dbUrl = ruleDataBase.getDatabaseUrl() + "?user=" + ruleDataBase.getUsername() + "&password=" + ruleDataBase.getPassword();
        if (!StringUtil.isBlank(ruleDataBase.getOptionalParameter())) {
            dbUrl = dbUrl + "&" + ruleDataBase.getOptionalParameter();
        }
        timerSchedulerEntity.setDatabaseUrl(dbUrl);
        timerSchedulerEntity.setDataBaseType(ruleDataBase.getDatabaseType());
        log.info("dataBaseUrl:{}", timerSchedulerEntity.getDatabaseUrl());
    }
}
 
Example 6
Source File: DocumentType.java    From jsoup-learning with MIT License 5 votes vote down vote up
@Override
void outerHtmlHead(StringBuilder accum, int depth, Document.OutputSettings out) {
    accum.append("<!DOCTYPE ").append(attr("name"));
    if (!StringUtil.isBlank(attr("publicId")))
        accum.append(" PUBLIC \"").append(attr("publicId")).append("\"");
    if (!StringUtil.isBlank(attr("systemId")))
        accum.append(" \"").append(attr("systemId")).append("\"");
    accum.append('>');
}
 
Example 7
Source File: LinksSelector.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> selectList(Element element) {
    Elements elements = element.select("a");
    List<String> links = new ArrayList<String>(elements.size());
    for (Element element0 : elements) {
        if (!StringUtil.isBlank(element0.baseUri())) {
            links.add(element0.attr("abs:href"));
        } else {
            links.add(element0.attr("href"));
        }
    }
    return links;
}
 
Example 8
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public boolean validationConditions(HttpServletRequest request, RuleEngineEntity ruleEngineEntity) throws GovernanceException {
    if (StringUtil.isBlank(ruleEngineEntity.getConditionField()) || !checkProcessorExist(request)) {
        return true;
    }
    try {
        String payload = ruleEngineEntity.getPayload();
        String condition = ruleEngineEntity.getConditionField();
        String url = new StringBuffer(this.getProcessorUrl()).append(ConstantProperties.PROCESSOR_CHECK_WHERE_CONDITION)
                .append("?").append("payload=").append(URLEncoder.encode(payload, "UTF-8"))
                .append("&condition=").append(URLEncoder.encode(condition, "UTF-8"))
                .toString();

        CloseableHttpResponse closeResponse = commonService.getCloseResponse(request, url);
        int statusCode = closeResponse.getStatusLine().getStatusCode();
        if (200 != statusCode) {
            throw new GovernanceException(ErrorCode.PROCESS_CONNECT_ERROR);
        }
        String msg = EntityUtils.toString(closeResponse.getEntity());
        Map jsonObject = JsonHelper.json2Object(msg, Map.class);
        Integer code = Integer.valueOf(jsonObject.get("errorCode").toString());
        if (PROCESSOR_SUCCESS_CODE != code) {
            throw new GovernanceException(msg);
        }
        return true;
    } catch (Exception e) {
        log.error("check condition fail", e);
        throw new GovernanceException(e.getMessage());
    }

}
 
Example 9
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
private String parsingDetailSQL(RuleEngineEntity engineEntity) {
    StringBuffer buffer = new StringBuffer();
    if (StringUtil.isBlank(engineEntity.getFromDestination())) {
        return null;
    }
    //get ruleEngineConditionList
    String selectField = StringUtil.isBlank(engineEntity.getSelectField()) ? ConstantProperties.ASTERISK : engineEntity.getSelectField();
    buffer.append("SELECT ").append(selectField).append(" FROM").append(" ").append(engineEntity.getFromDestination());
    if (!StringUtil.isBlank(engineEntity.getConditionField())) {
        buffer.append(" WHERE ").append(engineEntity.getConditionField());
    }

    return buffer.toString();
}
 
Example 10
Source File: LinksSelector.java    From webmagic with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> selectList(Element element) {
    Elements elements = element.select("a");
    List<String> links = new ArrayList<String>(elements.size());
    for (Element element0 : elements) {
        if (!StringUtil.isBlank(element0.baseUri())) {
            links.add(element0.attr("abs:href"));
        } else {
            links.add(element0.attr("href"));
        }
    }
    return links;
}
 
Example 11
Source File: CommonService.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public static Map<String, String> uRLRequest(String URL) {
    Map<String, String> mapRequest = new HashMap<>();

    if (StringUtil.isBlank(URL)) {
        return mapRequest;
    }
    String[] arrSplit = URL.split("[?]");
    mapRequest.put("dataBaseUrl", arrSplit[0]);
    if (arrSplit.length > 1) {
        mapRequest.put("optionalParameter", arrSplit[1]);
    }
    return mapRequest;
}
 
Example 12
Source File: RuleEngineService.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
private boolean checkRuleName(String ruleName, String regex) {
    if (StringUtil.isBlank(ruleName)) {
        return false;
    }
    return Pattern.matches(regex, ruleName);
}
 
Example 13
Source File: DocumentType.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private boolean has(final String attribute) {
    return !StringUtil.isBlank(attr(attribute));
}
 
Example 14
Source File: DocumentType.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private boolean has(final String attribute) {
    return !StringUtil.isBlank(attr(attribute));
}
 
Example 15
Source File: CandidacyProcessDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void setExecutionInterval(final HttpServletRequest request) {
    final String executionIntervalId = (String) getFromRequest(request, "executionIntervalId");
    if (executionIntervalId != null && !StringUtil.isBlank(executionIntervalId)) {
        request.setAttribute("executionInterval", FenixFramework.getDomainObject(executionIntervalId));
    }
}
 
Example 16
Source File: TextNode.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 Test if this text node is blank -- that is, empty or only whitespace (including newlines).
 @return true if this document is empty or only whitespace, false if it contains any text content.
 */
public boolean isBlank() {
    return StringUtil.isBlank(coreValue());
}
 
Example 17
Source File: TextNode.java    From jsoup-learning with MIT License 2 votes vote down vote up
/**
 Test if this text node is blank -- that is, empty or only whitespace (including newlines).
 @return true if this document is empty or only whitespace, false if it contains any text content.
 */
public boolean isBlank() {
    return StringUtil.isBlank(getWholeText());
}
 
Example 18
Source File: AbstractHACCommunicationManager.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 2 votes vote down vote up
/**
 * Check whether HAC is up
 * 
 * @return true if HAC is online, false otherwise
 */
public boolean checkHacHealth() {
	final String response = sendAuthenticatedGetRequest(CharactersConstants.EMPTY_STRING);
	return !StringUtil.isBlank(response);
}
 
Example 19
Source File: TextNode.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 Test if this text node is blank -- that is, empty or only whitespace (including newlines).
 @return true if this document is empty or only whitespace, false if it contains any text content.
 */
public boolean isBlank() {
    return StringUtil.isBlank(getWholeText());
}
 
Example 20
Source File: TextNode.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 Test if this text node is blank -- that is, empty or only whitespace (including newlines).
 @return true if this document is empty or only whitespace, false if it contains any text content.
 */
public boolean isBlank() {
    return StringUtil.isBlank(coreValue());
}