List of usage examples for java.net URLDecoder decode
public static String decode(String s, Charset charset)
From source file:dev.meng.wikipedia.profiler.util.StringUtils.java
public static String URLDecode(String string) { try {/*from ww w . j a v a 2 s . co m*/ return URLDecoder.decode(string, "utf-8"); } catch (UnsupportedEncodingException ex) { LogHandler.console(StringUtils.class, ex); return string; } }
From source file:org.saiku.adhoc.rest.MetadataDiscoverResource.java
@GET @Produces({ "application/json" }) @Path("/{domainId}/{modelId}/model") public MetadataModel getModel(@PathParam("domainId") String domainId, @PathParam("modelId") String modelId) { try {/*from ww w .ja va2s . c om*/ if (log.isDebugEnabled()) { log.debug("REST:GET " + " getModel domainId=" + domainId + " modelId=" + modelId); } return metadataProvider.loadModel(URLDecoder.decode(domainId, "UTF-8"), modelId); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:org.yamj.core.service.artwork.poster.YahooPosterScanner.java
@Override public List<ArtworkDetailDTO> getPosters(String title, int year) { List<ArtworkDetailDTO> dtos = new ArrayList<ArtworkDetailDTO>(); try {/* w w w . j a v a 2s . c o m*/ StringBuilder sb = new StringBuilder("http://fr.images.search.yahoo.com/search/images?p="); sb.append(URLEncoder.encode(title, "UTF-8")); sb.append("+poster&fr=&ei=utf-8&js=1&x=wrt"); String xml = httpClient.requestContent(sb.toString()); // TODO scan more posters at once int beginIndex = xml.indexOf("imgurl="); if (beginIndex > 0) { int endIndex = xml.indexOf("rurl=", beginIndex); if (endIndex > 0) { String url = URLDecoder.decode(xml.substring(beginIndex + 7, endIndex - 1), "UTF-8"); dtos.add(new ArtworkDetailDTO(getScannerName(), url)); } else { String url = URLDecoder.decode(xml.substring(beginIndex + 7), "UTF-8"); dtos.add(new ArtworkDetailDTO(getScannerName(), url)); } } } catch (IOException error) { LOG.error("Failed retreiving poster URL from yahoo images : {}", title, error); } return dtos; }
From source file:net.iponweb.hadoop.streaming.avro.AvroAsJsonOutputFormat.java
static <K> void configureDataFileWriter(DataFileWriter<K> writer, JobConf job) throws UnsupportedEncodingException { if (FileOutputFormat.getCompressOutput(job)) { int level = job.getInt(org.apache.avro.mapred.AvroOutputFormat.DEFLATE_LEVEL_KEY, org.apache.avro.mapred.AvroOutputFormat.DEFAULT_DEFLATE_LEVEL); String codecName = job.get(AvroJob.OUTPUT_CODEC, DEFLATE_CODEC); CodecFactory factory = codecName.equals(DEFLATE_CODEC) ? CodecFactory.deflateCodec(level) : CodecFactory.fromString(codecName); writer.setCodec(factory);//from www. j a v a 2s.c o m } writer.setSyncInterval( job.getInt(org.apache.avro.mapred.AvroOutputFormat.SYNC_INTERVAL_KEY, DEFAULT_SYNC_INTERVAL)); // copy metadata from job for (Map.Entry<String, String> e : job) { if (e.getKey().startsWith(AvroJob.TEXT_PREFIX)) writer.setMeta(e.getKey().substring(AvroJob.TEXT_PREFIX.length()), e.getValue()); if (e.getKey().startsWith(AvroJob.BINARY_PREFIX)) writer.setMeta(e.getKey().substring(AvroJob.BINARY_PREFIX.length()), URLDecoder.decode(e.getValue(), "ISO-8859-1").getBytes("ISO-8859-1")); } }
From source file:org.archive.crawler.restlet.BeanBrowseResource.java
public BeanBrowseResource(Context ctx, Request req, Response res) throws ResourceException { super(ctx, req, res); getVariants().add(new Variant(MediaType.TEXT_HTML)); getVariants().add(new Variant(MediaType.APPLICATION_XML)); setModifiable(true); // accept POSTs appCtx = cj.getJobContext();//from w ww . j a va 2 s .c o m beanPath = (String) req.getAttributes().get("beanPath"); if (beanPath != null) { try { beanPath = URLDecoder.decode(beanPath, "UTF-8"); } catch (UnsupportedEncodingException e) { // inconceivable! UTF-8 required all Java impls } } else { beanPath = ""; } Configuration tmpltCfg = new Configuration(); tmpltCfg.setClassForTemplateLoading(this.getClass(), ""); tmpltCfg.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER); setTemplateConfiguration(tmpltCfg); }
From source file:in.huohua.peterson.network.NetworkUtils.java
public static Map<String, List<String>> getQueryParams(final String url) { try {//from ww w . ja v a2 s . c o m final Map<String, List<String>> params = new HashMap<String, List<String>>(); final String[] urlParts = url.split("\\?"); if (urlParts.length > 1) { final String query = urlParts[1]; for (final String param : query.split("&")) { final String[] pair = param.split("="); final String key = URLDecoder.decode(pair[0], "UTF-8"); String value = ""; if (pair.length > 1) { value = URLDecoder.decode(pair[1], "UTF-8"); } List<String> values = params.get(key); if (values == null) { values = new ArrayList<String>(); params.put(key, values); } values.add(value); } } return params; } catch (final UnsupportedEncodingException exception) { return new HashMap<String, List<String>>(); } }
From source file:com.aliyun.datahub.auth.AliyunRequestSigner.java
public String getSignature(String resource, DefaultRequest req) { try {/*from w ww . ja v a 2 s. co m*/ resource = URLDecoder.decode(resource, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } String strToSign = SecurityUtils.buildCanonicalString(resource, req, "x-datahub-"); if (log.isLoggable(Level.FINE)) { log.fine("String to sign: " + strToSign); } byte[] crypto = SecurityUtils.hmacsha1Signature(strToSign.getBytes(), accessKey.getBytes()); String signature = Base64.encodeBase64String(crypto).trim(); return "DATAHUB " + accessId + ":" + signature; }
From source file:com.sun.socialsite.web.ui.core.struts2.ProfileView.java
public void setEncodedOwnerId(String encodedOwnerId) { try {//from w w w.j av a 2 s.c o m setOwnerId(URLDecoder.decode(encodedOwnerId, "UTF-8")); } catch (UnsupportedEncodingException ex) { log.error("Failed to decode ownerId [" + encodedOwnerId + "]", ex); } }
From source file:com.seer.datacruncher.eventtrigger.DynamicClassLoader.java
private static String extractClasspath(ClassLoader classLoader) { StringBuffer classLoaderBuf = new StringBuffer(); try {// www . ja va 2 s . c o m while (classLoader != null) { if (classLoader instanceof URLClassLoader) { URL urls[] = ((URLClassLoader) classLoader).getURLs(); for (int i = 0; i < urls.length; i++) { if (classLoaderBuf.length() > 0) { classLoaderBuf.append(File.pathSeparatorChar); } classLoaderBuf.append(URLDecoder.decode(urls[i].getFile(), "UTF-8").toString()); } } classLoader = classLoader.getParent(); } } catch (UnsupportedEncodingException e) { logger.error("Exception:" + e.getMessage(), e); } return classLoaderBuf.toString(); }
From source file:interactivespaces.service.web.server.internal.netty.NettyHttpRequest.java
@Override public Map<String, String> getUriQueryParameters() { Map<String, String> params = Maps.newHashMap(); String rawQuery = getUri().getRawQuery(); if (rawQuery != null && !rawQuery.isEmpty()) { String[] components = rawQuery.split("\\&"); for (String component : components) { int pos = component.indexOf('='); if (pos != -1) { String decode = component.substring(pos + 1); try { decode = URLDecoder.decode(decode, "UTF-8"); } catch (Exception e) { // Don't care }/* w ww .j ava 2s. c o m*/ params.put(component.substring(0, pos).trim(), decode); } else { params.put(component.trim(), ""); } } } return params; }