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

The following examples show how to use org.springframework.util.Assert#hasText() . 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: RocketMQAutoConfiguration.java    From spring-boot-starter-rocketmq with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnClass(DefaultMQProducer.class)
@ConditionalOnMissingBean(DefaultMQProducer.class)
@ConditionalOnProperty(prefix = "spring.rocketmq", value = {"name-server", "producer.group"})
public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) {

    RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer();
    String groupName = producerConfig.getGroup();
    Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null");

    DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup());
    producer.setNamesrvAddr(rocketMQProperties.getNameServer());
    producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout());
    producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
    producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
    producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
    producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch());
    producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());

    return producer;
}
 
Example 2
Source File: RocketMQAutoConfiguration.java    From rocketmq-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnClass(DefaultMQProducer.class)
@ConditionalOnMissingBean(DefaultMQProducer.class)
@ConditionalOnProperty(prefix = "spring.rocketmq", value = {"nameServer", "producer.group"})
public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) {

    RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer();
    String groupName = producerConfig.getGroup();
    Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null");

    DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup());
    producer.setNamesrvAddr(rocketMQProperties.getNameServer());
    producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout());
    producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
    producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
    producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
    producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch());
    producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());

    return producer;
}
 
Example 3
Source File: UserNamespaceAuthorizationServiceImpl.java    From herd with Apache License 2.0 6 votes vote down vote up
@Override
public UserNamespaceAuthorizations getUserNamespaceAuthorizationsByUserId(String userId)
{
    // Validate and trim the user id.
    Assert.hasText(userId, "A user id must be specified.");
    String userIdLocal = userId.trim();

    // Retrieve and return a list of user namespace authorization entities for the specified user id.
    List<UserNamespaceAuthorizationEntity> userNamespaceAuthorizationEntities =
        userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByUserId(userIdLocal);

    // Create and populate the user namespace authorizations object from the returned entities.
    UserNamespaceAuthorizations userNamespaceAuthorizations = new UserNamespaceAuthorizations();
    userNamespaceAuthorizations.getUserNamespaceAuthorizations().addAll(createUserNamespaceAuthorizationsFromEntities(userNamespaceAuthorizationEntities));

    return userNamespaceAuthorizations;
}
 
Example 4
Source File: KafkaChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Register a new {@link KafkaListenerEndpoint} alongside the
 * {@link KafkaListenerContainerFactory} to use to create the underlying container.
 * <p>The {@code factory} may be {@code null} if the default factory has to be
 * used for that endpoint.
 */
protected void registerEndpoint(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> factory) {
    Assert.notNull(endpoint, "Endpoint must not be null");
    Assert.hasText(endpoint.getId(), "Endpoint id must be set");

    Assert.state(this.endpointRegistry != null, "No KafkaListenerEndpointRegistry set");
    endpointRegistry.registerListenerContainer(endpoint, resolveContainerFactory(endpoint, factory), true);
}
 
