List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:cn.guoyukun.spring.web.controller.permission.PermissionList.java
public void assertHasAnyPermission(String[] permissions, String errorCode) { if (StringUtils.isEmpty(errorCode)) { errorCode = getDefaultErrorCode(); }//from w w w . j av a2 s. co m if (permissions == null || permissions.length == 0) { throw new UnauthorizedException( MessageUtils.message(errorCode, resourceIdentity + ":" + Arrays.toString(permissions))); } Subject subject = SecurityUtils.getSubject(); for (String permission : permissions) { String resourcePermission = resourcePermissions.get(permission); if (resourcePermission == null) { resourcePermission = this.resourceIdentity + ":" + permission; } if (subject.isPermitted(resourcePermission)) { return; } } throw new UnauthorizedException( MessageUtils.message(errorCode, resourceIdentity + ":" + Arrays.toString(permissions))); }
From source file:bamons.process.monitoring.web.BatchMonitoringController.java
/** * * Job ?/*from ww w . ja va 2 s. co m*/ * * @param request request ? * @param response response ? * @return job JSON * @throws Exception */ @RequestMapping(value = "/job/restart.do", produces = { "application/json; charset=UTF-8" }) public @ResponseBody Map<String, Object> jobRestart(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean status = true; int jobExecutionId = ServletRequestUtils.getIntParameter(request, "jobExecutionId", 0); String jobName = ServletRequestUtils.getStringParameter(request, "jobName", ""); String statusMessage = ""; Map<String, Object> map = new HashMap<String, Object>(); if (jobExecutionId > 0 && !StringUtils.isEmpty(jobName)) { try { batchMonitoringService.jobRestart(jobExecutionId, jobName); } catch (Exception e) { statusMessage = e.toString(); status = false; } } else { status = false; statusMessage = "jobExecutionId or jobName Error"; } map.put("success", true); map.put("status", status); map.put("statusMessage", statusMessage); return map; }
From source file:com.github.hateoas.forms.spring.AffordanceBuilderFactory.java
private AffordanceBuilder linkTo(final Link path, final RequestMethod method, final CustomizableSpringActionInputParameter parameter) { String pathMapping = path.getHref(); List<String> params = path.getVariableNames(); String query = join(params);//www. j av a 2 s . com String mapping = StringUtils.isEmpty(query) ? pathMapping : pathMapping + "{?" + query + "}"; PartialUriTemplate partialUriTemplate = new PartialUriTemplate( AffordanceBuilder.getBuilder().build().toString() + mapping); SpringActionDescriptor actionDescriptor = new SpringActionDescriptor(method.name().toLowerCase(), method.name()); if (parameter != null) { actionDescriptor.setRequestBody(parameter); } if (paramsOnBody && !Affordance.isSafe(actionDescriptor.getHttpMethod())) { partialUriTemplate = new PartialUriTemplate( AffordanceBuilder.getBuilder().build().toString() + pathMapping); } return new AffordanceBuilder(partialUriTemplate.expand(Collections.emptyMap()), Collections.singletonList((ActionDescriptor) actionDescriptor)); }
From source file:com.scf.core.persistence.entity.EntityObject.java
public void preUpdate(String modifyUserId) { this.modifyTime = new Date(); if (!StringUtils.isEmpty(modifyUserId)) { this.modifyUserId = modifyUserId; } else {//from w w w.j ava 2s . com this.modifyUserId = CommonConstants.DEFAULT_OPER_USER_ID; } }
From source file:com.formkiq.core.service.UserServiceImpl.java
@Override public void deleteUser(final String email) { if (!StringUtils.isEmpty(email)) { User user = this.userDao.findUser(email); if (user != null) { if (!(UserRole.ROLE_ADMIN.equals(user.getRole()) && this.userDao.getAdminUserCount() == 1)) { this.userDao.deleteUser(user); } else { throw new PreconditionFailedException("Cannot delete, only admin"); }/* ww w .ja v a 2 s. c o m*/ } else { throw new PreconditionFailedException("Email " + email + " not found"); } } else { throw new PreconditionFailedException("Invalid Email"); } }
From source file:com.ethercamp.harmony.keystore.FileSystemKeystore.java
/** * @return platform dependent path to Ethereum folder *//*from www . j av a2s.c o m*/ public Path getKeyStoreLocation() { if (!StringUtils.isEmpty(keystoreDir)) { return Paths.get(keystoreDir); } final String keystoreDir = "keystore"; final String osName = System.getProperty("os.name").toLowerCase(); if (osName.indexOf("win") >= 0) { return Paths.get(System.getenv("APPDATA") + "/Ethereum/" + keystoreDir); } else if (osName.indexOf("mac") >= 0) { return Paths.get(System.getProperty("user.home") + "/Library/Ethereum/" + keystoreDir); } else { // must be linux/unix return Paths.get(System.getProperty("user.home") + "/.ethereum/" + keystoreDir); } }
From source file:com.capitalone.dashboard.collector.TeamDataClient.java
/** * Removes scope-owners (teams) from the collection which have went to an * non-active state//from w ww .j a v a 2 s . co m * * @param teamId * A given Team ID that went inactive and should be removed from * the data collection */ private void removeInactiveScopeOwnerByTeamId(String teamId) { if (!StringUtils.isEmpty(teamId) && !CollectionUtils.isEmpty(teamRepo.getTeamIdById(teamId))) { ObjectId inactiveTeamId = teamRepo.getTeamIdById(teamId).get(0).getId(); if (inactiveTeamId != null) { teamRepo.delete(inactiveTeamId); } } }
From source file:com.ufukuzun.myth.dialect.handler.AjaxRequestResponseBodyReturnValueHandler.java
@Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { AjaxRequestBody ajaxRequestBody = parameter.getParameterAnnotation(AjaxRequestBody.class); boolean performValidation = ajaxRequestBody.validate(); String targetName = ajaxRequestBody.targetName(); Assert.notNull(targetName);/*from w ww . j a v a2 s . c o m*/ Object argument = readWithMessageConverters(webRequest, parameter, parameter.getGenericParameterType()); if (argument != null && AjaxRequest.class.isInstance(argument) && !StringUtils.isEmpty(targetName)) { AjaxRequest<?> ajaxRequest = (AjaxRequest<?>) argument; mavContainer.addAttribute(targetName, ajaxRequest.getModel()); if (performValidation) { ajaxRequest .setModelValid(myth.validate(mavContainer.getModel(), ajaxRequest.getModel(), targetName)); } } return argument; }
From source file:bamons.process.monitoring.service.BatchMonitoringServiceImpl.java
/** * * Job ? ?./* w ww. j ava 2 s. co m*/ * * @param jobExecutionId Job ID * @param jobName Job ? * @throws Exception */ @Override public void jobRestart(int jobExecutionId, String jobName) throws Exception { try { String params = jobOperator.getParameters(jobExecutionId); String[] paramValues = new String[2]; String targetDate = ""; String filePath = ""; StringTokenizer st = new StringTokenizer(params, ","); while (st.hasMoreTokens()) { String sd = st.nextToken(); if (sd.contains("targetDate")) { paramValues = sd.split("="); targetDate = paramValues[1]; break; } if (sd.contains("filePath")) { paramValues = sd.split("="); filePath = paramValues[1]; break; } } StringBuilder sb = new StringBuilder(); sb.append("time(long)="); sb.append(System.currentTimeMillis()); if (!StringUtils.isEmpty(targetDate)) { sb.append(",targetDate="); sb.append(targetDate); } else if (!StringUtils.isEmpty(filePath)) { sb.append(",filePath="); sb.append(filePath); } jobOperator.start(jobName, sb.toString()); } catch (Exception e) { throw e; } }
From source file:org.elasticsoftware.elasterix.server.AbstractSipTest.java
private Map<String, String> tokenize(String value) { Map<String, String> map = new HashMap<String, String>(); // sanity check if (StringUtils.isEmpty(value)) { return map; }// w ww.j ava 2s. com // Authorization: Digest username="124",realm="elasticsoftware",nonce="24855234", // uri="sip:sip.outerteams.com:5060",response="749c35e9fe30d6ba46cc801bdfe535a0",algorithm=MD5 StringTokenizer st = new StringTokenizer(value, " ,", false); while (st.hasMoreTokens()) { String token = st.nextToken(); int idx = token.indexOf("="); if (idx != -1) { map.put(token.substring(0, idx).toLowerCase(), token.substring(idx + 1).replace('\"', ' ').trim()); } else { map.put(token.toLowerCase(), token); } } return map; }