/** * Looks up a href within our universe. If the href refers to a document that is not loaded, it * will be loaded. The URL #target will then be checked against the SVG diagram's index and the * coresponding element returned. If there is no coresponding index, null is returned. */ public SVGElement getElement(URI path, boolean loadIfAbsent) { try { // Strip fragment from URI URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null); SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); if (dia == null && loadIfAbsent) { // System.err.println("SVGUnivserse: " + xmlBase.toString()); // javax.swing.JOptionPane.showMessageDialog(null, xmlBase.toString()); URL url = xmlBase.toURL(); loadSVG(url, false); dia = (SVGDiagram) loadedDocs.get(xmlBase); if (dia == null) { return null; } } String fragment = path.getFragment(); return fragment == null ? dia.getRoot() : dia.getElement(fragment); } catch (Exception e) { Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse path " + path, e); return null; } }
/** @return Success status code */ public String parseExternalEndpoint() { if (this._externalUrl.toLowerCase().indexOf(ExternalEndpointBackingBean.WSDL_QUERY) == -1) this._externalUrl += ExternalEndpointBackingBean.WSDL_QUERY; ExternalEndpointBackingBean.log.info("ExternalURL->" + this._externalUrl); try { URI externalURI = new URI(this._externalUrl); PlanetsServiceExplorer pse = new PlanetsServiceExplorer(externalURI.toURL()); // Lets see if we can get a service description this._desc = DiscoveryUtils.getServiceDescription(externalURI.toURL()); if (this._desc == null) { this._endpoint = new PlanetsServiceEndpoint(pse); ServiceDescription.Builder sb = new ServiceDescription.Builder(_endpoint.getName(), _endpoint.getType()); this._desc = sb.endpoint(_endpoint.getLocation()).classname(_endpoint.getType()).build(); } else { ServiceDescription.Builder sb = new ServiceDescription.Builder(this._desc); this._desc = sb.endpoint(externalURI.toURL()).build(); this._endpoint = new PlanetsServiceEndpoint(this._desc); } } catch (URISyntaxException e) { ExternalEndpointBackingBean.log.severe("Invalid External URI->" + this._externalUrl); ExternalEndpointBackingBean.log.severe(e.getStackTrace().toString()); return "invalidURI"; } catch (MalformedURLException e) { ExternalEndpointBackingBean.log.severe("Malformed External URL->" + this._externalUrl); ExternalEndpointBackingBean.log.severe(e.getStackTrace().toString()); return "invalidURI"; } return "success"; }
public InputStream openResource(URI uri) throws IOException { if (uri.isAbsolute() && uri.getScheme().equals("file")) { try { return uri.toURL().openStream(); } catch (Exception except) { log.error("openResource: unable to open file URL " + uri + "; " + except.toString()); return null; } } // Note that if we get an absolute URI, the relativize operation will simply // return the absolute URI. URI relative = baseUri.relativize(uri); if (relative.isAbsolute() && relative.getScheme().equals("http")) { try { return relative.toURL().openStream(); } catch (Exception except) { log.error("openResource: unable to open http URL " + uri + "; " + except.toString()); return null; } } if (relative.isAbsolute() && !relative.getScheme().equals("urn")) { log.error("openResource: invalid scheme (should be urn:) " + uri); return null; } File f = new File(baseUri.getPath(), relative.getPath()); if (!f.exists()) { log.error("openResource: file not found " + f); return null; } return new FileInputStream(f); }
private <T> JsonResponse<T> commandResponse(String command, Type type) throws Exception { URI uri = this.getServerUri(command); // URI uri = new URI( serverUri.toString() + URLEncoder.encode(command) ); HttpURLConnection server = null; if (https) { server = (HttpsURLConnection) uri.toURL().openConnection(); } else { server = (HttpURLConnection) uri.toURL().openConnection(); } server.setConnectTimeout(30000); BufferedReader reader = new BufferedReader(new InputStreamReader(server.getInputStream())); // TypeToken cannot figure out T so instead it must be supplied // Type type = new TypeToken< JSONResponse<T> >() {}.getType(); GsonBuilder build = new GsonBuilder(); StringBuilder sBuild = new StringBuilder(); String input; while ((input = reader.readLine()) != null) sBuild.append(input); reader.close(); input = sBuild.toString(); build.registerTypeAdapter(JsonBoolean.class, new JsonBooleanDeserializer()); JsonResponse<T> response = null; try { response = build.create().fromJson(input, type); tryExtractError(response); return response; } catch (Exception e) { // well something messed up // if this part messes up then something REALLY bad happened response = build.create().fromJson(input, new TypeToken<JsonResponse<Object>>() {}.getType()); tryExtractError(response); // DO NOT RETURN AN ACTUAL OBJECT!!!!! // this makes the code in the UI confused return null; } }
// Get the size of a file from URL response header. public static Long getRemoteSize(String url) { Long remoteSize = (long) 0; HttpURLConnection httpConn = null; HttpsURLConnection httpsConn = null; try { URI uri = new URI(url); if (uri.getScheme().equalsIgnoreCase("http")) { httpConn = (HttpURLConnection) uri.toURL().openConnection(); if (httpConn != null) { String contentLength = httpConn.getHeaderField("content-length"); if (contentLength != null) { remoteSize = Long.parseLong(contentLength); } httpConn.disconnect(); } } else if (uri.getScheme().equalsIgnoreCase("https")) { httpsConn = (HttpsURLConnection) uri.toURL().openConnection(); if (httpsConn != null) { String contentLength = httpsConn.getHeaderField("content-length"); if (contentLength != null) { remoteSize = Long.parseLong(contentLength); } httpsConn.disconnect(); } } } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid URL " + url); } catch (IOException e) { throw new IllegalArgumentException("Unable to establish connection with URL " + url); } return remoteSize; }
private void downloadFile(URI uri) throws IOException, MalformedURLException { try (InputStream in = uri.toURL().openStream()) { Files.copy( in, Paths.get(new File(uri.toURL().getPath()).getName() + ".json"), StandardCopyOption.REPLACE_EXISTING); } catch (IOException ioe) { System.err.println("Failed to download: " + uri); } }
public void load(URI inputURI, boolean p_bIgnoreErrors) { char[] aBuf; try { // Reset the parameters to their defaults reset(); // Open the file. use a URL so we can do openStream() and load // predefined files from JARs. URL url = inputURI.toURL(); Reader SR = new InputStreamReader(new BufferedInputStream(url.openStream()), "UTF-8"); // Read the file in one string StringBuilder sbTmp = new StringBuilder(1024); aBuf = new char[1024]; int nCount; while ((nCount = SR.read(aBuf)) > -1) { sbTmp.append(aBuf, 0, nCount); } SR.close(); SR = null; // Parse it String tmp = sbTmp.toString().replace("\r\n", "\n"); fromString(tmp.replace("\r", "\n")); path = inputURI.getPath(); } catch (IOException e) { if (!p_bIgnoreErrors) throw new RuntimeException(e); } finally { aBuf = null; } }
@Override public Response intercept(Chain chain) throws IOException { String paramValue; Request request = chain.request(); if (location == "query") { String newQuery = request.url().uri().getQuery(); paramValue = paramName + "=" + apiKey; if (newQuery == null) { newQuery = paramValue; } else { newQuery += "&" + paramValue; } URI newUri; try { newUri = new URI( request.url().uri().getScheme(), request.url().uri().getAuthority(), request.url().uri().getPath(), newQuery, request.url().uri().getFragment()); } catch (URISyntaxException e) { throw new IOException(e); } request = request.newBuilder().url(newUri.toURL()).build(); } else if (location == "header") { request = request.newBuilder().addHeader(paramName, apiKey).build(); } return chain.proceed(request); }
/** * Obtiene el flujo de entrada de un fichero (para su lectura) a partir de su URI. * * @param uri URI del fichero a leer * @return Flujo de entrada hacia el contenido del fichero * @throws AOException Cuando ocurre cualquier problema obteniendo el flujo * @throws IOException Cuando no se ha podido abrir el fichero de datos. */ public static InputStream loadFile(final URI uri) throws AOException, IOException { if (uri == null) { throw new IllegalArgumentException( "Se ha pedido el contenido de una URI nula"); //$NON-NLS-1$ } if (uri.getScheme().equals("file")) { // $NON-NLS-1$ // Es un fichero en disco. Las URL de Java no soportan file://, con // lo que hay que diferenciarlo a mano // Retiramos el "file://" de la uri String path = uri.getSchemeSpecificPart(); if (path.startsWith("//")) { // $NON-NLS-1$ path = path.substring(2); } return new FileInputStream(new File(path)); } // Es una URL final InputStream tmpStream = new BufferedInputStream(uri.toURL().openStream()); // Las firmas via URL fallan en la descarga por temas de Sun, asi que // descargamos primero // y devolvemos un Stream contra un array de bytes final byte[] tmpBuffer = getDataFromInputStream(tmpStream); return new java.io.ByteArrayInputStream(tmpBuffer); }
void put(final URI uri, ArtifactData data) throws Exception { reporter.trace("put %s %s", uri, data); File tmp = createTempFile(repoDir, "mtp", ".whatever"); tmp.deleteOnExit(); try { copy(uri.toURL(), tmp); byte[] sha = SHA1.digest(tmp).digest(); reporter.trace("SHA %s %s", uri, Hex.toHexString(sha)); ArtifactData existing = get(sha); if (existing != null) { reporter.trace("existing"); xcopy(existing, data); return; } File meta = new File(repoDir, Hex.toHexString(sha) + ".json"); File file = new File(repoDir, Hex.toHexString(sha)); rename(tmp, file); reporter.trace("file %s", file); data.file = file.getAbsolutePath(); data.sha = sha; data.busy = false; CommandData cmddata = parseCommandData(data); if (cmddata.bsn != null) { data.name = cmddata.bsn + "-" + cmddata.version; } else data.name = Strings.display(cmddata.title, cmddata.bsn, cmddata.name, uri); codec.enc().to(meta).put(data); reporter.trace("TD = " + data); } finally { tmp.delete(); reporter.trace("puted %s %s", uri, data); } }
/** * Determine if code should be generated from the given wsdl * * @param wsdlOption * @param doneFile * @param wsdlURI * @return */ private boolean shouldRun(WadlOption wsdlOption, File doneFile, URI wsdlURI) { long timestamp = 0; if ("file".equals(wsdlURI.getScheme())) { timestamp = new File(wsdlURI).lastModified(); } else { try { timestamp = wsdlURI.toURL().openConnection().getDate(); } catch (Exception e) { // ignore } } boolean doWork = false; if (!doneFile.exists()) { doWork = true; } else if (timestamp > doneFile.lastModified()) { doWork = true; } else { File files[] = wsdlOption.getDependencies(); if (files != null) { for (int z = 0; z < files.length; ++z) { if (files[z].lastModified() > doneFile.lastModified()) { doWork = true; } } } } return doWork; }
@Override protected URL buildUrl(String resource, String query) throws URISyntaxException, MalformedURLException { int uriport = 0; if ("http".equals(proto) && port == 80) { // Default port uriport = -1; } else if ("https".equals(proto) && port == 443) { uriport = -1; } else { uriport = port; } String host = null; if (mode == LBMode.ROUND_ROBIN_THREADS) { // Bind thread to a specific host if (threadHost.get() == null) { threadHost.set(hosts.get((int) (requestCount++ % hosts.size()))); l4j.info("Thread bound to " + threadHost.get()); } host = threadHost.get(); } else { host = hosts.get((int) (requestCount++ % hosts.size())); } URI uri = new URI(proto, null, host, uriport, resource, query, null); URL u = uri.toURL(); l4j.debug("URL: " + u); return u; }
/** * Helper function to load up schema definition file locally when internet connection is disabled. */ static boolean configureLocal(String file) { // if we get here, try to access local copy File f = new File(file); URI uri = f.toURI(); URL url; try { url = uri.toURL(); try { URLConnection con = url.openConnection(); InputStream is = con.getInputStream(); if (is != null) { System.err.println("Using local copy of " + file + ". May be out of date..."); Message.configure(XSD_NAME, url); return true; } } catch (IllegalStateException e) { // pass through } catch (IOException e) { // pass through } } catch (MalformedURLException e) { // pass through } System.err.println("Unable to access local ks.xsd file"); return false; }
@Override public Element export(ExportSupport support) throws IOException { Element layerEl = support.createElement("layer"); layerEl.setAttribute("type", "osm-data"); layerEl.setAttribute("version", "0.1"); Element file = support.createElement("file"); layerEl.appendChild(file); if (requiresZip()) { String zipPath = "layers/" + String.format("%02d", support.getLayerIndex()) + "/data.osm"; file.appendChild(support.createTextNode(zipPath)); addDataFile(support.getOutputStreamZip(zipPath)); } else { URI uri = layer.getAssociatedFile().toURI(); URL url = null; try { url = uri.toURL(); } catch (MalformedURLException e) { throw new IOException(e); } file.appendChild(support.createTextNode(url.toString())); } return layerEl; }
@Test public void testFullFileDecryption() throws IOException, URISyntaxException { final URL testResourceUrl = new URL(VAULT_BASE_URI.toURL(), "fullFileDecryptionTestFile.txt"); final HttpClient client = new HttpClient(); // prepare 64MiB test data: final byte[] plaintextData = new byte[16777216 * Integer.BYTES]; final ByteBuffer bbIn = ByteBuffer.wrap(plaintextData); for (int i = 0; i < 16777216; i++) { bbIn.putInt(i); } final InputStream plaintextDataInputStream = new ByteArrayInputStream(plaintextData); // put request: final EntityEnclosingMethod putMethod = new PutMethod(testResourceUrl.toString()); putMethod.setRequestEntity(new ByteArrayRequestEntity(plaintextData)); final int putResponse = client.executeMethod(putMethod); putMethod.releaseConnection(); Assert.assertEquals(201, putResponse); // get request: final HttpMethod getMethod = new GetMethod(testResourceUrl.toString()); final int statusCode = client.executeMethod(getMethod); Assert.assertEquals(200, statusCode); // final byte[] received = new byte[plaintextData.length]; // IOUtils.read(getMethod.getResponseBodyAsStream(), received); // Assert.assertArrayEquals(plaintextData, received); Assert.assertTrue( IOUtils.contentEquals(plaintextDataInputStream, getMethod.getResponseBodyAsStream())); getMethod.releaseConnection(); }
@BeforeClass public static void setUpClass() throws IOException { // Run before the test JVM starts to ensure the dynamic download // actually happens during the test run PropsUtil.setProps(new PropsImpl()); String jarName = PropsUtil.get(PropsKeys.SETUP_LIFERAY_POOL_PROVIDER_JAR_NAME, new Filter("hikaricp")); Path jarPath = Paths.get("lib/portal", jarName); if (Files.exists(jarPath)) { Path tempFilePath = Files.createTempFile(null, null); Files.move(jarPath, tempFilePath, StandardCopyOption.REPLACE_EXISTING); URI uri = tempFilePath.toUri(); URL url = uri.toURL(); System.setProperty(_HIKARICP_JAR_URL, url.toExternalForm()); } }
public static void main(String args[]) throws URISyntaxException, MalformedURLException { URL url = null; URL url1 = null; try { url = new URL(unencoded); url1 = new URL(encoded); } catch (Exception e) { System.out.println("Unexpected exception :" + e); System.exit(-1); } if (url.sameFile(url1)) { throw new RuntimeException("URL does not understand escaping"); } /* check decoding of a URL */ URI uri = url1.toURI(); if (!uri.getPath().equals(path)) { throw new RuntimeException("Got: " + uri.getPath() + " expected: " + path); } /* check encoding of a URL */ URI uri1 = new URI(scheme, auth, path); url = uri.toURL(); if (!url.toString().equals(encoded)) { throw new RuntimeException("Got: " + url.toString() + " expected: " + encoded); } }
public static URI unredirect(URI uri) throws IOException { if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) { return uri; } URL url = uri.toURL(); HttpURLConnection connection = safelyOpenConnection(url); connection.setInstanceFollowRedirects(false); connection.setDoInput(false); connection.setRequestMethod("HEAD"); connection.setRequestProperty("User-Agent", "ZXing (Android)"); try { int responseCode = safelyConnect(uri.toString(), connection); switch (responseCode) { case HttpURLConnection.HTTP_MULT_CHOICE: case HttpURLConnection.HTTP_MOVED_PERM: case HttpURLConnection.HTTP_MOVED_TEMP: case HttpURLConnection.HTTP_SEE_OTHER: case 307: // No constant for 307 Temporary Redirect ? String location = connection.getHeaderField("Location"); if (location != null) { try { return new URI(location); } catch (URISyntaxException e) { // nevermind } } } return uri; } finally { connection.disconnect(); } }
private void uploadToGridFTPFromHttp(InvocationContext context, URI src, String remoteLocation) throws SecurityException, ToolsException, URISyntaxException, IOException { GridFtp ftp = new GridFtp(); GSSCredential gssCred = ((GSISecurityContext) context.getSecurityContext(MYPROXY_SECURITY_CONTEXT)) .getGssCredentails(); GlobusHostType host = (GlobusHostType) context.getExecutionDescription().getHost().getType(); for (String endpoint : host.getGridFTPEndPointArray()) { try { URI destURI = GfacUtils.createGsiftpURI(endpoint, remoteLocation); InputStream in = null; try { in = src.toURL().openStream(); ftp.uploadFile(destURI, gssCred, in); } finally { try { if (in != null) { in.close(); } } catch (Exception e) { log.warn("Cannot close URL inputstream"); } } return; } catch (ToolsException e) { log.error(e.getMessage(), e); } } }
@Override public void execute(JobExecutionContext context) throws JobExecutionException { if (checklistNotificationsUri == null) { return; } boolean started = !HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().isActive(); if (started) { HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin(); } try { URI researchObjectUri = (URI) context.getMergedJobDataMap().get(RESEARCH_OBJECT_URI); SyndFeedInput input = new SyndFeedInput(); URI requestedUri = createQueryUri(getTheLastFeedDate(researchObjectUri), researchObjectUri); try { context.setResult(input.build(new XmlReader(requestedUri.toURL()))); } catch (IllegalArgumentException | FeedException | IOException e) { LOGGER.error("Can't get the feed " + requestedUri.toString()); } } finally { if (started) { HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit(); } } }
@Override protected void processImport() throws SudokuInvalidFormatException { try { InputStreamReader streamReader; if (mUri.getScheme().equals("content")) { ContentResolver contentResolver = mContext.getContentResolver(); streamReader = new InputStreamReader(contentResolver.openInputStream(mUri)); } else { java.net.URI juri; juri = new java.net.URI(mUri.getScheme(), mUri.getSchemeSpecificPart(), mUri.getFragment()); streamReader = new InputStreamReader(juri.toURL().openStream()); } try { importXml(streamReader); } finally { streamReader.close(); } } catch (MalformedURLException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
@Test public void testUnsatisfiableRangeRequest() throws IOException, URISyntaxException { final URL testResourceUrl = new URL(VAULT_BASE_URI.toURL(), "unsatisfiableRangeRequestTestFile.txt"); final HttpClient client = new HttpClient(); // prepare file content: final byte[] fileContent = "This is some test file content.".getBytes(); // put request: final EntityEnclosingMethod putMethod = new PutMethod(testResourceUrl.toString()); putMethod.setRequestEntity(new ByteArrayRequestEntity(fileContent)); final int putResponse = client.executeMethod(putMethod); putMethod.releaseConnection(); Assert.assertEquals(201, putResponse); // get request: final HttpMethod getMethod = new GetMethod(testResourceUrl.toString()); getMethod.addRequestHeader("Range", "chunks=1-2"); final int getResponse = client.executeMethod(getMethod); final byte[] response = new byte[fileContent.length]; IOUtils.read(getMethod.getResponseBodyAsStream(), response); getMethod.releaseConnection(); Assert.assertEquals(416, getResponse); Assert.assertArrayEquals(fileContent, response); }
private void downloadInternal(URI address, File destination) throws Exception { OutputStream out = null; URLConnection conn; InputStream in = null; try { URL url = address.toURL(); out = new BufferedOutputStream(new FileOutputStream(destination)); conn = url.openConnection(); final String userAgentValue = calculateUserAgent(); conn.setRequestProperty("User-Agent", userAgentValue); in = conn.getInputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int numRead; long progressCounter = 0; while ((numRead = in.read(buffer)) != -1) { progressCounter += numRead; if (progressCounter / PROGRESS_CHUNK > 0) { System.out.print("."); progressCounter = progressCounter - PROGRESS_CHUNK; } out.write(buffer, 0, numRead); } } finally { System.out.println(""); if (in != null) { in.close(); } if (out != null) { out.close(); } } }
@Override protected IStatus run(IProgressMonitor monitor) { String tmp = NO_HELP_CONTENT; if (template != null) { URI uri = template.getHelpContent(); if (uri != null) { try { URLConnection conn = uri.toURL().openConnection(); conn.setUseCaches(false); tmp = IO.collect(conn.getInputStream()); } catch (IOException e) { log.log( new Status( IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error loading template help content.", e)); } } } final String text = tmp; if (control != null && !control.isDisposed()) { control .getDisplay() .asyncExec( new Runnable() { @Override public void run() { if (!control.isDisposed()) control.setText(text); } }); } return Status.OK_STATUS; }
private static String _toExternalForm(File file) throws Exception { URI uri = file.toURI(); URL url = uri.toURL(); return url.toExternalForm(); }
protected void handleAsURI(URI uri) { try { handleAsURL(uri.toURL()); } catch (MalformedURLException e) { throw illegalValue(uri, URL.class, e); } }
/** {@inheritDoc} */ public void saveKeyStore(KeyStore store, char[] password) throws KeyStoreException, IOException { if (LOG.isEnabledFor(Level.DEBUG)) { LOG.debug("Writing " + store + " to " + keystore_location); } try { OutputStream os = null; if ("file".equalsIgnoreCase(keystore_location.getScheme())) { os = new FileOutputStream(new File(keystore_location)); } else { os = keystore_location.toURL().openConnection().getOutputStream(); } store.store(os, password); } catch (NoSuchAlgorithmException failed) { KeyStoreException failure = new KeyStoreException("NoSuchAlgorithmException during keystore processing"); failure.initCause(failed); throw failure; } catch (CertificateException failed) { KeyStoreException failure = new KeyStoreException("CertificateException during keystore processing"); failure.initCause(failed); throw failure; } }
/** * Returns an InputStream pointed at an imported wsdl pathname relative to the parent document. * * @param importPath identifies the WSDL file within the context * @return a stream of the WSDL file */ protected InputStream getInputStream(String importPath) throws IOException { URL importURL = null; InputStream is = null; try { importURL = new URL(importPath); is = importURL.openStream(); } catch (Throwable t) { // No FFDC required } if (is == null) { try { is = classLoader.getResourceAsStream(importPath); } catch (Throwable t) { // No FFDC required } } if (is == null) { try { File file = new File(importPath); is = file.toURL().openStream(); } catch (Throwable t) { // No FFDC required } } if (is == null) { try { URI uri = new URI(importPath); is = uri.toURL().openStream(); } catch (Throwable t) { // No FFDC required } } return is; }
/** * Returns the diagram that has been loaded from this root. If diagram is not already loaded, * returns null. */ public SVGDiagram getDiagram(URI xmlBase, boolean loadIfAbsent) { if (xmlBase == null) { return null; } SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); if (dia != null || !loadIfAbsent) { return dia; } // Load missing diagram try { URL url; if ("jar".equals(xmlBase.getScheme()) && xmlBase.getPath() != null && !xmlBase.getPath().contains("!/")) { // Workaround for resources stored in jars loaded by Webstart. // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651 url = SVGUniverse.class.getResource("xmlBase.getPath()"); } else { url = xmlBase.toURL(); } loadSVG(url, false); dia = (SVGDiagram) loadedDocs.get(xmlBase); return dia; } catch (Exception e) { Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", e); } return null; }
private URI adjustAddress(URI address) throws MalformedURLException, URISyntaxException { if (address.toString().startsWith("https://play.google.com/music/services/")) { return address = new URI(address.toURL() + String.format("?u=0&xt=%1$s", cookie)); } return address; }