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.splicemachine.db.impl.sql.compile.TableElementList.java

/**
 * Checks if the index should use a larger page size.
 *
 * If the columns in the index are large, and if the user hasn't already
 * specified a page size to use, then we may need to default to the
 * large page size in order to get an index with sufficiently large pages.
 * For example, this DDL should use a larger page size for the index
 * that backs the PRIMARY KEY constraint:
 *
 * create table t (x varchar(1000) primary key)
 *
 * @param cdn Constraint node/*  w  w w  .ja v a 2  s.  c  o m*/
 *
 * @return properties to use for creating the index
 */
private Properties checkIndexPageSizeProperty(ConstraintDefinitionNode cdn) throws StandardException {
    Properties result = cdn.getProperties();
    if (result == null)
        result = new Properties();
    if (result.get(Property.PAGE_SIZE_PARAMETER) != null
            || PropertyUtil.getServiceProperty(getLanguageConnectionContext().getTransactionCompile(),
                    Property.PAGE_SIZE_PARAMETER) != null) {
        // do not override the user's choice of page size, whether it
        // is set for the whole database or just set on this statement.
        return result;
    }
    ResultColumnList rcl = cdn.getColumnList();
    int approxLength = 0;
    for (int index = 0; index < rcl.size(); index++) {
        String colName = ((ResultColumn) rcl.elementAt(index)).getName();
        DataTypeDescriptor dtd;
        if (td == null)
            dtd = getColumnDataTypeDescriptor(colName);
        else
            dtd = getColumnDataTypeDescriptor(colName, td);
        // There may be no DTD if the column does not exist. That syntax
        // error is not caught til later in processing, so here we just
        // skip the length checking if the column doesn't exist.
        if (dtd != null)
            approxLength += dtd.getTypeId().getApproximateLengthInBytes(dtd);
    }
    if (approxLength > Property.IDX_PAGE_SIZE_BUMP_THRESHOLD) {
        result.put(Property.PAGE_SIZE_PARAMETER, Property.PAGE_SIZE_DEFAULT_LONG);
    }
    return result;
}

From source file:com.sikulix.core.SX.java

public static void dumpSysProps(String filter) {
    filter = filter == null ? "" : filter;
    p("*** system properties dump " + filter);
    Properties sysProps = System.getProperties();
    ArrayList<String> keysProp = new ArrayList<String>();
    Integer nL = 0;/*from www.j av a  2  s .c o m*/
    String entry;
    for (Object e : sysProps.keySet()) {
        entry = (String) e;
        if (entry.length() > nL) {
            nL = entry.length();
        }
        if (filter.isEmpty() || !filter.isEmpty() && entry.contains(filter)) {
            keysProp.add(entry);
        }
    }
    Collections.sort(keysProp);
    String form = "%-" + nL.toString() + "s = %s";
    for (Object e : keysProp) {
        p(form, e, sysProps.get(e));
    }
    p("*** system properties dump end" + filter);
}

From source file:es.ehu.si.ixa.qwn.ppv.CLI.java

