Example usage for java.util Properties toString

List of usage examples for java.util Properties toString

Introduction

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

Prototype

@Override
    public synchronized String toString() 

Source Link

Usage

From source file:org.pentaho.platform.plugin.action.mdx.MDXBaseComponent.java

protected IPentahoConnection getConnection() {

    // first attempt to get the connection metadata from the catalog service. if that is not successful,
    // get the connection using the original approach.

    MdxConnectionAction connAction = (MdxConnectionAction) getActionDefinition();
    String catalogName = connAction.getCatalog().getStringValue();
    IMondrianCatalogService mondrianCatalogService = PentahoSystem.get(IMondrianCatalogService.class,
            "IMondrianCatalogService", PentahoSessionHolder.getSession()); //$NON-NLS-1$
    MondrianCatalog catalog = mondrianCatalogService.getCatalog(catalogName, PentahoSessionHolder.getSession());

    if (catalog == null) {
        return getConnectionOrig();
    }/* w ww  . java2s  .  c om*/

    Util.PropertyList connectProperties = Util.parseConnectString(catalog.getDataSourceInfo());

    Properties properties = new Properties();

    Iterator<Pair<String, String>> iter = connectProperties.iterator();
    while (iter.hasNext()) {
        Pair<String, String> pair = iter.next();
        properties.put(pair.getKey(), pair.getValue());
    }

    properties.put("Catalog", catalog.getDefinition());
    properties.put("Provider", "mondrian");
    properties.put("PoolNeeded", "false");
    properties.put(RolapConnectionProperties.Locale.name(), LocaleHelper.getLocale().toString());

    debug("Mondrian Connection Properties: " + properties.toString());

    MDXConnection mdxConnection = (MDXConnection) PentahoConnectionFactory.getConnection(
            IPentahoConnection.MDX_DATASOURCE, properties, PentahoSessionHolder.getSession(), this);

    if (connAction != null) {
        if ((connAction.getExtendedColumnNames() != ActionInputConstant.NULL_INPUT)) {
            mdxConnection.setUseExtendedColumnNames(connAction.getExtendedColumnNames().getBooleanValue());
        }
    }

    return mdxConnection;
}

From source file:com.smartmarmot.orabbix.Configurator.java

private static Query[] getQueries(String parameter, Properties _propsq) throws Exception {
    try {//from ww  w.  jav a  2s  .c  o m
        StringTokenizer stq = new StringTokenizer(_propsq.getProperty(parameter), Constants.DELIMITER);
        String[] QueryLists = new String[stq.countTokens()];
        int count = 0;
        while (stq.hasMoreTokens()) {
            String token = stq.nextToken().toString().trim();
            QueryLists[count] = token;
            count++;
        }

        Collection<Query> Queries = new ArrayList<Query>();
        for (int i = 0; i < QueryLists.length; i++) {
            try {
                Query q = getQueryProperties(_propsq, QueryLists[i]);
                Queries.add(q);
            } catch (Exception e1) {
                SmartLogger.logThis(Level.ERROR,
                        "Error on Configurator on reading query " + QueryLists[i] + e1);
                SmartLogger.logThis(Level.INFO, "Query " + QueryLists[i] + " skipped due to error " + e1);

            }
        }
        Query[] queries = (Query[]) Queries.toArray(new Query[0]);
        return queries;
    } catch (Exception ex) {

        SmartLogger.logThis(Level.ERROR,
                "Error on Configurator on reading properties file " + _propsq.toString() + " getQueries("
                        + parameter + "," + _propsq.toString() + ") " + ex.getMessage());
        return null;
    }

}

From source file:org.beepcore.beep.profile.sasl.otp.database.UserDatabasePool.java

