Java Code Examples for org.springframework.util.Assert#doesNotContain()

The following examples show how to use org.springframework.util.Assert#doesNotContain() . 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: WebSocketExtension.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private static WebSocketExtension parseExtension(String extension) {
	Assert.doesNotContain(extension, ",", "Expected a single extension value: " + extension);
	String[] parts = StringUtils.tokenizeToStringArray(extension, ";");
	String name = parts[0].trim();

	Map<String, String> parameters = null;
	if (parts.length > 1) {
		parameters = new LinkedHashMap<String, String>(parts.length - 1);
		for (int i = 1; i < parts.length; i++) {
			String parameter = parts[i];
			int eqIndex = parameter.indexOf('=');
			if (eqIndex != -1) {
				String attribute = parameter.substring(0, eqIndex);
				String value = parameter.substring(eqIndex + 1, parameter.length());
				parameters.put(attribute, value);
			}
		}
	}

	return new WebSocketExtension(name, parameters);
}
 
Example 2
Source File: Gpdb.java    From pxf with Apache License 2.0 6 votes vote down vote up
/**
 * Runs sql command on the given psql connection, and returns the command's result.
 *
 * @param sso psql connection
 * @param sql sql command to run
 * @param checkErrors if true assert that there is no ERROR in result
 * @return sql command's result
 * @throws Exception
 */
public String runSqlCmd(ShellSystemObject sso, String sql, boolean checkErrors) throws Exception {

	if (sso == null)
		return null;
	ReportUtils.report(report, getClass(), "running sql command " + sql);
	// sql commands do not return error code so using EXIT_CODE_NOT_EXISTS
	sso.runCommand(sql, ShellSystemObject.EXIT_CODE_NOT_EXISTS);

	String lastCmd = sso.getLastCmdResult();
	ReportUtils.report(report, getClass(), "sql command status: " + lastCmd);
	if (checkErrors) {
		Assert.doesNotContain(lastCmd, "ERROR");
	}

	return lastCmd;
}
 
Example 3
Source File: BusinessObjectDataDdlPartitionsHelper.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Validate partionFilters and business format
 *
 * @param generateDdlRequest the generateDdlRequestWrapper object
 *
 * @return BusinessObjectFormat object
 */
public BusinessObjectFormat validatePartitionFiltersAndFormat(GenerateDdlRequestWrapper generateDdlRequest)
{
    // Validate that partition values passed in the list of partition filters do not contain '/' character.
    if (generateDdlRequest.isPartitioned && !CollectionUtils.isEmpty(generateDdlRequest.partitionFilters))
    {
        // Validate that partition values do not contain '/' characters.
        for (List<String> partitionFilter : generateDdlRequest.partitionFilters)
        {
            for (String partitionValue : partitionFilter)
            {
                Assert.doesNotContain(partitionValue, "/", String.format("Partition value \"%s\" can not contain a '/' character.", partitionValue));
            }
        }
    }

    // Get business object format model object to directly access schema columns and partitions.
    BusinessObjectFormat businessObjectFormat =
        businessObjectFormatHelper.createBusinessObjectFormatFromEntity(generateDdlRequest.businessObjectFormatEntity);

    // Validate that we have at least one column specified in the business object format schema.
    assertSchemaColumnsNotEmpty(businessObjectFormat, generateDdlRequest.businessObjectFormatEntity);

    if (generateDdlRequest.isPartitioned)
    {
        // Validate that we have at least one partition column specified in the business object format schema.
        Assert.notEmpty(businessObjectFormat.getSchema().getPartitions(), String.format("No schema partitions specified for business object format {%s}.",
            businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(generateDdlRequest.businessObjectFormatEntity)));

        // Validate that partition column names do not contain '/' characters.
        for (SchemaColumn partitionColumn : businessObjectFormat.getSchema().getPartitions())
        {
            Assert.doesNotContain(partitionColumn.getName(), "/", String
                .format("Partition column name \"%s\" can not contain a '/' character. Business object format: {%s}", partitionColumn.getName(),
                    businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(generateDdlRequest.businessObjectFormatEntity)));
        }
    }
    return businessObjectFormat;
}
 
Example 4
Source File: CustomizableTraceInterceptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Set the template used for method entry log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * </ul>
 */
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
	Assert.hasText(enterMessage, "enterMessage must not be empty");
	checkForInvalidPlaceholders(enterMessage);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME);
	this.enterMessage = enterMessage;
}
 
Example 5
Source File: CustomizableTraceInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Set the template used for method entry log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * </ul>
 */
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
	Assert.hasText(enterMessage, "'enterMessage' must not be empty");
	checkForInvalidPlaceholders(enterMessage);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
			"enterMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
	Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
			"enterMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
	Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
			"enterMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
	this.enterMessage = enterMessage;
}
 
Example 6
Source File: CustomizableTraceInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the template used for method entry log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * </ul>
 */
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
	Assert.hasText(enterMessage, "enterMessage must not be empty");
	checkForInvalidPlaceholders(enterMessage);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME);
	this.enterMessage = enterMessage;
}
 
Example 7
Source File: CustomizableTraceInterceptor.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Set the template used for method entry log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * </ul>
 */
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
	Assert.hasText(enterMessage, "enterMessage must not be empty");
	checkForInvalidPlaceholders(enterMessage);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION);
	Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
			"enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME);
	this.enterMessage = enterMessage;
}
 
Example 8
Source File: LogViewEndpoint.java    From spring-boot-actuator-logview with MIT License 4 votes vote down vote up
private void securityCheck(String filename) {
    Assert.doesNotContain(filename, "..");
}
 