Example 5
Source File: JsonPathExpectationsHelper.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new {@code JsonPathExpectationsHelper}.
 * @param expression the {@link JsonPath} expression; never {@code null} or empty
 * @param args arguments to parameterize the {@code JsonPath} expression with,
 * using formatting specifiers defined in {@link String#format(String, Object...)}
 */
public JsonPathExpectationsHelper(String expression, Object... args) {
	Assert.hasText(expression, "expression must not be null or empty");
	this.expression = String.format(expression, args);
	this.jsonPath = (JsonPath) ReflectionUtils.invokeMethod(
			compileMethod, null, this.expression, emptyFilters);
}
 
Example 6
Source File: AdvertiseController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
     * 创建广告
     *
     * @param advertise 广告{@link Advertise}
     * @return
     */
    @RequestMapping(value = "create")
    @Transactional(rollbackFor = Exception.class)
    public MessageResult create(@Valid Advertise advertise, BindingResult bindingResult,
                                @SessionAttribute(SESSION_MEMBER) AuthMember member,
                                @RequestParam(value = "pay[]") String[] pay, String jyPassword) throws Exception {
        MessageResult result = BindingResultUtil.validate(bindingResult);
        if (result != null) {
            return result;
        }
        Assert.notEmpty(pay, msService.getMessage("MISSING_PAY"));
        Assert.hasText(jyPassword, msService.getMessage("MISSING_JYPASSWORD"));
        Member member1 = memberService.findOne(member.getId());
        Assert.isTrue(member1.getIdNumber() != null, msService.getMessage("NO_REALNAME"));
//        if (allow == 1) {
            //allow是1的时候,必须是认证商家才能发布广告
        Assert.isTrue(member1.getMemberLevel().equals(MemberLevelEnum.IDENTIFICATION), msService.getMessage("NO_BUSINESS"));
//        }
        String mbPassword = member1.getJyPassword();
        Assert.hasText(mbPassword, msService.getMessage("NO_SET_JYPASSWORD"));
        Assert.isTrue(Md5.md5Digest(jyPassword + member1.getSalt()).toLowerCase().equals(mbPassword), msService.getMessage("ERROR_JYPASSWORD"));
        AdvertiseType advertiseType = advertise.getAdvertiseType();
        StringBuffer payMode = checkPayMode(pay, advertiseType, member1);
        advertise.setPayMode(payMode.toString());
        OtcCoin otcCoin = otcCoinService.findOne(advertise.getCoin().getId());
        checkAmount(advertiseType, advertise, otcCoin, member1);
        advertise.setLevel(AdvertiseLevel.ORDINARY);
        advertise.setRemainAmount(advertise.getNumber());
        Member mb = new Member();
        mb.setId(member.getId());
        advertise.setMember(mb);
        Advertise ad = advertiseService.saveAdvertise(advertise);
        if (ad != null) {
            return MessageResult.success(msService.getMessage("CREATE_SUCCESS"));
        } else {
            return MessageResult.error(msService.getMessage("CREATE_FAILED"));
        }
    }
 
Example 7
Source File: GeneratorMain.java    From spring-boot-starter-dao with Apache License 2.0 5 votes vote down vote up
@Override
public void run(String... args) throws Exception {
	Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource("generator.properties"));
	String nodeName = properties.getProperty("mybatis.nodeName", null);
	Assert.hasText(nodeName, "节点名不可以为空");
	MybatisNodeProperties node = this.getNodeBYName(nodeName);
	this.buildProperties(properties, node);

	Assert.hasText(properties.getProperty("package.model"), "mapper的model目录不可以为空,配置项 package.model");
	Assert.hasText(properties.getProperty("package.repo"), "mapper的接口目录不可以为空,配置项 package.repo");
	Assert.hasText(properties.getProperty("package.mapper"), "mapper的xml目录不可以为空,配置项 package.mapper");

	this.generate(properties);

}
 
Example 8
Source File: MachineCenterImpl.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Override
public boolean deployServerCollection(long hostId, String ip) {
       Assert.hasText(ip);
       Map<String, Object> dataMap = new HashMap<String, Object>();
       dataMap.put(ConstUtils.HOST_KEY, ip);
       JobKey jobKey = JobKey.jobKey(ConstUtils.SERVER_JOB_NAME, ConstUtils.SERVER_JOB_GROUP);
       TriggerKey triggerKey = TriggerKey.triggerKey(ip, ConstUtils.SERVER_TRIGGER_GROUP + ip);
       boolean result = schedulerCenter.deployJobByCron(jobKey, triggerKey, dataMap, ScheduleUtil.getFiveMinuteCronByHostId(hostId), false);

       return result;
}
 
Example 9
Source File: DefaultMessageDescriptor.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * Instantiates a new message.
 *
 * @param code the code
 * @param defaultMessage the default message
 * @param params the params
 */
public DefaultMessageDescriptor(final String code, final String defaultMessage, final Serializable... params) {
    Assert.hasText(code, "Code cannot be null or empty");
    Assert.hasText(defaultMessage, "Default message cannot be null or empty");
    this.code = code;
    this.defaultMessage = defaultMessage;
    this.params = params;
}
 
