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.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java

/**
 * Modifies the properties file 'propFilePathToConfig' with assigned key from the resource properties.
 *///from   w ww .j  a va2s  . c o  m
protected void modifyPropertiesConfiguration(String propFilePathToConfig, List<String> updateKeys,
        Properties resourceProps) {
    try {
        PropertiesConfiguration propConfig = new PropertiesConfiguration(propFilePathToConfig);
        propConfig.setAutoSave(true);
        Properties temProps = new Properties();
        for (String propKey : updateKeys) {
            String resolve = resolve(resourceProps.getProperty(propKey), resourceProps);
            if (resolve != null) {
                if (propConfig.containsKey(propKey)) {
                    addToModifiedPropertiesMap(propFilePathToConfig, propKey, propConfig.getProperty(propKey));
                    propConfig.clearProperty(propKey);
                }
                temProps.put(propKey, resolve);
                propConfig.addProperty(propKey, resolve);
            }
        }
        logger.debug("modify properties file '{}' with '{}'", propFilePathToConfig, temProps.toString());
    } catch (ConfigurationException e) {
        logger.error("modify sahi properties went wrong", e);
    }

}

From source file:org.apache.fulcrum.quartz.factory.QuartzSchedulerFactory.java

public Object createCoreServiceImplementation(ServiceImplementationFactoryParameters arg0) {

    if (scheduler == null) {
        try {/*from  ww  w.j  a v a2s  .  c om*/
            /*
             * check and see if we have scheduler tables in the DB.
             */
            Properties hibernateProperties = hibernateSessionFactory.getHibernateProperties();
            String driver = hibernateProperties.getProperty(HIBERNATE_DRIVER_KEY);
            log.debug("url:" + hibernateProperties.getProperty(HIBERNATE_URL_KEY));
            log.debug("username:" + hibernateProperties.getProperty(HIBERNATE_USERNAME_KEY));
            log.debug("password:" + hibernateProperties.getProperty(HIBERNATE_PASSWORD_KEY));
            checkTables(driver);
            Properties defaults = new Properties();
            defaults.load(this.getClass().getResourceAsStream("/quartz.properties"));
            defaults.put("org.quartz.dataSource.quartzDS.driver",
                    hibernateProperties.getProperty(HIBERNATE_DRIVER_KEY));
            defaults.put("org.quartz.dataSource.quartzDS.URL",
                    hibernateProperties.getProperty(HIBERNATE_URL_KEY));
            defaults.put("org.quartz.dataSource.quartzDS.user",
                    hibernateProperties.getProperty(HIBERNATE_USERNAME_KEY));
            defaults.put("org.quartz.dataSource.quartzDS.password",
                    hibernateProperties.getProperty(HIBERNATE_PASSWORD_KEY));
            defaults.put("org.quartz.dataSource.quartzDS.maxConnections", DEFAULT_MAX_CONNECTIONS);
            log.info(defaults.toString());
            SchedulerFactory schedulerFactory = new StdSchedulerFactory(defaults);
            scheduler = schedulerFactory.getScheduler();
            scheduler.start();
        } catch (IOException ioe) {
            throw new NestableRuntimeException(ioe);
        } catch (SchedulerException se) {
            throw new NestableRuntimeException(se);
        } catch (SQLException sqle) {
            log.error("SQLException caught:", sqle);
            throw new NestableRuntimeException(sqle);
        }
    }

    return scheduler;
}

From source file:org.ow2.petals.roboconf.installer.PluginPetalsSuInstaller.java

