Get the report details given a url for the report data.
@param url url of the report
@return LibraryPolicyResult
513831
@SuppressWarnings({"PMD.AvoidDeeplyNestedIfStmts","PMD.NPathComplexity"}) // agreed PMD, fixme

    @Override
    public LibraryPolicyResult getDetailedReport(String url) {
        LibraryPolicyResult policyResult = null;
        try {
            JSONObject obj = parseAsObject(url);
            JSONObject matchSummary = (JSONObject) obj.get("matchSummary");
            JSONArray componentArray = (JSONArray) obj.get("components");
            if ((componentArray == null) || (componentArray.isEmpty())) return null;
            for (Object element : componentArray) {
                JSONObject component = (JSONObject) element;
                int licenseLevel = 0;
                JSONArray pathArray = (JSONArray) component.get("pathnames");

                String componentName = !CollectionUtils.isEmpty(pathArray) ? (String) pathArray.get(0) : getComponentNameFromIdentifier((JSONObject) component.get("componentIdentifier"));

                JSONObject licenseData = (JSONObject) component.get("licenseData");

                if (licenseData != null) {
                    //process license data
                    JSONArray effectiveLicenseThreats = (JSONArray) licenseData.get("effectiveLicenseThreats");
                    if (!CollectionUtils.isEmpty(effectiveLicenseThreats)) {
                        for (Object et : effectiveLicenseThreats) {
                            JSONObject etJO = (JSONObject) et;
                            Long longvalue = toLong(etJO, "licenseThreatGroupLevel");
                            if (longvalue != null) {
                                int newlevel = longvalue.intValue();
                                if (licenseLevel == 0) {
                                    licenseLevel = newlevel;
                                } else {
                                    licenseLevel = nexusIQSettings.isSelectStricterLicense() ? Math.max(licenseLevel, newlevel) : Math.min(licenseLevel, newlevel);
                                }
                            }
                        }

                    }
                }

                if (policyResult == null) {
                    policyResult = new LibraryPolicyResult();
                }

                if (licenseLevel > 0) {
                    policyResult.addThreat(LibraryPolicyType.License, LibraryPolicyThreatLevel.fromInt(licenseLevel), componentName);
                }

                JSONObject securityData = (JSONObject) component.get("securityData");
                if (securityData != null) {
                    //process security data
                    JSONArray securityIssues = (JSONArray) securityData.get("securityIssues");
                    if (!CollectionUtils.isEmpty(securityIssues)) {
                        for (Object si : securityIssues) {
                            JSONObject siJO = (JSONObject) si;
                            BigDecimal bigDecimalValue = decimal(siJO, "severity");
                            double securityLevel = (bigDecimalValue == null) ? getSeverityLevel(str(siJO, "threatCategory")) : bigDecimalValue.doubleValue();
                            policyResult.addThreat(LibraryPolicyType.Security, LibraryPolicyThreatLevel.fromDouble(securityLevel), componentName);
                        }
                    } 
                }
            } 
            
            policyResult.setTotalComponentCount(Integer.parseInt(matchSummary.get("totalComponentCount").toString()));
        	policyResult.setKnownComponentCount(Integer.parseInt(matchSummary.get("knownComponentCount").toString()));
            
        } catch (ParseException e) {
            LOG.error("Could not parse response from: " + url, e);
        } catch (RestClientException rce) {
            LOG.error("RestClientException from: " + url + ". Error code=" + rce.getMessage());
        }
                   
        return policyResult;
    }
1087052
public static Analysis readAnalysis(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return readAnalysis(reader);
        }
    }
627371
public RequestBuilder get(final String url) {

    checkNotNull(url, "url may not be null");
    final AsyncHttpClient.BoundRequestBuilder ningRequestBuilder = asyncHttpClient.prepareGet(url);
    return createNewRequestBuilder(url, ningRequestBuilder);
  }
758047
public static Response get(String url) throws URISyntaxException, HttpException {
        return send(new HttpGet(url), null, null);
    }
867230
public static JSONObject getJSONFromUrlViaGET(String url) {

        JSONObject jObj = null;

        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }

                jObj = new JSONObject(builder.toString());
            } else {
                // Log.e(ParseJSON.class.toString(), "Failed to download file");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jObj;
    }
