Example usage for com.liferay.portal.util PropsUtil set

List of usage examples for com.liferay.portal.util PropsUtil set

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsUtil set.

Prototype

public static void set(String key, String value) 

Source Link

Usage

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.test.util.PropsValuesReplacer.java

License:Open Source License

public PropsValuesReplacer(String name, Object value) throws Exception {
    Field propsKeysField = ReflectionUtil.getDeclaredField(PropsKeys.class, name);

    _propsKeysName = (String) propsKeysField.get(null);

    _propsKeysOldValue = PropsUtil.get(_propsKeysName);

    PropsUtil.set(_propsKeysName, String.valueOf(value));

    _propsValuesField = ReflectionUtil.getDeclaredField(PropsValues.class, name);

    _propsValuesOldValue = _propsValuesField.get(null);

    _propsValuesField.set(null, value);/*from  w  ww  .j a  va 2  s.c  om*/
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.test.util.PropsValuesReplacer.java

License:Open Source License

@Override
public void close() throws Exception {
    PropsUtil.set(_propsKeysName, _propsKeysOldValue);

    _propsValuesField.set(null, _propsValuesOldValue);
}

From source file:com.liferay.layout.type.controller.test.LayoutTypePortletImplTest.java

License:Open Source License

private static void _tearDown() {
    StringBundler sb = new StringBundler(_layoutStaticPortletsAll.length);

    for (String layoutStaticPortlet : _layoutStaticPortletsAll) {
        sb.append(layoutStaticPortlet);// w w w .jav a  2  s. co  m
    }

    PropsUtil.set(PropsKeys.LAYOUT_STATIC_PORTLETS_ALL, sb.toString());
}

From source file:org.kmworks.portal.rpc.Configuration.java

License:Open Source License

private static boolean initialize(HttpPrincipal principal, String secret, int waitForServerStartupTimeoutSec) {
    // set shared secret first!
    sharedSecret = secret;/*from ww w.  ja v  a  2s. co m*/
    PropsUtil.set(PropsKeys.TUNNELING_SERVLET_SHARED_SECRET, sharedSecret);
    // create the authetication token
    authToken = new AuthToken(principal);
    // try to retrieve associated user id
    long userId = getUserIdWaitFor(authToken, waitForServerStartupTimeoutSec);
    // setup PrincipalThreadLocal to satisfy Liferay model classes
    if (userId != 0L) {
        PrincipalThreadLocal.setName(userId);
        PrincipalThreadLocal.setPassword(principal.getPassword());
        return true;
    } else {
        return false;
    }
}

From source file:org.mimacom.maven.plugins.liferay.ServiceBuilderMojo.java

License:Apache License

protected void doExecute() throws Exception {
    File ignoreDir = new File(buildDir, "ignore");
    String serviceFileName = "META-INF/service.xml";
    File serviceFile = new File(resourcesDir, serviceFileName);

    boolean checkApi = false;
    boolean checkImpl = false;

    if (isServiceApiProject()) {
        checkApi = true;//from   w w  w  .  ja  v  a2  s  .  c o m
        setArtifactType(new File(buildDir, finalName + ".jar"), "jar");
    } else {
        checkImpl = true;
        setArtifactType(artifactWarFile(), "war");
        if (serviceFile.exists()) {
            log("found " + serviceFile.getAbsolutePath() + ", not looking for api dependency");
            checkApi = true;
        } else {
            serviceFile = findServiceFile(serviceFileName);
        }
    }

    if (!serviceFile.exists()) {
        getLog().warn(serviceFile.getAbsolutePath() + " does not exist");
        return;
    }

    getLog().info("Building from " + serviceFile.getAbsolutePath());

    PropsUtil.set("spring.configs", "META-INF/service-builder-spring.xml");
    PropsUtil.set(PropsKeys.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES, "false");

    InitUtil.initWithSpring();

    File apiDir = new File(ignoreDir, "api");
    File implDir = new File(ignoreDir, "impl");

    File metaInfIgnore = new File(implDir, "META-INF");
    File sqlDir = new File(implDir, "webapp/WEB-INF/sql");
    if (!sqlDir.exists()) {
        getLog().info("creating sql dir");
        sqlDir.mkdirs();
    }

    tools.initLog(getLog());
    tools.initLiferay();
    tools.buildService(serviceFile.getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-hbm.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-orm.xml").getAbsolutePath(),
            new File(metaInfIgnore, "portlet-model-hints.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "base-spring.xml").getAbsolutePath(), //
            null, //
            new File(metaInfIgnore, "dynamic-data-source-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "hibernate-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "infrastructure-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "shard-data-source-spring.xml").getAbsolutePath(), //
            apiDir.getAbsolutePath(), //
            implDir.getAbsolutePath(), //
            new File(implDir, "webapp/html/js/liferay/service.js").getAbsolutePath(), //
            null, //
            sqlDir.getAbsolutePath(), //
            "tables.sql", "indexes.sql", "indexes.properties", "sequences.sql", //
            autoNamespaceTables, beanLocatorUtil, propsUtil, pluginName, null);

    if (checkApi) {
        checkSources(apiDir, new File(buildDir, "generated-sources/api"));
    }
    if (checkImpl) {
        checkSources(implDir, new File(buildDir, "generated-sources/impl"));
    }

    if (!isServiceApiProject()) {
        String impl = "target/ignore/impl/";

        log("copying from service.xml to WEB-INF");
        copy(file(buildDir, "META-INF/service.xml"), todir(buildDir, finalName + "/WEB-INF"));

        log("setting build.number to " + buildNumber + " and copying service.properties from " + impl + " to "
                + outputDir);
        BufferedReader in = null;
        BufferedWriter out = null;
        try {
            in = new BufferedReader(new InputStreamReader(
                    new FileInputStream(new File(implDir, "service.properties")), "ISO-8859-1"));
            out = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(new File(outputDir, "service.properties")), "ISO-8859-1"));
            while (in.ready()) {
                String line = in.readLine();
                line = line.replaceFirst("(build\\.number\\s*=\\s*)\\d+", "$1" + buildNumber);
                out.write(line);
                out.newLine();
            }
        } finally {
            IOUtil.close(in);
            IOUtil.close(out);
        }

        log("copying from " + impl + "META-INF to " + outputDir + "/META-INF");
        copyNonExistingFiles(ALL_FILES, new File(implDir, "META-INF"), new File(outputDir, "META-INF"),
                new File(resourcesDir, "META-INF"));

        log("copying from " + impl + "webapp to " + buildDir + "/" + finalName);
        copyNonExistingFiles(ALL_FILES, new File(implDir, "webapp"), new File(buildDir, finalName),
                new File(resourcesDir, "webapp"));
    }
}

From source file:org.mimacom.maven.plugins.liferay.TwoArtifactsServiceBuilderMojo.java

License:Apache License

protected void doExecute() throws Exception {
    if (!apiSourceDir().exists()) {
        apiSourceDir().mkdirs();//from  w w  w  .  j a v a  2s  .co  m
    }
    addSourceDir(apiSourceDir());

    String serviceFileName = "META-INF/service.xml";
    File serviceFile = new File(resourcesDir, serviceFileName);

    setArtifactType(new File(buildDir, finalName + ".war"), "war");
    //        mavenHelper.attachArtifact(project, "jar", new File(buildDir, finalName + "-api.jar"));

    if (!serviceFile.exists()) {
        getLog().warn(serviceFile.getAbsolutePath() + " does not exist");
        return;
    }

    getLog().info("Building from " + serviceFile.getAbsolutePath());

    PropsUtil.set("spring.configs", "META-INF/service-builder-spring.xml");
    PropsUtil.set(PropsKeys.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES, "false");

    InitUtil.initWithSpring();

    File ignoreDir = new File(buildDir, "liferay-generated");
    File apiDir = new File(ignoreDir, "api");
    File implDir = new File(ignoreDir, "impl");

    File metaInfIgnore = new File(implDir, "META-INF");
    File sqlDir = new File(implDir, "webapp/WEB-INF/sql");
    if (!sqlDir.exists()) {
        getLog().info("creating sql dir");
        sqlDir.mkdirs();
    }

    log("Copying src/main/java to liferay-generated/impl");
    copy(fileset(dir(sourceDir)), todir(implDir), overwrite(true));

    log("Copying src/api/java to liferay-generated/api");
    copy(fileset(dir(apiSourceDir())), todir(apiDir), overwrite(true));

    tools.initLog(getLog());
    tools.initLiferay();
    tools.buildService(serviceFile.getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-hbm.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-orm.xml").getAbsolutePath(),
            new File(metaInfIgnore, "portlet-model-hints.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "portlet-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "base-spring.xml").getAbsolutePath(), //
            null, //
            new File(metaInfIgnore, "dynamic-data-source-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "hibernate-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "infrastructure-spring.xml").getAbsolutePath(), //
            new File(metaInfIgnore, "shard-data-source-spring.xml").getAbsolutePath(), //
            apiDir.getAbsolutePath(), //
            implDir.getAbsolutePath(), //
            new File(implDir, "webapp/html/js/liferay/service.js").getAbsolutePath(), //
            null, //
            sqlDir.getAbsolutePath(), //
            "tables.sql", "indexes.sql", "indexes.properties", "sequences.sql", //
            autoNamespaceTables, beanLocatorUtil, propsUtil, pluginName, null);

    log("Moving not customized apis from liferay-generated/api to generated-sources/api");
    File generatedApi = new File(buildDir, "generated-sources/api");
    makeComplementary(JAVA_FILES, apiDir, apiSourceDir(), generatedApi);
    addSourceDir(generatedApi);

    log("Moving not customized impls from liferay-generated/impl to generated-sources/impl");
    File generatedImpl = new File(buildDir, "generated-sources/impl");
    makeComplementary(JAVA_FILES, implDir, sourceDir, generatedImpl);
    addSourceDir(generatedImpl);

    log("Moving not customized modifyable impls from generated-sources/impl to src/main/java");
    move(fileset(dir(generatedImpl), includes("**/service/impl/*.java,**/model/impl/*.java"),
            excludes("**/*BaseImpl.java,**/*ModelImpl.java")), todir(sourceDir), overwrite(false));

    log("copying service.xml to WEB-INF");
    copy(file(resourcesDir, "META-INF/service.xml"), todir(buildDir, finalName + "/WEB-INF"));

    final String impl = "target/liferay-generated/impl/";
    log("setting build.number to " + buildNumber + " and copying service.properties from " + impl + " to "
            + outputDir);
    outputDir.mkdirs();
    BufferedReader in = null;
    BufferedWriter out = null;
    try {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream(new File(implDir, "service.properties")), "ISO-8859-1"));
        out = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream(new File(outputDir, "service.properties")), "ISO-8859-1"));
        while (in.ready()) {
            String line = in.readLine();
            line = line.replaceFirst("(build\\.number\\s*=\\s*)\\d+", "$1" + buildNumber);
            out.write(line);
            out.newLine();
        }
    } finally {
        IOUtil.close(in);
        IOUtil.close(out);
    }

    log("copying from " + impl + "META-INF to " + outputDir + "/META-INF");
    copyNonExistingFiles(ALL_FILES, new File(implDir, "META-INF"), new File(outputDir, "META-INF"),
            new File(resourcesDir, "META-INF"));

    log("copying from " + impl + "webapp to " + buildDir + "/" + finalName);
    copyNonExistingFiles(ALL_FILES, new File(implDir, "webapp"), new File(buildDir, finalName),
            new File(resourcesDir, "webapp"));
}