List of usage examples for org.apache.commons.io FilenameUtils normalize
public static String normalize(String filename, boolean unixSeparator)
From source file:aurelienribon.gdxsetupui.Helper.java
public static String getCorePrjPath(BaseProjectConfiguration cfg) { return FilenameUtils.normalize(cfg.destinationPath + "/" + cfg.projectName + cfg.suffixCommon + "/", true); }
From source file:aurelienribon.gdxsetupui.Helper.java
public static String getDesktopPrjPath(BaseProjectConfiguration cfg) { return FilenameUtils.normalize(cfg.destinationPath + "/" + cfg.projectName + cfg.suffixDesktop + "/", true); }
From source file:jodtemplate.pptx.io.xml.SlideXmlRelsWriter.java
@Override public void write(final Resources resources, final Slide slide, final XMLOutputFactory xmlOutputFactory) throws XMLStreamException, IOException { final String slideXmlPath = FilenameUtils .normalize(slide.getPresentation().getFullPath() + slide.getRelationship().getTarget(), true); final String slideXmlRelsPath = Utils.getRelsPathNoPrefixSeparator(slideXmlPath); final Resource slideXmlRelsRes = resources.getResource(slideXmlRelsPath); try (final OutputStream os = slideXmlRelsRes.getOutputStream()) { os.write(//from w ww . java 2 s .c o m "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n".getBytes(CharEncoding.UTF_8)); final XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(os); writer.writeStartElement(OOXMLDocument.RELATIONSHIPS_ELEMENT); writer.writeNamespace("", OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE); for (Relationship rel : slide.getOtherRelationships()) { writer.writeEmptyElement(OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE, OOXMLDocument.RELATIONSHIP_ELEMENT); writer.writeAttribute(OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE, OOXMLDocument.ID_ATTRIBUTE, rel.getId()); writer.writeAttribute(OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE, OOXMLDocument.TYPE_ATTRIBUTE, rel.getType()); writer.writeAttribute(OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE, OOXMLDocument.TARGET_ATTRIBUTE, rel.getTarget()); if (StringUtils.isNotBlank(rel.getTargetMode())) { writer.writeAttribute(OOXMLDocument.RELATIONSHIPS_RELS_NAMESPACE, OOXMLDocument.TARGET_MODE_ATTRIBUTE, rel.getTargetMode()); } writer.flush(); } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); writer.close(); } }
From source file:aurelienribon.gdxsetupui.Helper.java
public static String getAndroidPrjPath(BaseProjectConfiguration cfg) { return FilenameUtils.normalize(cfg.destinationPath + "/" + cfg.projectName + cfg.suffixAndroid + "/", true); }
From source file:aurelienribon.gdxsetupui.Helper.java
public static String getHtmlPrjPath(BaseProjectConfiguration cfg) { return FilenameUtils.normalize(cfg.destinationPath + "/" + cfg.projectName + cfg.suffixHtml + "/", true); }
From source file:aurelienribon.gdxsetupui.Helper.java
public static String getIosPrjPath(ProjectUpdateConfiguration cfg) { return FilenameUtils.normalize(cfg.destinationPath + "/" + cfg.projectName + cfg.suffixIos + "/", true); }
From source file:com.astamuse.asta4d.web.builtin.AbstractGenericPathHandler.java
public String convertPath(UrlMappingRule currentRule) { WebApplicationContext context = Context.getCurrentThreadContext(); String uri = context.getAccessURI(); String targetPath = genericMapResult.get(uri); if (targetPath != null) { if (targetPath.equals(NullHolder)) { return null; } else {/*from ww w.ja va 2s. com*/ return targetPath; } } else { String basePath = context.getData(WebApplicationContext.SCOPE_PATHVAR, VAR_BASEPATH); if (basePath == null) { basePath = _basePath; } if (basePath == null) {// default from web context root targetPath = uri; } else { basePath = FilenameUtils.normalize(basePath, true); String src = currentRule.getSourcePath(); // convert for /**/* String mask = "/**/*"; int idx = src.indexOf(mask); if (idx >= 0) { String parentPath = src.substring(0, idx); String childPath = uri.substring(parentPath.length()); if (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } if (!childPath.startsWith("/")) { childPath = "/" + childPath; } targetPath = basePath + childPath; } else {// be a one 2 one mapping targetPath = basePath; } } if (fileNameSecurityCheck(targetPath)) { genericMapResult.put(uri, targetPath); return targetPath; } else { genericMapResult.put(uri, NullHolder); return null; } } }
From source file:biz.gabrys.lesscss.extended.compiler.source.LocalSource.java
static boolean isAbsolutePath(final String path, final boolean windowsOperatingSystem) { if (path != null && path.indexOf('\0') > -1) { return false; }//w w w.j av a 2 s . c om final String normalizedPath = FilenameUtils.normalize(path, true); if (StringUtils.isEmpty(normalizedPath)) { return false; } final char separator = '/'; final char firstChar = normalizedPath.charAt(0); if (!windowsOperatingSystem) { return firstChar == separator; } if (!Character.isLetter(firstChar)) { return false; } final int colonIndex = normalizedPath.indexOf(':'); return colonIndex == 1 && normalizedPath.length() > 2 && normalizedPath.charAt(2) == separator; }
From source file:jodtemplate.pptx.PPTXDocumentProcessor.java
@Override public void process(final Map<String, Object> context, final Resources resources) throws JODTemplateException { final ExpressionHandler expressionHandler = configuration.getExpressionHandler(); try {// w ww. ja va 2 s. c om final Presentation presentation = pptxReader.read(resources); for (final Slide slide : presentation.getSlides()) { final String slideXmlPath = FilenameUtils .normalize(presentation.getFullPath() + slide.getRelationship().getTarget(), true); final Resource slideRes = resources.getResource(Utils.removePrefixSeparator(slideXmlPath)); Document dom; try (final InputStream is = slideRes.getInputStream()) { dom = jdomHelper.createJDOMDocument(is); } for (final DomProcessor preprocessor : configuration.getPreprocessors()) { dom = preprocessor.process(context, dom, slide, resources, configuration); } final String rawContents = jdomHelper.getRawContents(dom); final Parser parser = configuration.getParserFactory().createParser(); final List<String> parsedParts = parser.parse(rawContents); final StringBuilder translatedContents = new StringBuilder(); for (final String parsedPart : parsedParts) { if (expressionHandler.isExpression(parsedPart)) { translatedContents.append(expressionHandler.translateExpression(parsedPart)); } else { translatedContents.append(parsedPart); } } final Writer writer = new StringWriter(); expressionHandler.getEngine().process(slide.getRelationship().getId(), translatedContents.toString(), context, writer); final String filledContents = writer.toString(); dom = jdomHelper.createJDOMDocument(filledContents); for (final DomProcessor postprocessor : configuration.getPostprocessors()) { dom = postprocessor.process(context, dom, slide, resources, configuration); } try (final OutputStream os = slideRes.getOutputStream()) { jdomHelper.write(dom, os); } } pptxWriter.write(resources, presentation); } catch (IOException | XMLStreamException | JDOMException e) { throw new JODTemplateException("Template processing error", e); } }
From source file:jodtemplate.pptx.io.PPTXReaderImpl.java
@Override public Presentation read(final Resources resources) throws IOException, XMLStreamException { final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); ContentTypes contentTypes = new ContentTypes(); contentTypes = contentTypesReader.read("/[Content_Types].xml", resources, xmlInputFactory, contentTypes); final String presentationXmlPath = contentTypes.getOverridesByType(ContentTypes.PRESENTATION_TYPE).get(0) .getPartName();/*from w w w. jav a2 s. c o m*/ Presentation presentation = new Presentation(presentationXmlPath); presentation = presentationXmlRelsReader.read(presentation.getXmlRelsPath(), resources, xmlInputFactory, presentation); for (Slide slide : presentation.getSlides()) { final String slideXmlPath = FilenameUtils .normalize(presentation.getFullPath() + slide.getRelationship().getTarget(), true); final String slideXmlRelsPath = Utils.getRelsPath(slideXmlPath); slideXmlRelsReader.read(slideXmlRelsPath, resources, xmlInputFactory, slide); } imageReader.read(resources, presentation); return presentation; }