Example usage for org.apache.commons.io FilenameUtils separatorsToUnix

List of usage examples for org.apache.commons.io FilenameUtils separatorsToUnix

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils separatorsToUnix.

Prototype

public static String separatorsToUnix(String path) 

Source Link

Document

Converts all separators to the Unix separator of forward slash.

Usage

From source file:org.gradle.api.tasks.wrapper.WrapperScriptGenerator.java

private void createUnixScript(String jarPath, File scriptDestinationDir, String wrapperPropertiesPath)
        throws IOException {
    String unixWrapperScriptHead = IOUtils
            .toString(Wrapper.class.getResourceAsStream("unixWrapperScriptHead.txt"));
    String unixWrapperScriptTail = IOUtils
            .toString(Wrapper.class.getResourceAsStream("unixWrapperScriptTail.txt"));

    String fillingUnix = "" + UNIX_NL + "STARTER_MAIN_CLASS=" + FULLY_QUALIFIED_WRAPPER_NAME + UNIX_NL
            + "CLASSPATH=" + CURRENT_DIR_UNIX + "/" + FilenameUtils.separatorsToUnix(jarPath) + UNIX_NL
            + "WRAPPER_PROPERTIES=" + CURRENT_DIR_UNIX + "/"
            + FilenameUtils.separatorsToUnix(wrapperPropertiesPath) + UNIX_NL;

    String unixScript = unixWrapperScriptHead + fillingUnix + unixWrapperScriptTail;
    File unixScriptFile = new File(scriptDestinationDir, "gradlew");
    FileUtils.writeStringToFile(unixScriptFile, unixScript);
    createExecutablePermission(unixScriptFile);
}

From source file:org.gradle.integtests.fixtures.executer.GradleBackedArtifactBuilder.java

public void buildJar(File jarFile) {
    rootDir.file("build.gradle").writelns("apply plugin: 'java'", "dependencies { compile gradleApi() }",
            String.format("jar.destinationDir = file('%s')",
                    FilenameUtils.separatorsToUnix(jarFile.getParent())),
            String.format("jar.archiveName = '%s'", jarFile.getName()));
    executer.inDirectory(rootDir).withTasks("clean", "jar").run();
}

From source file:org.gradle.plugins.ide.eclipse.model.internal.PathUtil.java

public static String normalizePath(String path) {
    return FilenameUtils.separatorsToUnix(path);
}

From source file:org.gradle.webservice.TestTest.java

public void method() {
    FilenameUtils.separatorsToUnix("my/unix/filename");
    ToStringBuilder.reflectionToString(new Person("name"));
    new GrowthList();
    new PersonList().doSomethingWithImpl(); // compile with api-spi, runtime with api
}

From source file:org.grycap.gpf4med.util.URLUtils.java

/**
 * Parses a URL from a String. This method supports file-system paths 
 * (e.g. /foo/bar).//from  w  w w . j a va 2s . c  o m
 * @param str String representation of an URL.
 * @return an URL.
 * @throws IOException If an input/output error occurs.
 */
public static URL parseURL(final String str) throws MalformedURLException {
    URL url = null;
    if (StringUtils.isNotBlank(str)) {
        try {
            url = new URL(str);
        } catch (MalformedURLException e) {
            url = null;
            if (!str.matches("^[a-zA-Z]+[/]*:[^\\\\]")) {
                // convert path to UNIX path
                String path = FilenameUtils.separatorsToUnix(str.trim());
                final Pattern pattern = Pattern.compile("^([a-zA-Z]:/)");
                final Matcher matcher = pattern.matcher(path);
                path = matcher.replaceFirst("/");
                // convert relative paths to absolute paths
                if (!path.startsWith("/")) {
                    path = path.startsWith("~") ? path.replaceFirst("~", System.getProperty("user.home"))
                            : FilenameUtils.concat(System.getProperty("user.dir"), path);
                }
                // normalize path
                path = FilenameUtils.normalize(path, true);
                if (StringUtils.isNotBlank(path)) {
                    url = new File(path).toURI().toURL();
                } else {
                    throw new MalformedURLException("Invalid path: " + path);
                }
            } else {
                throw e;
            }
        }
    }
    return url;
}

From source file:org.hoteia.qalingo.core.service.EmailService.java

