Example usage for java.util HashMap clear

List of usage examples for java.util HashMap clear

Introduction

In this page you can find the example usage for java.util HashMap clear.

Prototype

public void clear() 

Source Link

Document

Removes all of the mappings from this map.

Usage

From source file:org.geefive.salesforce.soqleditor.SOQLQueryEngine.java

private Vector<HashMap<String, String>> hashObj(JSONObject results, HashMap<String, String> newRow,
        Vector<HashMap<String, String>> newRows, String object) throws JSONException {
    Iterator keys = results.keys();
    while (keys.hasNext()) {
        String column = (String) keys.next();
        if (results.get(column).getClass().equals(JSONObject.class) && !column.equalsIgnoreCase("attributes")) {
            if (results.getJSONObject(column).has("records")) {
                //its a many child json object treat  accordingly
                newRows = getResults(results.getJSONObject(column).getJSONArray("records"),
                        new HashMap<String, String>(newRow), newRows, column);
                //get rid of parent row.. only keep the children
                newRow.clear();

            } else {
                hashObj(results.getJSONObject(column), newRow, new Vector<HashMap<String, String>>(), column);
            }/*from www. j  a v  a2s.  c o m*/
        } else if (!column.equalsIgnoreCase("attributes")) {
            String pre = object.equals("") ? "" : object + ".";
            String columnValue = results.getString(column);
            newRow.put(pre + column, columnValue);
        }
    }
    if (!newRow.isEmpty())
        newRows.add(newRow);
    return newRows;
}

From source file:io.pravega.segmentstore.server.host.ZKSegmentContainerMonitorTest.java

@Test
public void testShutdownNotYetStartedContainer() throws Exception {
    @Cleanup//from  ww w  . j a v a  2 s .c  o m
    CuratorFramework zkClient = startClient();
    initializeHostContainerMapping(zkClient);

    SegmentContainerRegistry containerRegistry = createMockContainerRegistry();
    @Cleanup
    ZKSegmentContainerMonitor segMonitor = createContainerMonitor(containerRegistry, zkClient);
    segMonitor.initialize(Duration.ofSeconds(1));

    // Simulate a container that takes a long time to start. Should be greater than a few monitor loops.
    ContainerHandle containerHandle = mock(ContainerHandle.class);
    when(containerHandle.getContainerId()).thenReturn(2);
    CompletableFuture<ContainerHandle> startupFuture = FutureHelpers
            .delayedFuture(() -> CompletableFuture.completedFuture(containerHandle), 3000, executorService());
    when(containerRegistry.startContainer(eq(2), any())).thenReturn(startupFuture);

    // Use ZK to send that information to the Container Manager.
    HashMap<Host, Set<Integer>> currentData = deserialize(zkClient, PATH);
    currentData.put(PRAVEGA_SERVICE_ENDPOINT, Collections.singleton(2));
    zkClient.setData().forPath(PATH, SerializationUtils.serialize(currentData));

    // Verify it's not yet started.
    verify(containerRegistry, timeout(1000).atLeastOnce()).startContainer(eq(2), any());
    assertEquals(0, segMonitor.getRegisteredContainers().size());

    // Now simulate shutting it down.
    when(containerRegistry.stopContainer(any(), any())).thenReturn(CompletableFuture.completedFuture(null));

    currentData.clear();
    zkClient.setData().forPath(PATH, SerializationUtils.serialize(currentData));

    verify(containerRegistry, timeout(10000).atLeastOnce()).stopContainer(any(), any());
    Thread.sleep(2000);
    assertEquals(0, segMonitor.getRegisteredContainers().size());
}

