Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

In this page you can find the example usage for java.util Properties get.

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:com.agiletec.plugins.jpcrowdsourcing.aps.system.services.comment.ApiCommentInterface.java

public StringApiResponse addComment(JAXBComment jaxbComment, Properties properties)
        throws ApiException, Throwable {
    StringApiResponse response = new StringApiResponse();
    try {/*  www  . ja  va 2s. c o m*/
        UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);

        String ideaId = jaxbComment.getIdeaId();
        IIdea idea = this.getIdeaManager().getIdea(ideaId);
        if (null == idea) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
                    "Idea with code '" + ideaId + "' does not exist", Response.Status.CONFLICT);
        }
        IdeaInstance instance = this.getIdeaInstanceManager().getIdeaInstance(idea.getInstanceCode());
        if (null == instance) {
            _logger.warn("instance {} not found", idea.getInstanceCode());
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
                    "IdeaInstance with code '" + idea.getInstanceCode() + "' does not exist",
                    Response.Status.CONFLICT);
        }
        if (!isAuthOnInstance(user, instance)) {
            _logger.warn("the current user is not granted to any group required by instance {}",
                    instance.getCode());
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
                    "IdeaInstance with code '" + instance.getCode() + "' does not exist",
                    Response.Status.CONFLICT);
        }
        if (idea.getStatus() != IIdea.STATUS_APPROVED) {
            _logger.warn("the idea {} is not in statu approved ", idea.getId(), idea.getStatus());
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
                    "Idea with code '" + idea.getId() + "' does not exist", Response.Status.CONFLICT);
        }
        if (StringUtils.isBlank(jaxbComment.getCommentText())) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Comment Text is required",
                    Response.Status.CONFLICT);
        }
        IdeaComment comment = jaxbComment.getComment();
        comment.setUsername(user.getUsername());
        this.getIdeaCommentManager().addComment(comment);
        response.setResult(IResponseBuilder.SUCCESS, null);
    } catch (ApiException ae) {
        response.addErrors(ae.getErrors());
        response.setResult(IResponseBuilder.FAILURE, null);
    } catch (Throwable t) {
        _logger.error("Error adding comment", t);
        throw new ApsSystemException("Error adding comment", t);
    }
    return response;
}

From source file:com.liferay.blade.cli.InitCommand.java

private boolean isPluginsSDK70(File dir) {
    if ((dir == null) || !dir.exists() || !dir.isDirectory()) {
        return false;
    }/*w ww . jav a  2 s .c  o m*/

    File buildProperties = new File(dir, "build.properties");
    Properties properties = new Properties();

    InputStream in = null;

    try {
        in = new FileInputStream(buildProperties);

        properties.load(in);

        String sdkVersionValue = (String) properties.get("lp.version");

        if (sdkVersionValue.equals("7.0.0")) {
            return true;
        }
    } catch (Exception e) {
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
    }

    return false;
}

From source file:edu.umich.ctools.sectionsUtilityTool.Friend.java

