Example usage for java.util Hashtable put

List of usage examples for java.util Hashtable put

Introduction

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

Prototype

public synchronized V put(K key, V value) 

Source Link

Document

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

Usage

From source file:org.keycloak.testsuite.federation.kerberos.AbstractKerberosTest.java

protected String invokeLdap(GSSCredential gssCredential, String username) throws NamingException {
    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:10389");

    if (gssCredential != null) {
        env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI");
        env.put(Sasl.CREDENTIALS, gssCredential);
    }/*from   www .j a  v  a  2 s.  co  m*/

    DirContext ctx = new InitialDirContext(env);
    try {
        Attributes attrs = ctx.getAttributes("uid=" + username + ",ou=People,dc=keycloak,dc=org");
        String cn = (String) attrs.get("cn").get();
        String sn = (String) attrs.get("sn").get();
        return cn + " " + sn;
    } finally {
        ctx.close();
    }
}

From source file:io.fabric8.agent.download.DownloadManagerTest.java

/**
 * Prepares DownloadManager to test//from   w  w  w  .j  a  va 2  s.c  om
 *
 * @param remoteRepo
 * @param settingsFile
 * @param props
 * @return
 * @throws IOException
 */
private DownloadManager createDownloadManager(String remoteRepo, String settingsFile, Properties props)
        throws IOException {
    File mavenSettings = new File(karafHome, settingsFile);
    Hashtable<String, String> properties = new Hashtable<>();
    if (props != null) {
        for (Map.Entry<Object, Object> entry : props.entrySet()) {
            properties.put(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    properties.put("org.ops4j.pax.url.mvn.localRepository", systemRepoUri);
    properties.put("org.ops4j.pax.url.mvn.repositories", remoteRepo);
    properties.put("org.ops4j.pax.url.mvn.defaultRepositories", systemRepoUri);
    properties.put("org.ops4j.pax.url.mvn.settings", mavenSettings.toURI().toString());

    MavenResolver resolver = MavenResolvers.createMavenResolver(properties, "org.ops4j.pax.url.mvn");
    return DownloadManagers.createDownloadManager(resolver, Executors.newSingleThreadScheduledExecutor());
}

From source file:org.openengsb.openticket.integrationtest.util.AbstractExamTestHelper.java

public void registerConfigPersistence(String backendId, String configurationId) throws ConfigurationException {
    ManagedServiceFactory factoryService = getOsgiService(ManagedServiceFactory.class,
            "(service.pid=org.openengsb.persistence.config)", 30000);
    Hashtable<String, Object> props = new Hashtable<String, Object>();
    String pid = "org.openengsb.persistence.config." + UUID.randomUUID();
    props.put("backend.id", backendId);
    props.put("configuration.id", configurationId);
    props.put("service.pid", pid);
    factoryService.updated(pid, props);//from  w  w w .  j  a  v a 2s . c  om
}

From source file:uk.ac.ed.portlets.almaportlet.service.AlmaReaderService.java

/**
 * Parse xml as a list of hash table which wraps library object
 * @param xml xml as string from the web service
 * @return a list of hash table which wraps library object
 *//*from   w  w w . j  a v a  2 s .  c om*/
public ArrayList<Hashtable<String, String>> parseXML(String xml) throws Exception {
    ArrayList<Hashtable<String, String>> list = new ArrayList<Hashtable<String, String>>();

    Document document = DocumentHelper.parseText(xml);
    Element root = document.getRootElement();

    for (Iterator i = root.elementIterator(); i.hasNext();) {
        Element parent = (Element) i.next();

        Hashtable<String, String> table = new Hashtable<String, String>();
        for (Iterator r = parent.elementIterator(); r.hasNext();) {
            Element child = (Element) r.next();
            table.put(child.getName(), child.getStringValue());
        }
        list.add(table);
    }
    logger.debug("parseXML --> " + list);
    return list;
}

From source file:SoundPlayer.java

void addMidiControls() {
    // Add a slider to control the tempo
    final JSlider tempo = new JSlider(50, 200);
    tempo.setValue((int) (sequencer.getTempoFactor() * 100));
    tempo.setBorder(new TitledBorder("Tempo Adjustment (%)"));
    java.util.Hashtable labels = new java.util.Hashtable();
    labels.put(new Integer(50), new JLabel("50%"));
    labels.put(new Integer(100), new JLabel("100%"));
    labels.put(new Integer(200), new JLabel("200%"));
    tempo.setLabelTable(labels);//from w w w.  j a v a  2 s  .c om
    tempo.setPaintLabels(true);
    // The event listener actually changes the tmpo
    tempo.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sequencer.setTempoFactor(tempo.getValue() / 100.0f);
        }
    });

    this.add(tempo);

    // Create rows of solo and checkboxes for each track
    Track[] tracks = sequence.getTracks();
    for (int i = 0; i < tracks.length; i++) {
        final int tracknum = i;
        // Two checkboxes per track
        final JCheckBox solo = new JCheckBox("solo");
        final JCheckBox mute = new JCheckBox("mute");
        // The listeners solo or mute the track
        solo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackSolo(tracknum, solo.isSelected());
            }
        });
        mute.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackMute(tracknum, mute.isSelected());
            }
        });

        // Build up a row
        Box box = Box.createHorizontalBox();
        box.add(new JLabel("Track " + tracknum));
        box.add(Box.createHorizontalStrut(10));
        box.add(solo);
        box.add(Box.createHorizontalStrut(10));
        box.add(mute);
        box.add(Box.createHorizontalGlue());
        // And add it to this component
        this.add(box);
    }
}

From source file:com.reversemind.hypergate.server.PayloadProcessor.java