From source file:gov.utah.dts.sdc.actions.LoginAction.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public String execute() {
    log.info("LoginAction execute...");
    PersonService service = new PersonService();

    HashMap<String, String> map = new HashMap<String, String>();
    map.put("dn", (String) getSession().get(Constants.USER_DN));
    Integer cnt = new Integer(0);

    try {/*w  w  w .  ja  v  a2 s .c  o m*/
        log.info("LoginAction searching " + map.get("dn"));
        if (map.get("dn") != null) {
            cnt = service.getEqualsCount(map);
            log.debug("step 2");
        }
        if (cnt.intValue() == 1) {
            /*Match found containing authenticated users DN
             *forward to the success page.
             */
            List list = service.searchEquals(map);
            log.info("LoginAction (DN) Match Found " + list.size());
            Person person = (Person) list.get(0);
            getSession().put(Constants.USER_KEY, person);
        } else {
            map.clear();
            if (getSession().get(Constants.USER_EMAIL) != null) {
                map.put("email", getSession().get(Constants.USER_EMAIL).toString().toUpperCase());
                cnt = service.getEqualsCount(map);
            }

            if (cnt.intValue() == 1) {
                /*A email match was found in the DB for further
                 *identificaiton purposes forward to the registration
                 *page and request additional information
                 */
                List list = service.searchEquals(map);
                log.info("LoginAction (Email) match Found " + list.size());
                Person person = (Person) list.get(0);
                person = setUMDValues(person);
                getSession().put(Constants.USER_KEY, person);
                return Constants.REGISTER_MERGE;
            } else if (cnt.intValue() < 1) {
                log.info("No match found ");
                Person person = setUMDValues();
                getSession().put(Constants.USER_KEY, person);
                return Constants.REGISTER;
            }
        }
    } catch (Exception e) {
        log.error("ERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR", e);
        e.printStackTrace();
        addActionError(e.getMessage());
    }

    if (hasErrors()) {
        return ERROR;
    } else {
        return SUCCESS;
    }
}

From source file:edu.ku.brc.specify.toycode.RegAdder.java

/**
 * @param dataFileName// w w  w  .ja va 2s . co m
 * @param dbName
 * @param doClear
 */