1215240
public URL applyOnURL(URL url) {
        if (url == null) {
            return url;
        }
        try {
            return new URL(applyOnURL(url.toString()));
        } catch (MalformedURLException e) {
            throw new RuntimeException("Cannot applyl query string to: " + url, e);
        }
    }
120852
public static <T> T readUrlAsObject(String url, Class<T> type) {
		String contents = getUrlContents(url);
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping();

		try {
			return mapper.readValue(contents, type);
		} catch (IOException e) {
			JK.throww(e);
			return null;
		}
	}
350283
@GET
	@Path("getReport")
	public ReportMetaData getReport(@QueryParam("path") String path) {
		String absolutePath = StorageConstants.NEXT_SERVER_ROOT + path;
		if (!storageService.entityExists(absolutePath)) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);			
		}
		Report report;
		try {
			report = (Report) storageService.getEntity(absolutePath);
		} catch (NotFoundException e) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);
		}
		if (!ReportConstants.NEXT.equals(report.getType())) {
			throw new WebApplicationException(new Exception("No report at '"+  path + "'"), 
					ErrorCodes.NOT_FOUND);
		}
		
		return createReportMetaData(report);
	}
457443
public String makePlainCaptureQueryUrl(String url) {
		// TOOD: want "2014*" instead of "20140101000000-20141231115959*"
		return wbRequest.getAccessPoint().makeCaptureQueryUrl(url,
			wbRequest.getStartTimestamp(), wbRequest.getEndTimestamp());
	}
770686
public static boolean showDocument(URL url)
	{
		if ( url != null ){
			boolean success = JNLPProxy.showDocument(url);
			if ( ! success)
				logger.info("could not open URL "+url+" in browser. check your config or browser version.");
		return success;

		}
		else
			return false;
	}
471311
public URL getCharacteristicURL() {
        return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, this.serviceUUID,
                this.characteristicUUID, null);
    }
562110
public static URL url(final String url) {
        if (url == null) {
            return null;
        }
        try {
            if (url.startsWith("classpath:")) {
                return new URL(null, url, new ClasspathURLStreamHandler());
            }
            return new URL(url);
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException("Invalid URL: " + url, ex);
        }
    }
217370
public static File getCanonicalFileFromFileUrl(final URL url) {
        File file = null;
        if (url == null) {
            throw new NullPointerException("The URL cannot be null.");
        }
        if ("file".equals(url.getProtocol())) {
            final String fileName = url.getFile();
            final String path = URLUtils.uncorrect(fileName);
            file = new File(path);

            try {
                file = file.getCanonicalFile();
            } catch (final IOException e) {
                // Does not exist.
                file = file.getAbsoluteFile();
            }

        }
        return file;
    }
658055
protected static String reportURL(String type) throws EasyPostException {
    try {
      String urlType = URLEncoder.encode(type, "UTF-8").toLowerCase();
      return String.format("%s/reports/%s/", EasyPost.API_BASE, urlType);
    } catch (java.io.UnsupportedEncodingException e) {
      throw new EasyPostException("Undetermined Report Type");
    }
  }
544930
public static News getNewsByUrl(String url) throws Exception {
//        HttpRequest request = new HttpRequest(url);
//        String html = request.response().decode();
        String html = okHttpRequester.getResponse(url).html();
        return getNewsByHtml(html, url);
    }
137347
public static UrlBuilder parse(String url) {
        final UrlBuilder result = new UrlBuilder();
        result.with(url, UrlTokenizerState.SCHEME_OR_HOST);
        return result;
    }
1135296
public static UrlBuilder parse(URL url) {
        final UrlBuilder result = new UrlBuilder();

        if (url != null) {
            final String protocol = url.getProtocol();
            if (protocol != null && !protocol.isEmpty()) {
                result.withScheme(protocol);
            }

            final String host = url.getHost();
            if (host != null && !host.isEmpty()) {
                result.withHost(host);
            }

            final int port = url.getPort();
            if (port != -1) {
                result.withPort(port);
            }

            final String path = url.getPath();
            if (path != null && !path.isEmpty()) {
                result.withPath(path);
            }

            final String query = url.getQuery();
            if (query != null && !query.isEmpty()) {
                result.withQuery(query);
            }
        }

        return result;
    }