private void updatePropertiesFile(final Instance suInstance) throws PluginException {

    final Instance componentInstance = suInstance.getParent();

    this.logger.fine(
            this.agentId + ": updating the properties file for JBI component instance " + componentInstance);

    final String propertiesFileName = Utils.resolvePropertiesFileName(
            InstanceHelpers.findAllExportedVariables(componentInstance)
                    .get(COMPONENT_VARIABLE_NAME_PROPERTIESFILE),
            this.retrieveContainerInstance(suInstance).getName(), componentInstance.getName());
    this.logger.fine("Updated file: " + propertiesFileName);
    if (propertiesFileName != null && !propertiesFileName.isEmpty()) {
        final File propertiesFile = new File(propertiesFileName);
        if (!propertiesFile.exists()
                || (propertiesFile.exists() && propertiesFile.canWrite() && propertiesFile.isFile())) {

            // If the properties file exists, we read it
            final Properties properties = new Properties();
            if (propertiesFile.exists()) {
                try (final InputStream fis = new FileInputStream(propertiesFile)) {
                    properties.load(fis);
                } catch (final FileNotFoundException e) {
                    // This exception should not occur because we have previously verified that the file exists
                    this.logger.log(Level.WARNING,
                            String.format("The properties file ('%s') of component '%s' no more exist",
                                    propertiesFileName, componentInstance.getName()),
                            e);//from w  w  w  .  j av a2 s .co m
                } catch (final IOException e) {
                    throw new PluginException(
                            String.format("Error reading the properties file ('%s') of component '%s'.",
                                    propertiesFileName, componentInstance.getName()),
                            e);
                }
            }

            // Update property values with values coming from SU imports
            final Map<String, Collection<Import>> allImportedVariables = suInstance.getImports();
            final Properties importedValues = new Properties();
            for (final Entry<String, Collection<Import>> importEntry : allImportedVariables.entrySet()) {
                for (final Import anImport : importEntry.getValue()) {
                    for (final Entry<String, String> anExportImported : anImport.getExportedVars().entrySet()) {
                        importedValues.setProperty(anExportImported.getKey(), anExportImported.getValue());
                    }
                }
            }
            this.logger.fine(String.format("Imported variables used by the SU: %s", importedValues.toString()));

            final Map<String, String> allExportedVariables = InstanceHelpers
                    .findAllExportedVariables(suInstance);
            this.logger.fine(
                    String.format("All exported variables of the SU: %s", allExportedVariables.toString()));
            for (final Entry<String, String> entry : allExportedVariables.entrySet()) {
                // We must remove the SU component name implicitely added in exported variables
                final String keyName;
                if (entry.getKey().startsWith(suInstance.getComponent().getName())) {
                    keyName = entry.getKey().substring(suInstance.getComponent().getName().length() + 1);
                } else {
                    keyName = entry.getKey();
                }

                // We resolved placeholder of the exported variable value with imported variables
                try {
                    final String keyValue = PropertiesHelper.resolveString(entry.getValue(), importedValues);
                    properties.setProperty(keyName, keyValue);
                } catch (final PropertiesException e) {
                    throw new PluginException(
                            String.format("Unable to resolve placeholder ('%s') of the SU '%s'.",
                                    entry.getValue(), suInstance.getName()),
                            e);
                }
            }

            // Store the properties file
            Utils.storePropertiesFile(properties, propertiesFile, componentInstance.getName());

            // Signal the component to reload its properties file
            try {
                this.connectToContainer(this.retrieveContainerInstance(suInstance));
                try {
                    this.adminApi.newArtifactAdministration().reloadConfiguration(componentInstance.getName());
                } finally {
                    this.adminApi.disconnect();
                }
            } catch (final ContainerAdministrationException | ArtifactAdministrationException e) {
                throw new PluginException(e);
            }

        } else {
            throw new PluginException(String.format(
                    "Unable to create or write into the properties file ('%s') of component '%s'.",
                    propertiesFileName, componentInstance.getName()));
        }
    }
}

From source file:org.mifos.config.business.MifosConfigurationManager.java

