Example usage for java.net MalformedURLException getMessage

List of usage examples for java.net MalformedURLException getMessage

Introduction

In this page you can find the example usage for java.net MalformedURLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:fr.gael.dhus.datastore.processing.impl.ProcessProductTransfer.java

@Override
public void run(Product product) {
    String url = product.getOrigin();
    if (url == null) {
        return;//  w ww.  j a v a2s .co  m
    }
    if (!product.getPath().toString().equals(url)) {
        return;
    }
    File dest = incomingManager.getNewProductIncomingPath();
    Boolean compute_checksum = null;
    try {
        compute_checksum = UnZip.supported((new URL(url)).getPath());
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    LockFactory lf = new NativeFSLockFactory(dest.getParentFile());
    Lock lock = lf.makeLock(".lock-writing");
    try {
        lock.obtain(900000);
    } catch (Exception e) {
        logger.warn("Cannot lock incoming directory - continuing without (" + e.getMessage() + ")");
    }
    try {
        User owner = productDao.getOwnerOfProduct(product);
        actionRecordWritterDao.uploadStart(dest.getPath(), owner.getUsername());
        URL u = new URL(url);
        String userInfos = u.getUserInfo();
        String username = null;
        String password = null;
        if (userInfos != null) {
            String[] infos = userInfos.split(":");
            username = infos[0];
            password = infos[1];
        }

        // Hooks to remove the partially transfered product
        Hook hook = new Hook(dest.getParentFile());
        Runtime.getRuntime().addShutdownHook(hook);
        upload(url, username, password, dest, compute_checksum);
        Runtime.getRuntime().removeShutdownHook(hook);

        String local_filename = ScannerFactory.getFileFromPath(url);
        File productFile = new File(dest, local_filename);
        product.setPath(productFile.toURI().toURL());
        productDao.update(product);
    } catch (Exception e) {
        FileUtils.deleteQuietly(dest);
        throw new DataStoreException("Cannot transfer product \"" + url + "\".", e);
    } finally {
        try {
            lock.close();
        } catch (IOException e) {
        }
    }
}

From source file:net.sf.jabref.importer.fetcher.ACMPortalFetcher.java

@Override
public boolean processQueryGetPreview(String query, FetcherPreviewDialog preview, OutputPrinter status) {
    this.terms = query;
    piv = 0;//  w  w w  .j av a2 s . c o  m
    shouldContinue = true;
    acmOrGuide = acmButton.isSelected();
    fetchAbstract = absCheckBox.isSelected();
    String address = makeUrl();
    LinkedHashMap<String, JLabel> previews = new LinkedHashMap<>();

    try {
        URLDownload dl = new URLDownload(address);

        String page = dl.downloadToString(Globals.prefs.getDefaultEncoding());

        int hits = getNumberOfHits(page, RESULTS_FOUND_PATTERN, ACMPortalFetcher.HITS_PATTERN);

        int index = page.indexOf(RESULTS_FOUND_PATTERN);
        if (index >= 0) {
            page = page.substring(index + RESULTS_FOUND_PATTERN.length());
        }

        if (hits == 0) {
            status.showMessage(Localization.lang("No entries found for the search string '%0'", terms),
                    Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE);
            return false;
        } else if (hits > 20) {
            status.showMessage(
                    Localization.lang("%0 entries found. To reduce server load, only %1 will be downloaded.",
                            String.valueOf(hits), String.valueOf(PER_PAGE)),
                    Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE);
        }

        hits = getNumberOfHits(page, PAGE_RANGE_PATTERN, ACMPortalFetcher.MAX_HITS_PATTERN);
        parse(page, Math.min(hits, PER_PAGE), previews);
        for (Map.Entry<String, JLabel> entry : previews.entrySet()) {
            preview.addEntry(entry.getKey(), entry.getValue());
        }

        return true;

    } catch (MalformedURLException e) {
        LOGGER.warn("Problem with ACM fetcher URL", e);
    } catch (ConnectException e) {
        status.showMessage(Localization.lang("Could not connect to %0", getTitle()),
                Localization.lang("Search %0", getTitle()), JOptionPane.ERROR_MESSAGE);
        LOGGER.warn("Problem with ACM connection", e);
    } catch (IOException e) {
        status.showMessage(e.getMessage(), Localization.lang("Search %0", getTitle()),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.warn("Problem with ACM Portal", e);
    }
    return false;

}

From source file:org.commonjava.couch.db.CouchManager.java

public void modify(final Collection<? extends CouchDocumentAction> actions, final boolean allOrNothing)
        throws CouchDBException {
    for (final CouchDocumentAction action : actions) {
        final CouchDocument doc = action.getDocument();
        if (doc instanceof DenormalizedCouchDoc) {
            ((DenormalizedCouchDoc) doc).calculateDenormalizedFields();
        }/* ww  w .jav a 2s. c om*/
    }

    final BulkActionHolder bulk = new BulkActionHolder(actions, allOrNothing);
    final String body = serializer.toString(bulk);

    String url;
    try {
        url = buildUrl(config.getDatabaseUrl(), (Map<String, String>) null, BULK_DOCS);
    } catch (final MalformedURLException e) {
        throw new CouchDBException("Failed to format bulk-update URL: %s", e, e.getMessage());
    }

    final HttpPost request = new HttpPost(url);
    try {
        request.setEntity(new StringEntity(body, "application/json", "UTF-8"));
    } catch (final UnsupportedEncodingException e) {
        throw new CouchDBException("Failed to encode POST entity for bulk update: %s", e, e.getMessage());
    }

    try {
        final HttpResponse response = client.executeHttpWithResponse(request, "Bulk update failed");
        final StatusLine statusLine = response.getStatusLine();
        final int code = statusLine.getStatusCode();
        if (code != SC_OK && code != SC_CREATED) {
            String content = null;
            final HttpEntity entity = response.getEntity();
            if (entity != null) {
                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
                InputStream in = null;
                try {
                    in = entity.getContent();
                    copy(in, baos);
                } catch (final IOException e) {
                    throw new CouchDBException("Error reading response content for error: %s\nError was: %s", e,
                            statusLine, e.getMessage());
                } finally {
                    closeQuietly(in);
                }

                content = new String(baos.toByteArray());
            }

            throw new CouchDBException("Bulk operation failed. Status line: %s\nContent:\n----------\n\n%s",
                    statusLine, content);
        }
    } finally {
        client.cleanup(request);
    }

    // threadedExecute( new HashSet<CouchDocumentAction>( actions ), dbUrl );
}

From source file:com.googlecode.CallerLookup.Main.java

public void doUpdate() {
    showDialog(DIALOG_PROGRESS);//w w w . ja  v  a2  s . com
    savePreferences();
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                URL uri = new URL(UPDATE_URL);
                URLConnection urlc = uri.openConnection();
                long lastModified = urlc.getLastModified();
                if ((lastModified == 0) || (lastModified != mPrefs.getLong(PREFS_UPDATE, 0))) {
                    FileOutputStream file = getApplicationContext().openFileOutput(UPDATE_FILE, MODE_PRIVATE);
                    OutputStreamWriter content = new OutputStreamWriter(file);

                    String tmp;
                    InputStream is = urlc.getInputStream();
                    BufferedReader br = new BufferedReader(new InputStreamReader(is));
                    while ((tmp = br.readLine()) != null) {
                        content.write(tmp + "\n");
                    }

                    content.flush();
                    content.close();
                    file.close();

                    SharedPreferences.Editor prefsEditor = mPrefs.edit();
                    prefsEditor.putLong(PREFS_UPDATE, lastModified);
                    prefsEditor.commit();

                    Message message = mUpdateHandler.obtainMessage();
                    message.what = MESSAGE_UPDATE_FINISHED;
                    mUpdateHandler.sendMessage(message);
                } else {
                    Message message = mUpdateHandler.obtainMessage();
                    message.what = MESSAGE_UPDATE_UNNECESSARY;
                    mUpdateHandler.sendMessage(message);
                }
            } catch (MalformedURLException e) {
                System.out.println(e.getMessage());
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
        }
    }).start();
}