/**
 * Method getUser This method is provided as a means
 * for users of the OTP databases to retrieve the information
 * contained in them, in the form of an instance of
 * UserDatabase.  Please note that ALGORITHM should in time be
 * added - to be part of how one looks up an OTP database (using
 * both the username and the algorithm).  The init-word and init-hex
 * commands, in their nature, don't really allow for it, so this'll
 * do for now, but in time it should be that way.  It certainly
 * wouldn't be a difficult thing to do.  This would also entail
 * evolving the way init-hex/word are processed, as well...which
 * is slightly trickier than doing a dual parameter lookup.
 * /*from   w  w w.j ava  2  s .  c om*/
 * @param username Indicates which OTP database should 
 * be retrieved, based on who wishes to authenticate using it.
 *
 * @return UserDatabase the OTP database for the user specified.
 * 
 * @throws SASLException is thrown if the parameter is null or 
 * some error is encountered during the reading or processing
 * of the user's OTP database file.
 *
 */
public UserDatabase getUser(String username) throws SASLException {
    if (username == null) {
        throw new SASLException("Must supply a username to get an OTP DB");
    }

    if (userpool == null) {
        userpool = new Hashtable();
    }

    UserDatabase ud = (UserDatabase) userpool.get(username);

    if (ud == null) {
        Properties p = new Properties();

        try {
            if (log.isDebugEnabled()) {
                log.debug("Loading otp property file " + username + OTP_SUFFIX);
            }
            p.load(new FileInputStream(username + OTP_SUFFIX));
        } catch (IOException x) {
            log.error(UserDBNotFoundException.MSG + username);

            throw new UserDBNotFoundException(username);
        }

        try {
            ud = new UserDatabaseImpl(p.getProperty(OTP_ALGO), p.getProperty(OTP_LAST_HASH),
                    p.getProperty(OTP_SEED), p.getProperty(OTP_AUTHENTICATOR),
                    Integer.parseInt(p.getProperty(OTP_SEQUENCE)));
        } catch (Exception x) {
            throw new SASLException("OTP DB for " + username + "is corrupted");
        }
        userpool.put(username, ud);
        if (log.isDebugEnabled()) {
            log.debug(p.toString());
            log.debug("Stored otp settings for " + username);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("Fetching User Database for " + username);
    }
    return ud;
}

From source file:org.ejbca.performance.legacy.LegacyBaseCryptoToken.java

@Override
public void setProperties(Properties properties) {
    if (properties == null) {
        this.properties = new Properties();
    } else {//from   www.  j a  v  a 2s  . c o  m
        if (log.isDebugEnabled()) {
            // This is only a sections for debug logging. If we have enabled debug logging we don't want to display any password in the log.
            // These properties may contain autoactivation PIN codes and we will, only when debug logging, replace this with "hidden".
            if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)
                    || properties.containsKey("PIN")) {
                Properties prop = new Properties();
                prop.putAll(properties);
                if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)) {
                    prop.setProperty(CryptoToken.AUTOACTIVATE_PIN_PROPERTY, "hidden");
                }
                if (properties.containsKey("PIN")) {
                    prop.setProperty("PIN", "hidden");
                }
                log.debug("Prop: " + (prop != null ? prop.toString() : "null"));
            } else {
                // If no autoactivation PIN codes exists we can debug log everything as original.
                log.debug("Properties: " + (properties != null ? properties.toString() : "null"));
            }
        } // if (log.isDebugEnabled())
        this.properties = properties;
        String authCode = LegacyBaseCryptoToken.getAutoActivatePin(properties);
        this.mAuthCode = authCode == null ? null : authCode.toCharArray();
    }
}

From source file:org.cesecore.keys.token.BaseCryptoToken.java