private MifosConfigurationManager() {
    String defaultConfig = "org/mifos/config/resources/applicationConfiguration.default.properties";
    Properties props = new Properties();
    try {//from w ww .j av a2  s  .c  om
        InputStream applicationConfig = MifosResourceUtil.getClassPathResourceAsStream(defaultConfig);
        props.load(applicationConfig);

        ConfigurationLocator configurationLocator = new ConfigurationLocator();
        Resource customApplicationConfig = configurationLocator.getResource(CUSTOM_CONFIG_PROPS_FILENAME);
        if (customApplicationConfig.exists()) {
            InputStream is = customApplicationConfig.getInputStream();
            props.load(is);
            is.close();
        }
        LOGGER.info(
                "Dump of all configuration properties read by MifosConfigurationManager: " + props.toString());
    } catch (IOException e) {
        throw new MifosRuntimeException(e);
    }
    configuration = ConfigurationConverter.getConfiguration(props);
}

From source file:org.apache.ws.scout.transport.RMITransport.java

/** 
 * Sends an element and returns an element.
 *//* w w w . j a  v a2s .c  o  m*/
public Element send(Element request, URI endpointURI) throws TransportException {
    Element response = null;

    if (log.isDebugEnabled()) {
        log.debug("\nRequest message:\n" + XMLUtils.convertNodeToXMLString(request));
        log.debug("Calling " + endpointURI + " using rmi");
    }

    try {
        String host = endpointURI.getHost();
        int port = endpointURI.getPort();
        String scheme = endpointURI.getScheme();
        String service = endpointURI.getPath();
        String className = endpointURI.getQuery();
        String methodName = endpointURI.getFragment();
        Properties env = new Properties();
        //It be a lot nicer if this is configured through properties, but for now
        //I'd like to keep the changes localized, so this seems pretty reasonable.
        String factoryInitial = SecurityActions.getProperty("java.naming.factory.initial");
        if (factoryInitial == null)
            factoryInitial = "org.jnp.interfaces.NamingContextFactory";
        String factoryURLPkgs = SecurityActions.getProperty("java.naming.factory.url.pkgs");
        if (factoryURLPkgs == null)
            factoryURLPkgs = "org.jboss.naming";
        env.setProperty("java.naming.factory.initial", factoryInitial);
        env.setProperty("java.naming.factory.url.pkgs", factoryURLPkgs);
        env.setProperty("java.naming.provider.url", scheme + "://" + host + ":" + port);
        log.debug("Initial Context using env=" + env.toString());
        InitialContext context = new InitialContext(env);
        log.debug("Calling service=" + service + ", Class = " + className + ", Method=" + methodName);
        //Looking up the object (i.e. Publish)
        Object requestHandler = context.lookup(service);
        //Loading up the stub
        Class<?> c = Class.forName(className);
        //Getting a handle to method we want to call (i.e. publish.publish(Element element))
        Method method = c.getMethod(methodName, Element.class);
        //Calling that method
        Node node = (Node) method.invoke(requestHandler, request);
        //The result is in the first element
        if (node.getFirstChild() != null) {
            response = (Element) node.getFirstChild();
        }
    } catch (Exception ex) {
        throw new TransportException(ex);
    }
    if (log.isDebugEnabled()) {
        log.debug("\nResponse message:\n" + XMLUtils.convertNodeToXMLString(response));
    }
    return response;
}

From source file:net.techest.railgun.db.ConnectionPool.java

/**
 * ???//  w ww  .  ja  v a 2  s .c  om
 *
 * @param dbPoolName
 * @return
 * @throws DBException
 */
