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() . 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: ConsumerController.java    From apollo with 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 File: UserInfoController.java    From apollo with 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 File: NamespaceReleaseModel.java    From apollo with 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 File: NamespaceTextModel.java    From apollo with 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 File: NamespaceIdentifier.java    From apollo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInvalid() {
  return StringUtils.isContainEmpty(env, clusterName, namespaceName);
}
 
Example 6
Source File: ItemController.java    From apollo with Apache License 2.0 4 votes vote down vote up
private boolean isValidItem(ItemDTO item) {
  return Objects.nonNull(item) && !StringUtils.isContainEmpty(item.getKey());
}