@Override
public void setProperties(Properties properties) {
    if (properties == null) {
        this.properties = new Properties();
    } else {/*from w  w  w . j a v a 2  s  .com*/
        if (log.isDebugEnabled()) {
            // This is only a sections for debug logging. If we have enabled debug logging we don't want to display any password in the log.
            // These properties may contain autoactivation PIN codes and we will, only when debug logging, replace this with "hidden".
            if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)
                    || properties.containsKey("PIN")) {
                Properties prop = new Properties();
                prop.putAll(properties);
                if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)) {
                    prop.setProperty(CryptoToken.AUTOACTIVATE_PIN_PROPERTY, "hidden");
                }
                if (properties.containsKey("PIN")) {
                    prop.setProperty("PIN", "hidden");
                }
                log.debug("Prop: " + (prop != null ? prop.toString() : "null"));
            } else {
                // If no autoactivation PIN codes exists we can debug log everything as original.
                log.debug("Properties: " + (properties != null ? properties.toString() : "null"));
            }
        } // if (log.isDebugEnabled())
        this.properties = properties;
        String authCode = BaseCryptoToken.getAutoActivatePin(properties);
        this.mAuthCode = authCode == null ? null : authCode.toCharArray();
    }
}

From source file:edu.utah.further.i2b2.hook.further.FurtherInterceptionFilter.java

/**
 * @param filterConfig//w  w w .  j  a v  a  2 s.  c om
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 */
public void init(final FilterConfig filterConfig) throws ServletException {
    if (log.isDebugEnabled()) {
        log.debug("Initializing");
    }

    final Properties properties = new Properties();
    try {
        properties
                .load(Thread.currentThread().getContextClassLoader().getResourceAsStream("further.properties"));
    } catch (IOException e) {
        throw new ServletException("Unable to initialize FURTHeR i2b2 hook", e);
    }

    final String queryRequestUrl = properties.getProperty("query.request.url");
    final String queryStateUrl = properties.getProperty("query.state.url");
    final String queryResultsUrl = properties.getProperty("query.result.url");
    final String resultMaskBoundary = properties.getProperty("result.mask.boundary");
    final String maxQueryTime = properties.getProperty("query.max.time");

    if (log.isDebugEnabled()) {
        log.debug(properties.toString());
    }

    furtherServices.setQueryRequestUrl(queryRequestUrl);
    furtherServices.setQueryStateUrl(queryStateUrl);
    furtherServices.setQueryResultsUrl(queryResultsUrl);
    furtherServices.setResultMaskBoundary(Long.valueOf(resultMaskBoundary));
    furtherServices.setMaxQueryTime(Long.valueOf(maxQueryTime).longValue());
}

From source file:uk.ac.soton.itinnovation.sad.service.adapters.GenericEccClient.java

/**
 * Converts JSON into Properties object.
 *///from ww  w. j  a  va2 s .  com
private Properties jsonToProperties(JSONObject propertiesAsJson) {
    Properties result = new Properties();

    logger.debug("Converting JSON to Properties: " + propertiesAsJson.toString(2));

    Iterator<String> it = propertiesAsJson.keys();
    String propertyName, propertyValue;
    while (it.hasNext()) {
        propertyName = it.next();
        propertyValue = propertiesAsJson.getString(propertyName);
        result.put(propertyName, propertyValue);
    }

    logger.debug("Convertion result: " + result.toString());

    return result;
}

From source file:com.alfaariss.oa.engine.core.EngineLauncher.java

/**
 * Restarts the engine./*from w w w  .  j  a v  a  2 s  . c om*/
 *
 * Uses the supplied properties or if they are <code>null</code> the 
  * properties used during the start to restart the OA engine.
 * @param pConfig properties with the location of the configuration
 * @throws OAException if restart fails
 */
public void restart(Properties pConfig) throws OAException {
    Properties pRestartConfig = null;
    try {
        if (!_engine.isInitialized()) {
            _logger.info("Engine is not started yet; Trying to start");
            start(pConfig);
        } else {
            pRestartConfig = _pConfig;

            if (pConfig != null)
                pRestartConfig.putAll(pConfig);

            _configurationManager.stop();
            _configurationManager.start(pRestartConfig);

            _engine.restart(null);

            _logger.info("Restarted EngineLauncher");
        }
    } catch (OAException e) {
        throw e;
    } catch (Exception e) {
        StringBuffer sbError = new StringBuffer("Internal error during restart ");
        if (pRestartConfig == null)
            sbError.append("without supplied configuration");
        else {
            sbError.append("with the following supplied configuration: ");
            sbError.append(pRestartConfig.toString());
        }
        _logger.error(sbError.toString(), e);

        throw new OAException(SystemErrors.ERROR_INTERNAL);
    }
}

