Example usage for java.util Dictionary put

List of usage examples for java.util Dictionary put

Introduction

In this page you can find the example usage for java.util Dictionary put.

Prototype

public abstract V put(K key, V value);

Source Link

Document

Maps the specified key to the specified value in this dictionary.

Usage

From source file:org.energy_home.jemma.ah.internal.greenathome.Configurator.java

private Dictionary getServiceProperties(ServiceReference sr) {
    String[] keys = sr.getPropertyKeys();
    Dictionary props = new Hashtable();
    for (int i = 0; i < keys.length; i++) {
        props.put(keys[i], sr.getProperty(keys[i]));
    }//from   w  ww  . ja v a2 s  .  co m

    return props;
}

From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.Read99FilesWithThreeReadersTest.java

@Override
protected String useOverridePropertiesWithConfigAdmin(Dictionary props) throws Exception {
    props.put("lb.path", rootDirectory);
    props.put("lb.maxMessagesPerPoll", 100);

    return "com.garethahealy.camel.file.loadbalancer.example1";
}

From source file:ddf.catalog.test.TestXACML.java

@Override
protected void setLogLevels() throws IOException {

    logLevel = System.getProperty(TEST_LOGLEVEL_PROPERTY);

    Configuration logConfig = configAdmin.getConfiguration(LOG_CONFIG_PID, null);
    Dictionary<String, Object> properties = logConfig.getProperties();
    if (StringUtils.isEmpty(logLevel)) {
        properties.put(LOGGER_PREFIX + "ddf", DEFAULT_LOG_LEVEL);
        properties.put(LOGGER_PREFIX + "org.codice", DEFAULT_LOG_LEVEL);
        properties.put(LOGGER_PREFIX + "org.wso2.balana", DEFAULT_LOG_LEVEL);
    } else {/*from  w ww. ja  v  a2s.c o  m*/
        properties.put(LOGGER_PREFIX + "*", logLevel);
    }

    logConfig.update(properties);
}

From source file:org.codice.alliance.test.itests.SecurityAuditPluginTest.java

@Test
public void testSecurityAuditPlugin() throws Exception {
    Configuration config = configAdmin
            .getConfiguration("org.codice.alliance.catalog.plugin.security.audit.SecurityAuditPlugin", null);
    List attributes = new ArrayList<>();
    attributes.add("description");
    Dictionary properties = new Hashtable<>();
    properties.put("auditAttributes", attributes);
    config.update(properties);//from w  w  w .ja  va  2s .co  m

    String logFilePath = System.getProperty("karaf.data") + "/log/security.log";

    WaitCondition.expect("Security log has log message: " + configUpdateMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileFromAbsolutePath(logFilePath).contains(configUpdateMessage));

    String id = ingest(getResourceAsString("metacard1.xml"), "text/xml");

    update(id, getResourceAsString("metacard2.xml"), "text/xml");

    String expectedLogMessage = String.format(auditMessageFormat, "description", id, "My Description",
            "My Description (Updated)");
    WaitCondition.expect("Securitylog has log message: " + expectedLogMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileFromAbsolutePath(logFilePath).contains(expectedLogMessage));

    deleteMetacard(id);
}

From source file:io.wcm.caravan.jaxrs.publisher.impl.JaxRsBundleTracker.java

@Override
public ComponentInstance addingBundle(Bundle bundle, BundleEvent event) {
    String applicationPath = ApplicationPath.get(bundle);
    if (StringUtils.isNotBlank(applicationPath)) {

        if (log.isInfoEnabled()) {
            log.info("Mount JAX-RS application {} to {}", bundle.getSymbolicName(), applicationPath);
        }/*w w  w  .  j  a va 2  s.  c om*/

        // register JAX-RS application as servlet on HTTP whiteboard
        Dictionary<String, Object> serviceConfig = new Hashtable<>();
        serviceConfig.put("alias", applicationPath);
        serviceConfig.put(ServletContainerBridge.PROPERTY_BUNDLE, bundle);
        return servletContainerBridgeFactory.newInstance(serviceConfig);
    }
    return null;
}

From source file:org.fusesource.cloudmix.controller.bundle.JerseyServletFactory.java

