List of usage examples for java.net URLEncoder encode
@Deprecated public static String encode(String s)
From source file:com.micromux.cassandra.jdbc.SpashScreenTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { // configure OPTIONS if (!StringUtils.isEmpty(TRUST_STORE)) { OPTIONS = String.format("trustStore=%s&trustPass=%s", URLEncoder.encode(TRUST_STORE), TRUST_PASS); }/*from w w w . j a va2s . c om*/ Class.forName("com.micromux.cassandra.jdbc.CassandraDriver"); con = DriverManager.getConnection( String.format("jdbc:cassandra://%s:%d/%s?%s&version=3.0.0", HOST, PORT, "system", OPTIONS)); Statement stmt = con.createStatement(); // Drop Keyspace String dropKS = String.format("DROP KEYSPACE %s;", KEYSPACE); try { stmt.execute(dropKS); } catch (Exception e) { /* Exception on DROP is OK */} // Create KeySpace String createKS = String.format( "CREATE KEYSPACE \"%s\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};", KEYSPACE); stmt = con.createStatement(); stmt.execute(createKS); // Use Keyspace String useKS = String.format("USE %s;", KEYSPACE); stmt.execute(useKS); // Create the target Column family String create = "CREATE COLUMNFAMILY Test (KEY text PRIMARY KEY, a bigint, b bigint) ;"; stmt = con.createStatement(); stmt.execute(create); stmt.close(); con.close(); // open it up again to see the new CF con = DriverManager .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, KEYSPACE, OPTIONS)); }
From source file:cz.autoclient.github.local.ReleaseFileLocal.java
public ReleaseFileLocal(ReleaseLocal parent, JSONObject elm) { this.parent = parent; URL downloadUrl = null;//w w w . ja v a 2 s. c o m String name = null; long size = 0; try { name = elm.getString("name"); size = elm.getInt("size"); downloadUrl = new URL(parent.url, URLEncoder.encode(name)); } catch (JSONException e) { } catch (MalformedURLException ex) { System.out.println("Error creating url: \"" + parent.url + "\" + \"" + URLEncoder.encode(name) + "\""); ex.printStackTrace(); } ; this.downloadUrl = downloadUrl; this.name = name; this.size = size; }
From source file:it.agileday.data.TweetRepository.java
public TweetRepository(String hashTag, BitmapCache bitmapCache) { this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag); this.bitmapCache = bitmapCache; }
From source file:net.paygate.saml.util.RequestUtil.java
/** * Generates an encoded and compressed String from the specified XML-formatted * String. The String is encoded in the following order: * <p>//from w w w . j a v a 2s . co m * 1. URL encode <br> * 2. Base64 encode <br> * 3. Deflate <br> * * @param xmlString XML-formatted String that is to be encoded * @return String containing the encoded contents of the specified XML String */ public static String encodeMessage(String xmlString) throws IOException, UnsupportedEncodingException { // first DEFLATE compress the document (saml-bindings-2.0, // section 3.4.4.1) byte[] xmlBytes = xmlString.getBytes("UTF-8"); ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteOutputStream); deflaterOutputStream.write(xmlBytes, 0, xmlBytes.length); deflaterOutputStream.close(); // next, base64 encode it Base64 base64Encoder = new Base64(); byte[] base64EncodedByteArray = base64Encoder.encode(byteOutputStream.toByteArray()); String base64EncodedMessage = new String(base64EncodedByteArray); // finally, URL encode it String urlEncodedMessage = URLEncoder.encode(base64EncodedMessage); return urlEncodedMessage; }
From source file:com.micromux.cassandra.jdbc.PooledTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { // configure OPTIONS if (!StringUtils.isEmpty(TRUST_STORE)) { OPTIONS = String.format("trustStore=%s&trustPass=%s", URLEncoder.encode(TRUST_STORE), TRUST_PASS); }/*w w w.jav a2 s .co m*/ Class.forName("com.micromux.cassandra.jdbc.CassandraDriver"); con = DriverManager .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, "system", OPTIONS)); Statement stmt = con.createStatement(); // Drop Keyspace String dropKS = String.format("DROP KEYSPACE \"%s\";", KEYSPACE); try { stmt.execute(dropKS); } catch (Exception e) {/* Exception on DROP is OK */ } // Create KeySpace String createKS = String.format( "CREATE KEYSPACE \"%s\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};", KEYSPACE); stmt.execute(createKS); // Create KeySpace String useKS = String.format("USE \"%s\";", KEYSPACE); stmt.execute(useKS); // Create the target Column family String createCF = "CREATE COLUMNFAMILY pooled_test (somekey text PRIMARY KEY," + "someInt int" + ") ;"; stmt.execute(createCF); String insertWorld = "UPDATE pooled_test SET someInt = 1 WHERE somekey = 'world'"; stmt.execute(insertWorld); }
From source file:com.nagornyi.uc.common.captcha.ReCaptchaImpl.java
public ReCaptchaResponse checkAnswer(String remoteAddr, String response) { String postParameters = "secret=" + URLEncoder.encode(privateKey) + "&remoteip=" + URLEncoder.encode(remoteAddr) + "&response=" + URLEncoder.encode(response); String message = httpLoader.httpPost(VERIFY_URL, postParameters); if (message == null) { return new ReCaptchaResponse(false, "Null read from server."); }//from w ww. j a v a 2 s. c om Boolean success = false; String errorMessage = null; try { JSONObject captchaResponse = new JSONObject(message); success = captchaResponse.getBoolean("success"); } catch (JSONException e) { try { JSONObject captchaResponse = new JSONObject(message); errorMessage = captchaResponse.getString("error-codes"); } catch (JSONException e1) { return new ReCaptchaResponse(false, "Could not parse response: " + message); } } return new ReCaptchaResponse(success, errorMessage); }
From source file:org.openmrs.module.kenyaemr.page.controller.LoginPageController.java
public void controller(@RequestParam(value = "redirect", required = false) String redirect, PageModel model) { String loginServletUrl = "/" + WebConstants.CONTEXT_PATH + "/loginServlet"; if (StringUtils.isNotEmpty(redirect)) { // Prepend context path to application URLs as LoginServlet expects this if (!redirect.startsWith("/" + WebConstants.CONTEXT_PATH)) { redirect = "/" + WebConstants.CONTEXT_PATH + "/" + redirect; }//w w w . j a va 2 s. co m loginServletUrl += "?redirect=" + URLEncoder.encode(redirect); } model.addAttribute("loginServletUrl", loginServletUrl); }
From source file:com.micromux.cassandra.jdbc.DataSourceTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { // configure OPTIONS if (!StringUtils.isEmpty(TRUST_STORE)) { OPTIONS = String.format("trustStore=%s&trustPass=%s", URLEncoder.encode(TRUST_STORE), TRUST_PASS); }//from w ww . j a v a2s . co m Class.forName("com.micromux.cassandra.jdbc.CassandraDriver"); con = DriverManager .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, "system", OPTIONS)); Statement stmt = con.createStatement(); // Drop Keyspace String dropKS = String.format("DROP KEYSPACE \"%s\";", KEYSPACE); try { stmt.execute(dropKS); } catch (Exception e) { /* Exception on DROP is OK */} // Create KeySpace String createKS = String.format( "CREATE KEYSPACE \"%s\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};", KEYSPACE); // String createKS = String.format("CREATE KEYSPACE %s WITH strategy_class = SimpleStrategy AND strategy_options:replication_factor = 1;",KEYSPACE); stmt.execute(createKS); }
From source file:com.eyekabob.Checkin.java
public void submitButtonHandler(View v) { String venueName = ((EditText) findViewById(R.id.checkinVenue)).getText().toString(); if (venueName == null || "".equals(venueName.trim())) { Toast.makeText(this, "Venue name is required", Toast.LENGTH_SHORT).show(); return;/* w w w. ja v a 2s . c o m*/ } Map<String, String> params = new HashMap<String, String>(); Venue venue = (Venue) getIntent().getExtras().get("venue"); params.put("venueId", String.valueOf(venue.getId())); params.put("venue", URLEncoder.encode(venueName)); String shout = ((EditText) findViewById(R.id.checkinShout)).getText().toString(); params.put("shout", URLEncoder.encode(shout)); String uri = EyekabobHelper.Foursquare.getUri("checkins/add", params); new JSONRequestTask("POST").execute(uri); }
From source file:com.jiayao.reviewfinder.GoogleSearchEngine.java
public Map<String, String> search(String query) throws IOException { Log.i(TAG, "searching " + query); try {/*from w w w. j a v a 2 s . c om*/ JSONArray resultsJsonArray; resultsJsonArray = getJsonArray(Utils .downloadPageContent(new URL(GOOGLE_SEARCH_URL + siteRestriction + URLEncoder.encode(query)))); Map<String, String> results = new HashMap<String, String>(); for (int i = 0; i < resultsJsonArray.length(); i++) { JSONObject resultObj = resultsJsonArray.getJSONObject(i); String title = resultObj.getString(TITLE_NO_FORMATTING); String link = resultObj.getString("url"); results.put(title, link); } return results; } catch (JSONException e) { throw new RuntimeException(e); } }