From source file:org.pentaho.platform.plugin.action.mondrian.MondrianModelComponent.java

public static String getInitialQuery(final Properties properties, final String cubeName,
        IPentahoSession session) throws Throwable {

    // Apply any properties for this catalog specified in datasource.xml
    IMondrianCatalogService mondrianCatalogService = PentahoSystem.get(IMondrianCatalogService.class,
            "IMondrianCatalogService", PentahoSessionHolder.getSession());
    List<MondrianCatalog> catalogs = mondrianCatalogService.listCatalogs(PentahoSessionHolder.getSession(),
            true);/*  ww  w .j av a2s  .c  o  m*/
    String propCat = properties.getProperty(RolapConnectionProperties.Catalog.name());
    for (MondrianCatalog cat : catalogs) {
        if (cat.getDefinition().equalsIgnoreCase(propCat)) {
            Util.PropertyList connectProperties = Util.parseConnectString(cat.getDataSourceInfo());
            Iterator<Pair<String, String>> iter = connectProperties.iterator();
            while (iter.hasNext()) {
                Pair<String, String> pair = iter.next();
                if (!properties.containsKey(pair.getKey())) // Only set if not set already
                {
                    properties.put(pair.getKey(), pair.getValue());
                }
            }
            break;
        }
    }

    MDXConnection mdxConnection = (MDXConnection) PentahoConnectionFactory
            .getConnection(IPentahoConnection.MDX_DATASOURCE, properties, session, null);
    // mdxConnection.setProperties( properties );
    Connection connection = mdxConnection.getConnection();
    if (connection == null) {
        Logger.error("MondrianModelComponent", Messages.getInstance()
                .getErrorString("MondrianModel.ERROR_0001_INVALID_CONNECTION", properties.toString())); //$NON-NLS-1$ //$NON-NLS-2$
        return null;
    }

    try {
        return MondrianModelComponent.getInitialQuery(connection, cubeName);
    } catch (Throwable t) {
        if (t instanceof MondrianException) {
            // pull the cause out, otherwise it never gets logged
            Throwable cause = ((MondrianException) t).getCause();
            if (cause != null) {
                throw cause;
            } else {
                throw t;
            }
        } else {
            throw t;
        }
    }
}

From source file:org.jclouds.demo.tweetstore.config.SpringServletConfig.java

@PostConstruct
public void initialize() throws IOException {
    Properties props = new PropertiesLoader(servletConfig.getServletContext()).get();
    // skip Expect-100 - see https://issues.apache.org/jira/browse/JCLOUDS-181
    props.put(PROPERTY_STRIP_EXPECT_HEADER, true);
    LOGGER.trace("About to initialize members.");

    Module googleModule = new GoogleAppEngineConfigurationModule();
    Set<Module> modules = ImmutableSet.<Module>of(googleModule);
    // shared across all blobstores and used to retrieve tweets
    try {//from ww  w  .j a  v  a  2s  .  c o m
        twitter4j.conf.Configuration twitterConf = new ConfigurationBuilder()
                .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY))
                .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET))
                .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN))
                .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)).build();
        twitterClient = new TwitterFactory(twitterConf).getInstance();
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
                "properties for twitter not configured properly in " + props.toString(), e);
    }
    // common namespace for storing tweets
    container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER);

    // instantiate and store references to all blobstores by provider name
    providerTypeToBlobStoreMap = Maps.newHashMap();
    for (String hint : getBlobstoreContexts(props)) {
        providerTypeToBlobStoreMap.put(hint, ContextBuilder.newBuilder(hint).modules(modules).overrides(props)
                .build(BlobStoreContext.class));
    }

    // get a queue for submitting store tweet requests
    queue = QueueFactory.getQueue("twitter");

    LOGGER.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
            container, providerTypeToBlobStoreMap.keySet());
}