From source file:com.celamanzi.liferay.portlets.rails286.BodyTagVisitor.java

/** 
 * Recurses to every HTML tag.//from  w  w  w . j a  va 2s. c o  m
 * This function converts the hyperlinks to parameters in the portletUrl.
 * The RenderFilter picks this parameter, stores it to session and launches an
 * http request. GET works fine, POST has some problems.
 *
 * It is possible to escape the portlet link by adding "exit_portlet=true"
 * to the HTTP request parameters. (www.example.com?exit_portlet=true)
 */
public void visitTag(Tag tag) {

    //log.debug("Encountered a " + tag.getClass()); // Floods the debug channel
    RouteAnalyzer ra = new RouteAnalyzer(baseUrl, servlet);

    Pattern pattern = null;
    Matcher matcher = null;

    /**
     * Replace the <body> tag with <div id=%namespace%_body> 
     */
    if (tag instanceof BodyTag) {
        BodyTag b = (BodyTag) tag;
        String id = namespace + "_body"; // also defined in HeadProcessor()

        log.debug("Replacing <body> with <div id=" + id + ">");
        b.setTagName("div");
        b.getEndTag().setTagName("/div");
        b.setAttribute("id", "\"" + id + "\""); // damn, htmlparser does not produce clean XHTML
    }

    /**
     * Convert links ###(, only if portletUrl is defined).
     * - PortletURL is not available while "testing".
     * - skip if parameter 'exit_portlet=true'.
     */
    //     else if ((tag instanceof LinkTag) && (portletUrl != null))
    else if (tag instanceof LinkTag) {

        LinkTag link = (LinkTag) tag;
        PortletURL newHref = portletUrl;

        /** HTTP */
        if ((link.isHTTPLink()) && (!link.getLink().equals(""))) {
            log.debug("Encountered a HTTPLink: " + link.getLink());
            String href = link.getAttribute("href");
            String route = null;
            String onclick = null;
            String newLink = null;

            /** Ajax 
              */
            // links with href="#" and onclick="new Ajax.Updater"
            pattern = Pattern.compile("^#$");
            matcher = pattern.matcher(href);
            if (matcher.find()) {
                /* Prototype:
                <a onclick="new Ajax.Updater('result', '/caterpillar/test_bench/xhr/get_time', {asynchronous:true, evalScripts:true}); return false;" href="#">
                */
                onclick = (String) link.getAttribute("onclick");
                if (onclick != null) {
                    log.debug("onclick: " + onclick);
                    Pattern ajax_pattern = Pattern.compile("Ajax.Updater\\(([^\\)]*)");
                    Matcher ajax_matcher = ajax_pattern.matcher(onclick);
                    if (ajax_matcher.find()) {
                        // 'result', '/caterpillar/test_bench/xhr/get_time', {asynchronous:true, evalScripts:true}
                        String[] ajax = ajax_matcher.group(1).split(", ");
                        // /caterpillar/test_bench/xhr/get_time
                        String ajax_url = ajax[1].substring(1, ajax[1].length() - 1);
                        log.debug("Ajax url: " + ajax_url);
                        resourceUrl.setParameter("railsRoute", ajax_url);
                        // <a onclick="new Ajax.Updater('result', 'http://liferay-resource-url?route=/ajax_url', ....
                        onclick = onclick.replaceFirst(ajax_url, resourceUrl.toString());
                        log.debug("new onclick: " + onclick);
                        link.setAttribute("onclick", onclick);
                    }
                } else {
                    log.warn("Unknown type JavaScript link passed: " + link.toHtml());
                }
                return;
            }

            // the link might be plain "some_file.htm(l)",
            // that will raise MalformedURLException.
            String local_file = "^[a-zA-Z0-9_%]*.htm";
            pattern = Pattern.compile(local_file);
            matcher = pattern.matcher(href);
            if (matcher.find()) {
                log.debug("Protocolless URL: " + href);
                href = baseUrl + href;
            }

            /** 
             * Exiting portlet?
             *
             * - check if the parameter 'exit_portlet' is 'true'.
             *   => return the link as such, ie. not wrapped in PortletURL.
             */
            String exit_param = "exit_portlet=(true|false)";
            pattern = Pattern.compile(exit_param);
            matcher = pattern.matcher(href);

            if (matcher.find()) {
                log.debug("Exit portlet parameter encountered: " + exit_param);
                // TODO: use a proper replace regexp, so sanitization is not required.
                href = href.replaceFirst(exit_param, ""); // remove the parameter
                href = href.replaceFirst("&amp;$", ""); // sanitize
                href = href.replaceFirst("\\?&amp;", "?"); // sanitize
                href = href.replaceFirst("\\?$", ""); // sanitize
                log.debug("Saving link: " + href);
                link.setLink(href);

                /** URL -> PortletURL */
            } else {
                /** onclick javascript */
                if (link.getAttribute("onclick") != null) {
                    log.debug("Onclick attribute detected");
                    onclick = link.getAttribute("onclick");
                    //log.debug(onclick);

                    pattern = Pattern.compile("document.createElement('form')");
                    matcher = pattern.matcher(onclick);
                    log.debug("Onclick creates a form");

                    /** Replaces the onclick JavaScript's action URL to portlet actionUrl, and sets the originalActionUrl parameter. 
                     * This is handled in processAction().
                     * Some repetition with the regular HTML form handler (in this one giant function).
                     */
                    if (actionUrl != null) {
                        log.debug("Replacing onclick url with actionUrl");

                        // add originalActionUrl to form parameters by adding an input
                        // element to the page.
                        String js = null;
                        try {
                            js = "var inp=document.createElement(\"input\");inp.name='originalActionUrl';inp.value='"
                                    + ra.getRequestRoute(href) + "';f.appendChild(inp);";
                        } catch (java.net.MalformedURLException e) {
                            log.error(e.getMessage());
                        }
                        //log.debug(js);

                        // alter the onClick
                        onclick = onclick.replaceFirst("this.href", "'" + actionUrl.toString() + "'")
                                .replaceFirst("f.submit", js + "f.submit");
                        // set the new link
                        log.debug("Setting the onclick attribute to the new link");
                        link.setAttribute("onclick", onclick);
                        log.debug(onclick);
                        newLink = "#";
                    }

                    // onclick
                    /** Extract the Rails route */
                } else {
                    try {
                        route = ra.getRequestRoute(href);
                        // prevent parameter separator '&amp;' from being sent as &amp;amp;
                        route = route.replaceAll("&amp;", "&");
                    } catch (java.net.MalformedURLException e) {
                        log.error(e.getMessage());
                    }
                } // route

                /** Strip target.
                 * If there is a target, the browser will open a new tab (or an instance) and fail to convert links on that page
                 */
                String target = link.getAttribute("target");
                if (target != null) {
                    log.debug("Removing the target attribute \"" + target + "\"");
                    link.removeAttribute("target");
                }

                /** Change the link
                XXX: was absolute path checking made for download feature?
                Rails can also have a hard link...
                 */
                //if (!RouteAnalyzer.isAbsolutePath(route) && portletUrl != null) {
                if (portletUrl != null) {
                    if (route != null) {

                        //Clear scheme + location
                        Pattern url_pattern = Pattern.compile("^https?://[^/]*");
                        Matcher url_matcher = url_pattern.matcher(route);
                        if (url_matcher.find()) {
                            log.debug("absolute url - reverting to default host");
                            route = url_matcher.replaceFirst("");
                        }

                        newHref.setParameter("railsRoute", route);
                        log.debug("Added parameter railsRoute to the PortletURL: " + route);
                        newLink = newHref.toString();
                    }

                    log.debug("Replacing the original link tag to: " + newLink);
                    link.setLink(newLink);

                } else {
                    log.debug("portletUrl is null");
                }

            }
        } // exit portlet?
        /*      else if (link.isEndTag()) {
        log.debug("Link end tag detected -- where is the begin tag? This is a bug.");
        log.debug(tag.getText());
        }*/
        else if (link.isHTTPSLink()) {
            log.warn("Cannot handle HTTPS links yet");
        }
        //else if (link.isJavascriptLink()) { log.warn("Cannot handle JavaScript links yet"); }
        else if (link.isMailLink()) {
            log.debug("No changes to mail links");
        } else if (link.isFTPLink()) {
            log.debug("No changes to FTP links");
        } else if (link.isIRCLink()) {
            log.debug("No changes to IRC links");
        } else {
            log.warn("fixme: Encountered an unknown link type: " + link.getLink());
        }
    }

    /**
     * Convert images
     */
    else if (tag instanceof ImageTag) {
        ImageTag img = (ImageTag) tag;
        String src = img.getImageURL();
        java.net.URL srcUrl = null;

        // break if the source is an external image
        if (isExternal(src)) {
            log.debug("Preserving image " + src);
            return;
        }

        /* If the src should be translated:
         * 1) check if the src is absolute or relative
         * 2) if absolute => add baseUrl prefix
         * 3) if relative => add baseUrl + documentPath prefix
         */

        String path = "";

        // TODO: move RouteAnalyzer up here

        // HACK: lookout for http, let RouteAnalyzer do this
        Pattern rel_link_pattern = Pattern.compile("^http");
        Matcher rel_link_matcher = rel_link_pattern.matcher(src);
        if (rel_link_matcher.find()) {
            log.debug(src + " is already a full URL, preserving");
            return;
        }

        log.debug("Converting image " + src);

        // test if the src begins with slash '/'
        rel_link_pattern = Pattern.compile("^/");
        rel_link_matcher = rel_link_pattern.matcher(src);
        if (!rel_link_matcher.find()) {
            log.debug("The image path \"" + src + "\" is relative");
            path += '/';
        } else {
            log.debug("The image path \"" + src + "\" is absolute");
        }

        path += src;
        String url = null;
        try {
            url = ra.getFullURL(path).toString();
        } catch (java.net.MalformedURLException e) {
            log.error(e.getMessage());
            return;
        }

        log.debug("New image URL: " + url);
        img.setImageURL(url);
    }

    /**
     * Convert forms, only if actionUrl is defined
     */
    else if (tag instanceof FormTag) {
        if (actionUrl == null) {
            log.warn("Form action cannot be manipulated - portlet actionURL is null");
            return;
        }
        FormTag frm = (FormTag) tag;
        String method = frm.getFormMethod();
        //String formAction = frm.extractFormLocn();
        String formAction = frm.getFormLocation();
        log.debug("form " + method + " to action: " + formAction);
        //log.debug(frm.toString());

        /** 
         * Exiting portlet?
         * Yes, this is a duplicate from the LinkTag handling.
         * Not good, not good at all.
         */
        String exit_param = "exit_portlet=(true|false)";
        pattern = Pattern.compile(exit_param);
        matcher = pattern.matcher(formAction);
        if (matcher.find()) {
            log.debug("Exit portlet parameter encountered: " + exit_param);
            // TODO: use a proper replace regexp, so sanitization is not required.
            formAction = formAction.replaceFirst(exit_param, ""); // remove the parameter
            formAction = formAction.replaceFirst("&amp;$", ""); // sanitize
            formAction = formAction.replaceFirst("\\?&amp;", "?"); // sanitize
            formAction = formAction.replaceFirst("\\?$", ""); // sanitize
            log.debug("Saving form action: " + formAction);
            frm.setFormLocation(formAction);
            return;
        }

        /** RouteAnalyzer */
        try {
            formAction = ra.getRequestRoute(formAction);

        } catch (java.net.MalformedURLException e) {
            log.error(e.getMessage());
        }

        log.debug("Full action URL: " + formAction);

        if (method.equals("post") || method.equals("put")) {
            // replace the action URL with the portlet actionURL
            String portletAction = actionUrl.toString();
            log.debug("New form action URL: " + portletAction);
            frm.setFormLocation(portletAction);

            // TODO: iterate all form tags and add namespace

            // create a new hidden tag that stores the original action url
            String newtag = "<div style=\"display: none;\">";
            newtag += "<input name=\"" + namespace + "originalActionUrl"
                    + "\" type=\"text\" size=\"0\" value=\"" + formAction + "\" />";
            newtag += "<input name=\"" + namespace + "originalActionMethod"
                    + "\" type=\"text\" size=\"0\" value=\"" + method + "\" />";
            newtag += "</div>";

            // get the children to add a new node into
            NodeList inputs = frm.getChildren();
            try {
                Parser parser = new Parser(newtag);
                log.debug("Adding a new form child input tag: " + newtag);
                if (!newtag.equals("")) {
                    inputs.add(parser.parse(null));
                }
            } catch (ParserException pe) {
                log.error(pe.getMessage());
            }
            frm.setChildren(inputs);
        }

        // other specific tags and generic TagNode objects
    } else {
    }
}