Example 10
Source File: ServerEndpointRegistration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Create a new {@link ServerEndpointRegistration} instance from an
 * {@code javax.websocket.Endpoint} instance.
 * @param path the endpoint path
 * @param endpoint the endpoint instance
 */
public ServerEndpointRegistration(String path, Endpoint endpoint) {
	Assert.hasText(path, "Path must not be empty");
	Assert.notNull(endpoint, "Endpoint must not be null");
	this.path = path;
	this.endpoint = endpoint;
	this.endpointProvider = null;
}
 
Example 11
Source File: AndroidAction.java    From agent with MIT License 5 votes vote down vote up
/**
 * 2001.启动/重启 apk
 */
public void restartApk(String packageName, String launchActivity) throws IDeviceExecuteShellCommandException {
    Assert.hasText(packageName, "包名不能为空");
    Assert.hasText(launchActivity, "启动Activity不能为空");

    AndroidUtil.restartApk(androidDevice.getIDevice(), packageName, launchActivity);
}
 
Example 12
Source File: ProductFunction.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * @param fieldname
 *            must not be null
 * @return
 */
public Builder times(String fieldname) {
	Assert.hasText(fieldname, "Fieldname must not be 'empty'.");

	this.function.addArgument(fieldname);
	return this;
}
 
Example 13
Source File: AbstractVersionStrategy.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public PrefixVersionPathStrategy(String version) {
	Assert.hasText(version, "'version' must not be empty");
	this.prefix = version;
}
 
Example 14
Source File: NamedThreadLocal.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new NamedThreadLocal with the given name.
 * @param name a descriptive name for this ThreadLocal
 */
public NamedThreadLocal(String name) {
	Assert.hasText(name, "Name must not be empty");
	this.name = name;
}
 
Example 15
Source File: Account.java    From galeb with Apache License 2.0 4 votes vote down vote up
public Account setEmail(String email) {
    Assert.hasText(email, "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
    updateHash();
    this.email = email;
    return this;
}
 
Example 16
Source File: OptionsProviderImpl.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public void setClientExtensionsJSONParameter(String clientExtensionsJSONParameter) {
    Assert.hasText(clientExtensionsJSONParameter, "clientExtensionsJSONParameter must not be empty or null");
    this.clientExtensionsJSONParameter = clientExtensionsJSONParameter;
}
 
Example 17
Source File: StaticScriptSource.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Set a fresh script String, overriding the previous script.
 * @param script the script String
 */
public synchronized void setScript(String script) {
	Assert.hasText(script, "Script must not be empty");
	this.modified = !script.equals(this.script);
	this.script = script;
}
 
Example 18
Source File: ClientAuthenticationFactory.java    From spring-cloud-vault with Apache License 2.0 3 votes vote down vote up
private ClientAuthentication azureMsiAuthentication(VaultProperties vaultProperties) {

		AzureMsiProperties azureMsi = vaultProperties.getAzureMsi();

		Assert.hasText(azureMsi.getRole(),
				"Azure role (spring.cloud.vault.azure-msi.role) must not be empty");

		AzureMsiAuthenticationOptions options = AzureMsiAuthenticationOptions.builder()
				.role(azureMsi.getRole()).build();

		return new AzureMsiAuthentication(options, this.restOperations,
				this.externalRestOperations);
	}
 
Example 19
Source File: DefaultPathService.java    From Real-Time-Taxi-Dispatch-Simulator with MIT License 2 votes vote down vote up
public void setGoogleApiKey(String googleApiKey) {
    Assert.hasText(googleApiKey, "The googleApiKey must not be empty.");

}
 
Example 20
Source File: HeaderWebSessionIdResolver.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set the name of the session header to use for the session id.
 * The name is used to extract the session id from the request headers as
 * well to set the session id on the response headers.
 * <p>By default set to {@code DEFAULT_HEADER_NAME}
 * @param headerName the header name
 */
public void setHeaderName(String headerName) {
	Assert.hasText(headerName, "'headerName' must not be empty");
	this.headerName = headerName;
}