public static void viewTagInfo(String inurl, String tag) throws Exception { // pr = new PrintStream(new FileOutputStream("/semplest/lluis/keywordExp/urldata.txt")); pr = System.out; long start = System.currentTimeMillis(); pr.println(inurl + "****************************************************************"); printList(cleanUrlText(TextUtils.HTMLText(inurl, tag))); String urls = TextUtils.HTMLLinkString(inurl, inurl); String[] url = urls.split("\\s+"); Set<String> urlMap = new HashSet<String>(url.length); urlMap.add(inurl); for (String ur : url) { if (!urlMap.contains(ur)) { pr.println(ur + "***************************************************************"); try { printList(cleanUrlText(TextUtils.HTMLText(ur, tag))); } catch (Exception e) { System.out.println("Error with url :" + ur); e.printStackTrace(); logger.error("Problem", e); } urlMap.add(ur); } } pr.println("Time elapsed" + (start - System.currentTimeMillis())); }
public static void recordData(String inurl) throws Exception { // pr = new PrintStream(new FileOutputStream("http://en.wikipedia.org/wiki/HAProxy")); pr = System.out; long start = System.currentTimeMillis(); pr.println(inurl + "****************************************************************"); printList(cleanUrlText(TextUtils.HTMLText(inurl))); String urls = TextUtils.HTMLLinkString(inurl, inurl); String[] url = urls.split("\\s+"); HashSet<String> urlMap = new HashSet<String>(url.length); urlMap.add(inurl); for (String ur : url) { /* * if(!urlMap.contains(ur)){ pr.println(ur+"***************************************************************"); try{ * printList(cleanUrlText(TextUtils.HTMLText(ur))); }catch(Exception e){ System.out.println("Error with url :"+ ur); e.printStackTrace(); } * urlMap.add(ur); } */ } pr.println("Time elapsed" + (start - System.currentTimeMillis())); pr.close(); }
public static Contribution fromCursor(Cursor cursor) { // Hardcoding column positions! Contribution c = new Contribution(); c.contentUri = ContributionsContentProvider.uriForId(cursor.getInt(0)); c.filename = cursor.getString(1); c.localUri = TextUtils.isEmpty(cursor.getString(2)) ? null : Uri.parse(cursor.getString(2)); c.imageUrl = cursor.getString(3); c.timestamp = cursor.getLong(4) == 0 ? null : new Date(cursor.getLong(4)); c.state = cursor.getInt(5); c.dataLength = cursor.getLong(6); c.dateUploaded = cursor.getLong(7) == 0 ? null : new Date(cursor.getLong(7)); c.transferred = cursor.getLong(8); c.source = cursor.getString(9); c.description = cursor.getString(10); c.creator = cursor.getString(11); c.isMultiple = cursor.getInt(12) == 1; return c; }
public void doRequest(int type) { switch (type) { case REQUEST_SESSION: { String time = new Long(new Date().getTime()).toString(); String timestamp = time.substring(0, time.length() - 3); String postParam = "application_id=" + PUSH_APP_ID + "&auth_key=" + PUSH_AUTH_KEY + "&nonce=" + nonce + "×tamp=" + timestamp; String signature = ""; try { signature = QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); break; } JSONObject postObject = new JSONObject(); try { postObject.put("application_id", PUSH_APP_ID); postObject.put("auth_key", PUSH_AUTH_KEY); postObject.put("nonce", nonce); postObject.put("timestamp", timestamp); postObject.put("signature", signature); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); } BigVector postData = new BigVector(); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "session.json", postData, type, this); break; } case REQUEST_SIGN_UP_USER: { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); JSONObject credentialsObject = new JSONObject(); JSONObject postObject = new JSONObject(); try { credentialsObject.put("login", pin); credentialsObject.put("password", TextUtils.reverse(pin)); postObject.put("user", credentialsObject); } catch (Exception ex) { } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); DebugStorage.getInstance().Log(0, "Post data: " + postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "users.json", postData, type, this); break; } case REQUEST_SESSION_WITH_USER_AND_DEVICE_PARAMS: { JSONObject postObject = new JSONObject(); JSONObject userObject = new JSONObject(); JSONObject deviceObject = new JSONObject(); try { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); String postParam = "application_id=" + PUSH_APP_ID + "&auth_key=" + PUSH_AUTH_KEY + "&device[platform]=" + "blackberry" + "&device[udid]=" + pin + "&nonce=" + nonce + "×tamp=" + timestamp + "&user[login]=" + pin + "&user[password]=" + TextUtils.reverse(pin); String signature = ""; try { signature = QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam); } catch (Exception ex) { System.out.println("QBUtils.hmacsha1(PUSH_AUTH_SECRET, postParam) exception = " + ex); } postObject.put("application_id", PUSH_APP_ID); postObject.put("auth_key", PUSH_AUTH_KEY); postObject.put("timestamp", timestamp); postObject.put("nonce", nonce); postObject.put("signature", signature); userObject.put("login", pin); userObject.put("password", TextUtils.reverse(pin)); postObject.put("user", userObject); deviceObject.put("platform", "blackberry"); deviceObject.put("udid", pin); postObject.put("device", deviceObject); } catch (Exception ex) { DebugStorage.getInstance().Log(0, "<PushAuthScreen> doRequest REQUEST_SESSION ", ex); onClose(); } BigVector postData = new BigVector(); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager(POST, PUSH_SERVER_API + "session.json", postData, type, this); break; } case REQUEST_PUSH_TOKEN: { String pin = Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase(); JSONObject credentialsObject = new JSONObject(); JSONObject postObject = new JSONObject(); try { // credentialsObject.put("environment", "production"); credentialsObject.put("environment", "development"); credentialsObject.put("client_identification_sequence", pin); postObject.put("push_token", credentialsObject); } catch (Exception ex) { System.out.println("-----<doRequest><REQUEST_PUSH_TOKEN> Exception = " + ex); } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager( POST, PUSH_SERVER_API + "push_tokens.json", postData, type, this); break; } // REQUEST_PUSH_SUBSCRIBE case REQUEST_PUSH_SUBSCRIBE: { System.out.println("-----<doRequest><REQUEST_PUSH_SUBSCRIBE>"); JSONObject postObject = new JSONObject(); try { postObject.put("notification_channels", "bbps"); } catch (Exception ex) { System.out.println("-----<doRequest><REQUEST_PUSH_SUBSCRIBE> Exception = " + ex); } BigVector postData = new BigVector(); postData.addElement(TOKEN); postData.addElement(postObject.toString()); QBHTTPConnManager man = new QBHTTPConnManager( POST, PUSH_SERVER_API + "subscriptions.json", postData, type, this); break; } default: break; } }