protected MimeMessagePreparatorImpl getMimeMessagePreparator(final RequestData requestData,
        final String emailType, final Map<String, Object> model) throws Exception {
    MimeMessagePreparatorImpl mimeMessagePreparator = new MimeMessagePreparatorImpl();
    boolean emailFileMirroringActivated = engineSettingService.getEmailFileMirroringActivated(emailType);
    if (emailFileMirroringActivated) {
        mimeMessagePreparator.setMirroringActivated(emailFileMirroringActivated);

        String emailFileMirroringExtension = engineSettingService.getEmailFileMirroringExtension(emailType);
        String filePath = emailType.toLowerCase() + System.getProperty("file.separator") + UUID.randomUUID()
                + "-" + UUID.randomUUID() + emailFileMirroringExtension;
        // FILE SYSTEM FOLDER PATH
        String emailFileMirroringFolderPath = engineSettingService.getEmailFileMirroringFolderPath(emailType);
        if (!emailFileMirroringFolderPath.endsWith("/")) {
            emailFileMirroringFolderPath = emailFileMirroringFolderPath + "/";
        }//from  w  w w. j a v  a  2 s . c  o m
        String mirroringFilePath = FilenameUtils.separatorsToUnix(emailFileMirroringFolderPath + filePath);
        mimeMessagePreparator.setMirroringFilePath(mirroringFilePath);

        // MIRRORING WEB URL IN EMAIL
        String emailFileMirroringWebPath = engineSettingService.getEmailFileMirroringWebPath(emailType);
        if (!emailFileMirroringWebPath.endsWith("/")) {
            emailFileMirroringWebPath = emailFileMirroringWebPath + "/";
        }
        String webFileRelativeUrl = emailFileMirroringWebPath + filePath;
        model.put("mirroringWebPath", urlService.buildAbsoluteUrl(requestData, webFileRelativeUrl));
    }
    return mimeMessagePreparator;
}

From source file:org.hyperledger.fabric.sdk.helper.SDKUtil.java

/**
 * Compress the given directory src to target tar.gz file
 * @param src The source directory/*from   w  ww  . j a  v a2 s . com*/
 * @param target The target tar.gz file
 * @throws IOException
 */
public static void generateTarGz(String src, String target) throws IOException {
    File sourceDirectory = new File(src);
    File destinationArchive = new File(target);

    String sourcePath = sourceDirectory.getAbsolutePath();
    FileOutputStream destinationOutputStream = new FileOutputStream(destinationArchive);

    TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream(
            new GzipCompressorOutputStream(new BufferedOutputStream(destinationOutputStream)));
    archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);

    try {
        Collection<File> childrenFiles = org.apache.commons.io.FileUtils.listFiles(sourceDirectory, null, true);
        childrenFiles.remove(destinationArchive);

        ArchiveEntry archiveEntry;
        FileInputStream fileInputStream;
        for (File childFile : childrenFiles) {
            String childPath = childFile.getAbsolutePath();
            String relativePath = childPath.substring((sourcePath.length() + 1), childPath.length());

            relativePath = FilenameUtils.separatorsToUnix(relativePath);
            archiveEntry = new TarArchiveEntry(childFile, relativePath);
            fileInputStream = new FileInputStream(childFile);
            archiveOutputStream.putArchiveEntry(archiveEntry);

            try {
                IOUtils.copy(fileInputStream, archiveOutputStream);
            } finally {
                IOUtils.closeQuietly(fileInputStream);
                archiveOutputStream.closeArchiveEntry();
            }
        }
    } finally {
        IOUtils.closeQuietly(archiveOutputStream);
    }
}

From source file:org.hyperledger.fabric.sdk.helper.Utils.java

/**
 * Compress the contents of given directory using Tar and Gzip to an in-memory byte array.
 *
 * @param sourceDirectory  the source directory.
 * @param pathPrefix       a path to be prepended to every file name in the .tar.gz output, or {@code null} if no prefix is required.
 * @param chaincodeMetaInf/*  w  w  w  . j  av a  2  s. com*/
 * @return the compressed directory contents.
 * @throws IOException
 */