public void setProperties() {
    if (appExtSecureProperties != null) {
        //PropertiesFile information
        friendUrl = appExtProperties.getProperty(FRIEND_URL);
        contactEmail = appExtProperties.getProperty(FRIEND_CONTACT_EMAIL);
        referrerUrl = appExtProperties.getProperty(FRIEND_REFERRER);
        friendEmailFile = appExtProperties.getProperty(FRIEND_FRIEND_EMAIL);
        requesterEmailFile = appExtProperties.getProperty(FRIEND_REQUESTER_EMAIL);
        mailHost = appExtProperties.getProperty(FRIEND_MAIL_HOST);
        subjectLine = appExtProperties.getProperty(FRIEND_SUBJECT_LINE);
        ksFileName = appExtSecureProperties.getProperty(FRIEND_KS_FILENAME);
        ksPwd = appExtSecureProperties.getProperty(FRIEND_KS_PASSWORD);

        M_log.debug("ksFileName: " + ksFileName);
        M_log.debug("ksPwd: " + ksPwd);
        M_log.debug("friendUrl: " + friendUrl);
        M_log.debug("contactEmail: " + contactEmail);
        M_log.debug("referrerUrl: " + referrerUrl);
    } else {//from  w ww. java2s.  c o m
        M_log.error(
                "Failed to load Friend application properties from sectionsToolFriend.properties for SectionsTool");
    }

    //Setting up properties for keyStore
    Properties systemProps = System.getProperties();
    String keyStoreType = (String) systemProps.get("javax.net.ssl.keyStoreType");
    String trustStoreType = (String) systemProps.get("javax.net.ssl.trustStoreType");
    if (keyStoreType != null && !KEYSTORETYPE_PKCS12.equals(keyStoreType)) // existing keyStoreType 
    {
        M_log.error(this + " setProperties: existing settings of SSL keyStoreType mismatch: " + keyStoreType);
        sslInitialized = false;
    } else if (trustStoreType != null && !TRUSTSTORETYPE_JKS.equals(trustStoreType)) // existing trustStoreType
    {
        M_log.error(this + " init: existing settings of SSL trustStoretype mismatch: " + trustStoreType);
        sslInitialized = false;
    } else {
        // key store
        systemProps.put("javax.net.ssl.keyStoreType", KEYSTORETYPE_PKCS12);
        systemProps.put("javax.net.ssl.trustStoreType", TRUSTSTORETYPE_JKS);

        if (ksFileName.isEmpty()) {
            // log error for missing keystore file path
            M_log.error(this + " init the umich.friend.keystorefile path is not defined. ");
        } else {
            systemProps.put("javax.net.ssl.keyStore", ksFileName);
        }

        if (ksPwd.isEmpty()) {
            // log error for missing keystore password
            M_log.error(this + " init the umich.friend.keystorepassword is not defined. ");
        } else {
            systemProps.put("javax.net.ssl.keyStorePassword", ksPwd);
        }

        // set system properties
        System.setProperties(systemProps);

        sslInitialized = true;
    }
}

From source file:com.goodformobile.build.mobile.RIMPackageMojoTest.java

@Test
public void testExecuteOnBasicLibrary() throws Exception {

    File projectDirectory = getRelativeFile(
            "projects/library-project-1-preverified/BlackBerry_App_Descriptor.xml").getParentFile();
    File workProjectDirectory = setupCleanCopyOfProject(projectDirectory);

    RIMPackageMojo mojo = setupMojo();/*from   w w w.  j a  v a  2  s. c o m*/

    MavenProject project = getProject(mojo);

    project.setArtifactId("library-project-1");

    MavenProjectBasicStub projectStub = (MavenProjectBasicStub) project;
    projectStub.setBaseDir(workProjectDirectory);

    setupRIMStyleProject(workProjectDirectory, project);

    setVariableValueToObject(mojo, "systemModule", true);
    setVariableValueToObject(mojo, "bundleCodsInOutputJar", true);

    mojo.execute();

    // Ensure a jad is generated.
    File targetDirectory = new File(workProjectDirectory, "target");
    File expectedJad = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "library_project_1.jad");
    assertTrue("Unable to find generated jad: " + expectedJad.getAbsolutePath(), expectedJad.exists());

    Properties result = PropertyUtils.loadProperties(expectedJad);
    assertNotNull(result);
    assertEquals("library-project-1", result.get("MIDlet-Name"));
    assertEquals("1.0.0", result.get("MIDlet-Version"));
    assertEquals("MIDP-2.0", result.get("MicroEdition-Profile"));
    assertEquals("CLDC-1.1", result.get("MicroEdition-Configuration"));
    assertEquals("BlackBerry Developer", result.get("MIDlet-Vendor"));
    assertEquals("2", result.get("RIM-Library-Flags"));
    assertEquals("library-project-1.jar", result.get("MIDlet-Jar-URL"));
    assertEquals("library_project_1.cod", result.get("RIM-COD-URL"));

    // Ensure a cod file is generated.
    File expectedCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "library_project_1.cod");
    assertTrue("Unable to find generated cod: " + expectedCod.getAbsolutePath(), expectedCod.exists());

    // Ensure a cod file is copied to target
    File expectedTargetCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "classes"
            + File.separator + "library_project_1.cod");
    assertTrue("Unable to find generated cod: " + expectedTargetCod.getAbsolutePath(),
            expectedTargetCod.exists());
}

