Package de.anomic.crawler.ResultURLs

Examples of de.anomic.crawler.ResultURLs.EventOrigin


            post = new serverObjects();
            post.put("process", "0");
        }

        // find process number
        EventOrigin tabletype;
        try {
            tabletype = EventOrigin.getEvent(post.getInt("process", 0));
        } catch (final NumberFormatException e) {
            tabletype = EventOrigin.UNKNOWN;
        }

        if (
            post != null &&
            post.containsKey("autoforward") &&
            tabletype == EventOrigin.LOCAL_CRAWLING &&
            ResultURLs.getStackSize(EventOrigin.LOCAL_CRAWLING) == 0) {
            // the main menu does a request to the local crawler page, but in case this table is empty, the overview page is shown
            tabletype = (ResultURLs.getStackSize(EventOrigin.SURROGATES) == 0) ? EventOrigin.UNKNOWN : EventOrigin.SURROGATES;
        }
       
        // check if authorization is needed and/or given
        if (tabletype != EventOrigin.UNKNOWN ||
            (post != null && (post.containsKey("clearlist") ||
            post.containsKey("deleteentry")))) {
            final String authorization = (header.get(RequestHeader.AUTHORIZATION, "xxxxxx"));
            if (authorization.length() != 0) {
                if (! sb.verifyAuthentication(header, true)){
                    // force log-in (again, because wrong password was given)
                    prop.put("AUTHENTICATE", "admin log-in");
                    return prop;
                }
            } else {
                // force log-in
                prop.put("AUTHENTICATE", "admin log-in");
                return prop;
            }
        }

        if (post != null) {
            // custom number of lines
            if (post.containsKey("count")) {
                lines = post.getInt("count", 500);
            }

            // do the commands
            if (post.containsKey("clearlist")) ResultURLs.clearStack(tabletype);

            if (post.containsKey("deleteentry")) {
                final String hash = post.get("hash", null);
                if (hash != null) {
                    // delete from database
                    sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).remove(hash.getBytes());
                }
            }

            if (post.containsKey("deletedomain")) {
                final String hashpart = post.get("hashpart", null);
                final String domain = post.get("domain", null);
                if (hashpart != null) {
                    // delete all urls for this domain from database
                    try {
                        sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).deleteDomain(hashpart);
                        ResultURLs.deleteDomain(tabletype, domain, hashpart);
                    } catch (IOException e) {
                        Log.logException(e);
                    }
                }
            }

            if (post.containsKey("moreIndexed")) {
                lines = post.getInt("showIndexed", 500);
            }

            if (post.get("si") != null) showInit = !("0".equals(post.get("si")));
            if (post.get("se") != null) showExec = !("0".equals(post.get("se")));
            if (post.get("sd") != null) showDate = !("0".equals(post.get("sd")));
            if (post.get("sw") != null) showWords = !("0".equals(post.get("sw")));
            if (post.get("st") != null) showTitle = !("0".equals(post.get("st")));
            if (post.get("su") != null) showURL = !("0".equals(post.get("su")));
        } // end != null

        // create table
        if (tabletype == EventOrigin.UNKNOWN) {
            prop.put("table", "2");
        } else if (ResultURLs.getStackSize(tabletype) == 0 && ResultURLs.getDomainListSize(tabletype) == 0) {
            prop.put("table", "0");
        } else {
            prop.put("table", "1");
            if (lines > ResultURLs.getStackSize(tabletype)) lines = ResultURLs.getStackSize(tabletype);
            if (lines == ResultURLs.getStackSize(tabletype)) {
                prop.put("table_size", "0");
            } else {
                prop.put("table_size", "1");
                prop.put("table_size_count", lines);
            }
            prop.put("table_size_all", ResultURLs.getStackSize(tabletype));
           
            prop.putHTML("table_feedbackpage", "CrawlResults.html");
            prop.put("table_tabletype", tabletype.getCode());
            prop.put("table_showInit", (showInit) ? "1" : "0");
            prop.put("table_showExec", (showExec) ? "1" : "0");
            prop.put("table_showDate", (showDate) ? "1" : "0");
            prop.put("table_showWords", (showWords) ? "1" : "0");
            prop.put("table_showTitle", (showTitle) ? "1" : "0");
            prop.put("table_showURL", (showURL) ? "1" : "0");

            boolean dark = true;
            String urlstr, urltxt;
            yacySeed initiatorSeed, executorSeed;
            URIMetadataRow urle;
            URIMetadataRow.Components metadata;

            int cnt = 0;
            final Iterator<Map.Entry<String, InitExecEntry>> i = ResultURLs.results(tabletype);
            Map.Entry<String, InitExecEntry> entry;
            while (i.hasNext()) {
                entry = i.next();
                try {
                    urle = sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).load(UTF8.getBytes(entry.getKey()));
                    if (urle == null) {
                        Log.logWarning("PLASMA", "CrawlResults: URL not in index with url hash " + entry.getKey());
                        urlstr = null;
                        urltxt = null;
                        metadata = null;
                        continue;
                    }
                    metadata = urle.metadata();
                    urlstr = metadata.url().toNormalform(false, true);
                    urltxt = nxTools.shortenURLString(urlstr, 72); // shorten the string text like a URL
                   
                    initiatorSeed = entry.getValue() == null || entry.getValue().initiatorHash == null ? null : sb.peers.getConnected(ASCII.String(entry.getValue().initiatorHash));
                    executorSeed = entry.getValue() == null || entry.getValue().executorHash == null ? null : sb.peers.getConnected(ASCII.String(entry.getValue().executorHash));

                    prop.put("table_indexed_" + cnt + "_dark", (dark) ? "1" : "0");
                    prop.put("table_indexed_" + cnt + "_feedbackpage", "CrawlResults.html");
                    prop.put("table_indexed_" + cnt + "_tabletype", tabletype.getCode());
                    prop.put("table_indexed_" + cnt + "_urlhash", entry.getKey());

                    if (showInit) {
                        prop.put("table_indexed_" + cnt + "_showInit", "1");
                        prop.put("table_indexed_" + cnt + "_showInit_initiatorSeed", (initiatorSeed == null) ? "unknown" : initiatorSeed.getName());
                    } else
                        prop.put("table_indexed_" + cnt + "_showInit", "0");

                    if (showExec) {
                        prop.put("table_indexed_" + cnt + "_showExec", "1");
                        prop.put("table_indexed_" + cnt + "_showExec_executorSeed", (executorSeed == null) ? "unknown" : executorSeed.getName());
                    } else
                        prop.put("table_indexed_" + cnt + "_showExec", "0");

                    if (showDate && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showDate", "1");
                        prop.put("table_indexed_" + cnt + "_showDate_modified", daydate(urle.moddate()));
                    } else
                        prop.put("table_indexed_" + cnt + "_showDate", "0");

                    if (showWords && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showWords", "1");
                        prop.put("table_indexed_" + cnt + "_showWords_count", urle.wordCount());
                    } else
                        prop.put("table_indexed_" + cnt + "_showWords", "0");

                    if (showTitle) {
                        prop.put("table_indexed_" + cnt + "_showTitle", (showTitle) ? "1" : "0");
                            prop.put("table_indexed_" + cnt + "_showTitle_available", "1");

                            if (metadata == null || metadata.dc_title() == null || metadata.dc_title().trim().length() == 0)
                                prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "0");
                            else {
                                prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "1");
                                prop.putHTML("table_indexed_" + cnt + "_showTitle_available_nodescr_urldescr", metadata.dc_title());
                            }

                            prop.put("table_indexed_" + cnt + "_showTitle_available_urlHash", entry.getKey());
                            prop.putHTML("table_indexed_" + cnt + "_showTitle_available_urltitle", urlstr);
                    } else
                        prop.put("table_indexed_" + cnt + "_showTitle", "0");

                    if (showURL) {
                        prop.put("table_indexed_" + cnt + "_showURL", "1");
                            prop.put("table_indexed_" + cnt + "_showURL_available", "1");

                            prop.put("table_indexed_" + cnt + "_showURL_available_urlHash", entry.getKey());
                            prop.putHTML("table_indexed_" + cnt + "_showURL_available_urltitle", urlstr);
                            prop.put("table_indexed_" + cnt + "_showURL_available_url", urltxt);
                    } else
                        prop.put("table_indexed_" + cnt + "_showURL", "0");

                    dark = !dark;
                    cnt++;
                } catch (final Exception e) {
                    Log.logSevere("PLASMA", "genTableProps", e);
                }
            }
            prop.put("table_indexed", cnt);
           
            cnt = 0;
            dark = true;
            final Iterator<String> j = ResultURLs.domains(tabletype);
            String domain;
            while (j.hasNext() && cnt < 100) {
                domain = j.next();
                if (domain == null) break;
                prop.put("table_domains_" + cnt + "_dark", (dark) ? "1" : "0");
                prop.put("table_domains_" + cnt + "_feedbackpage", "CrawlResults.html");
                prop.put("table_domains_" + cnt + "_tabletype", tabletype.getCode());
                prop.put("table_domains_" + cnt + "_domain", domain);
                prop.put("table_domains_" + cnt + "_hashpart", DigestURI.hosthash6(domain));
                prop.put("table_domains_" + cnt + "_count", ResultURLs.domainCount(tabletype, domain));
                dark = !dark;
                cnt++;
            }
            prop.put("table_domains", cnt);
        }
        prop.put("process", tabletype.getCode());
        // return rewrite properties
        return prop;
    }