private BasicDataSource setupDataSource(String dbPoolName) throws DBException {
    BasicDataSource dataSource = null;
    try {
        Properties p = new Properties();
        p.setProperty("driverClassName",
                Configure.getSystemConfig().getString(dbPoolName + "_DRIVER", "com.mysql.jdbc.Driver"));
        p.setProperty("url", Configure.getSystemConfig().getString(dbPoolName + "_URL"));
        p.setProperty("username", Configure.getSystemConfig().getString(dbPoolName + "_USERNAME"));
        p.setProperty("password", Configure.getSystemConfig().getString(dbPoolName + "_PASSWORD"));
        p.setProperty("maxActive", Configure.getSystemConfig().getString(dbPoolName + "_MAXACTIVE", "30"));
        p.setProperty("maxWait", Configure.getSystemConfig().getString(dbPoolName + "_MAXWAIT", "5000"));
        p.setProperty("maxIdle", Configure.getSystemConfig().getString(dbPoolName + "_MAXIDLE", "30"));

        dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(p);
        Log4j.getInstance().error("DB Pool ?? " + p.toString());
        pools.put(MD5.getMD5(dbPoolName.getBytes()), dataSource);
    } catch (Exception ex) {
        Log4j.getInstance().error("DB Pool ? " + ex.getMessage());
        throw new DBException("DB Pool ? " + ex.getMessage());
    }
    return dataSource;
}

