List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:com.rmn.qa.AutomationCapabilityMatcher.java
public AutomationCapabilityMatcher() { super();/*from w ww . j a v a 2 s. c om*/ String propertyValue = System.getProperty(AutomationConstants.EXTRA_CAPABILITIES_PROPERTY_NAME); if (!StringUtils.isEmpty(propertyValue)) { if (propertyValue.contains(",")) { String[] capabilities = propertyValue.split(","); for (String capability : capabilities) { log.info("Adding capability: " + capability); additionalConsiderations.add(capability); } } else { log.info("Adding capability from property value: " + propertyValue); additionalConsiderations.add(propertyValue); } } }
From source file:com.ec2box.common.interceptor.CSRFInterceptor.java
@Override protected String handleToken(ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(true); synchronized (session) { String sessionToken = (String) session.getAttribute(AuthUtil.CSRF_TOKEN_NM); String token = request.getParameter(AuthUtil.CSRF_TOKEN_NM); if (StringUtils.isEmpty(token) || StringUtils.isEmpty(sessionToken) || !token.equals(sessionToken)) { AuthUtil.deleteAllSession(session); return this.handleInvalidToken(invocation); }/*w ww . j a v a2 s .c o m*/ //generate new token upon post if ("POST".equals(request.getMethod()) && !request.getContentType().contains("multipart/form-data")) { AuthUtil.generateCSRFToken(session); } } return this.handleValidToken(invocation); }
From source file:glluch.com.ontotaxoseeker.TestsGen.java
public static String save(Object o, String className) throws FileNotFoundException, IOException { if (StringUtils.isEmpty(className)) { Out.p("TestsGen.save have received an anonomous object"); className = "anonimousClass"; }//from w ww . jav a 2 s . c om FileOutputStream fileOut = new FileOutputStream("resources/test/" + className + ".ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(o); out.close(); fileOut.close(); System.out.printf( "Serialized data is saved in " + "resources/test/" + className + ".ser" + System.lineSeparator()); return "resources/test/" + className + ".ser"; }
From source file:com.qwazr.store.store.StoreManager.java
/** * Get a File with a path relative to the ROOT_DIR. This API checks that the * file is a child of the ROOT_DIR// w w w. j ava 2s . c o m * * @param relativePath * a relative path * @return a file relative to the ROOT_DIR * @throws IOException * if any I/O error occurs */ public final File getFile(String relativePath) throws IOException { if (StringUtils.isEmpty(relativePath) || relativePath.equals("/")) return rootDir; File finalFile = new File(rootDir, relativePath); File file = finalFile; while (file != null) { if (file.equals(rootDir)) return finalFile; file = file.getParentFile(); } throw new IOException("Permission denied."); }
From source file:com.gamewin.weixin.web.readurl.ReadUrlController.java
@RequestMapping(value = "redirectUrl", method = { RequestMethod.GET, RequestMethod.POST }) public String readUrl(HttpServletRequest request, HttpServletResponse response, Model model, String taskid, String qrcodeId) {//from w ww . j a va2 s.com String userIp = getIpAddr(request); if (!StringUtils.isEmpty(qrcodeId)) { HistoryUrl entity = new HistoryUrl(); ManageQRcode manageQRcode = manageQRcodeService.getManageQRcode(Long.parseLong(qrcodeId)); if (manageQRcode.getTask().getId().equals(Long.parseLong(taskid))) { Integer count = manageQRcodeService.selectHistoryUrlByuserIpAndqrcodeId(userIp, manageQRcode.getId()); if (count == 0) { if ("Y".equals(manageQRcode.getQrState())) { manageQRcode.setQrSubscribeCount(manageQRcode.getQrSubscribeCount() + 1); manageQRcode.setQrSubscribeAdminCount(manageQRcode.getQrSubscribeAdminCount() + 1); manageQRcodeService.saveManageQRcode(manageQRcode); entity.setStatus("Y"); } else { manageQRcode.setQrSubscribeAdminCount(manageQRcode.getQrSubscribeAdminCount() + 1); manageQRcodeService.saveManageQRcode(manageQRcode); entity.setStatus("N"); } } entity.setCreateDate(new Date()); entity.setQrcodeId(manageQRcode.getId()); entity.setTaskId(manageQRcode.getTask().getId()); entity.setUserIp(userIp); manageQRcodeService.saveHistoryUrl(entity); model.addAttribute("redirectUrl", manageQRcode.getQrUrl()); return "readUrl/redirectUrl"; } } return null; }
From source file:com.thoughtworks.go.server.controller.Message.java
public void populateModel(HashMap<String, Object> data) { if (StringUtils.isEmpty(message)) { return;//from w w w . j a va 2 s .c o m } data.put(key, this); }
From source file:com.thinkbiganalytics.policy.validation.DateValidator.java
@Override public boolean validate(String value) { if (!StringUtils.isEmpty(value)) { try {/*from w ww . j av a 2s . c o m*/ parseDate(value); return true; } catch (IllegalArgumentException e) { log.debug("Invalid date format [{}]", value); return false; } } return false; }
From source file:jease.cms.web.system.redirect.Editor.java
public void validate() { validate(StringUtils.isEmpty(source.getValue()), I18N.get("Source_is_required")); validate(StringUtils.isEmpty(target.getValue()), I18N.get("Target_is_required")); }
From source file:controllers.WatchApp.java
@Transactional public static Result unwatch(ResourceParam resourceParam) { User user = UserApp.currentUser();/*from w ww . j ava 2 s .com*/ Resource resource = resourceParam.resource; if (user.isAnonymous()) { return forbidden(views.html.error.forbidden.render(Messages.get("issue.error.unwatch.anonymous"), resource.getProject())); } if (!AccessControl.isAllowed(user, resource, Operation.READ)) { return forbidden(views.html.error.forbidden.render(Messages.get("issue.error.unwatch.permission"), resource.getProject())); } Unwatch unwatch = Unwatch.findBy(user, resource.getType(), resource.getId()); Watch.unwatch(user, resource); if (HttpUtil.isJSONPreferred(request())) { return ok(); } else { if (unwatch == null) { String message = getUnwatchMessage(resource); if (!StringUtils.isEmpty(message)) { flash(utils.Constants.SUCCESS, message); } } return redirect(RouteUtil.getUrl(resource.getType(), resource.getId())); } }
From source file:com.jxt.web.filter.DefaultFilterBuilder.java
@Override public Filter build(String filterText) { if (StringUtils.isEmpty(filterText)) { return Filter.NONE; }/* www.j a v a 2s.co m*/ filterText = decode(filterText); logger.debug("build filter from string. {}", filterText); return makeFilterFromJson(filterText); }