List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:org.jsconf.core.impl.BeanFactory.java
public String registerBean() { String beanId = this.id; BeanDefinitionBuilder beanDefinition; if (StringUtils.isEmpty(beanId)) { if (StringUtils.hasText(this.childName)) { beanId = this.childName; } else {/*from w ww. ja v a2 s . co m*/ beanId = this.key; } } this.log.debug("Initalize bean id : {}", beanId); if (StringUtils.hasText(this.parentId)) { beanDefinition = buildBeanFromParent(beanId); } else if (StringUtils.hasText(this.className)) { beanDefinition = buildBeanFromClass(beanId); } else if (StringUtils.hasText(this.interfaceName)) { beanDefinition = buildBeanFromInterface(); } else { throw new BeanCreationException(beanId, "Bean have not class or parent defined"); } this.log.debug("Regitre bean id : {}", beanId); this.context.registerBeanDefinition(beanId, beanDefinition.getBeanDefinition()); return beanId; }
From source file:cn.guoyukun.spring.web.interceptor.SetCommonDataInterceptor.java
private String extractCurrentURL(HttpServletRequest request, boolean needQueryString) { String url = request.getRequestURI(); String queryString = request.getQueryString(); if (!StringUtils.isEmpty(queryString)) { queryString = "?" + queryString; for (String pattern : excludeParameterPatterns) { queryString = queryString.replaceAll(pattern, ""); }/*from w ww . java 2 s. c o m*/ if (queryString.startsWith("&")) { queryString = "?" + queryString.substring(1); } } if (!StringUtils.isEmpty(queryString) && needQueryString) { url = url + queryString; } return getBasePath(request) + url; }
From source file:com.shigengyu.hyperion.core.WorkflowState.java
protected WorkflowState() { final State annotation = this.getClass().getAnnotation(State.class); if (annotation == null) { throw new WorkflowStateException("Workflow state [{}] does not have [{}] annotation specified", this.getClass().getName(), State.class.getName()); }/*from w w w . j av a 2s . c o m*/ workflowStateId = annotation.id(); name = StringUtils.isEmpty(annotation.name()) ? this.getClass().getSimpleName() : annotation.name(); displayName = StringUtils.isEmpty(annotation.displayName()) ? name : annotation.displayName(); intermediate = annotation.intermediate(); }
From source file:com.web.mavenproject6.controller.VKController.java
private JSONObject execute(String apiMethod, Param... params) throws IOException, JSONException { if (accessToken != null || StringUtils.isEmpty(accessToken)) { return new JSONObject(); }/*from w ww. ja v a 2 s. c o m*/ String paramString = "?".concat(accessToken); if (params != null) { for (Param p : params) { paramString = paramString.concat("&").concat(p.getName()).concat("=").concat(p.getValue()); } } HttpClient client = new DefaultHttpClient(); HttpGet method = new HttpGet(apiUrl.concat(apiMethod).concat(paramString)); HttpResponse resp = client.execute(method); BufferedReader reader = new BufferedReader(new InputStreamReader(resp.getEntity().getContent())); JSONObject json = new JSONObject(reader.readLine()); reader.close(); return json; }
From source file:com.work.petclinic.web.OwnerController.java
@RequestMapping(value = "/list", method = RequestMethod.GET) public String processFindForm(Owner owner, BindingResult result, Model model, HttpSession session) { Collection<Owner> results = null; // find owners by last name if (StringUtils.isEmpty(owner.getLastName())) { // allow parameterless GET request for /owners to return all records results = this.clinicService.findOwners(); } else {/*from w w w. j av a 2 s .co m*/ results = this.clinicService.findOwnerByLastName(owner.getLastName()); } if (results.size() < 1) { // no owners found result.rejectValue("lastName", "notFound", new Object[] { owner.getLastName() }, "not found"); return "owners/findOwners"; } session.setAttribute("searchLastName", owner.getLastName()); if (results.size() > 1) { // multiple owners found model.addAttribute("owners", results); return "owners/ownersList"; } else { // 1 owner found owner = results.iterator().next(); return "redirect:/owners/" + owner.getId(); } }
From source file:org.ihtsdo.otf.refset.api.authentication.UserController.java
@RequestMapping(method = RequestMethod.POST, value = "/getUserDetails", produces = "application/json", consumes = "application/json") @ApiOperation(value = "Authenticate a user for given username and password provided in request header and returns user details ", notes = "This api call authenticate a user and also authorize a user for Refset app access. Pre-Auth tokens(X-REFSET-PRE-AUTH-USERNAME & X-REFSET-PRE-AUTH-TOKEN)" + " supplied in request header, are being used for authentication/authorization. If successful" + " it returns an User details object and a authentication token X-REFSET-AUTH-TOKEN as part of response header" + " to be used in header of subsequent requests for API handshake") @PreAuthorize("hasRole('ROLE_USER')") public ResponseEntity<Result<Map<String, Object>>> login() throws Exception { logger.debug("authenticating user {}"); Result<Map<String, Object>> r = Utility.getResult(); Map<String, Object> data = new HashMap<String, Object>(); User u = org.ihtsdo.otf.refset.common.Utility.getUserDetails(); if (StringUtils.isEmpty(u.getGivenname())) { Authentication authentication = new UsernamePasswordAuthenticationToken(u, u.getPassword()); provider.authenticate(authentication); u = (User) authentication.getPrincipal(); }/*from ww w .j av a2 s . c o m*/ u.setPassword(null);//make it empty before sending it in response data.put("user", u); r.setData(data); r.getMeta().setMessage(SUCCESS); r.getMeta().setStatus(HttpStatus.OK); return new ResponseEntity<Result<Map<String, Object>>>(r, HttpStatus.OK); }
From source file:com.expedia.seiso.domain.service.search.Validator.java
private boolean validateQuery(SearchQuery tokenizedSearchQuery, ConstraintValidatorContext context) { boolean isValid = true; if (tokenizedSearchQuery == null || StringUtils.isEmpty(tokenizedSearchQuery.getQuery())) { isValid = false;//from ww w . j a v a 2s .co m this.addConstraintViolation(context, "empty search query"); } else if (!this.queryPattern.matcher(tokenizedSearchQuery.getQuery()).matches()) { isValid = false; this.addConstraintViolation(context, "search query '" + tokenizedSearchQuery.getQuery() + "' does not match pattern " + this.queryPattern); } return isValid; }
From source file:cf.spring.CfComponentConfiguration.java
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { final MultiValueMap<String, Object> attributes = importMetadata .getAllAnnotationAttributes(CfComponent.class.getName()); type = evaluate(attributes, "type"); index = Integer.valueOf(evaluate(attributes, "index")); uuid = evaluate(attributes, "uuid"); if (StringUtils.isEmpty(uuid)) { uuid = UUID.randomUUID().toString(); }//from w w w . java2 s .co m host = evaluate(attributes, "host"); port = Integer.valueOf(evaluate(attributes, "port")); username = evaluate(attributes, "username"); password = evaluate(attributes, "password"); if (StringUtils.isEmpty(password)) { password = new BigInteger(256, ThreadLocalRandom.current()).toString(32); } }
From source file:org.wallride.web.controller.admin.user.UserSearchController.java
@RequestMapping(method = RequestMethod.GET) public String search(@PathVariable String language, @Validated @ModelAttribute("form") UserSearchForm form, BindingResult result, @PageableDefault(50) Pageable pageable, Model model, HttpServletRequest servletRequest) throws UnsupportedEncodingException { Page<User> users = userService.getUsers(form.toUserSearchRequest(), pageable); model.addAttribute("users", users); model.addAttribute("pageable", pageable); model.addAttribute("pagination", new Pagination<>(users, servletRequest)); UriComponents uriComponents = ServletUriComponentsBuilder.fromRequest(servletRequest) .queryParams(ControllerUtils.convertBeanForQueryParams(form, conversionService)).build(); if (!StringUtils.isEmpty(uriComponents.getQuery())) { model.addAttribute("query", URLDecoder.decode(uriComponents.getQuery(), "UTF-8")); }// w w w .j a v a2 s . c o m return "user/index"; }
From source file:com.jeanchampemont.notedown.web.SettingsController.java
@RequestMapping(value = "/user", method = RequestMethod.POST) public String updateUser(SettingsUserForm form, ModelMap model) { User user = authenticationService.getCurrentUser(); boolean success = true; boolean hasChanged = false; if (!user.getEmail().equals(form.getEmail().toLowerCase())) { hasChanged = true;/*from w w w . ja v a2 s .c o m*/ Optional<User> existingUser = userService.getUserByEmail(form.getEmail()); if (!existingUser.isPresent()) { success = userService.changeEmail(user, form.getEmail(), form.getOldPassword()); if (!success) { model.put("wrongPassword", true); } else { //Changing email need new authentication authenticationService.newAuthentication(user.getEmail(), form.getOldPassword()); } } else { success = false; model.put("emailExists", true); } } if (success && !StringUtils.isEmpty(form.getNewPassword())) { hasChanged = true; success = userService.changePassword(user, form.getOldPassword(), form.getNewPassword()); if (!success) { model.put("wrongPassword", true); } } if (success && !user.getDisplayName().equals(form.getDisplayName())) { hasChanged = true; user.setDisplayName(form.getDisplayName()); user = userService.update(user); success = true; } model.put("success", success && hasChanged); model.put("tab", "user"); return user(model); }