Java Code Examples for org.apache.commons.lang3.StringUtils#deleteWhitespace()

The following examples show how to use org.apache.commons.lang3.StringUtils#deleteWhitespace() . 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: ActionCrawlWorkCompleted.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private String attachment(Business business, WorkCompleted workCompleted) throws Exception {
	StringBuffer buffer = new StringBuffer();
	for (Attachment o : business.entityManagerContainer().listEqual(Attachment.class, WorkCompleted.job_FIELDNAME,
			workCompleted.getJob())) {
		if ((!Config.query().getCrawlWorkCompleted().getExcludeAttachment().contains(o.getName()))
				&& (!Config.query().getCrawlWorkCompleted().getExcludeSite().contains(o.getSite()))
				&& (!StringUtils.equalsIgnoreCase(o.getName(),
						Config.processPlatform().getDocToWordDefaultFileName()))
				&& (!StringUtils.equalsIgnoreCase(o.getSite(),
						Config.processPlatform().getDocToWordDefaultSite()))) {
			if (StringUtils.isNotEmpty(o.getText())) {
				buffer.append(o.getText());
			} else {
				buffer.append(this.storageObjectToText(o));
			}
		}
	}
	return StringUtils.deleteWhitespace(buffer.toString());
}
 
Example 2
Source File: ActionCrawlWork.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private String attachment(Business business, Work work) throws Exception {
	StringBuffer buffer = new StringBuffer();
	for (Attachment o : business.entityManagerContainer().listEqual(Attachment.class, Work.job_FIELDNAME,
			work.getJob())) {
		if ((!Config.query().getCrawlWork().getExcludeAttachment().contains(o.getName()))
				&& (!Config.query().getCrawlWork().getExcludeSite().contains(o.getSite()))
				&& (!StringUtils.equalsIgnoreCase(o.getName(),
						Config.processPlatform().getDocToWordDefaultFileName()))
				&& (!StringUtils.equalsIgnoreCase(o.getSite(),
						Config.processPlatform().getDocToWordDefaultSite()))) {
			if (StringUtils.isNotEmpty(o.getText())) {
				buffer.append(o.getText());
			} else {
				buffer.append(this.storageObjectToText(o));
			}
		}
	}
	return StringUtils.deleteWhitespace(buffer.toString());
}
 
Example 3
Source File: ActionCrawlWork.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private String attachment(Business business, Work work) throws Exception {
	StringBuffer buffer = new StringBuffer();
	for (Attachment o : business.entityManagerContainer().listEqual(Attachment.class, Work.job_FIELDNAME,
			work.getJob())) {
		if ((!Config.query().getCrawlWork().getExcludeAttachment().contains(o.getName()))
				&& (!Config.query().getCrawlWork().getExcludeSite().contains(o.getSite()))
				&& (!StringUtils.equalsIgnoreCase(o.getName(),
						Config.processPlatform().getDocToWordDefaultFileName()))
				&& (!StringUtils.equalsIgnoreCase(o.getSite(),
						Config.processPlatform().getDocToWordDefaultSite()))) {
			if (StringUtils.isNotEmpty(o.getText())) {
				buffer.append(o.getText());
			} else {
				buffer.append(this.storageObjectToText(o));
			}
		}
	}
	return StringUtils.deleteWhitespace(buffer.toString());
}
 
Example 4
Source File: InteracETransferValidator.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private ValidationResult validatePhoneNumber(String input) {
    // check for correct format and strip +, space and -
    if (input.matches("\\+?1[ -]?\\d{3}[ -]?\\d{3}[ -]?\\d{4}")) {
        input = input.replace("+", "");
        input = StringUtils.deleteWhitespace(input);
        input = input.replace("-", "");

        String inputAreaCode = input.substring(1, 4);
        for (String s : NPAS) {
            // check area code agains list and return if valid
            if (inputAreaCode.compareTo(s) == 0)
                return new ValidationResult(true);
        }
        return new ValidationResult(false, Res.get("validation.interacETransfer.invalidAreaCode"));
    } else {
        return new ValidationResult(false, Res.get("validation.interacETransfer.invalidPhone"));
    }
}
 
Example 5
Source File: DisplayContextInConditionalCommentsCheck.java    From AEM-Rules-for-SonarQube with Apache License 2.0 5 votes vote down vote up
@Override
public void comment(CommentNode node) {
    String code = StringUtils.deleteWhitespace(node.getCode());
    if(isConditionalComment(code)){
        getExpressions(code).stream()
                .filter(expression -> !expression.containsOption(Syntax.CONTEXT_OPTION))
                .forEach(expression -> createViolation(node.getStartLinePosition(), RULE_MESSAGE));
    }

}
 
