/** * Return a list of all the images stored in this RMS * * @param recordStore */ public static Vector getImageList(String recordStore) { Log.debug("Getting Image list store name=[" + recordStore + "]"); RecordStore imagesRS = null; Vector v = new Vector(); try { imagesRS = RecordStore.openRecordStore(recordStore, true); RecordEnumeration re = imagesRS.enumerateRecords(null, null, true); if (re != null) { Log.debug("ImageRMSUtils: Record Enumeration was not null "); int numRecs = re.numRecords(); // For each record for (int i = 0; i < numRecs; i++) { // Get the next record's ID int recId = re.nextRecordId(); // throws // InvalidRecordIDException // Get the record Log.debug("Got a record"); byte[] rec = imagesRS.getRecord(recId); ByteArrayInputStream bin = new ByteArrayInputStream(rec); DataInputStream din = new DataInputStream(bin); v.addElement(din.readUTF()); bin.close(); } } else { Log.error("ImageRMSUtils Exception Record Enumeration was null "); } Log.debug("Retrieved " + v.size() + " images from RMS"); } catch (InvalidRecordIDException ignore) { Log.error("RecordId Exception " + ignore.getMessage()); } catch (Exception e) { Log.error("ImageRMSUtils Exception " + e.getMessage()); } finally { try { // Close the Record Store if (imagesRS != null) imagesRS.closeRecordStore(); } catch (Exception ignore) { // Ignore } } return v; }
public Vector search(String query, int page) throws Exception { try { SearchResultsParser parser = new SearchResultsParser(); String url = SEARCH_URL + StringUtil.urlEncode(query) + "&page=" + page; Log.debug("URL: " + url); HttpUtil.doPost(url, parser); Vector statuses = parser.getStatuses(); return statuses; } catch (Exception ex) { throw new Exception("Error while searching tweets: " + ex.getMessage()); } }