From source file:fr.ortolang.diffusion.bootstrap.BootstrapServiceBean.java

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void bootstrap() throws BootstrapServiceException {
    LOGGER.log(Level.INFO, "Starting bootstrap...");

    Map<String, List<String>> anonReadRules = new HashMap<String, List<String>>();
    anonReadRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read"));

    try {/* w  ww . j  a  va  2  s  . co  m*/

        if (!registry.exists(MembershipService.SUPERUSER_IDENTIFIER)) {
            LOGGER.log(Level.FINE, "creating root profile");
            membership.createProfile(MembershipService.SUPERUSER_IDENTIFIER, "Super", "User",
                    "root@ortolang.org", ProfileStatus.ACTIVE);
        }

        if (!registry.exists(MembershipService.UNAUTHENTIFIED_IDENTIFIER)) {
            LOGGER.log(Level.FINE, "creating anonymous profile");
            membership.createProfile(MembershipService.UNAUTHENTIFIED_IDENTIFIER, "Anonymous", "User",
                    "anon@ortolang.org", ProfileStatus.ACTIVE);
            LOGGER.log(Level.FINE, "change owner of anonymous profile to root and set anon read rules");
            authorisation.updatePolicyOwner(MembershipService.UNAUTHENTIFIED_IDENTIFIER,
                    MembershipService.SUPERUSER_IDENTIFIER);
            authorisation.setPolicyRules(MembershipService.UNAUTHENTIFIED_IDENTIFIER, anonReadRules);
        }

        if (!registry.exists(MembershipService.MODERATORS_GROUP_KEY)) {
            LOGGER.log(Level.FINE, "creating moderators group");
            membership.createGroup(MembershipService.MODERATORS_GROUP_KEY, "Publication Moderators",
                    "Moderators of the platform check technical aspect of publication");
            membership.addMemberInGroup(MembershipService.MODERATORS_GROUP_KEY,
                    MembershipService.SUPERUSER_IDENTIFIER);
            authorisation.setPolicyRules(MembershipService.MODERATORS_GROUP_KEY, anonReadRules);
        }

        if (!registry.exists(MembershipService.PUBLISHERS_GROUP_KEY)) {
            LOGGER.log(Level.FINE, "creating publishers group");
            membership.createGroup(MembershipService.PUBLISHERS_GROUP_KEY, "Publishers",
                    "Publishers of the platform validates final publication");
            membership.addMemberInGroup(MembershipService.PUBLISHERS_GROUP_KEY,
                    MembershipService.SUPERUSER_IDENTIFIER);
            authorisation.setPolicyRules(MembershipService.PUBLISHERS_GROUP_KEY, anonReadRules);
        }

        if (!registry.exists(MembershipService.REVIEWERS_GROUP_KEY)) {
            LOGGER.log(Level.FINE, "creating reviewers group");
            membership.createGroup(MembershipService.REVIEWERS_GROUP_KEY, "Reviewers",
                    "Reviewers of the platform rate content");
            membership.addMemberInGroup(MembershipService.REVIEWERS_GROUP_KEY,
                    MembershipService.SUPERUSER_IDENTIFIER);
            authorisation.setPolicyRules(MembershipService.REVIEWERS_GROUP_KEY, anonReadRules);
        }

        if (!registry.exists(MembershipService.ESR_GROUP_KEY)) {
            LOGGER.log(Level.FINE, "creating esr group");
            membership.createGroup(MembershipService.ESR_GROUP_KEY, "ESR Members",
                    "People from Superior Teaching and Research Group");
            authorisation.setPolicyRules(MembershipService.ESR_GROUP_KEY, anonReadRules);
        }

        if (!registry.exists(MembershipService.ADMINS_GROUP_KEY)) {
            LOGGER.log(Level.FINE, "creating admins group");
            membership.createGroup(MembershipService.ADMINS_GROUP_KEY, "Administrators",
                    "Administrators of the platform");
            authorisation.setPolicyRules(MembershipService.ADMINS_GROUP_KEY, anonReadRules);
        }

        if (!registry.exists(BootstrapService.WORKSPACE_KEY)) {
            LOGGER.log(Level.FINE, "create system workspace");
            core.createWorkspace(BootstrapService.WORKSPACE_KEY, "system", "System Workspace",
                    WorkspaceType.SYSTEM.toString());
            Properties props = new Properties();
            props.setProperty("bootstrap.status", "done");
            props.setProperty("bootstrap.timestamp", System.currentTimeMillis() + "");
            props.setProperty("bootstrap.version", BootstrapService.VERSION);
            String hash = core.put(new ByteArrayInputStream(props.toString().getBytes()));
            core.createDataObject(BootstrapService.WORKSPACE_KEY, "/bootstrap.txt", hash);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.DEFAULT)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.DEFAULT + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> defaultPolicyRules = new HashMap<String, List<String>>();
            defaultPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER,
                    Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, defaultPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.DEFAULT,
                    "Default template allows all users to read and download content", pid);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.FORALL)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.FORALL + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> forallPolicyRules = new HashMap<String, List<String>>();
            forallPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER,
                    Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, forallPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.FORALL,
                    "All users can read and download this content", pid);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.AUTHENTIFIED)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.AUTHENTIFIED + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> authentifiedPolicyRules = new HashMap<String, List<String>>();
            authentifiedPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER,
                    Collections.singletonList("read"));
            authentifiedPolicyRules.put(MembershipService.ALL_AUTHENTIFIED_GROUP_KEY,
                    Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, authentifiedPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.AUTHENTIFIED,
                    "All users can read this content but download is restricted to authentified users only",
                    pid);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.ESR)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.ESR + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> esrPolicyRules = new HashMap<String, List<String>>();
            esrPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read"));
            esrPolicyRules.put(MembershipService.ESR_GROUP_KEY, Arrays.asList("read", "download"));
            esrPolicyRules.put("${workspace.privileged}", Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, esrPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.ESR,
                    "All users can read this content but download is restricted to ESR users only", pid);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.PRIVILEGED)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.PRIVILEGED + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> privilegedPolicyRules = new HashMap<String, List<String>>();
            privilegedPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER,
                    Collections.singletonList("read"));
            privilegedPolicyRules.put(MembershipService.ESR_GROUP_KEY, Collections.singletonList("read"));
            privilegedPolicyRules.put("${workspace.privileged}", Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, privilegedPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.PRIVILEGED,
                    "Only privileged users can read and download this content", pid);
        }

        if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.RESTRICTED)) {
            LOGGER.log(Level.FINE,
                    "create [" + AuthorisationPolicyTemplate.RESTRICTED + "] authorisation policy template");
            String pid = UUID.randomUUID().toString();
            authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER);
            Map<String, List<String>> restrictedPolicyRules = new HashMap<String, List<String>>();
            restrictedPolicyRules.put("${workspace.members}", Arrays.asList("read", "download"));
            authorisation.setPolicyRules(pid, restrictedPolicyRules);
            authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.RESTRICTED,
                    "Only workspace members can read and download this content, all other users cannot see this content",
                    pid);
        }

        InputStream is = getClass().getClassLoader()
                .getResourceAsStream("forms/" + FormService.IMPORT_ZIP_FORM + ".json");
        String json = IOUtils.toString(is, "UTF-8");
        if (!registry.exists(FormService.IMPORT_ZIP_FORM)) {
            LOGGER.log(Level.FINE, "create form : " + FormService.IMPORT_ZIP_FORM);
            form.createForm(FormService.IMPORT_ZIP_FORM, "Import Zip Process Start Form", json);
        } else {
            LOGGER.log(Level.FINE, "update form : " + FormService.IMPORT_ZIP_FORM);
            form.updateForm(FormService.IMPORT_ZIP_FORM, "Import Zip Process Start Form", json);
        }
        is.close();

        is = getClass().getClassLoader()
                .getResourceAsStream("forms/" + FormService.REVIEW_SNAPSHOT_FORM + ".json");
        json = IOUtils.toString(is, "UTF-8");
        if (!registry.exists(FormService.REVIEW_SNAPSHOT_FORM)) {
            LOGGER.log(Level.FINE, "create form : " + FormService.REVIEW_SNAPSHOT_FORM);
            form.createForm(FormService.REVIEW_SNAPSHOT_FORM, "Workspace publication's review form", json);
        } else {
            LOGGER.log(Level.FINE, "update form : " + FormService.REVIEW_SNAPSHOT_FORM);
            form.updateForm(FormService.REVIEW_SNAPSHOT_FORM, "Workspace publication's review form", json);
        }
        is.close();

        is = getClass().getClassLoader()
                .getResourceAsStream("forms/" + FormService.MODERATE_SNAPSHOT_FORM + ".json");
        json = IOUtils.toString(is, "UTF-8");
        if (!registry.exists(FormService.MODERATE_SNAPSHOT_FORM)) {
            LOGGER.log(Level.FINE, "create form : " + FormService.MODERATE_SNAPSHOT_FORM);
            form.createForm(FormService.MODERATE_SNAPSHOT_FORM, "Workspace publication's moderation form",
                    json);
        } else {
            LOGGER.log(Level.FINE, "update form : " + FormService.MODERATE_SNAPSHOT_FORM);
            form.updateForm(FormService.MODERATE_SNAPSHOT_FORM, "Workspace publication's moderation form",
                    json);
        }
        is.close();

        is = getClass().getClassLoader()
                .getResourceAsStream("forms/" + FormService.PUBLISH_SNAPSHOT_FORM + ".json");
        json = IOUtils.toString(is, "UTF-8");
        if (!registry.exists(FormService.PUBLISH_SNAPSHOT_FORM)) {
            LOGGER.log(Level.FINE, "create form : " + FormService.PUBLISH_SNAPSHOT_FORM);
            form.createForm(FormService.PUBLISH_SNAPSHOT_FORM, "Workspace publication's form", json);
        } else {
            LOGGER.log(Level.FINE, "update form : " + FormService.MODERATE_SNAPSHOT_FORM);
            form.updateForm(FormService.PUBLISH_SNAPSHOT_FORM, "Workspace publication's form", json);
        }
        is.close();

        is = getClass().getClassLoader().getResourceAsStream("forms/" + FormService.ITEM_FORM + ".json");
        json = IOUtils.toString(is, "UTF-8");
        if (!registry.exists(FormService.ITEM_FORM)) {
            LOGGER.log(Level.FINE, "create form : " + FormService.ITEM_FORM);
            form.createForm(FormService.ITEM_FORM, "Schema Form for an ORTOLANG item", json);
        } else {
            LOGGER.log(Level.FINE, "update form : " + FormService.ITEM_FORM);
            form.updateForm(FormService.ITEM_FORM, "Schema Form for an ORTOLANG item", json);
        }
        is.close();

        LOGGER.log(Level.FINE, "import metadataformat schemas");
        InputStream schemaItemInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-item-schema-0.16-with-parts.json");
        String schemaItemHash = core.put(schemaItemInputStream);
        core.createMetadataFormat(MetadataFormat.ITEM,
                "Les mtadonnes de prsentation permettent de paramtrer l\'affichage de la ressource dans la partie consultation du site. Nouvelle fonctionnalit : les sous-parties.",
                schemaItemHash, "ortolang-item-form", true, true);

        InputStream schemaInputStream2 = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-acl-schema.json");
        String schemaHash2 = core.put(schemaInputStream2);
        core.createMetadataFormat(MetadataFormat.ACL,
                "Les mtadonnes de contrle d'accs permettent de paramtrer la visibilit d'une ressource lors de sa publication.",
                schemaHash2, "", true, false);

        InputStream schemaWorkspaceInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-workspace-schema.json");
        String schemaWorkspaceHash = core.put(schemaWorkspaceInputStream);
        core.createMetadataFormat(MetadataFormat.WORKSPACE,
                "Les mtadonnes associes  un espace de travail.", schemaWorkspaceHash, "", true, true);

        InputStream schemaPidInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-pid-schema.json");
        String schemaPidHash = core.put(schemaPidInputStream);
        core.createMetadataFormat(MetadataFormat.PID, "Les mtadonnes associes aux pids d'un object.",
                schemaPidHash, "", true, false);

        InputStream schemaThumbInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-thumb-schema.json");
        String schemaThumbHash = core.put(schemaThumbInputStream);
        core.createMetadataFormat(MetadataFormat.THUMB, "Schema for ORTOLANG objects thumbnail",
                schemaThumbHash, "", false, false);

        InputStream schemaTemplateInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/ortolang-template-schema.json");
        String schemaTemplateHash = core.put(schemaTemplateInputStream);
        core.createMetadataFormat(MetadataFormat.TEMPLATE, "Schema for ORTOLANG collection template",
                schemaTemplateHash, "", false, false);

        InputStream schemaTrustRankInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-trustrank-schema.json");
        String schemaTrustRankHash = core.put(schemaTrustRankInputStream);
        core.createMetadataFormat(MetadataFormat.TRUSTRANK, "Schema for applying a trusted notation on item",
                schemaTrustRankHash, "", true, true);

        InputStream schemaRatingInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-rating-schema.json");
        String schemaRatingHash = core.put(schemaRatingInputStream);
        core.createMetadataFormat(MetadataFormat.RATING, "Schema for applying a rating on item",
                schemaRatingHash, "", true, true);

        InputStream schemaAudioInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-audio.json");
        String schemaAudioHash = core.put(schemaAudioInputStream);
        core.createMetadataFormat(MetadataFormat.AUDIO, "Schema for ORTOLANG audio metadata", schemaAudioHash,
                "", false, false);

        InputStream schemaVideoInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-video.json");
        String schemaVideoHash = core.put(schemaVideoInputStream);
        core.createMetadataFormat(MetadataFormat.VIDEO, "Schema for ORTOLANG video metadata", schemaVideoHash,
                "", false, false);

        InputStream schemaImageInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-image.json");
        String schemaImageHash = core.put(schemaImageInputStream);
        core.createMetadataFormat(MetadataFormat.IMAGE, "Schema for ORTOLANG image metadata", schemaImageHash,
                "", false, false);

        InputStream schemaXMLInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-xml.json");
        String schemaXmlHash = core.put(schemaXMLInputStream);
        core.createMetadataFormat(MetadataFormat.XML, "Schema for ORTOLANG XML metadata", schemaXmlHash, "",
                false, false);

        InputStream schemaPDFInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-pdf.json");
        String schemaPDFHash = core.put(schemaPDFInputStream);
        core.createMetadataFormat(MetadataFormat.PDF, "Schema for ORTOLANG PDF metadata", schemaPDFHash, "",
                false, false);

        InputStream schemaTextInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-text.json");
        String schemaTextHash = core.put(schemaTextInputStream);
        core.createMetadataFormat(MetadataFormat.TEXT, "Schema for ORTOLANG text metadata", schemaTextHash, "",
                false, false);

        InputStream schemaOfficeInputStream = getClass().getClassLoader()
                .getResourceAsStream("schema/system-x-office.json");
        String schemaOfficeHash = core.put(schemaOfficeInputStream);
        core.createMetadataFormat(MetadataFormat.OFFICE, "Schema for ORTOLANG Office metadata",
                schemaOfficeHash, "", false, false);

        loadMetadataFormat(MetadataFormat.OAI_DC, "Schema for Dublin Core elements in JSON format", "", true,
                true);
        loadMetadataFormat(MetadataFormat.OLAC, "Schema for OLAC elements in JSON format", "", true, true);
        loadMetadataFormat(MetadataFormat.TCOF, "Schema for TCOF elements in JSON format", "", true, true);

        LOGGER.log(Level.INFO, "reimport process types");
        runtime.importProcessTypes();

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "error during bootstrap", e);
        throw new BootstrapServiceException("error during bootstrap", e);
    }

}