private Hashtable getJndiProperties(Properties jndi) {
    Set set = jndi.keySet();/*from w w  w. j ava 2s .c o  m*/
    Hashtable localTable = new Hashtable();
    for (Object key : set) {
        localTable.put(key, jndi.get(key));
    }
    return localTable;
}

From source file:Controller.ControllerImage.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//from  w ww .  j a  v a2s . com
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (!isMultipart) {

    } else {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        List items = null;
        try {
            items = upload.parseRequest(request);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Iterator iter = items.iterator();
        Hashtable params = new Hashtable();
        String fileName = null;
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            if (item.isFormField()) {
                params.put(item.getFieldName(), item.getString());
            } else {

                try {
                    String itemName = item.getName();
                    fileName = itemName.substring(itemName.lastIndexOf("\\") + 1);
                    String RealPath = getServletContext().getRealPath("/") + "upload\\" + fileName;
                    String code = (String) params.get("txtCode");
                    String name = (String) params.get("txtName");
                    String price = (String) params.get("txtPrice");
                    int a = Integer.parseInt(price);
                    String image = (String) params.get("txtImage");
                    //Update  product
                    if (fileName.equals("")) {

                        Products sp = new Products();
                        sp.Update(code, name, price, image);
                        RequestDispatcher rd = request.getRequestDispatcher("product.jsp");
                        rd.forward(request, response);

                    } else {
                        // bat dau ghi file
                        File savedFile = new File(RealPath);
                        item.write(savedFile);
                        //ket thuc ghi
                        Products sp = new Products();
                        sp.Update(code, name, price, "upload\\" + fileName);

                        RequestDispatcher rd = request.getRequestDispatcher("product.jsp");
                        rd.forward(request, response);
                    }

                } catch (Exception e) {
                    RequestDispatcher rd = request.getRequestDispatcher("InformationError.jsp");
                    rd.forward(request, response);
                }
            }

        }
    }

    this.processRequest(request, response);

}

From source file:mesquite.chromaseq.AbiDownloaderImpl.AbiDownloaderImpl.java

private void conditionallyAddQueryArg(Hashtable args, String value, String queryKey) {
    if (!StringUtil.blank(value)) {
        args.put(queryKey, value);
    }// w w  w  . j  av  a  2s. co m
}

From source file:de.suse.swamp.core.util.BugzillaTools.java

/**
 * This method will return a HashMap with key= name of bugzilla xml element
 * value = value of the elements CDDATA.
 * additional values are "people", a SWAMPHashSet of people contained in the bug
 * "delta": Date of the last action in the bug
 * "description": String - the first comment
 *
 * @param bugid//from   w  w w . ja  va2 s  .co  m
 * @return
 * @throws Exception
 */
public Hashtable getBugData(int bugid, List excludeFields) throws Exception {

    /* Hashtable cacheBugData = getCacheEntry(bugid, excludeFields);
    if (cacheBugData != null) {
    Logger.LOG("Reading Bugzilla XML for bug #" + bugid + " from cache.", log);
    return cacheBugData;
    }
            
    String queryUrl = swamp.getProperty("BUGZILLA_QUERYURL") + bugid;
    queryUrl += "&excludefield=attachment";
    if (excludeFields != null && excludeFields.size() > 0){
    for (Iterator it = excludeFields.iterator(); it.hasNext(); ){
        queryUrl += "&excludefield=" + it.next();
    }
    }
    Logger.LOG("Reading Bugzilla XML for bug #" + bugid, log);
    try {
    xmlToData(queryUrl);
    if (bugData.get("assigned_to") == null) {
        Logger.ERROR("Bugzilla session not valid. Trying new login...");
        BugzillaTools.cookies = null;
        xmlToData(queryUrl);
    }
    } catch (Exception e) {
    if (e.getMessage().indexOf("NotPermitted") >= 0){
        Logger.ERROR("Bugzilla session not valid. Trying new login...");
        BugzillaTools.cookies = null;
        xmlToData(queryUrl);
    } else {
        throw e;
    }
    }
    bugData.put("excludefields", excludeFields);
    bugData.put("date", new Date());
    synchronized (bugzillaCache) {
    bugzillaCache.put(new Integer(bugid), bugData);
    }
    return bugData; */
    Hashtable h = new Hashtable();
    h.put("foo", "bar");
    return h;
}

From source file:com.microsoft.applicationinsights.test.framework.telemetries.RequestTelemetryItem.java

/**
 * Converts JSON object to Request TelemetryItem
 * @param json The JSON object//from   w  ww . j  ava  2  s  .co m
 */
private void initRequestTelemetryItem(JSONObject json) throws URISyntaxException, JSONException {
    System.out.println("Converting JSON object to RequestTelemetryItem");
    JSONObject requestProperties = json.getJSONArray("request").getJSONObject(0);

    String address = requestProperties.getString("url");
    Integer port = requestProperties.getJSONObject("urlData").getInt("port");
    Integer responseCode = requestProperties.getInt("responseCode");
    String requestName = requestProperties.getString("name");

    JSONArray parameters = requestProperties.getJSONObject("urlData").getJSONArray("queryParameters");
    Hashtable<String, String> queryParameters = new Hashtable<String, String>();
    for (int i = 0; i < parameters.length(); ++i) {
        JSONObject parameterPair = parameters.getJSONObject(i);
        String name = parameterPair.getString("parameter");
        String value = parameterPair.getString("value");
        queryParameters.put(name, value);
    }

    this.setProperty("uri", address);
    this.setProperty("port", port.toString());
    this.setProperty("responseCode", responseCode.toString());
    this.setProperty("requestName", requestName);

    for (String key : queryParameters.keySet()) {
        this.setProperty("queryParameter." + key, queryParameters.get(key));
    }
}