List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.ge.predix.uaa.token.lib.FastTokenServices.java
protected Map<String, Object> getTokenClaims(final String accessToken) { if (StringUtils.isEmpty(accessToken)) { return null; }/*from www . java 2 s. c o m*/ Jwt token = JwtHelper.decode(accessToken); Map<String, Object> claims = JsonUtils.readValue(token.getClaims(), new TypeReference<Map<String, Object>>() { // Nothing to add here. }); return claims; }
From source file:com.formkiq.core.service.UserServiceImpl.java
/** * Encrypts the User Password and set it into the object. * @param user User/*from w w w . j ava 2 s .c om*/ * @param password unencrypted password */ private void setUserPassword(final User user, final String password) { if (!StringUtils.isEmpty(password)) { String securedPassHash = generatedSecuredPasswordHash(password); user.setPassword(securedPassHash); } }
From source file:burstcoin.jminer.core.CoreProperties.java
private static long asLong(String key, long defaultValue) { String integerProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null; Long value = null;/*from w w w . j av a 2 s .c om*/ if (!StringUtils.isEmpty(integerProperty)) { try { value = Long.valueOf(integerProperty); } catch (NumberFormatException e) { LOG.error("value of property: '" + key + "' should be a numeric (long) value."); } } return value != null ? value : defaultValue; }
From source file:cn.guoyukun.spring.jpa.plugin.web.controller.BaseTreeableController.java
@RequestMapping(value = "ajax/load") @PageableDefaults(sort = { "parentIds=asc", "weight=asc" }) @ResponseBody/*from ww w .j a v a 2 s. com*/ public Object load(HttpServletRequest request, @RequestParam(value = "async", defaultValue = "true") boolean async, @RequestParam(value = "asyncLoadAll", defaultValue = "false") boolean asyncLoadAll, @RequestParam(value = "searchName", required = false) String searchName, @RequestParam(value = "id", required = false) ID parentId, @RequestParam(value = "excludeId", required = false) ID excludeId, @RequestParam(value = "onlyCheckLeaf", required = false, defaultValue = "false") boolean onlyCheckLeaf, Searchable searchable) { M excludeM = baseService.findOne(excludeId); List<M> models = null; if (!StringUtils.isEmpty(searchName)) {//name searchable.addSearchParam("name_like", searchName); models = baseService.findAllByName(searchable, excludeM); if (!async || asyncLoadAll) {//?? ??? searchable.removeSearchFilter("name_like"); List<M> children = baseService.findChildren(models, searchable); models.removeAll(children); models.addAll(children); } else { //? ?? } } else { //?parentId if (parentId != null) { //?? searchable.addSearchFilter("parentId", SearchOperator.eq, parentId); } if (async && !asyncLoadAll) { //? ? // ? ?? baseService.addExcludeSearchFilter(searchable, excludeM); } if (parentId == null && !asyncLoadAll) { models = baseService.findRootAndChild(searchable); } else { models = baseService.findAllWithSort(searchable); } } return convertToZtreeList(request.getContextPath(), models, async && !asyncLoadAll && parentId != null, onlyCheckLeaf); }
From source file:com.sastix.cms.client.impl.CmsClient.java
@Override public CacheDTO getCachedResource(QueryCacheDTO queryCacheDTO) throws DataNotFound, CacheValidationException { nullValidationChecker(queryCacheDTO, QueryCacheDTO.class); boolean isNotValidObject = queryCacheDTO.getCacheKey() == null; CacheDTO cacheDTO = null;//from www . ja v a2s . co m if (isNotValidObject) { throw new CacheValidationException("QueryCacheDTO object is missing the cacheKey"); } else { if (hazelcastInstance.isPresent()) { final String cache = StringUtils.isEmpty(queryCacheDTO.getCacheRegion()) ? Constants.DEFAULT_CACHE_NAME : queryCacheDTO.getCacheRegion(); LOG.debug("Trying to find resource ({},{}) in local HZ instance", queryCacheDTO.getCacheKey(), cache); if (hazelcastInstance.get().getMap(cache).containsKey(queryCacheDTO.getCacheKey())) { try { cacheDTO = (CacheDTO) hazelcastInstance.get().getMap(cache) .get(queryCacheDTO.getCacheKey()); if (cacheDTO.getCacheExpirationTime().isBeforeNow()) { final RemoveCacheDTO removeCacheDTO = new RemoveCacheDTO(); removeCacheDTO.setCacheKey(queryCacheDTO.getCacheKey()); removeCacheDTO.setCacheRegion(queryCacheDTO.getCacheRegion()); removeCachedResource(removeCacheDTO); } else { LOG.debug("Resource ({},{}) found in local HZ instance", queryCacheDTO.getCacheKey(), cache); return cacheDTO; } } catch (Exception e) { LOG.debug("QueryCacheDTO with key={} was not found in region={}", queryCacheDTO.getCacheKey(), queryCacheDTO.getCacheRegion()); } } } StringBuffer url = new StringBuffer(getUrlRoot()).append(Constants.GET_CACHE); LOG.debug("API call: " + url); LOG.debug("Request DTO: " + queryCacheDTO.toString()); cacheDTO = retryRestTemplate.postForObject(url.toString(), queryCacheDTO, CacheDTO.class); LOG.debug("Response DTO: {}", cacheDTO); } return cacheDTO; }
From source file:uk.gov.nationalarchives.discovery.taxonomy.cli.CLIRunner.java
private void updateTrainingSet(String categoryCiaid, Integer fixedLimitSize) throws IOException, ParseException { if (StringUtils.isEmpty(categoryCiaid)) { trainingSetService.createTrainingSet(null, fixedLimitSize); } else {//from w ww . j a v a2s .com trainingSetService.updateTrainingSetForCategory(categoryCiaid, null, fixedLimitSize); } }
From source file:se.inera.intyg.intygstjanst.web.service.impl.CertificateServiceImpl.java
private void assertConsent(Personnummer civicRegistrationNumber) throws MissingConsentException { if (civicRegistrationNumber == null || StringUtils.isEmpty(civicRegistrationNumber.getPersonnummer())) { throw new IllegalArgumentException("Invalid/missing civicRegistrationNumber"); }//from w w w . j a va 2 s.c o m if (!consentService.isConsent(civicRegistrationNumber)) { throw new MissingConsentException(civicRegistrationNumber); } }
From source file:burstcoin.jminer.core.CoreProperties.java
private static List<String> asStringList(String key, List<String> defaultValue) { String stringListProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null; List<String> value = null; if (!StringUtils.isEmpty(stringListProperty)) { try {//from w w w .j a v a 2s .c o m value = Arrays.asList(stringListProperty.trim().split(STRING_LIST_PROPERTY_DELIMITER)); } catch (NullPointerException | NumberFormatException e) { LOG.error("property: '" + key + "' value should be 'string(s)' separated by '" + STRING_LIST_PROPERTY_DELIMITER + "' (comma)."); } } return value != null ? value : defaultValue; }
From source file:com.formkiq.core.form.service.FormValidatorServiceImpl.java
@Override public Map<String, String> validateWorkflowRoute(final WorkflowRoute route) { Map<String, String> errors = new HashMap<>(); if (StringUtils.isEmpty(route.getName())) { errors.put("name", "WorkflowRoute name is required"); }// w w w .j a v a 2s . com if (CollectionUtils.isEmpty(route.getNotifications())) { errors.put("name", "At least 1 notification is required"); } return errors; }
From source file:com.emergya.spring.security.oauth.google.GoogleAuthorizationCodeAccessTokenProvider.java
private MultiValueMap<String, String> getParametersForAuthorizeRequest(GoogleAuthCodeResourceDetails resource, AccessTokenRequest request) {//from www. ja v a 2 s .c om MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.set("response_type", "code"); form.set("client_id", resource.getClientId()); if (request.get("scope") != null) { form.set("scope", request.getFirst("scope")); } else { form.set("scope", OAuth2Utils.formatParameterList(resource.getScope())); } // Extracting the redirect URI from a saved request should ignore the current URI, so it's not simply a call to // resource.getRedirectUri() String redirectUri = resource.getPreEstablishedRedirectUri(); Object preservedState = request.getPreservedState(); if (redirectUri == null && preservedState != null) { // no pre-established redirect uri: use the preserved state // TODO: treat redirect URI as a special kind of state (this is a historical mini hack) redirectUri = String.valueOf(preservedState); } else { redirectUri = request.getCurrentUri(); } String stateKey = request.getStateKey(); if (stateKey != null) { form.set("state", stateKey); if (preservedState == null) { throw new InvalidRequestException( "Possible CSRF detected - state parameter was present but no state could be found"); } } form.set("approval_prompt", resource.getApprovalPrompt()); if (StringUtils.isEmpty(resource.getLoginHint())) { form.set("login_hint", resource.getLoginHint()); } if (redirectUri != null) { form.set("redirect_uri", redirectUri); } return form; }