From source file:org.apache.juddi.v3.client.transport.RMITransport.java

private void initContext() throws NamingException, ConfigurationException {
    Properties env = new Properties();
    UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
    String factoryInitial = client.getClientConfig().getHomeNode().getFactoryInitial();
    String factoryURLPkgs = client.getClientConfig().getHomeNode().getFactoryURLPkgs();
    String factoryNamingProvider = client.getClientConfig().getHomeNode().getFactoryNamingProvider();
    if (factoryInitial != null && !"".equals(factoryInitial))
        env.setProperty(Property.UDDI_PROXY_FACTORY_INITIAL, factoryInitial);
    if (factoryURLPkgs != null && !"".equals(factoryURLPkgs))
        env.setProperty(Property.UDDI_PROXY_FACTORY_URL_PKS, factoryURLPkgs);
    if (factoryNamingProvider != null && !"".equals(factoryNamingProvider))
        env.setProperty(Property.UDDI_PROXY_PROVIDER_URL, factoryNamingProvider);
    logger.debug("Initial Context using env=" + env.toString());
    context = new InitialContext(env);
}

From source file:mondrian.rolap.RolapConnectionPool.java

public synchronized DataSource getDriverManagerPoolingDataSource(String jdbcConnectString,
        Properties jdbcProperties) {
    // First look for a data source with identical specification. This in
    // turn helps us to use the cache of Dialect objects.

    // Need to include user name to define the pool key as some DBMSs
    // like Oracle don't include schemas in the JDBC URL - instead the
    // user drives the schema. This makes JDBC pools act like JNDI pools,
    // with, in effect, a pool per DB user.

    List<Object> key = Arrays.<Object>asList("DriverManagerPoolingDataSource", jdbcConnectString,
            jdbcProperties);//from   ww w. j  a va  2s .  c om
    DataSource dataSource = dataSourceMap.get(key);
    if (dataSource != null) {
        return dataSource;
    }

    // use the DriverManagerConnectionFactory to create connections
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(jdbcConnectString, jdbcProperties);

    try {
        String propertyString = jdbcProperties.toString();
        dataSource = getPoolingDataSource(jdbcConnectString + propertyString, connectionFactory);
    } catch (Throwable e) {
        throw Util.newInternal(e, "Error while creating connection pool (with URI " + jdbcConnectString + ")");
    }
    dataSourceMap.put(key, dataSource);
    return dataSource;
}

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

private static Query[] getQueries(String parameter, Properties _propsq) throws Exception {
    try {//  w  ww  .j  a  v  a 2 s. com
        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;
    }

}