From source file:com.attentec.AttentecService.java

/**
 * Fetch image from server./*from w w  w  . j a v a2  s . c o m*/
 * @param path to the image
 * @return return png image as an ByteArray
 * @throws GetImageException on failure of any kind
 */
private byte[] getImage(final String path) throws GetImageException {
    URL url;
    try {
        url = new URL(PreferencesHelper.getServerUrlbase(ctx) + path.replaceAll(" ", "%20"));
    } catch (MalformedURLException e) {
        throw new GetImageException("Could not parse URL: " + e.getMessage());
    }
    Log.d(TAG, "Getting image with URL: " + url.toString());

    //Open connection
    URLConnection ucon;
    try {
        ucon = url.openConnection();
    } catch (IOException e) {
        throw new GetImageException("Could not open URL-connection: " + e.getMessage());
    }

    //Get Image
    InputStream is;
    try {
        is = ucon.getInputStream();
    } catch (IOException e) {
        throw new GetImageException("Could not get InputStream: " + e.getMessage());
    }
    //Setup buffers
    BufferedInputStream bis = new BufferedInputStream(is, INPUT_BUFFER_SIZE);
    ByteArrayBuffer baf = new ByteArrayBuffer(INPUT_BUFFER_SIZE);

    //Put content into bytearray
    int current = 0;
    try {
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }
    } catch (IOException e) {
        throw new GetImageException("Could not read from BufferedInputStream(bis): " + e.getMessage());
    }

    return baf.toByteArray();
}

