Java Code Examples for com.ctrip.framework.apollo.core.utils.StringUtils#isContainEmpty()

The following examples show how to use com.ctrip.framework.apollo.core.utils.StringUtils#isContainEmpty() . These examples are extracted from open source projects. 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 Project: apollo   File: ConsumerController.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@PostMapping(value = "/consumers")
public ConsumerToken createConsumer(@RequestBody Consumer consumer,
                                    @RequestParam(value = "expires", required = false)
                                    @DateTimeFormat(pattern = "yyyyMMddHHmmss") Date
                                        expires) {

  if (StringUtils.isContainEmpty(consumer.getAppId(), consumer.getName(),
                                 consumer.getOwnerName(), consumer.getOrgId())) {
    throw new BadRequestException("Params(appId、name、ownerName、orgId) can not be empty.");
  }

  Consumer createdConsumer = consumerService.createConsumer(consumer);

  if (Objects.isNull(expires)) {
    expires = DEFAULT_EXPIRES;
  }

  return consumerService.generateAndSaveConsumerToken(createdConsumer, expires);
}
 
Example 2
Source Project: apollo   File: UserInfoController.java    License: Apache License 2.0 5 votes vote down vote up
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@PostMapping("/users")
public void createOrUpdateUser(@RequestBody UserPO user) {
  if (StringUtils.isContainEmpty(user.getUsername(), user.getPassword())) {
    throw new BadRequestException("Username and password can not be empty.");
  }

  if (userService instanceof SpringSecurityUserService) {
    ((SpringSecurityUserService) userService).createOrUpdate(user);
  } else {
    throw new UnsupportedOperationException("Create or update user operation is unsupported");
  }

}
 
Example 3
Source Project: apollo   File: NamespaceReleaseModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInvalid() {
  return StringUtils.isContainEmpty(appId, env, clusterName, namespaceName, releaseTitle);
}
 
Example 4
Source Project: apollo   File: NamespaceTextModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInvalid() {
  return StringUtils.isContainEmpty(appId, env, clusterName, namespaceName) || namespaceId <= 0;
}
 
Example 5
Source Project: apollo   File: NamespaceIdentifier.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInvalid() {
  return StringUtils.isContainEmpty(env, clusterName, namespaceName);
}
 
Example 6
Source Project: apollo   File: ItemController.java    License: Apache License 2.0 4 votes vote down vote up
private boolean isValidItem(ItemDTO item) {
  return Objects.nonNull(item) && !StringUtils.isContainEmpty(item.getKey());
}