public void afterPropertiesSet() throws Exception {
    // This property is needed for JAXB to properly operate inside OSGi
    System.setProperty("com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize", "true");

    Dictionary<String, String> initParams = new Hashtable<String, String>();
    initParams.put("com.sun.jersey.config.feature.Redirect", "true");
    initParams.put("com.sun.jersey.config.feature.ImplicitViewables", "true");

    initParams.put("com.sun.jersey.config.property.resourceConfigClass",
            "org.fusesource.cloudmix.controller.bundle.OSGiResourceConfig");
    initParams.put("jersey_osgi.classnames", classNames);

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {/*from w w w .j a v a2  s .c om*/
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        // TODO is there another way to do this now using the standard Jersey stuff?
        //SpringServlet jerseyServlet = new SpringServlet(applicationContext, authenticator);
        SpringServlet jerseyServlet = new SpringServlet();
        httpService.registerServlet(rootContext, jerseyServlet, initParams, null);
        LOG.info("Registered servlet at: " + rootContext);
        LOG.info("With initialization  : " + initParams);
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}

From source file:ddf.test.itests.catalog.TestSecurityAuditPlugin.java

@Test
public void testSecurityAuditPlugin() throws Exception {
    Configuration config = configAdmin
            .getConfiguration("org.codice.ddf.catalog.plugin.security.audit.SecurityAuditPlugin", null);
    List attributes = new ArrayList<>();
    attributes.add("description");
    Dictionary properties = new Hashtable<>();
    properties.put("auditAttributes", attributes);
    config.update(properties);/*from  w  w w .  j a  v a 2s .  co m*/

    String logFilePath = System.getProperty("karaf.data") + "/log/security.log";

    File securityLog = new File(logFilePath);
    WaitCondition.expect("Securitylog exists").within(2, TimeUnit.MINUTES).checkEvery(2, TimeUnit.SECONDS)
            .until(securityLog::exists);

    WaitCondition.expect("Securitylog has log message: " + configUpdateMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileContent(securityLog).contains(configUpdateMessage));

    String id = ingestXmlFromResourceAndWait("metacard1.xml");

    update(id, getResourceAsString("metacard2.xml"), "text/xml");

    String expectedLogMessage = String.format(auditMessageFormat, "description", id, "My Description",
            "My Description (Updated)");
    WaitCondition.expect("Securitylog has log message: " + expectedLogMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileContent(securityLog).contains(expectedLogMessage));

    delete(id);
}

From source file:org.wso2.carbon.registry.servlet.internal.RegistryAtomServiceComponent.java

private void registerServlet() throws Exception {

    if (registryService == null) {
        String msg = "Unable to Register Servlet. Registry Service Not Found.";
        log.error(msg);/*from w  w w . j ava  2  s  .c o  m*/
        throw new Exception(msg);
    }

    if (!CarbonUtils.isRemoteRegistry()) {

        Dictionary servletParam = new Hashtable(2);
        servletParam.put("org.apache.abdera.protocol.server.Provider",
                "org.wso2.carbon.registry.app.RegistryProvider");
        httpService.registerServlet("/registry/atom", new AbderaServlet(), servletParam, defaultHttpContext);
        httpService.registerServlet("/registry/tags", new AbderaServlet(), servletParam, defaultHttpContext);
    }
    registerJUDDIServlet();
    httpService.registerServlet("/registry/resource", new ResourceServlet(), null, defaultHttpContext);
}

From source file:org.wso2.stratos.identity.saml2.sso.mgt.ui.internal.StratosSSOMgtUIServiceComponent.java

protected void activate(ComponentContext ctxt) {
    // register a servlet filter for SSO login page
    HttpServlet loginPageRedirectorServlet = new HttpServlet() {
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
        }//from w  w  w  .  jav a2  s  . c  om
    };

    Filter ssoLoginPageFilter = new SSOLoginPageFilter();
    Dictionary loginPageFilterAttrs = new Hashtable(2);
    Dictionary loginPageFilterParams = new Hashtable(2);
    loginPageFilterParams.put("url-pattern", "/carbon/sso-saml/login.jsp");
    loginPageFilterParams.put("associated-filter", ssoLoginPageFilter);
    loginPageFilterParams.put("servlet-attributes", loginPageFilterAttrs);
    ctxt.getBundleContext().registerService(Servlet.class.getName(), loginPageRedirectorServlet,
            loginPageFilterParams);

    HttpServlet redirectJSPRedirectorServlet = new HttpServlet() {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
        }
    };

    // register a servlet filter for SSO redirect page
    Filter redirectPageFilter = new SSORedirectPageFilter();
    Dictionary redirectorPageFilterAttrs = new Hashtable(2);
    Dictionary redirectorPageFilterParams = new Hashtable(2);
    redirectorPageFilterParams.put("url-pattern", "/carbon/sso-saml/redirect_ajaxprocessor.jsp");
    redirectorPageFilterParams.put("associated-filter", redirectPageFilter);
    redirectorPageFilterParams.put("servlet-attributes", redirectorPageFilterAttrs);
    ctxt.getBundleContext().registerService(Servlet.class.getName(), redirectJSPRedirectorServlet,
            redirectorPageFilterParams);

    // Read the config parameters from sso-idp-config.xml
    Util.populateLoginPageConfigParams();
}

From source file:org.apache.sling.datasource.DataSourceIT.java

@SuppressWarnings("unchecked")
@Test//from   ww  w .  j  a v a  2 s.  c  o m
public void testDataSourceAsService() throws Exception {
    Configuration config = ca.createFactoryConfiguration(PID, null);
    Dictionary<String, Object> p = new Hashtable<String, Object>();
    p.put("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
    p.put("datasource.name", "test");
    p.put("initialSize", "5");
    p.put("defaultAutoCommit", "default");
    p.put("defaultReadOnly", "false");
    p.put("datasource.svc.properties", new String[] { "initSQL=SELECT 1", });
    p.put("maxActive", 70);
    config.update(p);

    Filter filter = context.createFilter("(&(objectclass=javax.sql.DataSource)(datasource.name=test))");
    ServiceTracker<DataSource, DataSource> st = new ServiceTracker<DataSource, DataSource>(context, filter,
            null);
    st.open();

    DataSource ds = st.waitForService(10000);
    assertNotNull(ds);

    Connection conn = ds.getConnection();
    assertNotNull(conn);

    //Cannot access directly so access via reflection
    assertEquals("70", getProperty(ds, "poolProperties.maxActive"));
    assertEquals("5", getProperty(ds, "poolProperties.initialSize"));
    assertEquals("SELECT 1", getProperty(ds, "poolProperties.initSQL"));
    assertEquals("false", getProperty(ds, "poolProperties.defaultReadOnly"));
    assertNull(getProperty(ds, "poolProperties.defaultAutoCommit"));

    config = ca.listConfigurations("(datasource.name=test)")[0];
    Dictionary dic = config.getProperties();
    dic.put("defaultReadOnly", Boolean.TRUE);
    config.update(dic);

    TimeUnit.MILLISECONDS.sleep(100);
    assertEquals("true", getProperty(ds, "poolProperties.defaultReadOnly"));
}