List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:org.eclipse.virgo.ide.runtime.internal.core.Server20Handler.java
private void createRepositoryConfiguration(IServerBehaviour serverBehaviour, String fileName) { // copy com.springsource.repository.properties into the stage and add the stage repository File serverHome = ServerUtils.getServer(serverBehaviour).getRuntimeBaseDirectory().toFile(); Properties properties = new Properties(); try {/*from w w w . j a va 2s . co m*/ properties.load(new FileInputStream(new File(serverHome, "config" + File.separatorChar + fileName))); } catch (FileNotFoundException e) { // TODO CD add logging } catch (IOException e) { // TODO CD add logging } properties.put("stage.type", "watched"); properties.put("stage.watchDirectory", "stage"); String chain = properties.getProperty("chain"); chain = "stage" + (StringUtils.hasLength(chain) ? "," + chain : ""); properties.put("chain", chain); try { File stageDirectory = new File(serverHome, "stage"); if (!stageDirectory.exists()) { stageDirectory.mkdirs(); } properties.store(new FileOutputStream(new File(serverHome, "stage" + File.separator + fileName)), "Generated by SpringSource dm Server Tools " + ServerCorePlugin.getDefault().getBundle().getVersion()); } catch (FileNotFoundException e) { // TODO CD add logging } catch (IOException e) { // TODO CD add logging } }
From source file:com.jaxio.celerio.template.TemplateExecution.java
public String getHeaderComment(String prepend) { String currentFilename = previousEngine.getCurrentFullFilename(); if (!StringUtils.hasLength(currentFilename)) { throw new IllegalStateException("You cannot set a header before setting the output filename"); }// w ww . java2 s . c o m HeaderComment headerComment = config.getCelerio().getConfiguration().getHeaderComment(); if (!headerComment.getInclude()) { return ""; } CommentStyle commentStyle = CommentStyle.fromFilename(currentFilename); if (commentStyle == null) { return ""; } List<String> comments = newArrayList(headerComment.getComments()); if (TRUE == headerComment.getShowTemplateName() || config.getCelerio().getConfiguration().getRootPackage().startsWith("integration.test.")) { comments.add("Template " + templatePack.getName() + ":" + template.getName().replace('\\', '/')); if (template.hasProjectLink()) { comments.add("Template is part of Open Source Project: " + template.getTemplatePackInfo().getProjectLink()); } } return commentStyle.decorate(comments, prepend); }
From source file:com.starit.diamond.server.controller.AdminController.java
/** * ?//from ww w. j a v a2s. c om * * @param userName * @param password * @param modelMap * @return */ @RequestMapping(value = "/changePassword", method = RequestMethod.POST) public String changePassword(HttpServletRequest request, HttpServletResponse response, @RequestParam("userName") String userName, @RequestParam("password") String password, ModelMap modelMap) { userName = userName.trim(); password = password.trim(); if (!StringUtils.hasLength(userName) || DiamondUtils.hasInvalidChar(userName.trim())) { request.getSession().setAttribute("message", "??"); return "redirect:" + listUser(request, response, modelMap); } if (!StringUtils.hasLength(password) || DiamondUtils.hasInvalidChar(password.trim())) { request.getSession().setAttribute("message", "?"); return "redirect:" + listUser(request, response, modelMap); } if (this.userService.updatePassword(userName, password)) { request.getSession().setAttribute("message", "?,??"); } else { request.getSession().setAttribute("message", "!"); } return "redirect:" + listUser(request, response, modelMap); }
From source file:uk.ac.gda.dls.client.views.ImageFileDisplayer.java
@Override public void processFile(String filename) { if (StringUtils.hasLength(filename)) { queueProcess(filename); } }
From source file:grails.plugin.cache.web.PageInfo.java
/** * Returns true if the page's etag header indicates it is the same as the * copy held by the client as indicated by the request's if-none-match * header.//from w w w . java2s . c o m */ public boolean isMatch(HttpServletRequest request) { String ifNoneMatch = request.getHeader(HttpHeaders.IF_NONE_MATCH); String etag = getHeader(HttpHeaders.ETAG); if (!StringUtils.hasLength(ifNoneMatch) || !StringUtils.hasLength(etag)) { return false; } return ifNoneMatch == etag; }
From source file:grails.plugin.cache.web.PageInfo.java
public Map<String, Object> getCacheDirectives() { String cacheControl = getHeader(HttpHeaders.CACHE_CONTROL); Map<String, Object> directives = new HashMap<String, Object>(); if (StringUtils.hasLength(cacheControl)) { for (String directive : cacheControl.split(",\\s*")) { Matcher matcher = PATTERN_CACHE_DIRECTIVE.matcher(directive); if (!matcher.find()) { continue; }/*from www . j av a 2 s . c o m*/ String name = matcher.group(1); String value = matcher.group(2); if (StringUtils.hasLength(value)) { try { directives.put(name, Integer.valueOf(value)); } catch (NumberFormatException e) { directives.put(name, value); } } else { directives.put(name, true); } } } return directives; }
From source file:org.codehaus.groovy.grails.scaffolding.AbstractGrailsTemplateGenerator.java
protected String makeRelativeIfPossible(String fileName, String base) throws IOException { if (StringUtils.hasLength(base)) { fileName = StringGroovyMethods.minus(fileName, new File(base).getCanonicalPath()); }//from ww w . jav a 2 s. c o m return fileName; }
From source file:com.jaxio.celerio.configuration.Configuration.java
public void setApplicationName(String applicationName) { if (StringUtils.hasLength(applicationName)) { this.applicationName = applicationName; }/* ww w . ja v a 2 s . c o m*/ }
From source file:org.zilverline.core.AbstractCollection.java
/** * Determines the URL of the collection. * <p>/*from w w w . j a va2 s .c om*/ * The URL maps the contentDir to another location. e.g. A document * 'ldap.pdf' in contentDir 'e:\collection\books\' with an URL of * 'http://search.company.com/books/' will be returned in a search result as * <code>http://search.company.com/books/ldap.pdf</code> * </p> * * @return the URL of the collection as a String, possibly null in the * exeptional case where there is no contentDir */ public final String getUrlDefault() { if (StringUtils.hasLength(url)) { if (url.endsWith("/")) { return url; } else { return url + "/"; } } else { if (contentDir != null) { return "file://" + contentDir.toURI().getPath(); } else { log.warn("Collection " + name + " does not have a contentDir."); return null; } } }