@PostConstruct void init() throws SldException { if (getDirectory() != null) { try { if (getDirectory().getFile().exists()) { if (getDirectory().getFile().isDirectory()) { File[] sldFiles = getDirectory() .getFile() .listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".sld") || name.endsWith(".xml"); } }); for (File file : sldFiles) { RawSld raw = new RawSld(); raw.setXml(FileUtils.readFileToString(file, FILE_ENCODING)); String fileName = StringUtils.stripFilenameExtension(file.getName()); StyledLayerDescriptorInfo tmp = parseXml(fileName, raw.getXml()); raw.setName(fileName); raw.setTitle(tmp.getTitle()); raw.setVersion(tmp.getVersion()); log.info("added sld '{}' to service", fileName); allSlds.put(raw.getName(), raw); } } } } catch (Exception e) { // NOSONAR log.warn("Error while initilizing SLD service.", e); } } }
public String getPageTitle() { if (StringUtils.isEmpty(this.pathToPage)) return ""; this.pageTitle = StringUtils.getFilename(this.pathToPage); this.pageTitle = StringUtils.stripFilenameExtension(this.pageTitle); this.pageTitle = StringUtils.replace(this.pageTitle, "_", " "); this.pageTitle = StringUtils.capitalize(this.pageTitle); this.pageTitle = StringUtils.trimWhitespace(this.pageTitle); return this.pageTitle; }
@ModelAttribute("jobName") public String getJobName(HttpServletRequest request) { String path = request.getPathInfo(); if (path == null) { path = request.getServletPath(); } int index = path.lastIndexOf("jobs/") + 5; if (index >= 0) { path = path.substring(index); } if (!path.contains(".")) { return path; } for (String extension : extensions) { if (path.endsWith(extension)) { path = StringUtils.stripFilenameExtension(path); // Only remove one extension so a job can be called job.html and // still be addressed break; } } return path; }
/** * 지정한 경로에서 파일의 확장자를 제외한 경로를 반환한다. 예) "mypath/myfile.txt" -> "mypath/myfile". * * @param path 파일 경로(<tt>null</tt>이 될 수도 있음) * @return 확장자가 삭제된 파일의 경우 또는 파일이 없다면 <tt>null</tt> */ public static String stripFilenameExtension(String path) { return org.springframework.util.StringUtils.stripFilenameExtension(path); }