public void process(final String dataFileName, final String dbName, final boolean doClear) {
    File file = new File(dataFileName);
    BufferedReader reader = null;

    boolean isReg = dbName.startsWith("reg");

    if (doClear) {
        if (isReg) {
            BasicSQLUtils.deleteAllRecordsFromTable("register", BasicSQLUtils.SERVERTYPE.MySQL);
            BasicSQLUtils.deleteAllRecordsFromTable("registeritem", BasicSQLUtils.SERVERTYPE.MySQL);
        } else {
            BasicSQLUtils.deleteAllRecordsFromTable("track", BasicSQLUtils.SERVERTYPE.MySQL);
            BasicSQLUtils.deleteAllRecordsFromTable("trackitem", BasicSQLUtils.SERVERTYPE.MySQL);
        }
    }

    try {
        reader = new BufferedReader(new FileReader(file));
        String text = null;

        HashMap<String, String> mappedValues = new HashMap<String, String>();

        // repeat until all lines is read
        while ((text = reader.readLine()) != null) {
            if (text.startsWith("-----------")) {
                if (isReg) {
                    insertReg(mappedValues);
                } else {
                    insertTrack(mappedValues);
                }
                mappedValues.clear();
                continue;
            }

            if (StringUtils.isNotEmpty(text)) {
                String[] pair = StringUtils.split(text, "=");
                if (pair.length == 2) {
                    mappedValues.put(pair[0].trim(), pair[1].trim());

                } else if (pair.length == 1) {
                    //mappedValues.put(pair[0], "");
                } else {
                    System.err.println("Error pairs " + pair.length + " [" + text + "]");
                }
            }
            lineNo++;
        }

        System.out.println("Cnt: " + cnt);

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (stmt != null)
                stmt.close();
            if (trkStmt1 != null)
                trkStmt1.close();
            if (trkStmt2 != null)
                trkStmt2.close();
            if (trkStmt3 != null)
                trkStmt3.close();
            if (trkStmt4 != null)
                trkStmt4.close();
            if (regStmt1 != null)
                regStmt1.close();
            if (regStmt2 != null)
                regStmt2.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }

        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:edu.ku.brc.web.ParsePaleo.java

/**
 * //  w ww .j  ava2 s .c  om
 */
private void buildTaxonTree() {
    try {
        Connection conn = dbConn.getConnection();

        int rootRecId = -1;
        taxonInsertStmt.setString(1, "Root");
        taxonInsertStmt.setString(2, null);
        taxonInsertStmt.setInt(3, 0); // ParentID
        taxonInsertStmt.setInt(4, 0); // RankID
        int rv = taxonInsertStmt.executeUpdate();
        if (rv == 1) {
            Integer recId = BasicSQLUtils.getInsertedId(taxonInsertStmt);
            if (recId != null) {
                rootRecId = recId;
            }
        }
        if (rootRecId == -1) {
            throw new RuntimeException("Bad Root Taxon Node.");
        }

        rootNode = new TreeNode(rootRecId, "Root", 0, 0, null);

        Statement stmt = conn.createStatement();

        HashMap<String, String> values = new HashMap<String, String>();
        String sql = "SELECT p.ID FROM wp_xuub_posts p where p.post_type LIKE '%_page'";
        Vector<Integer> ids = BasicSQLUtils.queryForInts(sql);
        for (int recId : ids) {
            values.clear();
            sql = String.format(
                    "SELECT pm.meta_key, pm.meta_value FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE ID = %d AND (NOT (pm.meta_key LIKE '\\_%c'))",
                    recId, '%');
            Vector<Object[]> data = BasicSQLUtils.query(sql);
            for (Object[] row : data) {
                if (row[1] != null) {
                    values.put(row[0].toString(), row[1].toString());
                }
            }

            System.out.println(values);
            if (values.size() == 0) {
                System.out.println(sql);
                continue;
            }

            String phylum = values.get("phylum");
            String clazz = values.get("class");
            String family = values.get("family");
            String genus = values.get("genus");
            String species = values.get("species");
            String common = values.get("common_name");

            String[] names = { phylum, clazz, family, genus, species };
            int[] ranks = { 30, 60, 140, 180, 220 };

            int len = 0;
            while (len < names.length && names[len] != null) {
                len++;
            }
            buildTree(rootNode, names, ranks, 0, common, len);
        }
        stmt.close();

        dbS3Conn.commit();

        System.out.println("Done with taxon tree.");

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:fr.paris.lutece.plugins.calendar.service.AgendaSubscriberService.java

/**
 * Notify the subscription//from   w  w  w . ja  v a 2  s  . c  om
 * @param agenda The agenda
 * @param request HttpServletRequest
 * @param plugin The plugin
 * @throws SiteMessageException site message exception
 */
public void doNotificationSubscription(AgendaResource agenda, HttpServletRequest request, Plugin plugin)
        throws SiteMessageException {
    String strEmail = request.getParameter(Constants.PARAMETER_EMAIL);

    CalendarNotification calendarNotification = new CalendarNotification();
    //Generate key
    UUID key = java.util.UUID.randomUUID();
    calendarNotification.setKey(key.toString());
    calendarNotification.setEmail(strEmail);
    calendarNotification.setIdAgenda(Integer.parseInt(agenda.getId()));
    Calendar calendar = GregorianCalendar.getInstance();
    if (agenda.isNotify()) {
        calendar.add(Calendar.DAY_OF_MONTH, agenda.getPeriodValidity());
    } else {
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
    calendarNotification.setDateExpiry(new Timestamp(calendar.getTimeInMillis()));
    CalendarNotificationHome.create(calendarNotification, plugin);
    if (agenda.isNotify()) {
        String strSenderName = AppPropertiesService.getProperty(PROPERTY_SENDER_NAME);
        String strSenderEmail = AppPropertiesService.getProperty(PROPERTY_SENDER_EMAIL);
        String strObject = I18nService.getLocalizedString(PROPERTY_SUBSCRIBE_HTML_OBJECT, request.getLocale());

        String strBaseUrl = AppPathService.getBaseUrl(request) + URL_JSP_SUBSCRIPTION_NOTIFICATION;
        UrlItem url = new UrlItem(strBaseUrl);
        url.addParameter(Constants.MARK_KEY, key.toString());

        String strlink = I18nService.getLocalizedString(PROPERTY_SUBSCRIBE_HTML_LINK, request.getLocale());
        String strMessage = I18nService.getLocalizedString(PROPERTY_SUBSCRIBE_HTML_MESSAGE,
                request.getLocale());
        String linkHtml = HTML_LINK_OPEN_1 + url.getUrl() + HTML_LINK_OPEN_2 + strlink + HTML_LINK_CLOSE;

        HashMap<String, String> emailModel = new HashMap<String, String>();
        emailModel.put(MARK_MESSAGE, strMessage);
        emailModel.put(MARK_LINK, linkHtml);

        HtmlTemplate templateAgenda = AppTemplateService.getTemplate(TEMPLATE_NOTIFY_SUBSCRIPTION_MAIL,
                request.getLocale(), emailModel);
        String strEmailCode = templateAgenda.getHtml();

        MailService.sendMailHtml(strEmail, strSenderName, strSenderEmail, strObject, strEmailCode);
        emailModel.clear();

        SiteMessageService.setMessage(request, PROPERTY_SUBSCRIPTION_MAIL_SEND_ALERT_MESSAGE,
                PROPERTY_SUBSCRIPTION_MAIL_SEND_TITLE_MESSAGE, SiteMessage.TYPE_INFO);
    } else {
        ServletConfig config = LocalVariables.getConfig();
        HttpServletResponse response = LocalVariables.getResponse();
        try {
            String strAdresse = URL_JSP_SUBSCRIPTION_REDIRECTION + Constants.INTERROGATION_MARK
                    + Constants.MARK_KEY + Constants.EQUAL + key;
            response.sendRedirect(strAdresse);
        } catch (Exception e) {
            SiteMessageService.setMessage(request, PROPERTY_REDIRECTION_TITLE_MESSAGE,
                    PROPERTY_REDIRECTION_ALERT_MESSAGE, SiteMessage.TYPE_INFO);
        }
        LocalVariables.setLocal(config, request, response);
    }
}

From source file:com.google.gwt.emultest.java.util.HashMapTest.java

public void testClear() {
    HashMap<String, String> hashMap = new HashMap<String, String>();
    checkEmptyHashMapAssumptions(hashMap);

    hashMap.put("Hello", "Bye");
    assertFalse(hashMap.isEmpty());/*from   w  ww. j a v a2  s  .c  o  m*/
    assertTrue(hashMap.size() == SIZE_ONE);

    hashMap.clear();
    assertTrue(hashMap.isEmpty());
    assertTrue(hashMap.size() == 0);
}

From source file:edu.ku.brc.web.ParsePaleo.java

/**
 * /*from  w ww.  ja va  2  s . c  o  m*/
 */
private void process() {

    Pattern p = Pattern.compile("\"([^\"]*)\"");

    try {
        pw = new PrintWriter("filedownload.sh");

        Connection conn = dbConn.getConnection();

        createStrats();
        createAges();

        String pStr = "INSERT INTO data (citation, georange, paleodist, remarks, taxonId) VALUES(?,?,?,?,?)";
        PreparedStatement pStmt = dbS3Conn.prepareStatement(pStr, Statement.RETURN_GENERATED_KEYS);

        String pStrStrat = "INSERT INTO data_strat (dataId, stratId, formation) VALUES(?,?,?)";
        PreparedStatement pStmtStrat = dbS3Conn.prepareStatement(pStrStrat);

        String pStrAges = "INSERT INTO data_ages (dataId, stratId) VALUES(?,?)";
        PreparedStatement pStmtAges = dbS3Conn.prepareStatement(pStrAges);

        String pStrAttach = "INSERT INTO attach (imgname, url, caption, type) VALUES(?,?,?,?)";
        PreparedStatement pStmtAttach = dbS3Conn.prepareStatement(pStrAttach);

        String pStrTaxonAttach = "INSERT INTO taxon_attach (taxonId, attachId) VALUES(?,?)";
        PreparedStatement pStmtTaxonAttach = dbS3Conn.prepareStatement(pStrTaxonAttach);

        Statement stmt = conn.createStatement();
        Statement stmt2 = conn.createStatement();

        HashMap<String, String> values = new HashMap<String, String>();
        String sql = "SELECT p.ID FROM wp_xuub_posts p where p.post_type LIKE '%_page'";
        Vector<Integer> ids = BasicSQLUtils.queryForInts(sql);
        for (int recId : ids) {
            values.clear();
            sql = String.format(
                    "SELECT pm.meta_key, pm.meta_value FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE ID = %d AND (NOT (pm.meta_key LIKE '\\_%c'))",
                    recId, '%');
            Vector<Object[]> data = BasicSQLUtils.query(sql);
            for (Object[] row : data) {
                if (row[1] != null) {
                    values.put(row[0].toString(), row[1].toString());
                }
            }

            System.out.println(values);
            if (values.size() == 0) {
                System.out.println(sql);
                continue;
            }

            String phylum = values.get("phylum");
            String clazz = values.get("class");
            String family = values.get("family");
            String genus = values.get("genus");
            String species = values.get("species");
            String[] names = { phylum, clazz, family, genus, species };
            int len = 0;
            while (len < names.length && names[len] != null) {
                len++;
            }
            TreeNode node = getTreeNode(rootNode, names, 0, len);
            if (node == null) {
                node = getTreeNode(rootNode, names, 0, len);
                throw new RuntimeException("Could find tree node" + names);
            }

            int i = 1;
            pStmt.setString(i++, getStrValue(values, "cite", recId));
            pStmt.setString(i++, getStrValue(values, "geo_range", recId));
            pStmt.setString(i++, getStrValue(values, "paleo_dist", recId));
            pStmt.setString(i++, getStrValue(values, "remarks", recId));
            pStmt.setInt(i++, node.recId);

            if (pStmt.executeUpdate() == 0) {
                System.err.println("Error inserting record.");
            }

            Integer dataId = BasicSQLUtils.getInsertedId(pStmt);

            String agesStr = values.get("ages");
            if (isNotEmpty(agesStr)) {
                Matcher m = p.matcher(agesStr);

                while (m.find()) {
                    String age = replace(m.group(), "\"", "");
                    Integer stratId = ages.get(age);
                    if (stratId == null) {
                        System.out.println(String.format("[%s][%s]", m.group(), age));
                        stratId = 0;
                    }

                    pStmtAges.setInt(1, dataId);
                    pStmtAges.setInt(2, stratId);
                    if (pStmtAges.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }
                }
            }

            int index = 0;
            for (String stratKey : stratKeys) {
                String stratStr = values.get(stratKey);
                if (isNotEmpty(stratStr) && index > 0) {
                    Matcher m = p.matcher(stratStr);
                    while (m.find()) {
                        String strat = replace(m.group(), "\"", "");
                        pStmtStrat.setInt(1, dataId);
                        pStmtStrat.setInt(2, index);
                        pStmtStrat.setString(3, strat);
                        if (pStmtStrat.executeUpdate() == 0) {
                            System.err.println("Error inserting record.");
                        }
                    }
                }
                index++;
            }

            sql = String.format(
                    "SELECT p.ID, post_title, p.post_name, p.post_type, pm.meta_value FROM wp_xuub_posts p "
                            + "INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id "
                            + "WHERE post_parent = %d AND post_type = 'attachment' AND NOT (pm.meta_value LIKE 'a:%c')",
                    recId, '%', '%');
            System.out.println(sql);
            ResultSet rsId = stmt2.executeQuery(sql);
            while (rsId.next()) {
                int pId = rsId.getInt(1);
                String title = rsId.getString(2);
                if (title.contains("2000px"))
                    continue;

                sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = "
                        + pId;
                ResultSet rs = stmt.executeQuery(sql);
                while (rs.next()) {
                    String fileName = rs.getString(3);
                    String url = rs.getString(4);

                    if (fileName.contains("Early") || fileName.contains("Middle")
                            || fileName.contains("Late")) {
                        continue;
                    }

                    String path = "/Users/rods/Documents/XCodeProjects/DigitalAtlasAcientLife/DigitalAtlasAcientLife/Resources/images/"
                            + fileName;
                    File file = new File(path);
                    if (!file.exists()) {
                        pw.println(String.format("curl %s > %s", url, fileName));
                    }

                    //String captKey = String.format("%s_%dc", nm, j);
                    //String captVal = values.get(captKey);

                    pStmtAttach.setString(1, fileName);
                    pStmtAttach.setString(2, url);
                    pStmtAttach.setString(3, "");
                    pStmtAttach.setInt(4, 0); // Type

                    if (pStmtAttach.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }

                    Integer attachId = BasicSQLUtils.getInsertedId(pStmtAttach);
                    if (attachId == null) {
                        throw new RuntimeException("Error saving attachment record.");
                    }

                    pStmtTaxonAttach.setInt(1, node.recId);
                    pStmtTaxonAttach.setInt(2, attachId);
                    if (pStmtTaxonAttach.executeUpdate() == 0) {
                        System.err.println("Error inserting record.");
                    }
                }
                rs.close();
            }
            rsId.close();

            /*
            for (int k=0;k<1;k++)
            {
            String nm = k == 0 ? "photo" : "map";
            for (int j=1;j<9;j++)
            {
                String key = String.format("%s_%dd", nm, j);
                String val = values.get(key);
                if (isNotEmpty(val))
                {
                    System.out.println(String.format("%d [%s][%s]", recId, val, key));
                            
                    sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = " + val;
                    ResultSet rs   = stmt.executeQuery(sql);
                    while (rs.next())
                    {
                        //int    pId      = rs.getInt(1);
                        //String title    = rs.getString(2);
                        String fileName = rs.getString(3);
                        String url      = rs.getString(4);
                                
                        pw.println(String.format("curl %s > %s", url, fileName));
                                
                        String captKey = String.format("%s_%dc", nm, j);
                        String captVal = values.get(captKey);
                                
                        pStmtAttach.setString(1, fileName);
                        pStmtAttach.setString(2, url);
                        pStmtAttach.setString(3, k == 0 ? captVal : "");
                        pStmtAttach.setInt(4, k); // Type
                                
                        if (pStmtAttach.executeUpdate() == 0)
                        {
                            System.err.println("Error inserting record.");
                        }
                                
                        Integer attachId = BasicSQLUtils.getInsertedId(pStmtAttach);
                        if (attachId == null)
                        {
                            throw new RuntimeException("Error saving attachment record.");
                        }
                                
                        pStmtTaxonAttach.setInt(1, node.recId);
                        pStmtTaxonAttach.setInt(2, attachId);
                        if (pStmtTaxonAttach.executeUpdate() == 0)
                        {
                            System.err.println("Error inserting record.");
                        }
                    }
                }
            }
            }*/

            // a:5:{s:5:"width";i:3300;s:6:"height";i:2550;s:4:"file";s:38:"Polygona_maxwelli_EarlyPleistocene.jpg";s:5:"sizes";
            //  a:2:{s:9:"thumbnail";
            //   a:4:{s:4:"file";s:46:"Polygona_maxwelli_EarlyPleistocene-250x250.jpg";s:5:"width";i:250;s:6:"height";i:250;s:9:"mime-type";s:10:"image/jpeg";}
            // s:6:"medium";a:4:{s:4:"file";s:48:"Polygona_maxwelli_EarlyPleistocene-2000x1545.jpg";s:5:"width";i:2000;s:6:"height";i:1545;s:9:"mime-type";s:10:"image/jpeg";}}
            //s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}}
            //                sql = "SELECT p.ID, p.post_title, pm.meta_value, p.guid FROM wp_xuub_posts p " +
            //                     "INNER JOIN wp_xuub_postmeta pm ON p.ID = pm.post_id WHERE pm.meta_key = '_wp_attached_file' AND p.ID = " + recId;
            //                ResultSet rs   = stmt.executeQuery(sql);
            //                while (rs.next())
            //                {
            //                    int    pId      = rs.getInt(1);
            //                    String title    = rs.getString(2);
            //                    String fileName = rs.getString(3);
            //                    String url      = rs.getString(4);
            //                }

        }
        dbS3Conn.commit();

        //recurseForAttachments(pStmtTaxonAttach, rootNode);

        stmt.close();
        stmt2.close();
        pStmt.close();
        pStmtStrat.close();
        pStmtAges.close();
        pStmtAttach.close();
        pStmtTaxonAttach.close();
        stmt.close();

        dbS3Conn.commit();

        pw.close();

        System.out.println("Done");

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:ws.wamp.jawampa.client.SessionEstablishedState.java

void clearAllSubscriptions(Throwable e) {
    for (HashMap<String, SubscriptionMapEntry> subscriptionByUri : subscriptionsByFlags.values()) {
        for (Entry<String, SubscriptionMapEntry> entry : subscriptionByUri.entrySet()) {
            for (Subscriber<? super PubSubData> s : entry.getValue().subscribers) {
                if (e == null)
                    s.onCompleted();//from w w w.  j ava 2s .  c  o  m
                else
                    s.onError(e);
            }
            entry.getValue().state = PubSubState.Unsubscribed;
        }
        subscriptionByUri.clear();
    }
    subscriptionsBySubscriptionId.clear();
}

From source file:helma.servlet.AbstractServletClient.java

protected void parseParameters(HttpServletRequest request, RequestTrans reqtrans, String encoding)
        throws IOException {
    // check if there are any parameters before we get started
    String queryString = request.getQueryString();
    String contentType = request.getContentType();
    boolean isFormPost = "post".equals(request.getMethod().toLowerCase()) && contentType != null
            && contentType.toLowerCase().startsWith("application/x-www-form-urlencoded");

    if (queryString == null && !isFormPost) {
        return;/*from   w  w  w  .  j  av a 2s .c om*/
    }

    HashMap parameters = new HashMap();

    // Parse any query string parameters from the request
    if (queryString != null) {
        parseParameters(parameters, queryString.getBytes(), encoding, false);
        if (!parameters.isEmpty()) {
            reqtrans.setParameters(parameters, false);
            parameters.clear();
        }
    }

    // Parse any posted parameters in the input stream
    if (isFormPost) {
        int max = request.getContentLength();
        if (max > totalUploadLimit * 1024) {
            throw new IOException("Exceeded Upload limit");
        }
        int len = 0;
        byte[] buf = new byte[max];
        ServletInputStream is = request.getInputStream();

        while (len < max) {
            int next = is.read(buf, len, max - len);

            if (next < 0) {
                break;
            }

            len += next;
        }

        // is.close();
        parseParameters(parameters, buf, encoding, true);
        if (!parameters.isEmpty()) {
            reqtrans.setParameters(parameters, true);
            parameters.clear();
        }
    }
}