From source file:org.commonjava.couch.db.CouchManager.java

public boolean viewExists(final String appName, final String viewName) throws CouchDBException {
    try {//from ww  w  .ja  v a 2 s. c o m
        return exists(buildUrl(config.getDatabaseUrl(), (Map<String, String>) null, APP_BASE, appName,
                VIEW_BASE, viewName));
    } catch (final MalformedURLException e) {
        throw new CouchDBException("Cannot format view URL for: %s in: %s. Reason: %s", e, viewName, appName,
                e.getMessage());
    } catch (final CouchDBException e) {
        throw new CouchDBException("Cannot verify existence of view: %s in: %s. Reason: %s", e, viewName,
                appName, e.getMessage());
    }
}

From source file:com.googlecode.fightinglayoutbugs.DetectInvalidImageUrls.java

private void checkVisibleImgElements() {
    int numImgElementsWithoutSrcAttribute = 0;
    int numImgElementsWithEmptySrcAttribute = 0;
    final Set<String> seen = new HashSet<String>();
    for (WebElement img : _webPage.findElements(By.tagName("img"))) {
        if (img.isDisplayed()) {
            final String src = img.getAttribute("src");
            if (src == null) {
                ++numImgElementsWithoutSrcAttribute;
            } else if ("".equals(src)) {
                ++numImgElementsWithEmptySrcAttribute;
            } else {
                if (seen.add(src)) {
                    try {
                        checkImageUrl(src,
                                "Detected visible <img> element with invalid src attribute \"" + src + "\"");
                    } catch (MalformedURLException e) {
                        addLayoutBugIfNotPresent("Detected visible <img> element with invalid src attribute \""
                                + src + "\" -- " + e.getMessage());
                    }/*from  w ww  . j  a v  a 2  s.  co m*/
                }
            }
        }
    }
    if (numImgElementsWithEmptySrcAttribute > 0) {
        if (numImgElementsWithEmptySrcAttribute == 1) {
            addLayoutBugIfNotPresent("Detected visible <img> element with empty src attribute.");
        } else {
            addLayoutBugIfNotPresent("Detected " + numImgElementsWithEmptySrcAttribute
                    + " visible <img> elements with empty src attribute.");
        }
    }
    if (numImgElementsWithoutSrcAttribute > 0) {
        if (numImgElementsWithEmptySrcAttribute == 1) {
            addLayoutBugIfNotPresent("Detected visible <img> without src attribute.");
        } else {
            addLayoutBugIfNotPresent("Detected " + numImgElementsWithoutSrcAttribute
                    + " visible <img> elements without src attribute.");
        }
    }
}

