Package net.yacy.search

Examples of net.yacy.search.Switchboard


import de.anomic.server.serverSwitch;

public class get {
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        // return variable that accumulates replacements
        final Switchboard switchboard = (Switchboard) env;
        final boolean isAdmin=switchboard.verifyAuthentication(header);
        final serverObjects prop = new serverObjects();
        String tag = null;
        final String date;
        //String url=""; //urlfilter not yet implemented
View Full Code Here


public final class list {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        if (post == null || env == null) throw new NullPointerException("post: " + post + ", sb: " + env);
        final Switchboard sb = (Switchboard) env;

        final String blackListName = post.get("listname", "");

        // return variable that accumulates replacements
        final serverObjects prop = new serverObjects();
        if ((post == null) || (env == null)) return prop;
        if (!Protocol.authentifyRequest(post, env)) return prop;

        final String col = post.get("col", "");
        final File listsPath = env.getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);

        String otherPeerName = null;
        if (post.containsKey("iam")) {
            final Seed bla = sb.peers.get(post.get("iam", ""));
            if (bla != null) otherPeerName = bla.getName();
        }
        if (otherPeerName == null) otherPeerName = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP);

        if ((sb.isRobinsonMode()) && (!sb.isInMyCluster(otherPeerName))) {
            // if we are a robinson cluster, answer only if this client is known by our network definition
            return null;
        }

        if (col.equals("black")) {
View Full Code Here

import de.anomic.server.serverSwitch;

public class delete_p {
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        // return variable that accumulates replacements
        final Switchboard switchboard = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        final boolean isAdmin=switchboard.verifyAuthentication(header);
        if(post!= null){
        if(!isAdmin){
          // force authentication if desired
              if(post.containsKey("login")){
                prop.put("AUTHENTICATE","admin log-in");
View Full Code Here

public class IndexImportOAIPMHList_p {

    public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
        final serverObjects prop = new serverObjects();
        final Switchboard sb = (Switchboard) env;

        prop.put("refresh", 0);
        prop.put("import", 0);
        prop.put("source", 0);
       
View Full Code Here

import de.anomic.server.serverSwitch;

public class all {
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        // return variable that accumulates replacements
        final Switchboard switchboard = (Switchboard) env;
        final boolean isAdmin=switchboard.verifyAuthentication(header);
        final serverObjects prop = new serverObjects();

        Iterator<String> it;
        if(post != null && post.containsKey("tag")){
            it=switchboard.bookmarksDB.getBookmarksIterator(post.get("tag"), isAdmin);
View Full Code Here

    public static serverObjects respond(
            final RequestHeader header,
            final serverObjects post,
            final serverSwitch env) {
        final servletProperties prop = new servletProperties();
        final Switchboard sb = (Switchboard)env;

        // read post for handle
        final String handle = (post == null) ? "" : post.get("handle", "");
        if (post != null) {
            if (post.containsKey("terminate")) try {
View Full Code Here

        searchengines.put("OAIster@OCLC", "http://oaister.worldcat.org/search?q=");
        searchengines.put("oai.yacy.net", "http://oai.yacy.net/yacysearch.html?verify=true&resource=local&nav=all&display=2&meanCount=5&query=");
    }

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final boolean authenticated = sb.adminAuthenticated(header) >= 2;
        final int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0);
        final servletProperties prop = new servletProperties();

        prop.put("display", display);

        String default_left = sb.getConfig("compare_yacy.left", defaultsearchL);
        if (!searchengines.containsKey(default_left)) default_left = defaultsearchL;
        String default_right = sb.getConfig("compare_yacy.right", defaultsearchR);
        if (!searchengines.containsKey(default_right)) default_right = defaultsearchR;

        if (post != null) {
            if (searchengines.get(post.get("left", default_left)) != null) {
                default_left = post.get("left", default_left);
                sb.setConfig("compare_yacy.left", default_left);
            }
            if (searchengines.get(post.get("right", default_right)) != null) {
                default_right = post.get("right", default_right);
                sb.setConfig("compare_yacy.right", default_right);
            }
        }

        prop.put("searchengines", order.length);
        String name;
View Full Code Here

public class suggest {

    private static final int meanMax = 30;

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final servletProperties prop = new servletProperties();

        final String ext = header.get("EXT", "");
        final boolean json = ext.equals("json");
        final boolean xml = ext.equals("xml");
View Full Code Here

        } catch (final ConcurrentModificationException e) {}
        return accessClone;
    }
   
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
    
        // return variable that accumulates replacements
        final serverObjects prop = new serverObjects();
        prop.setLocalized(!(header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml"));
        int page = 0;
        if (post != null) {
            page = post.getInt("page", 0);
        }
        prop.put("page", page);
    
        final int maxCount = 1000;
        boolean dark = true;
        if (page == 0) {
            final Iterator<String> i = sb.accessHosts();
            String host;
            int entCount = 0;
            try {
                while ((entCount < maxCount) && (i.hasNext())) {
                    host = i.next();
                    prop.putHTML("page_list_" + entCount + "_host", host);
                    prop.putNum("page_list_" + entCount + "_countSecond", sb.latestAccessCount(host, 1000));
                    prop.putNum("page_list_" + entCount + "_countMinute", sb.latestAccessCount(host, 1000 * 60));
                    prop.putNum("page_list_" + entCount + "_count10Minutes", sb.latestAccessCount(host, 1000 * 60 * 10));
                    prop.putNum("page_list_" + entCount + "_countHour", sb.latestAccessCount(host, 1000 * 60 * 60));
                    entCount++;
                }
            } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this
            prop.put("page_list", entCount);
            prop.put("page_num", entCount);
           
            entCount = 0;
            try {
                for (final Map.Entry<String, Integer> bfe: serverCore.bfHost.entrySet()) {
                    prop.putHTML("page_bflist_" + entCount + "_host", bfe.getKey());
                    prop.putNum("page_bflist_" + entCount + "_countSecond", bfe.getValue());
                    entCount++;
                }
            } catch (final ConcurrentModificationException e) {} // we dont want to synchronize this
            prop.put("page_bflist", entCount);
        } else if (page == 1) {
            String host = (post == null) ? "" : post.get("host", "");
            int entCount = 0;
            Collection<Track> access;
            Track entry;
            if (host.length() > 0) {
                access = sb.accessTrack(host);
                if (access != null) {
                    try {
                        final Iterator<Track> ii = listclone(access).iterator();
                        while (ii.hasNext()) {
                            entry = ii.next();
                            prop.putHTML("page_list_" + entCount + "_host", host);
                            prop.put("page_list_" + entCount + "_date", SimpleFormatter.format(new Date(entry.getTime())));
                            prop.putHTML("page_list_" + entCount + "_path", entry.getPath());
                            entCount++;
                        }
                    } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this
                }
            } else {
                try {
                    final Iterator<String> i = sb.accessHosts();
                    while ((entCount < maxCount) && (i.hasNext())) {
                        host = i.next();
                        access = sb.accessTrack(host);
                        final Iterator<Track> ii = listclone(access).iterator();
                        while (ii.hasNext()) {
                                entry = ii.next();
                                prop.putHTML("page_list_" + entCount + "_host", host);
                                prop.put("page_list_" + entCount + "_date", SimpleFormatter.format(new Date(entry.getTime())));
View Full Code Here

        return SimpleFormatter.format(date);
    }


    public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) throws IOException {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        if (post == null) {
            post = new serverObjects();
            post.put("page", "start");
        }

        prop.put("topmenu", sb.getConfigBool("publicTopmenu", true) ? 1 : 0);

        String access = sb.getConfig("WikiAccess", "admin");
        final String pagename = get(post, "page", "start");
        final String ip = get(post, HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
        String author = get(post, "author", ANONYMOUS);
        if (author.equals(ANONYMOUS)) {
            author = WikiBoard.guessAuthor(ip);
            if (author == null) {
                author = (sb.peers.mySeed() == null) ? ANONYMOUS : sb.peers.mySeed().get("Name", ANONYMOUS);
            }
        }

        if (post != null && post.containsKey("access")) {
            // only the administrator may change the access right
            if (!sb.verifyAuthentication(header)) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }

            access = post.get("access", "admin");
            sb.setConfig("WikiAccess", access);
        }
        if (access.equals("admin")) {
            prop.put("mode_access", "0");
        } else if (access.equals("all")) {
            prop.put("mode_access", "1");
        }

        WikiBoard.Entry page = sb.wikiDB.read(pagename);

        if (post != null && post.containsKey("submit")) {

            if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }

            // store a new page
            byte[] content;
            content = UTF8.getBytes(post.get("content", ""));
            final WikiBoard.Entry newEntry = sb.wikiDB.newEntry(pagename, author, ip, post.get("reason", "edit"), content);
            sb.wikiDB.write(newEntry);
            // create a news message
            final Map<String, String> map = new HashMap<String, String>();
            map.put("page", pagename);
            map.put("author", author.replace(',', ' '));
            if (!sb.isRobinsonMode() && post.get("content", "").trim().length() > 0 && !ByteBuffer.equals(page.page(), content)) {
                sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_WIKI_UPDATE, map);
            }
            page = newEntry;
            prop.putHTML("LOCATION", "/Wiki.html?page=" + pagename);
            prop.put("LOCATION", prop.get("LOCATION"));
        }

        if (post != null && post.containsKey("edit")) {
            if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }
View Full Code Here

TOP

Related Classes of net.yacy.search.Switchboard

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.