View Full Code Here


        return new indexingQueueEntry(in.process, in.queueEntry, documents, null);
    }

    private Document[] parseDocument(final Response response) throws InterruptedException {
        Document[] documents = null;
        final EventOrigin processCase = response.processCase(this.peers.mySeed().hash);

        if (this.log.isFine()) {
            this.log.logFine("processResourceStack processCase=" + processCase +
                ", depth=" + response.depth() +
                ", maxDepth=" + ((response.profile() == null) ? "null" : Integer.toString(response.profile().depth())) +
View Full Code Here

    private void storeDocumentIndex(final Segments.Process process, final Response queueEntry, final Document document, final Condenser condenser, final SearchEvent searchEvent, final String sourceName) {

        // CREATE INDEX
        final String dc_title = document.dc_title();
        final DigestURI referrerURL = queueEntry.referrerURL();
        EventOrigin processCase = queueEntry.processCase(this.peers.mySeed().hash);
        if (process == Segments.Process.SURROGATES) {
            processCase = EventOrigin.SURROGATES;
        }

        if (condenser == null || document.indexingDenied()) {
View Full Code Here

        // 2) result of search queries, some indexes are here (not possible here)
        // 3) result of index transfer, some of them are here (not possible here)
        // 4) proxy-load (initiator is "------------")
        // 5) local prefetch/crawling (initiator is own seedHash)
        // 6) local fetching for global crawling (other known or unknwon initiator)
        EventOrigin processCase = EventOrigin.UNKNOWN;
        // FIXME the equals seems to be incorrect: String.equals(boolean)
        if (initiator() == null || initiator().length == 0 || ASCII.String(initiator()).equals("------------")) {
            // proxy-load
            processCase = EventOrigin.PROXY_LOAD;
        } else if (UTF8.String(initiator()).equals(mySeedHash)) {
View Full Code Here

            post = new serverObjects();
            post.put("process", "0");
        }

        // find process number
        EventOrigin tabletype;
        try {
            tabletype = EventOrigin.getEvent(post.getInt("process", 0));
        } catch (final NumberFormatException e) {
            tabletype = EventOrigin.UNKNOWN;
        }

        if (
            post != null &&
            post.containsKey("autoforward") &&
            tabletype == EventOrigin.LOCAL_CRAWLING &&
            ResultURLs.getStackSize(EventOrigin.LOCAL_CRAWLING) == 0) {
            // the main menu does a request to the local crawler page, but in case this table is empty, the overview page is shown
            tabletype = (ResultURLs.getStackSize(EventOrigin.SURROGATES) == 0) ? EventOrigin.UNKNOWN : EventOrigin.SURROGATES;
        }

        // check if authorization is needed and/or given
        if (tabletype != EventOrigin.UNKNOWN ||
            (post != null && (post.containsKey("clearlist") ||
            post.containsKey("deleteentry")))) {
            final String authorization = (header.get(RequestHeader.AUTHORIZATION, "xxxxxx"));
            if (authorization.length() != 0) {
                if (! sb.verifyAuthentication(header)){
                    // force log-in (again, because wrong password was given)
                    prop.put("AUTHENTICATE", "admin log-in");
                    return prop;
                }
            } else {
                // force log-in
                prop.put("AUTHENTICATE", "admin log-in");
                return prop;
            }
        }

        if (post != null) {
            // custom number of lines
            if (post.containsKey("count")) {
                lines = post.getInt("count", 500);
            }

            // do the commands
            if (post.containsKey("clearlist")) ResultURLs.clearStack(tabletype);

            if (post.containsKey("deleteentry")) {
                final String hash = post.get("hash", null);
                if (hash != null) {
                    // delete from database
                    sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).remove(hash.getBytes());
                }
            }

            if (post.containsKey("deletedomain")) {
                final String domain = post.get("domain", null);
                final String hashpart = domain == null ? null : DigestURI.hosthash6(domain);
                if (hashpart != null) {
                    // delete all urls for this domain from database
                    try {
                        sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).deleteDomain(hashpart);
                        ResultURLs.deleteDomain(tabletype, domain, hashpart);
                    } catch (final IOException e) {
                        Log.logException(e);
                    }
                }
            }

            if (post.containsKey("moreIndexed")) {
                lines = post.getInt("showIndexed", 500);
            }

            if (post.get("si") != null) showInit    = !("0".equals(post.get("si")));
            if (post.get("se") != null) showExec    = !("0".equals(post.get("se")));
            if (post.get("sd") != null) showDate    = !("0".equals(post.get("sd")));
            if (post.get("sw") != null) showWords   = !("0".equals(post.get("sw")));
            if (post.get("st") != null) showTitle   = !("0".equals(post.get("st")));
            if (post.get("sc") != null) showCountry = !("0".equals(post.get("sc")));
            if (post.get("sp") != null) showIP      = !("0".equals(post.get("sp")));
            if (post.get("su") != null) showURL     = !("0".equals(post.get("su")));
        } // end != null

        // create table
        if (tabletype == EventOrigin.UNKNOWN) {
            prop.put("table", "2");
        } else if (ResultURLs.getStackSize(tabletype) == 0 && ResultURLs.getDomainListSize(tabletype) == 0) {
            prop.put("table", "0");
        } else {
            prop.put("table", "1");
            if (lines > ResultURLs.getStackSize(tabletype)) lines = ResultURLs.getStackSize(tabletype);
            if (lines == ResultURLs.getStackSize(tabletype)) {
                prop.put("table_size", "0");
            } else {
                prop.put("table_size", "1");
                prop.put("table_size_count", lines);
            }
            prop.put("table_size_all", ResultURLs.getStackSize(tabletype));

            prop.putHTML("table_feedbackpage", "CrawlResults.html");
            prop.put("table_tabletype", tabletype.getCode());
            prop.put("table_showInit",    (showInit) ? "1" : "0");
            prop.put("table_showExec",    (showExec) ? "1" : "0");
            prop.put("table_showDate",    (showDate) ? "1" : "0");
            prop.put("table_showWords",   (showWords) ? "1" : "0");
            prop.put("table_showTitle",   (showTitle) ? "1" : "0");
            prop.put("table_showCountry", (showCountry) ? "1" : "0");
            prop.put("table_showIP",      (showIP) ? "1" : "0");
            prop.put("table_showURL",     (showURL) ? "1" : "0");

            boolean dark = true;
            String urlstr, urltxt;
            Seed initiatorSeed, executorSeed;
            URIMetadataRow urle;
            URIMetadataRow.Components metadata;

            int cnt = 0;
            final Iterator<Map.Entry<String, InitExecEntry>> i = ResultURLs.results(tabletype);
            Map.Entry<String, InitExecEntry> entry;
            while (i.hasNext()) {
                entry = i.next();
                try {
                    urle = sb.indexSegments.urlMetadata(Segments.Process.LOCALCRAWLING).load(UTF8.getBytes(entry.getKey()));
                    if (urle == null) {
                        Log.logWarning("PLASMA", "CrawlResults: URL not in index with url hash " + entry.getKey());
                        urlstr = null;
                        urltxt = null;
                        metadata = null;
                        continue;
                    }
                    metadata = urle.metadata();
                    urlstr = metadata.url().toNormalform(false, true);
                    urltxt = nxTools.shortenURLString(urlstr, 72); // shorten the string text like a URL

                    initiatorSeed = entry.getValue() == null || entry.getValue().initiatorHash == null ? null : sb.peers.getConnected(ASCII.String(entry.getValue().initiatorHash));
                    executorSeed = entry.getValue() == null || entry.getValue().executorHash == null ? null : sb.peers.getConnected(ASCII.String(entry.getValue().executorHash));

                    prop.put("table_indexed_" + cnt + "_dark", (dark) ? "1" : "0");
                    prop.put("table_indexed_" + cnt + "_feedbackpage", "CrawlResults.html");
                    prop.put("table_indexed_" + cnt + "_tabletype", tabletype.getCode());
                    prop.put("table_indexed_" + cnt + "_urlhash", entry.getKey());

                    if (showInit) {
                        prop.put("table_indexed_" + cnt + "_showInit", "1");
                        prop.put("table_indexed_" + cnt + "_showInit_initiatorSeed", (initiatorSeed == null) ? "unknown" : initiatorSeed.getName());
                    } else
                        prop.put("table_indexed_" + cnt + "_showInit", "0");

                    if (showExec) {
                        prop.put("table_indexed_" + cnt + "_showExec", "1");
                        prop.put("table_indexed_" + cnt + "_showExec_executorSeed", (executorSeed == null) ? "unknown" : executorSeed.getName());
                    } else
                        prop.put("table_indexed_" + cnt + "_showExec", "0");

                    if (showDate && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showDate", "1");
                        prop.put("table_indexed_" + cnt + "_showDate_modified", daydate(urle.moddate()));
                    } else
                        prop.put("table_indexed_" + cnt + "_showDate", "0");

                    if (showWords && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showWords", "1");
                        prop.put("table_indexed_" + cnt + "_showWords_count", urle.wordCount());
                    } else
                        prop.put("table_indexed_" + cnt + "_showWords", "0");

                    if (showTitle) {
                        prop.put("table_indexed_" + cnt + "_showTitle", (showTitle) ? "1" : "0");
                        prop.put("table_indexed_" + cnt + "_showTitle_available", "1");

                        if (metadata == null || metadata.dc_title() == null || metadata.dc_title().trim().length() == 0)
                            prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "0");
                        else {
                            prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "1");
                            prop.putHTML("table_indexed_" + cnt + "_showTitle_available_nodescr_urldescr", metadata.dc_title());
                        }

                        prop.put("table_indexed_" + cnt + "_showTitle_available_urlHash", entry.getKey());
                        prop.putHTML("table_indexed_" + cnt + "_showTitle_available_urltitle", urlstr);
                    } else
                        prop.put("table_indexed_" + cnt + "_showTitle", "0");

                    if (showCountry && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showCountry", "1");
                        prop.put("table_indexed_" + cnt + "_showCountry_country", metadata.url().getLocale().getCountry());
                    } else
                        prop.put("table_indexed_" + cnt + "_showCountry", "0");

                    if (showIP && urle != null) {
                        prop.put("table_indexed_" + cnt + "_showIP", "1");
                        prop.put("table_indexed_" + cnt + "_showIP_ip", metadata.url().getInetAddress().getHostAddress());
                    } else
                        prop.put("table_indexed_" + cnt + "_showIP", "0");

                    if (showURL) {
                        prop.put("table_indexed_" + cnt + "_showURL", "1");
                        prop.put("table_indexed_" + cnt + "_showURL_available", "1");

                        prop.put("table_indexed_" + cnt + "_showURL_available_urlHash", entry.getKey());
                        prop.putHTML("table_indexed_" + cnt + "_showURL_available_urltitle", urlstr);
                        prop.put("table_indexed_" + cnt + "_showURL_available_url", urltxt);
                    } else
                        prop.put("table_indexed_" + cnt + "_showURL", "0");

                    dark = !dark;
                    cnt++;
                } catch (final Exception e) {
                    Log.logSevere("PLASMA", "genTableProps", e);
                }
            }
            prop.put("table_indexed", cnt);

            cnt = 0;
            dark = true;
            final Iterator<String> j = ResultURLs.domains(tabletype);
            String domain;
            while (j.hasNext() && cnt < 100) {
                domain = j.next();
                if (domain == null) break;
                prop.put("table_domains_" + cnt + "_dark", (dark) ? "1" : "0");
                prop.put("table_domains_" + cnt + "_feedbackpage", "CrawlResults.html");
                prop.put("table_domains_" + cnt + "_tabletype", tabletype.getCode());
                prop.put("table_domains_" + cnt + "_domain", domain);
                prop.put("table_domains_" + cnt + "_count", ResultURLs.domainCount(tabletype, domain));
                dark = !dark;
                cnt++;
            }
            prop.put("table_domains", cnt);
        }
        prop.put("process", tabletype.getCode());
        // return rewrite properties
        return prop;
    }