Example 6
Source File: JvmCommandFactory.java    From jwala with Apache License 2.0 5 votes vote down vote up
/**
 * Method to generate remote command for extracting jar for jvm
 *
 * @param jvm
 * @return
 */
private ExecCommand getExecCommandForDeploy(Jvm jvm) {
    final String remoteScriptDir = ApplicationProperties.getRequired(PropertyKeys.REMOTE_SCRIPT_DIR);

    final String trimmedJvmName = StringUtils.deleteWhitespace(jvm.getJvmName());
    final String archivePath = Paths.get(remoteScriptDir + '/' + trimmedJvmName + '/'
            + DEPLOY_CONFIG_ARCHIVE_SCRIPT_NAME).normalize().toString();
    final String jvmJarFile = Paths.get(remoteScriptDir + '/' + trimmedJvmName + ".jar").normalize().toString();
    final String jvmInstanceDir = Paths.get(jvm.getTomcatMedia().getRemoteDir().toString() + '/' + trimmedJvmName)
            .normalize().toString();
    final String jdkJarDir = Paths.get(jvm.getJavaHome() + "/bin/jar").normalize().toString();

    return new ExecCommand(archivePath, jvmJarFile, jvmInstanceDir, jdkJarDir);
}
 
Example 7
Source File: OrderParam.java    From amforeas with GNU General Public License v3.0 5 votes vote down vote up
public OrderParam(String col, String dir) {
    if (StringUtils.isBlank(dir) || StringUtils.isBlank(col))
        throw new IllegalArgumentException("Invalid order parameters");

    if (ASC.equalsIgnoreCase(dir)) {
        this.direction = ASC;
    } else if (DESC.equalsIgnoreCase(dir)) {
        this.direction = DESC;
    } else {
        throw new IllegalArgumentException("Invalid direction parameter");
    }
    this.column = StringUtils.deleteWhitespace(col);
}
 
Example 8
Source File: AbstractJarMojo.java    From livingdoc-core with GNU General Public License v3.0 5 votes vote down vote up
protected static File getJarFile(File basedir, String finalName, String classifier) {

        if (StringUtils.isBlank(classifier)) {
            return new File(basedir, finalName + ".jar");
        }

        String modifiedClassifier = StringUtils.deleteWhitespace(classifier);
        if (modifiedClassifier.charAt(0) != '-') {
            modifiedClassifier = '-' + modifiedClassifier;
        }

        return new File(basedir, finalName + modifiedClassifier + ".jar");
    }
 
Example 9
Source File: ActionCrawlWorkCompleted.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private String body(Business business, WorkCompleted workCompleted) throws Exception {
	String value = converter.text(
			business.entityManagerContainer().listEqualAndEqual(Item.class, Item.itemCategory_FIELDNAME,
					ItemCategory.pp, Item.bundle_FIELDNAME, workCompleted.getJob()),
			true, true, true, true, true, ",");
	return StringUtils.deleteWhitespace(value);
}
 
Example 10
Source File: ActionCrawlCms.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private String attachment(Business business, Document document) throws Exception {
	StringBuffer buffer = new StringBuffer();
	for (FileInfo o : business.entityManagerContainer().listEqual(FileInfo.class, FileInfo.documentId_FIELDNAME,
			document.getId())) {
		if (!Config.query().getCrawlCms().getExcludeAttachment().contains(o.getName())) {
			buffer.append(this.storageObjectToText(o));
		}
	}
	return StringUtils.deleteWhitespace(buffer.toString());
}
 
Example 11
Source File: ActionCrawlWorkCompleted.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String title(WorkCompleted workCompleted) {
	return StringUtils.deleteWhitespace(workCompleted.getTitle());
}
 
Example 12
Source File: ActionCrawlCms.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String body(Business business, Document document) throws Exception {
	String value = converter.text(business.entityManagerContainer().listEqualAndEqual(Item.class,
			Item.itemCategory_FIELDNAME, ItemCategory.cms, Item.bundle_FIELDNAME, document.getId()), true, true,
			true, true, true, ",");
	return StringUtils.deleteWhitespace(value);
}
 