public static byte[] generateTarGz(File sourceDirectory, String pathPrefix, File chaincodeMetaInf)
        throws IOException {
    logger.trace(format("generateTarGz: sourceDirectory: %s, pathPrefix: %s, chaincodeMetaInf: %s",
            sourceDirectory == null ? "null" : sourceDirectory.getAbsolutePath(), pathPrefix,
            chaincodeMetaInf == null ? "null" : chaincodeMetaInf.getAbsolutePath()));

    ByteArrayOutputStream bos = new ByteArrayOutputStream(500000);

    String sourcePath = sourceDirectory.getAbsolutePath();

    TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream(
            new GzipCompressorOutputStream(bos));
    archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);

    try {
        Collection<File> childrenFiles = org.apache.commons.io.FileUtils.listFiles(sourceDirectory, null, true);

        ArchiveEntry archiveEntry;
        FileInputStream fileInputStream;
        for (File childFile : childrenFiles) {
            String childPath = childFile.getAbsolutePath();
            String relativePath = childPath.substring((sourcePath.length() + 1), childPath.length());

            if (pathPrefix != null) {
                relativePath = Utils.combinePaths(pathPrefix, relativePath);
            }

            relativePath = FilenameUtils.separatorsToUnix(relativePath);

            if (TRACE_ENABED) {
                logger.trace(format("generateTarGz: Adding '%s' entry from source '%s' to archive.",
                        relativePath, childFile.getAbsolutePath()));
            }

            archiveEntry = new TarArchiveEntry(childFile, relativePath);
            fileInputStream = new FileInputStream(childFile);
            archiveOutputStream.putArchiveEntry(archiveEntry);

            try {
                IOUtils.copy(fileInputStream, archiveOutputStream);
            } finally {
                IOUtils.closeQuietly(fileInputStream);
                archiveOutputStream.closeArchiveEntry();
            }

        }

        if (null != chaincodeMetaInf) {
            childrenFiles = org.apache.commons.io.FileUtils.listFiles(chaincodeMetaInf, null, true);

            final URI metabase = chaincodeMetaInf.toURI();

            for (File childFile : childrenFiles) {

                final String relativePath = Paths
                        .get("META-INF", metabase.relativize(childFile.toURI()).getPath()).toString();

                if (TRACE_ENABED) {
                    logger.trace(format("generateTarGz: Adding '%s' entry from source '%s' to archive.",
                            relativePath, childFile.getAbsolutePath()));
                }

                archiveEntry = new TarArchiveEntry(childFile, relativePath);
                fileInputStream = new FileInputStream(childFile);
                archiveOutputStream.putArchiveEntry(archiveEntry);

                try {
                    IOUtils.copy(fileInputStream, archiveOutputStream);
                } finally {
                    IOUtils.closeQuietly(fileInputStream);
                    archiveOutputStream.closeArchiveEntry();
                }

            }

        }
    } finally {
        IOUtils.closeQuietly(archiveOutputStream);
    }

    return bos.toByteArray();
}

From source file:org.hyperledger.fabric.sdkintegration.Util.java

/**
 * Generate a targz inputstream from source folder.
 *
 * @param src        Source location/*  w  w w . ja  va2 s  . c om*/
 * @param pathPrefix prefix to add to the all files found.
 * @return return inputstream.
 * @throws IOException
 */
public static InputStream generateTarGzInputStream(File src, String pathPrefix) throws IOException {
    File sourceDirectory = src;

    ByteArrayOutputStream bos = new ByteArrayOutputStream(500000);

    String sourcePath = sourceDirectory.getAbsolutePath();

    TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream(
            new GzipCompressorOutputStream(new BufferedOutputStream(bos)));
    archiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);

    try {
        Collection<File> childrenFiles = org.apache.commons.io.FileUtils.listFiles(sourceDirectory, null, true);

        ArchiveEntry archiveEntry;
        FileInputStream fileInputStream;
        for (File childFile : childrenFiles) {
            String childPath = childFile.getAbsolutePath();
            String relativePath = childPath.substring((sourcePath.length() + 1), childPath.length());

            if (pathPrefix != null) {
                relativePath = Utils.combinePaths(pathPrefix, relativePath);
            }

            relativePath = FilenameUtils.separatorsToUnix(relativePath);

            archiveEntry = new TarArchiveEntry(childFile, relativePath);
            fileInputStream = new FileInputStream(childFile);
            archiveOutputStream.putArchiveEntry(archiveEntry);

            try {
                IOUtils.copy(fileInputStream, archiveOutputStream);
            } finally {
                IOUtils.closeQuietly(fileInputStream);
                archiveOutputStream.closeArchiveEntry();
            }
        }
    } finally {
        IOUtils.closeQuietly(archiveOutputStream);
    }

    return new ByteArrayInputStream(bos.toByteArray());
}