View Full Code Here

        // 2) result of search queries, some indexes are here (not possible here)
        // 3) result of index transfer, some of them are here (not possible here)
        // 4) proxy-load (initiator is "------------")
        // 5) local prefetch/crawling (initiator is own seedHash)
        // 6) local fetching for global crawling (other known or unknwon initiator)
        EventOrigin processCase = EventOrigin.UNKNOWN;
        // FIXME the equals seems to be incorrect: String.equals(boolean)
        if (initiator() == null || initiator().length == 0 || ASCII.String(initiator()).equals("------------")) {
            // proxy-load
            processCase = EventOrigin.PROXY_LOAD;
        } else if (UTF8.String(initiator()).equals(mySeedHash)) {
View Full Code Here

        return new indexingQueueEntry(in.process, in.queueEntry, documents, null);
    }

    private Document[] parseDocument(final Response response) throws InterruptedException {
        Document[] documents = null;
        final EventOrigin processCase = response.processCase(this.peers.mySeed().hash);

        if (this.log.isFine()) {
            this.log.logFine("processResourceStack processCase=" + processCase +
                ", depth=" + response.depth() +
                ", maxDepth=" + ((response.profile() == null) ? "null" : Integer.toString(response.profile().depth())) +
View Full Code Here

        // CREATE INDEX
        final String dc_title = document.dc_title();
        final DigestURI url = new DigestURI(document.dc_source());
        final DigestURI referrerURL = queueEntry.referrerURL();
        EventOrigin processCase = queueEntry.processCase(this.peers.mySeed().hash);
        if (process == Segments.Process.SURROGATES) {
            processCase = EventOrigin.SURROGATES;
        }

        if (condenser == null || document.indexingDenied()) {
View Full Code Here

TOP

Related Classes of de.anomic.crawler.ResultURLs.EventOrigin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.