From source file:com.goodformobile.build.mobile.RIMPackageMojoTest.java

@Test
public void testExecuteOnBasicLibraryExcludeCods() throws Exception {

    File projectDirectory = getRelativeFile(
            "projects/library-project-1-preverified/BlackBerry_App_Descriptor.xml").getParentFile();
    File workProjectDirectory = setupCleanCopyOfProject(projectDirectory);

    RIMPackageMojo mojo = setupMojo();//from w w  w .j  a  v  a  2 s.  c o m

    MavenProject project = getProject(mojo);

    project.setArtifactId("library-project-1");

    MavenProjectBasicStub projectStub = (MavenProjectBasicStub) project;
    projectStub.setBaseDir(workProjectDirectory);

    setupRIMStyleProject(workProjectDirectory, project);

    setVariableValueToObject(mojo, "systemModule", true);
    setVariableValueToObject(mojo, "bundleCodsInOutputJar", false);

    mojo.execute();

    // Ensure a jad is generated.
    File targetDirectory = new File(workProjectDirectory, "target");
    File expectedJad = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "library_project_1.jad");
    assertTrue("Unable to find generated jad: " + expectedJad.getAbsolutePath(), expectedJad.exists());

    Properties result = PropertyUtils.loadProperties(expectedJad);
    assertNotNull(result);
    assertEquals("library-project-1", result.get("MIDlet-Name"));
    assertEquals("1.0.0", result.get("MIDlet-Version"));
    assertEquals("MIDP-2.0", result.get("MicroEdition-Profile"));
    assertEquals("CLDC-1.1", result.get("MicroEdition-Configuration"));
    assertEquals("BlackBerry Developer", result.get("MIDlet-Vendor"));
    assertEquals("2", result.get("RIM-Library-Flags"));
    assertEquals("library-project-1.jar", result.get("MIDlet-Jar-URL"));
    assertEquals("library_project_1.cod", result.get("RIM-COD-URL"));

    // Ensure a cod file is generated.
    File expectedCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "library_project_1.cod");
    assertTrue("Unable to find generated cod: " + expectedCod.getAbsolutePath(), expectedCod.exists());

    // Ensure a cod file is not copied to target
    File expectedTargetCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "classes"
            + File.separator + "library_project_1.cod");
    assertFalse("Found unexpected cod in target directory: " + expectedTargetCod.getAbsolutePath(),
            expectedTargetCod.exists());

}

From source file:com.haulmont.cuba.gui.theme.ThemeConstantsRepository.java

public void loadThemeProperties(String fileName, Map<String, String> themeMap) {
    InputStream propertiesStream = null;
    try {/* w  w w  . ja va 2s. c om*/
        propertiesStream = resources.getResourceAsStream(fileName);
        if (propertiesStream == null) {
            throw new DevelopmentException("Unable to load theme constants for: '" + fileName + "'");
        }

        InputStreamReader propertiesReader = new InputStreamReader(propertiesStream, StandardCharsets.UTF_8);

        Properties properties = new Properties();
        try {
            properties.load(propertiesReader);
        } catch (IOException e) {
            throw new DevelopmentException("Unable to parse theme constants for: '" + fileName + "'");
        }

        Object includeValue = properties.get("@include");
        if (includeValue != null) {
            String[] themeIncludes = StringUtils.split(includeValue.toString(), " ,");

            for (String include : themeIncludes) {
                loadThemeProperties(include, themeMap);
            }
        }

        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            Object key = entry.getKey();
            Object value = entry.getValue();

            if (key != null && !"@include".equals(key) && value != null) {
                themeMap.put(key.toString(), value.toString());
            }
        }
    } finally {
        IOUtils.closeQuietly(propertiesStream);
    }
}

From source file:nl.iwelcome.connector.google.GoogleAppsTemplate.java

private String authenticate() {
    Properties result = RestInvoker.preparePostTo(loginUrl).using(restTemplate).expecting(Properties.class)
            .withParam("accountType", "HOSTED").withParam("Email", email).withParam("Passwd", password)
            .withParam("service", "apps").execute();
    return (String) result.get("Auth");
}

From source file:com.artnaseef.jmeter.report.ResultCodesPerSecondReport.java