Example 9
Source File: CustomizableTraceInterceptor.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Set the template used for method exit log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[returnValue]}</li>
 * <li>{@code $[invocationTime]}</li>
 * </ul>
 */
public void setExitMessage(String exitMessage) {
	Assert.hasText(exitMessage, "exitMessage must not be empty");
	checkForInvalidPlaceholders(exitMessage);
	Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
			"exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION);
	this.exitMessage = exitMessage;
}
 
Example 10
Source File: CustomizableTraceInterceptor.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
public void setExceptionMessage(String exceptionMessage) {
	Assert.hasText(exceptionMessage, "exceptionMessage must not be empty");
	checkForInvalidPlaceholders(exceptionMessage);
	Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
			"exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	this.exceptionMessage = exceptionMessage;
}
 
Example 11
Source File: BasicAuthenticationInterceptor.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Create a new interceptor which adds Basic Authentication for the
 * given username and password, encoded using the specified charset.
 * @param username the username to use
 * @param password the password to use
 * @param charset the charset to use
 * @see HttpHeaders#setBasicAuth(String, String, Charset)
 */
public BasicAuthenticationInterceptor(String username, String password, @Nullable Charset charset) {
	Assert.doesNotContain(username, ":", "Username must not contain a colon");
	this.username = username;
	this.password = password;
	this.charset = charset;
}
 
Example 12
Source File: BasicAuthenticationInterceptor.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Create a new interceptor which adds Basic Authentication for the
 * given username and password, encoded using the specified charset.
 * @param username the username to use
 * @param password the password to use
 * @param charset the charset to use
 * @see HttpHeaders#setBasicAuth(String, String, Charset)
 */
public BasicAuthenticationInterceptor(String username, String password, @Nullable Charset charset) {
	Assert.doesNotContain(username, ":", "Username must not contain a colon");
	this.username = username;
	this.password = password;
	this.charset = charset;
}
 
Example 13
Source File: CustomizableTraceInterceptor.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Set the template used for method exit log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[returnValue]}</li>
 * <li>{@code $[invocationTime]}</li>
 * </ul>
 */
public void setExitMessage(String exitMessage) {
	Assert.hasText(exitMessage, "exitMessage must not be empty");
	checkForInvalidPlaceholders(exitMessage);
	Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
			"exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION);
	this.exitMessage = exitMessage;
}
 
Example 14
Source File: CustomizableTraceInterceptor.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
public void setExceptionMessage(String exceptionMessage) {
	Assert.hasText(exceptionMessage, "exceptionMessage must not be empty");
	checkForInvalidPlaceholders(exceptionMessage);
	Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
			"exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	this.exceptionMessage = exceptionMessage;
}
 
Example 15
Source File: CustomizableTraceInterceptor.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Set the template used for method exit log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[returnValue]}</li>
 * <li>{@code $[invocationTime]}</li>
 * </ul>
 */
public void setExitMessage(String exitMessage) {
	Assert.hasText(exitMessage, "'exitMessage' must not be empty");
	checkForInvalidPlaceholders(exitMessage);
	Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
			"exitMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
	this.exitMessage = exitMessage;
}
 
Example 16
Source File: CustomizableTraceInterceptor.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
public void setExceptionMessage(String exceptionMessage) {
	Assert.hasText(exceptionMessage, "'exceptionMessage' must not be empty");
	checkForInvalidPlaceholders(exceptionMessage);
	Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
			"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
	Assert.doesNotContain(exceptionMessage, PLACEHOLDER_INVOCATION_TIME,
			"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
	this.exceptionMessage = exceptionMessage;
}
 
Example 17
Source File: CustomizableTraceInterceptor.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
public void setExceptionMessage(String exceptionMessage) {
	Assert.hasText(exceptionMessage, "exceptionMessage must not be empty");
	checkForInvalidPlaceholders(exceptionMessage);
	Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
			"exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
	this.exceptionMessage = exceptionMessage;
}
 
Example 18
Source File: AlternateKeyHelper.java    From herd with Apache License 2.0 3 votes vote down vote up
/**
 * Validates and returns a trimmed alternate key parameter value.
 *
 * @param indefiniteArticle the indefinite article to use with the specified parameter name
 * @param parameterName the alternate key parameter name
 * @param parameterValue the alternate key parameter value
 *
 * @return the trimmed alternate key parameter value
 * @throws IllegalArgumentException if alternate key parameter is missing or not valid
 */
public String validateStringParameter(String indefiniteArticle, String parameterName, String parameterValue) throws IllegalArgumentException
{
    Assert.hasText(parameterValue, String.format("%s %s must be specified.", indefiniteArticle, parameterName));
    Assert.doesNotContain(parameterValue, "/", String.format("%s can not contain a forward slash character.", StringUtils.capitalize(parameterName)));
    return parameterValue.trim();
}
 
Example 19
Source File: CustomizableTraceInterceptor.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Set the template used for method exit log messages.
 * This template can contain any of the following placeholders:
 * <ul>
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[returnValue]}</li>
 * <li>{@code $[invocationTime]}</li>
 * </ul>
 */
public void setExitMessage(String exitMessage) {
	Assert.hasText(exitMessage, "exitMessage must not be empty");
	checkForInvalidPlaceholders(exitMessage);
	Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
			"exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION);
	this.exitMessage = exitMessage;
}
 
Example 20
Source File: BasicAuthorizationInterceptor.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new interceptor which adds a BASIC authorization header
 * for the given username and password.
 * @param username the username to use
 * @param password the password to use
 */
public BasicAuthorizationInterceptor(@Nullable String username, @Nullable String password) {
	Assert.doesNotContain(username, ":", "Username must not contain a colon");
	this.username = (username != null ? username : "");
	this.password = (password != null ? password : "");
}