From source file:org.infoglue.cms.controllers.kernel.impl.simple.InstallationController.java

public void updateServer(String appServer, String smtpServer, String smtpAuth, String smtpUser,
        String smtpPassword, String systemEmailSender, String hostName, String superUserName,
        String superUserPassword, String superUserEmail, String operatingMode, HttpServletRequest request)
        throws Exception {
    if (appServer.equals("") || hostName.equals("") || superUserName.equals("") || superUserPassword.equals("")
            || superUserEmail.equals("") || operatingMode.equals("")) {
        throw new Exception("Mandatory field(s) missing");
    }//from   www .j  av  a  2 s . co m

    String dbProvider = (String) request.getSession().getAttribute("install_dbProvider");
    //String jdbcDriverName = (String)request.getSession().getAttribute("install_jdbcDriverName");
    //String jdbcURL = (String)request.getSession().getAttribute("install_jdbcURL");
    //String igUser = (String)request.getSession().getAttribute("install_dbUser");
    //String igPassword = (String)request.getSession().getAttribute("install_dbPassword");

    if (dbProvider == null) {
        dbProvider = getJDBCEngine();
        request.getSession().setAttribute("install_dbProvider", dbProvider);
    }

    //String jdbcEngine = getJDBCEngine();

    //cms.properties
    String cmsFilePath = CastorDatabaseService.class.getResource("/cms.properties").toURI().getPath();
    if (logger.isInfoEnabled())
        logger.info("cmsFilePath:" + cmsFilePath);
    String contents = FileHelper
            .getStreamAsString(CastorDatabaseService.class.getResourceAsStream("/cms.properties"));
    if (logger.isInfoEnabled())
        logger.info("contents:" + contents);

    contents = contents.replaceAll("@configured@", "true");
    contents = contents.replaceAll("@useUpdateSecurity@", "true");
    contents = contents.replaceAll("@externalWebServerAddress@", "");
    contents = contents.replaceAll("@webServerAddress@", "http://" + hostName);
    contents = contents.replaceAll("@digitalAssetPath@", "");
    contents = contents.replaceAll("@URIEncoding@", "UTF-8");
    if (CmsPropertyHandler.getApplicationName().equalsIgnoreCase("cms")) {
        contents = contents.replaceAll("@context.root.cms@", request.getContextPath().replaceAll("/", ""));
        contents = contents.replaceAll("@context.root.working@", "infoglueDeliverWorking");
        contents = contents.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
        contents = contents.replaceAll("@context.root.live@", "infoglueDeliverLive");
    } else {
        if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("0")) {
            contents = contents.replaceAll("@context.root.cms@", "infoglueCMS");
            contents = contents.replaceAll("@context.root.working@",
                    request.getContextPath().replaceAll("/", ""));
            contents = contents.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contents = contents.replaceAll("@context.root.live@", "infoglueDeliverLive");
        } else if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("2")) {
            contents = contents.replaceAll("@context.root.cms@", "infoglueCMS");
            contents = contents.replaceAll("@context.root.working@", "infoglueDeliverWorking");
            contents = contents.replaceAll("@context.root.preview@",
                    request.getContextPath().replaceAll("/", ""));
            contents = contents.replaceAll("@context.root.live@", "infoglueDeliverLive");
        } else if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("3")) {
            contents = contents.replaceAll("@context.root.cms@", "infoglueCMS");
            contents = contents.replaceAll("@context.root.working@", "infoglueDeliverWorking");
            contents = contents.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contents = contents.replaceAll("@context.root.live@", request.getContextPath().replaceAll("/", ""));
        } else {
            contents = contents.replaceAll("@context.root.cms@", "infoglueCMS");
            contents = contents.replaceAll("@context.root.working@",
                    request.getContextPath().replaceAll("/", ""));
            contents = contents.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contents = contents.replaceAll("@context.root.live@", "infoglueDeliverLive");
        }
    }

    String applicationServerRoot = CmsPropertyHandler.getContextRootPath();
    applicationServerRoot = FilenameUtils.separatorsToUnix(applicationServerRoot);
    if (!applicationServerRoot.endsWith("\\")) {
        applicationServerRoot = applicationServerRoot.substring(0, applicationServerRoot.lastIndexOf("/"));
        applicationServerRoot = applicationServerRoot.substring(0, applicationServerRoot.lastIndexOf("/") + 1);
    }
    logger.error("applicationServerRoot:" + applicationServerRoot);

    contents = contents.replaceAll("@useShortTableNames@",
            ((dbProvider.equalsIgnoreCase("oracle") || dbProvider.equalsIgnoreCase("db2")) ? "true" : "false"));
    contents = contents.replaceAll("@database.driver.engine@", dbProvider);
    contents = contents.replaceAll("@warningEmailReceiver@", superUserEmail);
    contents = contents.replaceAll("@operatingMode.cms@", "0");
    contents = contents.replaceAll("@administratorUserName@", superUserName);
    contents = contents.replaceAll("@administratorPassword@", superUserPassword);
    contents = contents.replaceAll("@administratorEmail@", superUserEmail);

    contents = contents.replaceAll("@loginUrl@", "Login.action");
    contents = contents.replaceAll("@logoutUrl@", "");
    contents = contents.replaceAll("@invalidLoginUrl@", "Login!invalidLogin.action");
    contents = contents.replaceAll("@authenticatorClass@",
            "org.infoglue.cms.security.InfoGlueBasicAuthenticationModule");
    contents = contents.replaceAll("@authorizerClass@",
            "org.infoglue.cms.security.InfoGlueBasicAuthorizationModule");
    contents = contents.replaceAll("@serverName@", "" + hostName);
    contents = contents.replaceAll("@authConstraint@", "cmsUser");

    contents = contents.replaceAll("@databaseEngine@", dbProvider);
    contents = contents.replaceAll("@logTransactions@", "false");
    contents = contents.replaceAll("@errorUrl@", "/error.jsp");
    contents = contents.replaceAll("@tree@", "html");
    contents = contents.replaceAll("@showContentVersionFirst@", "true");
    contents = contents.replaceAll("@showComponentsFirst@", "true");
    contents = contents.replaceAll("@protectContentTypes@", "false");
    contents = contents.replaceAll("@protectWorkflows@", "false");
    contents = contents.replaceAll("@protectCategories@", "false");
    contents = contents.replaceAll("@wysiwygEditor@", "ckeditor4");
    contents = contents.replaceAll("@edition.pageSize@", "20");
    contents = contents.replaceAll("@masterServer@", "");
    contents = contents.replaceAll("@slaveServer@", "");
    contents = contents.replaceAll("@up2dateUrl@", "http://www.infoglue.org/ViewPage.action?siteNodeId=23");

    contents = contents.replaceAll("@portletBase@", Matcher.quoteReplacement(applicationServerRoot));
    contents = contents.replaceAll("@mail.smtp.host@", smtpServer);
    contents = contents.replaceAll("@mail.smtp.auth@", smtpAuth);
    contents = contents.replaceAll("@mail.smtp.user@", smtpUser);
    contents = contents.replaceAll("@mail.smtp.password@", smtpPassword);
    contents = contents.replaceAll("@mail.contentType@", "text/html");
    contents = contents.replaceAll("@systemEmailSender@", systemEmailSender);
    contents = contents.replaceAll("@niceURIEncoding@", "utf-8");
    contents = contents.replaceAll("@logDatabaseMessages@", "false");
    contents = contents.replaceAll("@enablePortal@", "true");

    if (logger.isInfoEnabled())
        logger.info("contents after:" + contents);
    if (logger.isInfoEnabled())
        logger.info("Want to write to:" + cmsFilePath);
    File targetFile = new File(cmsFilePath);
    if (logger.isInfoEnabled())
        logger.info("targetFile:" + targetFile.exists());

    FileHelper.writeToFile(targetFile, contents, false);

    CacheController.clearCache("serverNodePropertiesCache");
    CmsPropertyHandler.initializeProperties();
    CmsPropertyHandler.resetHardCachedSettings();
    InfoGlueAuthenticationFilter.initializeCMSProperties();
    //END cms.properties

    //deliver.properties
    String deliverFilePath = CastorDatabaseService.class.getResource("/deliver.properties").toURI().getPath();
    if (logger.isInfoEnabled())
        logger.info("deliverFilePath:" + deliverFilePath);
    String contentsDeliver = FileHelper
            .getStreamAsString(CastorDatabaseService.class.getResourceAsStream("/deliver.properties"));
    if (logger.isInfoEnabled())
        logger.info("contentsDeliver:" + contentsDeliver);

    contentsDeliver = contentsDeliver.replaceAll("@configured@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@useSelectivePageCacheUpdate@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@livePublicationThreadClass@",
            "org.infoglue.deliver.util.SelectiveLivePublicationThread");
    contentsDeliver = contentsDeliver.replaceAll("@compressPageCache@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@siteNodesToRecacheOnPublishing@", "");
    contentsDeliver = contentsDeliver.replaceAll("@pathsToRecacheOnPublishing@", "/");
    contentsDeliver = contentsDeliver.replaceAll("@recachePublishingMethod@", "");
    contentsDeliver = contentsDeliver.replaceAll("@recacheUrl@", "");
    contentsDeliver = contentsDeliver.replaceAll("@useUpdateSecurity@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@forceImportTagFileCaching@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@operatingMode.deliver@", operatingMode);

    if (CmsPropertyHandler.getApplicationName().equalsIgnoreCase("cms")) {
        contentsDeliver = contentsDeliver.replaceAll("@context.root.cms@",
                request.getContextPath().replaceAll("/", ""));
        contentsDeliver = contentsDeliver.replaceAll("@context.root.working@", "infoglueDeliverWorking");
        contentsDeliver = contentsDeliver.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
        contentsDeliver = contentsDeliver.replaceAll("@context.root.live@", "infoglueDeliverLive");
    } else {
        if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("0")) {
            contentsDeliver = contentsDeliver.replaceAll("@context.root.cms@", "infoglueCMS");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.working@",
                    request.getContextPath().replaceAll("/", ""));
            contentsDeliver = contentsDeliver.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.live@", "infoglueDeliverLive");
        } else if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("2")) {
            contentsDeliver = contentsDeliver.replaceAll("@context.root.cms@", "infoglueCMS");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.working@", "infoglueDeliverWorking");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.preview@",
                    request.getContextPath().replaceAll("/", ""));
            contentsDeliver = contentsDeliver.replaceAll("@context.root.live@", "infoglueDeliverLive");
        } else if (CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("3")) {
            contentsDeliver = contentsDeliver.replaceAll("@context.root.cms@", "infoglueCMS");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.working@", "infoglueDeliverWorking");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.live@",
                    request.getContextPath().replaceAll("/", ""));
        } else {
            contentsDeliver = contentsDeliver.replaceAll("@context.root.cms@", "infoglueCMS");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.working@",
                    request.getContextPath().replaceAll("/", ""));
            contentsDeliver = contentsDeliver.replaceAll("@context.root.preview@", "infoglueDeliverPreview");
            contentsDeliver = contentsDeliver.replaceAll("@context.root.live@", "infoglueDeliverLive");
        }
    }

    contentsDeliver = contentsDeliver.replaceAll("@URIEncoding@", "UTF-8");
    contentsDeliver = contentsDeliver.replaceAll("@externalWebServerAddress@", "");
    contentsDeliver = contentsDeliver.replaceAll("@webServerAddress@", "http://" + hostName);
    contentsDeliver = contentsDeliver.replaceAll("@digitalAssetPath@", "");

    contentsDeliver = contentsDeliver.replaceAll("@useShortTableNames@",
            ((dbProvider.equalsIgnoreCase("oracle") || dbProvider.equalsIgnoreCase("db2")) ? "true" : "false"));
    contentsDeliver = contentsDeliver.replaceAll("@database.driver.engine@", dbProvider);
    contentsDeliver = contentsDeliver.replaceAll("@warningEmailReceiver@", superUserEmail);
    contentsDeliver = contentsDeliver.replaceAll("@operatingMode.cms@", "0");
    contentsDeliver = contentsDeliver.replaceAll("@administratorUserName@", superUserName);
    contentsDeliver = contentsDeliver.replaceAll("@administratorPassword@", superUserPassword);
    contentsDeliver = contentsDeliver.replaceAll("@administratorEmail@", superUserEmail);

    contentsDeliver = contentsDeliver.replaceAll("@loginUrl@", "Login.action");
    contentsDeliver = contentsDeliver.replaceAll("@logoutUrl@", "");
    contentsDeliver = contentsDeliver.replaceAll("@invalidLoginUrl@", "Login!invalidLogin.action");
    contentsDeliver = contentsDeliver.replaceAll("@authenticatorClass@",
            "org.infoglue.cms.security.InfoGlueBasicAuthenticationModule");
    contentsDeliver = contentsDeliver.replaceAll("@authorizerClass@",
            "org.infoglue.cms.security.InfoGlueBasicAuthorizationModule");
    contentsDeliver = contentsDeliver.replaceAll("@serverName@", "" + hostName);
    contentsDeliver = contentsDeliver.replaceAll("@authConstraint@", "cmsUser");

    contentsDeliver = contentsDeliver.replaceAll("@databaseEngine@", dbProvider);
    contentsDeliver = contentsDeliver.replaceAll("@logTransactions@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@errorUrl@", "/error.jsp");
    contentsDeliver = contentsDeliver.replaceAll("@tree@", "html");
    contentsDeliver = contentsDeliver.replaceAll("@showContentVersionFirst@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@showComponentsFirst@", "true");
    contentsDeliver = contentsDeliver.replaceAll("@protectContentTypes@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@protectWorkflows@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@protectCategories@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@wysiwygEditor@", "FCKEditor");
    contentsDeliver = contentsDeliver.replaceAll("@edition.pageSize@", "20");
    contentsDeliver = contentsDeliver.replaceAll("@masterServer@", "");
    contentsDeliver = contentsDeliver.replaceAll("@slaveServer@", "");
    contentsDeliver = contentsDeliver.replaceAll("@up2dateUrl@",
            "http://www.infoglue.org/ViewPage.action?siteNodeId=23");
    contentsDeliver = contentsDeliver.replaceAll("@portletBase@",
            Matcher.quoteReplacement(applicationServerRoot));
    contentsDeliver = contentsDeliver.replaceAll("@mail.smtp.host@", smtpServer);
    contentsDeliver = contentsDeliver.replaceAll("@mail.smtp.auth@", smtpAuth);
    contentsDeliver = contentsDeliver.replaceAll("@mail.smtp.user@", smtpUser);
    contentsDeliver = contentsDeliver.replaceAll("@mail.smtp.password@", smtpPassword);
    contentsDeliver = contentsDeliver.replaceAll("@mail.contentType@", "text/html");
    contentsDeliver = contentsDeliver.replaceAll("@systemEmailSender@", systemEmailSender);
    contentsDeliver = contentsDeliver.replaceAll("@niceURIEncoding@", "utf-8");
    contentsDeliver = contentsDeliver.replaceAll("@logDatabaseMessages@", "false");
    contentsDeliver = contentsDeliver.replaceAll("@enablePortal@", "true");

    if (logger.isInfoEnabled())
        logger.info("contentsDeliver after:" + contentsDeliver);
    if (logger.isInfoEnabled())
        logger.info("Want to write to:" + deliverFilePath);
    File targetFileDeliver = new File(deliverFilePath);
    if (logger.isInfoEnabled())
        logger.info("targetFileDeliver:" + targetFileDeliver.exists());

    FileHelper.writeToFile(targetFileDeliver, contentsDeliver, false);

    CacheController.clearCache("serverNodePropertiesCache");
    CmsPropertyHandler.initializeProperties();
    CmsPropertyHandler.resetHardCachedSettings();
    InfoGlueAuthenticationFilter.initializeProperties();
    if (logger.isInfoEnabled())
        logger.info("Operatingmode:" + CmsPropertyHandler.getOperatingMode());
    if (logger.isInfoEnabled())
        logger.info("adminEmail:" + CmsPropertyHandler.getAdministratorEmail());
    //END deliver.properties

}