public final void compileGraph() throws IOException {
    String kb = parsedArguments.getString("kb");
    String ukb = parsedArguments.getString("ukbPath");

    // normal case: single graph is created
    if (!kb.equals("all")) {
        ukb_compile(ukb, kb);//from www .jav a2s  . c  om
        System.out.println("new graph generated: " + kb + ".bin");
    }
    // compile all graphs in the distribution
    else {
        System.out.println("Default behavior: all the graphs in the qwn-ppv distribution will be compiled");
        Properties AvailableGraphs = new Properties();
        try {
            AvailableGraphs
                    .load(Thread.currentThread().getContextClassLoader().getResourceAsStream("graphs.txt"));
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

        for (String key : AvailableGraphs.stringPropertyNames()) {
            String jarlocation = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
            String location = jarlocation.substring(0, jarlocation.lastIndexOf("/"));
            String destKBPath = location + File.separator + "graphs" + File.separator
                    + (String) AvailableGraphs.get(key);

            try {
                GZIPInputStream kbExtract = new GZIPInputStream(this.getClass().getClassLoader()
                        .getResourceAsStream("graphs/" + (String) AvailableGraphs.get(key) + ".txt.gz"));
                File KBPath = new File(location + File.separator + "graphs");
                KBPath.mkdirs();
                OutputStream kbDestination = new FileOutputStream(destKBPath + ".txt");
                IOUtils.copy(kbExtract, kbDestination);
                kbExtract.close();
                kbDestination.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            ukb_compile(ukb, destKBPath + ".txt");
        }
    }
}

From source file:com.mirth.connect.server.controllers.DefaultConfigurationController.java

@Override
public void setUpdateSettings(UpdateSettings settings) throws ControllerException {
    Properties properties = settings.getProperties();
    for (Object name : properties.keySet()) {
        saveProperty(PROPERTIES_CORE, (String) name, (String) properties.get(name));
    }/*from   ww  w .  ja  v a  2  s. c o  m*/
}

From source file:com.mirth.connect.server.controllers.DefaultConfigurationController.java

@Override
public void setServerSettings(ServerSettings settings) throws ControllerException {
    String serverName = settings.getServerName();
    if (serverName != null) {
        saveProperty(PROPERTIES_CORE + "." + serverId, "server.name", serverName);
        this.serverName = serverName;
    }/*w  w  w .  ja va  2  s.  c o  m*/

    Properties properties = settings.getProperties();
    for (Object name : properties.keySet()) {
        saveProperty(PROPERTIES_CORE, (String) name, (String) properties.get(name));
    }
}

From source file:com.yifanlu.PSXperiaTool.Interface.GUI.java

private void setFieldsFromProperties(Properties settings) {
    nameInput.setText(settings.getProperty("KEY_DISPLAY_NAME"));
    titleIdInput.setText(settings.getProperty("KEY_TITLE_ID"));
    developerInput.setText(settings.getProperty("KEY_DEVELOPER"));
    publisherInput.setText(settings.getProperty("KEY_PUBLISHER"));
    parentalRatingInput.setText(settings.getProperty("KEY_PARENTAL_RATING"));
    storeTypeInput.setText(settings.getProperty("KEY_STORE_TYPE"));
    descriptionTextInput.setText(settings.getProperty("KEY_DESCRIPTION"));
    analogModeCheckbox.setSelected(settings.getProperty("KEY_ANALOG_MODE").equals("YES") ? true : false);
    mIconImage = (File) settings.get("IconFile");
}

From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java

private boolean isOrOperator(Properties ldapfilters, Properties searchCriteria) {
    if (ldapfilters.size() > 1) {
        if (searchCriteria.containsKey(JahiaUserManagerService.MULTI_CRITERIA_SEARCH_OPERATION)) {
            if (((String) searchCriteria.get(JahiaUserManagerService.MULTI_CRITERIA_SEARCH_OPERATION)).trim()
                    .toLowerCase().equals("and")) {
                return false;
            }/*from  w  w w.ja  v a2  s  .  c  om*/
        }
    }
    return true;
}

From source file:com.mnxfst.testing.client.TSClient.java

/**
 * Executes the referenced test plan for all given host names. The result contains a mapping from a host name to the returned result identifier
 * of that ptest-server instance /* w ww .j a  v  a 2  s  .com*/
 * @param hostNames
 * @param port
 * @param threads
 * @param recurrences
 * @param recurrenceType
 * @param testplan
 * @param additionalParameters
 * @param urlEncoding
 * @return
 * @throws TSClientConfigurationException
 * @throws TSClientExecutionException
 */
protected Map<String, String> executeTestPlan(String[] hostNames, int port, long threads, long recurrences,
        TSPlanRecurrenceType recurrenceType, byte[] testplan, Properties additionalParameters,
        String urlEncoding) throws TSClientConfigurationException, TSClientExecutionException {

    // the ptest-server understands http get, thus we use it TODO refactor to post and send testplan as well and do not reference it anymore!
    StringBuffer buffer = new StringBuffer("/?");
    buffer.append(REQUEST_PARAMETER_EXECUTE).append("=1");
    buffer.append("&").append(REQUEST_PARAMETER_RECURRENCES).append("=").append(recurrences);
    buffer.append("&").append(REQUEST_PARAMETER_RECURRENCE_TYPE).append("=").append(recurrenceType.toString());
    buffer.append("&").append(REQUEST_PARAMETER_THREADS).append("=").append(threads);

    try {
        if (additionalParameters != null && !additionalParameters.isEmpty()) {
            for (Object key : additionalParameters.keySet()) {
                String value = (String) additionalParameters.get(key);
                buffer.append("&").append(key).append("=").append(URLEncoder.encode(value, urlEncoding));
            }
        }
    } catch (UnsupportedEncodingException e) {
        throw new TSClientConfigurationException(
                "Unsupported encoding type: " + urlEncoding + ". Error: " + e.getMessage());
    }

    StringBuffer hn = new StringBuffer();
    for (int i = 0; i < hostNames.length; i++) {
        hn.append(hostNames[i]);
        if (i < hostNames.length - 1)
            hn.append(", ");
    }

    System.out.println("Execute testplan:");
    System.out.println("\thostNames: " + hn.toString());
    System.out.println("\tport: " + port);
    System.out.println("\tthreads: " + threads);
    System.out.println("\trecurrences: " + recurrences);
    System.out.println("\trecurrenceType: " + recurrenceType);
    System.out.println("\turl enc: " + urlEncoding);
    System.out.println("\n\turi: " + buffer.toString());

    TSClientPlanExecCallable[] testplanCallables = new TSClientPlanExecCallable[hostNames.length];
    for (int i = 0; i < hostNames.length; i++) {
        testplanCallables[i] = new TSClientPlanExecCallable(hostNames[i], port, buffer.toString(), testplan);
    }

    ExecutorService executorService = Executors.newFixedThreadPool(hostNames.length);
    List<Future<NameValuePair>> executionResults = new ArrayList<Future<NameValuePair>>();
    try {
        executionResults = executorService.invokeAll(Arrays.asList(testplanCallables));
    } catch (InterruptedException e) {
        System.out.println("Test execution interrupted: " + e.getMessage());
    }

    // collect results from callables
    Map<String, String> result = new HashMap<String, String>();
    for (Future<NameValuePair> r : executionResults) {
        try {
            NameValuePair nvp = r.get();
            result.put(nvp.getName(), nvp.getValue());
        } catch (InterruptedException e) {
            System.out.println("Interrupted while waiting for results. Error: " + e.getMessage());
        } catch (ExecutionException e) {
            System.out.println("Interrupted while waiting for results. Error: " + e.getMessage());
        }
    }

    return result;
}

From source file:it.geosolutions.geoserver.jms.impl.handlers.catalog.JMSCatalogRemoveEventHandler.java

private static void remove(final Catalog catalog, CatalogInfo info, Properties options)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {

    if (info instanceof LayerGroupInfo) {

        final LayerGroupInfo deserObject = CatalogUtils.localizeLayerGroup((LayerGroupInfo) info, catalog);
        catalog.remove(deserObject);/*from w ww. j av a 2 s  .c o m*/
        // catalog.save(CatalogUtils.getProxy(deserObject));
        // info=CatalogUtils.localizeLayerGroup((LayerGroupInfo) info,
        // catalog);

    } else if (info instanceof LayerInfo) {

        final LayerInfo layer = CatalogUtils.localizeLayer((LayerInfo) info, catalog);
        catalog.remove(layer);
        // catalog.save(CatalogUtils.getProxy(layer));
        // info=CatalogUtils.localizeLayer((LayerInfo) info, catalog);

    } else if (info instanceof MapInfo) {

        final MapInfo localObject = CatalogUtils.localizeMapInfo((MapInfo) info, catalog);
        catalog.remove(localObject);
        // catalog.save(CatalogUtils.getProxy(localObject));
        // info= CatalogUtils.localizeMapInfo((MapInfo) info,catalog);

    } else if (info instanceof NamespaceInfo) {

        final NamespaceInfo namespace = CatalogUtils.localizeNamespace((NamespaceInfo) info, catalog);
        catalog.remove(namespace);
        // catalog.save(CatalogUtils.getProxy(namespace));
        // info =CatalogUtils.localizeNamespace((NamespaceInfo) info,
        // catalog);
    } else if (info instanceof StoreInfo) {

        StoreInfo store = CatalogUtils.localizeStore((StoreInfo) info, catalog);
        catalog.remove(store);
        // catalog.save(CatalogUtils.getProxy(store));

        // info=CatalogUtils.localizeStore((StoreInfo)info,catalog);
    } else if (info instanceof ResourceInfo) {

        final ResourceInfo resource = CatalogUtils.localizeResource((ResourceInfo) info, catalog);
        catalog.remove(resource);
        // catalog.save(CatalogUtils.getProxy(resource));
        // info =CatalogUtils.localizeResource((ResourceInfo)info,catalog);
    } else if (info instanceof StyleInfo) {

        final StyleInfo style = CatalogUtils.localizeStyle((StyleInfo) info, catalog);

        catalog.remove(style);

        // check options
        final String purge = (String) options.get("purge");
        if (purge != null && Boolean.parseBoolean(purge)) {
            try {
                catalog.getResourcePool().deleteStyle(style, true);
            } catch (IOException e) {
                if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) {
                    LOGGER.severe(e.getLocalizedMessage());
                }
            }
        }

        // catalog.detach(CatalogUtils.getProxy(deserializedObject));
        // info = CatalogUtils.localizeStyle((StyleInfo) info, catalog);

    } else if (info instanceof WorkspaceInfo) {

        final WorkspaceInfo workspace = CatalogUtils.localizeWorkspace((WorkspaceInfo) info, catalog);
        catalog.remove(workspace);
        // catalog.detach(workspace);
        // info = CatalogUtils.localizeWorkspace((WorkspaceInfo) info,
        // catalog);
    } else if (info instanceof CatalogInfo) {
        // TODO may we don't want to send this empty message!
        // TODO check the producer
        // DO NOTHING
        if (LOGGER.isLoggable(java.util.logging.Level.WARNING)) {
            LOGGER.warning("info - ID: " + info.getId() + " toString: " + info.toString());
        }
    } else {
        throw new IllegalArgumentException("Bad incoming object: " + info.toString());
    }
}

From source file:org.pentaho.support.cmd.CommandLineUtility.java

/**
 * loads the supportutil.xml file and creates instance of selected retriever
 * and executes/*from   ww  w.ja  va2  s. co  m*/
 * 
 * @param args
 * @param server
 */
private static void executeService(String[] args, String server) {

    final Properties prop = loadSupportProperty();

    // if installation is manual and server is bi-server read web.xml
    if (getInstallationType() == 3 && getServer() == 1) {
        if (prop.getProperty(CMDConstant.BI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_12);
            System.exit(0);
        } else {

            WEB_XML = new StringBuilder();
            WEB_XML.append(prop.getProperty(CMDConstant.BI_TOM_PATH)).append(File.separator)
                    .append(CMDConstant.WEB_APP).append(File.separator).append(CMDConstant.PENTAHO)
                    .append(File.separator).append(CMDConstant.WEB_INF).append(File.separator)
                    .append(CMDConstant.WEB_XML);

            PENTAHO_SOLU_PATH = getSolutionPath(server, WEB_XML.toString());
            prop.put(CMDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
            prop.put(CMDConstant.BI_PATH, PENTAHO_SOLU_PATH);
        }

    } else if (getInstallationType() == 3 && getServer() == 2) {
        // if installation is manual and server is di-server read web.xml
        if (prop.getProperty(CMDConstant.DI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_22);
            System.exit(0);
        } else {

            WEB_XML = new StringBuilder();
            WEB_XML.append(prop.getProperty(CMDConstant.DI_TOM_PATH)).append(File.separator)
                    .append(CMDConstant.WEB_APP).append(File.separator).append(CMDConstant.PENTAHO_DI)
                    .append(File.separator).append(CMDConstant.WEB_INF).append(File.separator)
                    .append(CMDConstant.WEB_XML);

            PENTAHO_SOLU_PATH = getSolutionPath(server, WEB_XML.toString());
            prop.put(CMDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
            prop.put(CMDConstant.BI_PATH, PENTAHO_SOLU_PATH);
        }
    }

    if (getServer() == 1) {

        if (prop.get(CMDConstant.BI_PATH) == null) {

            System.out.println(CMDConstant.ERROR_1);
            System.exit(0);
        }
        if (prop.get(CMDConstant.BI_TOM_PATH) == null) {

            System.out.println(CMDConstant.ERROR_12);
            System.exit(0);
        } else {
            setBIServerPath(prop);
        }

    } else if (getServer() == 2) {
        if (prop.get(CMDConstant.DI_PATH) == null) {
            System.out.println(CMDConstant.ERROR_2);
            System.exit(0);
        }
        if (prop.get(CMDConstant.DI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_22);
            System.exit(0);
        } else {
            setDIServerPath(prop);
        }
    }

    ApplicationContext context = new ClassPathXmlApplicationContext(CMDConstant.SPRING_FILE_NAME);
    factory = (CofingRetrieverFactory) context.getBean(CMDConstant.COFINGRETRIEVERACTORY);
    ConfigRetreiver[] config = factory.getConfigRetrevier(args);

    ExecutorService service = Executors.newFixedThreadPool(10);
    // loop for all created instance and call respective retriever
    for (final ConfigRetreiver configobj : config) {

        if (getServer() == 1) {

            configobj.setBISeverPath(prop);
            configobj.setServerName("biserver");
        } else if (getServer() == 2) {

            configobj.setDIServerPath(prop);
            configobj.setServerName("diserver");
        }

        if (getInstallationType() == 1) {

            // if installation is installer set Installer
            configobj.setInstallType("Installer");
        } else if (getInstallationType() == 2) {

            // if installation is Archive set Archive
            configobj.setInstallType("Archive");
        } else if (getInstallationType() == 3) {

            // if installation is Manual set Manual
            configobj.setInstallType("Manual");
        }

        // if instance if fileretriever sets required detail
        if (configobj instanceof FileRetriever) {

            configobj.setBidiXml(serverXml);
            configobj.setBidiBatFile(serverBatFile);
            configobj.setBidiProrperties(serverProrperties);
            configobj.setTomcatXml(tomcatXml);
        }

        service.execute(new Runnable() {
            public void run() {
                configobj.readAndSaveConfiguration(prop);
            }
        });

    }

    try {
        service.shutdown();
        Thread.sleep(60000);

        // call for zip
        if (SupportZipUtil.zipFile(prop)) {

            File file = new File(prop.getProperty(CMDConstant.SUPP_INFO_DEST_PATH) + File.separator
                    + prop.getProperty(CMDConstant.SUPP_INF_DIR));
            if (file.exists()) {
                // call for delete empty directory
                delete(file);
                System.exit(0);
            }
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}