Example usage for org.apache.commons.lang3 StringUtils deleteWhitespace

List of usage examples for org.apache.commons.lang3 StringUtils deleteWhitespace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils deleteWhitespace.

Prototype

public static String deleteWhitespace(final String str) 

Source Link

Document

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

 StringUtils.deleteWhitespace(null)         = null StringUtils.deleteWhitespace("")           = "" StringUtils.deleteWhitespace("abc")        = "abc" StringUtils.deleteWhitespace("   ab  c  ") = "abc" 

Usage

From source file:org.kuali.coeus.propdev.impl.person.ProposalPerson.java

/**
 * set the <code>simpleName</code> &amp; the full name.
 *//*  w  ww . j a  va  2 s . co m*/
@Override
public void setFullName(String fullName) {
    this.fullName = fullName;
    setSimpleName(getFullName());
    setSimpleName(StringUtils.lowerCase(getSimpleName()));
    setSimpleName(StringUtils.deleteWhitespace(getSimpleName()));
    setSimpleName(StringUtils.remove(getSimpleName(), '.'));
}

From source file:org.kuali.coeus.s2sgen.impl.print.S2SPrintingServiceImpl.java

protected String getReportName() {
    String dateString = new Date().toString();
    return StringUtils.deleteWhitespace(dateString);
}

From source file:org.kuali.coeus.s2sgen.impl.print.S2SPrintingServiceImpl.java