Example 13
Source File: ActionCrawlWork.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String body(Business business, Work work) throws Exception {
	String value = converter.text(business.entityManagerContainer().listEqualAndEqual(Item.class,
			Item.itemCategory_FIELDNAME, ItemCategory.pp, Item.bundle_FIELDNAME, work.getJob()), true, true, true,
			true, true, ",");
	return StringUtils.deleteWhitespace(value);
}
 
Example 14
Source File: ActionCrawlCms.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String body(Business business, Document document) throws Exception {
	String value = converter.text(business.entityManagerContainer().listEqualAndEqual(Item.class,
			Item.itemCategory_FIELDNAME, ItemCategory.cms, Item.bundle_FIELDNAME, document.getId()), true, true,
			true, true, true, ",");
	return StringUtils.deleteWhitespace(value);
}
 
Example 15
Source File: ActionCrawlCms.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String title(Document document) {
	return StringUtils.deleteWhitespace(document.getTitle());
}
 
Example 16
Source File: ActionCrawlCms.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String title(Document document) {
	return StringUtils.deleteWhitespace(document.getTitle());
}
 
Example 17
Source File: BaseAction.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void setSummary(Entry entry, String body, String attachment) {
	String summary = StringUtils.join(HanLP.extractSummary(body + attachment, 10), ",");
	summary = StringUtils.deleteWhitespace(summary);
	entry.setSummary(StringTools.utf8SubString(summary, JpaObject.length_255B));
}
 
Example 18
Source File: ActionCrawlWorkCompleted.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private String title(WorkCompleted workCompleted) {
	return StringUtils.deleteWhitespace(workCompleted.getTitle());
}
 
Example 19
Source File: TwoFactorAuthenticationProvider.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Authentication authenticate( Authentication auth )
    throws AuthenticationException
{
    log.info( String.format( "Login attempt: %s", auth.getName() ) );

    String username = auth.getName();

    UserCredentials userCredentials = userService.getUserCredentialsWithEagerFetchAuthorities( username );

    if ( userCredentials == null )
    {
        throw new BadCredentialsException( "Invalid username or password" );
    }

    // Initialize all required properties of user credentials since these will become detached

    userCredentials.getAllAuthorities();

    // -------------------------------------------------------------------------
    // Check two-factor authentication
    // -------------------------------------------------------------------------

    if ( userCredentials.isTwoFA() )
    {
        TwoFactorWebAuthenticationDetails authDetails =
            (TwoFactorWebAuthenticationDetails) auth.getDetails();

        // -------------------------------------------------------------------------
        // Check whether account is locked due to multiple failed login attempts
        // -------------------------------------------------------------------------

        if ( authDetails == null )
        {
            log.info( "Missing authentication details in authentication request." );
            throw new PreAuthenticatedCredentialsNotFoundException( "Missing authentication details in authentication request." );
        }

        String ip = authDetails.getIp();
        String code = StringUtils.deleteWhitespace( authDetails.getCode() );

        if ( securityService.isLocked( username ) )
        {
            log.info( String.format( "Temporary lockout for user: %s and IP: %s", username, ip ) );

            throw new LockedException( String.format( "IP is temporarily locked: %s", ip ) );
        }

        if ( !LongValidator.getInstance().isValid( code ) || !SecurityUtils.verify( userCredentials, code ) )
        {
            log.info( String.format( "Two-factor authentication failure for user: %s", userCredentials.getUsername() ) );

            throw new BadCredentialsException( "Invalid verification code" );
        }
    }

    // -------------------------------------------------------------------------
    // Delegate authentication downstream, using UserCredentials as principal
    // -------------------------------------------------------------------------

    Authentication result = super.authenticate( auth );

    // Put detached state of the user credentials into the session as user
    // credentials must not be updated during session execution

    userCredentials = SerializationUtils.clone( userCredentials );

    // Initialize cached authorities

    userCredentials.isSuper();
    userCredentials.getAllAuthorities();

    return new UsernamePasswordAuthenticationToken( userCredentials, result.getCredentials(), result.getAuthorities() );
}
 
Example 20
Source File: RemoveAllWhitespace.java    From levelup-java-examples with Apache License 2.0 3 votes vote down vote up
@Test
public void remove_all_whitespace_apache_commons () {
	
	String madJug = "Madison Java User Group";
	
	String removeAllSpaces = StringUtils.deleteWhitespace(madJug);
	
	assertEquals("MadisonJavaUserGroup", removeAllSpaces);
}