From source file:cz.vsb.gis.ruz76.gt.Examples.java

public SimpleFeatureCollection overlayCollectionOutput(String pointString, double distance) {
    //Problems with WFS ourptu - JSON and SHP works
    //https://github.com/geotools/geotools/blob/master/modules/unsupported/process-feature/src/main/java/org/geotools/process/vector/BufferFeatureCollection.java
    long milis = System.currentTimeMillis();
    String geoserverpath = "/data/install/gis/geoserver/geoserver-2.8.2";
    SimpleFeatureCollection collection = null;
    try {//from  w w  w . j  a  va  2 s  . c o  m

        //SHP Read
        ShapefileDataStore sfds = new ShapefileDataStore(
                new URL("file://" + geoserverpath + "/data_dir/data/sf/restricted.shp"));
        SimpleFeatureSource fs = sfds.getFeatureSource("restricted");

        SimpleFeatureType TYPE = fs.getSchema();
        //double distance = 10000.0d;
        GeometryFactory gf = new GeometryFactory();
        String xy[] = pointString.split(" ");
        Point point = gf.createPoint(new Coordinate(Double.parseDouble(xy[0]), Double.parseDouble(xy[1])));

        Polygon p1 = (Polygon) point.buffer(distance);
        List<SimpleFeature> features = new ArrayList<>();
        SimpleFeatureIterator sfi = fs.getFeatures().features();
        while (sfi.hasNext()) {
            SimpleFeature sf = sfi.next();
            MultiPolygon mp2 = (MultiPolygon) sf.getDefaultGeometry();
            Polygon p2 = (Polygon) mp2.getGeometryN(0);
            Polygon p3 = (Polygon) p2.intersection(p1);
            if (p3.getArea() > 0) {
                sf.setDefaultGeometry(p3);
                features.add(sf);
            }
        }
        collection = new ListFeatureCollection(TYPE, features);
        //saveFeatureCollectionToShapefile(geoserverpath + "/data_dir/data/" + workspace + "/overlay/overlay.shp", features, TYPE);

    } catch (MalformedURLException ex) {
        System.out.println(ex.getMessage());
        Logger.getLogger(Examples.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex2) {
        System.out.println(ex2.getMessage());
        Logger.getLogger(Examples.class.getName()).log(Level.SEVERE, null, ex2);
    }

    return collection;
}

From source file:com.sikulix.core.SX.java

public static URL getFileURL(Object... args) {
    File aFile = getFile(args);//from  ww  w.  j a  v a  2s. co  m
    if (isNotSet(aFile)) {
        return null;
    }
    try {
        return new URL("file:" + aFile.toString());
    } catch (MalformedURLException e) {
        error("getFileURL: %s error(%s)", aFile, e.getMessage());
        return null;
    }
}