protected void logPrintDetails(Map<String, byte[]> xmlStreamMap) {
    String loggingDirectory = s2SConfigurationService
            .getValueAsString(ConfigurationConstants.PRINT_LOGGING_DIRECTORY);
    if (loggingDirectory != null) {

        for (String key : xmlStreamMap.keySet()) {
            byte[] xmlBytes = xmlStreamMap.get(key);
            String xmlString = new String(xmlBytes);
            String dateString = new Timestamp(new Date().getTime()).toString();
            String reportName = StringUtils.deleteWhitespace(key);
            String createdTime = StringUtils.replaceChars(StringUtils.deleteWhitespace(dateString), ":", "_");
            File dir = new File(loggingDirectory);
            if (!dir.exists() || !dir.isDirectory()) {
                dir.mkdirs();/*from  w  ww .  j  a  va 2s . com*/
            }
            File file = new File(dir, reportName + createdTime + ".xml");
            try (BufferedWriter out = new BufferedWriter(new FileWriter(file))) {
                out.write(xmlString);
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    }
}

From source file:org.kuali.kra.rules.KcDocumentBaseAuditRuleTest.java

@Test
public void testRequiredCustomAttributeFieldsMissing() throws Exception {
    ProposalDevelopmentDocument document = getNewDocument();

    Map<String, CustomAttribute> requiredFields = new HashMap<String, CustomAttribute>();

    Map<String, CustomAttributeDocument> customAttributeDocuments = ((KcTransactionalDocumentBase) document)
            .getCustomAttributeDocuments();
    for (Map.Entry<String, CustomAttributeDocument> customAttributeDocumentEntry : customAttributeDocuments
            .entrySet()) {/*from w  w  w.ja v  a 2s  . c o m*/
        CustomAttributeDocument customAttributeDocument = customAttributeDocumentEntry.getValue();
        CustomAttribute customAttribute = customAttributeDocument.getCustomAttribute();
        if (customAttributeDocument.isRequired()) {
            requiredFields.put("customData." + customAttribute.getGroupName() + customAttribute.getName(),
                    customAttribute);
        }
        CustomAttributeDocValue newValue = new CustomAttributeDocValue();
        newValue.setCustomAttribute(customAttributeDocument.getCustomAttribute());
        newValue.setId(customAttributeDocument.getId().longValue());
        newValue.setValue(null);
        document.getCustomDataList().add(newValue);
    }

    assertFalse("Audit Rule should produce an audit error", auditRule.processRunAuditBusinessRules(document));
    assertEquals(requiredFields.size(), GlobalVariables.getAuditErrorMap().size());

    for (String key : requiredFields.keySet()) {
        CustomAttribute customAttribute = requiredFields.get(key);

        Map<String, AuditCluster> map = GlobalVariables.getAuditErrorMap();
        AuditCluster auditCluster = map
                .get("CustomData" + StringUtils.deleteWhitespace(customAttribute.getGroupName()) + "Errors");

        assertEquals(1, auditCluster.getSize());
        assertEquals(customAttribute.getGroupName(), auditCluster.getLabel());
        assertEquals("Error", auditCluster.getCategory());
        AuditError auditError = (AuditError) auditCluster.getAuditErrorList().get(0);
        int index = 0;
        for (CustomAttributeDocValue value : document.getCustomDataList()) {
            if (value.getId().longValue() == customAttribute.getId().longValue()) {
                break;
            }
            index++;
        }
        assertTrue(auditError.getErrorKey().matches("customDataHelper.customDataList.*value"));
        assertEquals(
                StringUtils.deleteWhitespace(
                        Constants.CUSTOM_ATTRIBUTES_PAGE + "." + customAttribute.getGroupName()),
                auditError.getLink());
        assertEquals(customAttribute.getLabel(), auditError.getParams()[0]);
        assertEquals(RiceKeyConstants.ERROR_REQUIRED, auditError.getMessageKey());
    }

}

From source file:org.libreplan.business.materials.entities.MaterialCategory.java

@SuppressWarnings("unused")
@AssertTrue(message = "Subcategory names must be unique.")
public boolean isUniqueSubcategoryNameConstraint() {
    Set<String> subcategoriesNames = new HashSet<>();

    for (MaterialCategory mc : this.getAllSubcategories()) {

        if (!StringUtils.isBlank(mc.getName())) {
            String name = StringUtils.deleteWhitespace(mc.getName().toLowerCase());

            if (subcategoriesNames.contains(name)) {
                return false;
            } else {
                subcategoriesNames.add(name);
            }//from   w ww.  jav a 2 s  . c o  m
        }
    }
    return true;
}

From source file:org.libreplan.importers.JiraRESTClient.java

/**
 * Query Jira for all issues with the specified query parameter
 *
 * @param url/*from   w w  w .ja  va2s  .  co m*/
 *            the url(end point)
 * @param username
 *            the user name
 * @param password
 *            the password
 * @param path
 *            the path segment
 * @param query
 *            the query
 * @return list of jira issues
 */
public static List<IssueDTO> getIssues(String url, String username, String password, String path,
        String query) {

    WebClient client = createClient(url);

    checkAutherization(client, username, password);

    // Go to baseURI
    client.back(true);

    client.path(path);

    if (!query.isEmpty()) {
        client.query("jql", query);
    }

    client.query("maxResults", MAX_RESULTS);
    client.query("fields", StringUtils.deleteWhitespace(FIELDS_TO_INCLUDE_IN_RESPONSE));

    SearchResultDTO searchResult = client.get(SearchResultDTO.class);

    return searchResult.getIssues();
}

From source file:org.libreplan.web.common.components.finders.CriterionMultipleFiltersFinder.java

@Override
public List<FilterPair> getMatching(String filter) {
    getListMatching().clear();/* w w  w. j a v  a  2 s  .c  o  m*/
    if ((filter != null) && (!filter.isEmpty())) {
        filter = StringUtils.deleteWhitespace(filter.toLowerCase());
        searchInCriterionTypes(filter);
    }
    addNoneFilter();
    return getListMatching();
}

From source file:org.libreplan.web.common.components.finders.CriterionMultipleFiltersFinder.java

private void searchInCriterionTypes(String filter) {
    boolean limited = (filter.length() < 3);
    Map<CriterionType, List<Criterion>> mapCriterions = getCriterionsMap();
    for (CriterionType type : mapCriterions.keySet()) {
        String name = StringUtils.deleteWhitespace(type.getName().toLowerCase());
        if (name.contains(filter)) {
            setFilterPairCriterionType(type, limited);
        } else {/* ww w .j a v a2  s . c o m*/
            searchInCriterions(type, filter);
        }
    }
}

From source file:org.libreplan.web.common.components.finders.CriterionMultipleFiltersFinder.java

private void searchInCriterions(CriterionType type, String filter) {
    Map<CriterionType, List<Criterion>> mapCriterions = getCriterionsMap();
    for (Criterion criterion : mapCriterions.get(type)) {
        String name = StringUtils.deleteWhitespace(criterion.getName().toLowerCase());
        if (name.contains(filter)) {
            addCriterion(type, criterion);
            if ((filter.length() < 3) && (getListMatching().size() > 9)) {
                return;
            }/* ww  w. j av a  2  s .  c o m*/
        }
    }
}

From source file:org.libreplan.web.common.components.finders.MultipleFiltersFinder.java

public boolean isValidFormatText(List filterValues, String value) {
    if (filterValues.isEmpty()) {
        return true;
    }//from w  w  w  .ja v a  2s  . co m

    updateDeletedFilters(filterValues, value);
    value = StringUtils.deleteWhitespace(value);
    String[] values = value.split(";");
    if (values.length != filterValues.size()) {
        return false;
    }

    for (FilterPair filterPair : (List<FilterPair>) filterValues) {
        String filterPairText = filterPair.getType() + "(" + filterPair.getPattern() + ")";
        if (!isFilterAdded(values, filterPairText)) {
            return false;
        }
    }

    return true;
}