protected void extractReportProperties(Properties prop) {
    this.detailOutputFile = prop.getProperty(ReportLauncher.PROPERTY_DETAIL_FILE_NAME);

    String out = prop.getProperty(ReportLauncher.PROPERTY_OUTPUT_FILENAME);
    if (out != null) {
        this.outputFile = out;
    }/*from   w w w. j a  v  a 2 s . co m*/

    Integer size;
    size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_HEIGHT);
    if (size != null) {
        this.reportHeight = size;
    }
    size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_WIDTH);
    if (size != null) {
        this.reportWidth = size;
    }

    Long slotSize = (Long) prop.get(ReportLauncher.PROPERTY_TIME_SLOT_SIZE);
    if (slotSize != null) {
        this.timeSlotSize = slotSize;
    }
}

From source file:com.fingerprintsoft.vitunit.runner.model.VitUnitTestClass.java

@SuppressWarnings("unchecked")
protected Class<? extends IDataTypeFactory> getDataTypeFactory() {

    DataSetConfiguration annotation = getActualClass().getAnnotation(DataSetConfiguration.class);

    Class<? extends IDataTypeFactory> dataTypeFactoryClass = annotation.dataTypeFactoryClass();
    String dbunitPropertiesFile = annotation.dbunitProperties();
    if (dbunitPropertiesFile != null) {
        InputStream resourceAsStream = this.getClass().getClassLoader()
                .getResourceAsStream(dbunitPropertiesFile);
        Properties properties = new Properties();
        try {//from  ww w  .j a v  a2 s.co m
            properties.load(resourceAsStream);
            String factoryClassName = (String) properties.get("dbunit.datatype.factory");
            dataTypeFactoryClass = (Class<? extends IDataTypeFactory>) this.getClass().getClassLoader()
                    .loadClass(factoryClassName);
        } catch (IOException e) {
            throw new SetupException("Could not load properties.", e);
        } catch (ClassNotFoundException e) {
            throw new SetupException("Could not load properties.", e);
        } catch (Exception e) {
            throw new SetupException("Could not load properties.", e);
        }
    }

    return dataTypeFactoryClass;

}

From source file:com.zotoh.maedr.etc.CmdApps.java

/**
 * @param appdir//from www .j  a v a 2  s.  c om
 * @param appprops
 * @param props
 * @throws Exception
 */
protected void create2(File appdir, String appprops, Properties props) throws Exception {
    boolean wdb = (Boolean) props.get("storage");
    File realm = new File(appdir, REALM);
    File cfg = new File(appdir, CFG);
    //        File w= new File(appdir, TMP);
    File db = new File(appdir, DB);
    //        File mf= (File)props.get("mf");
    String pcfg = niceFPath(cfg);
    String dfcz = Module.getPipelineModule().getDefDelegateClass();
    String s = rc2Str("com/zotoh/maedr/env/" + APPPROPS, "utf-8");
    if (!isEmpty(appprops)) {
        s = appprops;
    }
    String pwd = PwdFactory.getInstance().createRandomText(24);
    writeFile(new File(realm, KEYFILE), "B64:" + Base64.encodeBase64URLSafeString(asBytes(pwd)), "utf-8");

    String dg = fullClassNS(props, "delegate", dfcz);
    s = strstr(s, "${DELEGATE_CLASS}", dg);
    s = strstr(s, "${MANIFEST_FILE}", ""); //niceFPath(mf));
    s = strstr(s, "${WORK_DIR}", ""); //niceFPath(w));
    s = strstr(s, "${DB_URL}", niceFPath(db));
    s = strstr(s, "${DB_FLAG}", (wdb ? "" : "#"));
    s = strstr(s, "${WANT_DB}", (wdb ? "true" : "false"));

    File out = new File(pcfg + "/" + APPPROPS);
    writeFile(out, s, "utf-8");

    s = rc2Str("com/zotoh/maedr/env/" + CLOUDDATA, "utf-8");
    out = new File(pcfg + "/" + CLOUDDATA);
    writeFile(out, s, "utf-8");

    // copy test server p12 file
    byte[] bits = rc2bytes("com/zotoh/maedr/env/test.p12", getCZldr());
    out = new File(pcfg + "/test.p12");
    writeFile(out, bits);
}