List of usage examples for com.google.common.net UriEscapers uriQueryStringEscaper
public static Escaper uriQueryStringEscaper(boolean plusForSpace)
From source file:com.google.walkaround.wave.server.auth.ServletAuthHelper.java
private static String queryEncode(String s) { return UriEscapers.uriQueryStringEscaper(false).escape(s); }
From source file:com.google.walkaround.wave.server.rpc.PhotosHandler.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String photoId = requireParameter(req, "photoId"); // http://code.google.com/apis/contacts/docs/2.0/developers_guide_protocol.html#groups_feed_url // says "You can also substitute 'default' for the user's email address, // which tells the server to return the contact groups for the user whose // credentials accompany the request". I didn't read the document in enough // detail to check whether this is supposed to apply to photos as well, but // it seems to work. URL targetUrl = new URL("https://www.google.com/m8/feeds/photos/media/default/" + UriEscapers.uriQueryStringEscaper(false).escape(photoId)); HTTPResponse response = fetch.fetch( new HTTPRequest(targetUrl, HTTPMethod.GET, FetchOptions.Builder.withDefaults().disallowTruncate())); if (response.getResponseCode() == 404) { // Rather than a broken image, use the unknown avatar. log.info("Missing image, using default"); resp.sendRedirect(SharedConstants.UNKNOWN_AVATAR_URL); } else {/* w w w . j ava2s . c o m*/ ProxyHandler.copyResponse(response, resp); } // TODO(hearnden): Do something to make the client cache photos sensibly. }
From source file:com.google.walkaround.wave.server.inbox.Searcher.java
private static String queryEscape(String s) { return UriEscapers.uriQueryStringEscaper(false).escape(s); }
From source file:com.google.walkaround.wave.server.attachment.AttachmentMetadataHandler.java
private void doRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException { Map<AttachmentId, Optional<AttachmentMetadata>> result = attachments.getMetadata(getIds(req), MAX_REQUEST_TIME_MS);/* w w w .j ava2 s .c om*/ JSONObject json = new JSONObject(); try { for (Entry<AttachmentId, Optional<AttachmentMetadata>> entry : result.entrySet()) { JSONObject metadata = new JSONObject( entry.getValue().isPresent() ? entry.getValue().get().getMetadataJsonString() : INVALID_ATTACHMENT_ID_METADATA_STRING); String queryParams = "attachment=" + UriEscapers.uriQueryStringEscaper(false).escape(entry.getKey().getId()); metadata.put("url", "/download?" + queryParams); metadata.put("thumbnailUrl", "/thumbnail?" + queryParams); json.put(entry.getKey().getId(), metadata); } } catch (JSONException e) { throw new Error(e); } ServletUtil.writeJsonResult(resp.getWriter(), json.toString()); }
From source file:com.google.walkaround.wave.server.googleimport.ImportOverviewHandler.java
private String makeLocalWaveLink(SlobId convSlobId) { return "/wave?id=" + UriEscapers.uriQueryStringEscaper(false).escape(convSlobId.getId()); }
From source file:com.google.walkaround.wave.server.auth.OAuthCallbackHandler.java
private String urlEncode(String s) { return UriEscapers.uriQueryStringEscaper(false).escape(s); }