Package de.anomic.search

Examples of de.anomic.search.Switchboard


import de.anomic.server.serverSwitch;


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

        String color_text    = "888888";
        String color_back    = "FFFFFF";
        String color_dot     = "11BB11";
View Full Code Here


public class IndexCreateParserErrors_p {
   
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        // return variable that accumulates replacements
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        prop.put("rejected", "0");
        int showRejectedCount = 100;
       
        if (post != null) {
View Full Code Here

            j++;
        }
    }
   
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;

        // clean up all search events
        SearchEventCache.cleanupEvents(true);
       
        // case if no values are requested
        if ((post == null) || (sb == null)) {
            // we create empty entries for template strings
            final serverObjects prop = defaultValues();
            final RankingProfile ranking;
            if(sb == null) ranking = new RankingProfile(ContentDomain.TEXT);
            else ranking = sb.getRanking();
            putRanking(prop, ranking, "local");
            return prop;
        }
       
        if (post.containsKey("EnterRanking")) {
            final RankingProfile ranking = new RankingProfile("local", post.toString());
            sb.setConfig("rankingProfile", crypt.simpleEncode(ranking.toExternalString()));
            final serverObjects prop = defaultValues();
            //prop.putAll(ranking.toExternalMap("local"));
            putRanking(prop, ranking, "local");
            return prop;
        }
       
        if (post.containsKey("ResetRanking")) {
            sb.setConfig("rankingProfile", "");
            final RankingProfile ranking = new RankingProfile(ContentDomain.TEXT);
            final serverObjects prop = defaultValues();
            //prop.putAll(ranking.toExternalMap("local"));
            putRanking(prop, ranking, "local");
            return prop;
View Full Code Here

public class User{
   
    public static servletProperties respond(final RequestHeader requestHeader, final serverObjects post, final serverSwitch env) {
        final servletProperties prop = new servletProperties();
        final Switchboard sb = Switchboard.getSwitchboard();
        UserDB.Entry entry=null;

        //default values
        prop.put("logged_in", "0");
        prop.put("logged-in_limit", "0");
        prop.put("status", "0");
        //identified via HTTPPassword
        entry=sb.userDB.proxyAuth((requestHeader.get(RequestHeader.AUTHORIZATION, "xxxxxx")));
        if(entry != null){
          prop.put("logged-in_identified-by", "1");
        //try via cookie
        }else{
            entry=sb.userDB.cookieAuth(requestHeader.getHeaderCookies());
            prop.put("logged-in_identified-by", "2");
            //try via ip
            if(entry == null){
                entry=sb.userDB.ipAuth((requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
                if(entry != null){
                    prop.put("logged-in_identified-by", "0");
                }
            }
        }
       
        //identified via userDB
        if(entry != null){
            prop.put("logged-in", "1");
            prop.put("logged-in_username", entry.getUserName());
            if(entry.getTimeLimit() > 0){
                prop.put("logged-in_limit", "1");
                final long limit=entry.getTimeLimit();
                final long used=entry.getTimeUsed();
                prop.put("logged-in_limit_timelimit", limit);
                prop.put("logged-in_limit_timeused", used);
                int percent=0;
                if(limit!=0 && used != 0)
                    percent=(int)((float)used/(float)limit*100);
                prop.put("logged-in_limit_percent", percent/3);
                prop.put("logged-in_limit_percent2", (100-percent)/3);
            }
        //logged in via static Password
        }else if(sb.verifyAuthentication(requestHeader, true)){
            prop.put("logged-in", "2");
        //identified via form-login
        //TODO: this does not work for a static admin, yet.
        }else if(post != null && post.containsKey("username") && post.containsKey("password")){
            final String username=post.get("username");
            final String password=post.get("password");
           
            entry=sb.userDB.passwordAuth(username, password);
            final boolean staticAdmin = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").equals(
                    Digest.encodeMD5Hex(
                            Base64Order.standardCoder.encodeString(username + ":" + password)
                    )
            );
            String cookie="";
View Full Code Here

import de.anomic.yacy.graphics.ProfilingGraph;

public class PerformanceGraph {
   
    public static RasterPlotter respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
       
        if (post == null) post = new serverObjects();
       
        final int width = post.getInt("width", 660);
        final int height = post.getInt("height", 240);
View Full Code Here

public class Steering {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch ss) {
        if (post == null || ss == null) { return new serverObjects(); }

        final Switchboard sb = (Switchboard) ss;
        final serverObjects prop = new serverObjects();
        prop.put("info", "0"); //no information submitted

        final String requestIP = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
       
        // handle access rights
        if (!sb.verifyAuthentication(header, false)) {
            Log.logInfo("STEERING", "log-in attempt for steering from " + requestIP);
            prop.put("AUTHENTICATE", "admin log-in"); // force log-in
            return prop;
        }

        if (post.containsKey("shutdown")) {
            Log.logInfo("STEERING", "shutdown request from " + requestIP);
            sb.terminate(10, "shutdown request from Steering; ip = " + requestIP);
            prop.put("info", "3");
           
            return prop;
        }

        if (post.containsKey("restart")) {
            Log.logInfo("STEERING", "restart request from " + requestIP);
            yacyRelease.restart();
            prop.put("info", "4");
           
            return prop;
        }
       
        if (post.containsKey("update")) {
            Log.logInfo("STEERING", "update request from " + requestIP);
            final boolean devenvironment = new File(sb.getAppPath(), ".svn").exists();
            final String releaseFileName = post.get("releaseinstall", "");
            final File releaseFile = new File(sb.getDataPath(), "DATA/RELEASE/".replace("/", File.separator) + releaseFileName);
            if ((!devenvironment) && (releaseFileName.length() > 0) && (releaseFile.exists())) {
                yacyRelease.deployRelease(releaseFile);
            }
            prop.put("info", "5");
            prop.putHTML("info_release", releaseFileName);
View Full Code Here

import de.anomic.yacy.yacySeed;

public class Surftips {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
       
        final boolean authenticated = sb.adminAuthenticated(header) >= 2;
        final int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0);
        prop.put("display", display);
       
        final boolean showScore = ((post != null) && (post.containsKey("score")));
       
        // access control
        boolean publicPage = sb.getConfigBool("publicSurftips", true);
        final boolean authorizedAccess = sb.verifyAuthentication(header, false);
        if ((post != null) && (post.containsKey("publicPage"))) {
            if (!authorizedAccess) {
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }
            publicPage = post.get("publicPage", "0").equals("1");
            sb.setConfig("publicSurftips", publicPage);
        }
       
        if ((publicPage) || (authorizedAccess)) {
       
            // read voting
            String hash;
            if ((post != null) && ((hash = post.get("voteNegative", null)) != null)) {
                if (!sb.verifyAuthentication(header, false)) {
                    prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                    return prop;
                }
                // make new news message with voting
                if (sb.isRobinsonMode()) {
                    final HashMap<String, String> map = new HashMap<String, String>();
                    map.put("urlhash", hash);
                    map.put("vote", "negative");
                    map.put("refid", post.get("refid", ""));
                    sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map);
                }
            }
            if ((post != null) && ((hash = post.get("votePositive", null)) != null)) {
                if (!sb.verifyAuthentication(header, false)) {
                    prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                    return prop;
                }
                // make new news message with voting
                final HashMap<String, String> map = new HashMap<String, String>();
View Full Code Here

    public static String dateString(final Date date) {
        return SimpleFormatter.format(date);
    }

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

        boolean hasRights = sb.verifyAuthentication(header, true);
       
        //final int display = (hasRights || post == null) ? 1 : post.getInt("display", 0);
        //prop.put("display", display);  
        prop.put("display", 1); // Fixed to 1

       
        final boolean xml = (header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml");
        final String address = sb.peers.mySeed().getPublicAddress();

        if(hasRights) {
            prop.put("mode_admin", "1");
        } else {
            prop.put("mode_admin", "0");
        }

        if (post == null) {
            prop.putHTML("peername", sb.peers.mySeed().getName());
            prop.put("address", address);
            return putBlogDefault(prop, sb, address, 0, 10, hasRights, xml);
        }

        final int start = post.getInt("start",0); //indicates from where entries should be shown
        final int num   = post.getInt("num",10)//indicates how many entries should be shown

        if (!hasRights) {
            final UserDB.Entry userentry = sb.userDB.proxyAuth(header.get(RequestHeader.AUTHORIZATION, "xxxxxx"));
            if (userentry != null && userentry.hasRight(UserDB.AccessRight.BLOG_RIGHT)) {
                hasRights=true;
            } else if (post.containsKey("login")) {
                //opens login window if login link is clicked
                prop.put("AUTHENTICATE","admin log-in");
            }
        }

        String pagename = post.get("page", DEFAULT_PAGE);
        final String ip = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");

        String StrAuthor = post.get("author", "");

        if ("anonymous".equals(StrAuthor)) {
            StrAuthor = sb.blogDB.guessAuthor(ip);

            if (StrAuthor == null || StrAuthor.length() == 0) {
                if (sb.peers.mySeed() == null) {
                    StrAuthor = "anonymous";
                } else {
                    StrAuthor = sb.peers.mySeed().get("Name", "anonymous");
                }
            }
        }

        byte[] author;
        author = UTF8.getBytes(StrAuthor);

        if (hasRights && post.containsKey("delete") && "sure".equals(post.get("delete"))) {
            page = sb.blogDB.readBlogEntry(pagename);
            for (final String comment : page.getComments()) {
                sb.blogCommentDB.delete(comment);
            }
            sb.blogDB.deleteBlogEntry(pagename);
            pagename = DEFAULT_PAGE;
        }

        if (post.containsKey("discard")) {
            pagename = DEFAULT_PAGE;
        }

        if (post.containsKey("submit") && hasRights) {
            // store a new/edited blog-entry
            byte[] content;
            content = UTF8.getBytes(post.get("content", ""));

            final Date date;
            List<String> comments = null;

            //set name for new entry or date for old entry
            if (DEFAULT_PAGE.equals(pagename)) {
                pagename = String.valueOf(System.currentTimeMillis());
                date = null;
            } else {
                page = sb.blogDB.readBlogEntry(pagename);
                comments = page.getComments();
                date = page.getDate();
            }
            final String commentMode = post.get("commentMode", "2");
            final String StrSubject = post.get("subject", "");
            byte[] subject;
            subject = UTF8.getBytes(StrSubject);

            sb.blogDB.writeBlogEntry(sb.blogDB.newEntry(pagename, subject, author, ip, date, content, comments, commentMode));

            // create a news message
            if (!sb.isRobinsonMode()) {
                final Map<String, String> map = new HashMap<String, String>();
                map.put("page", pagename);
                map.put("subject", StrSubject.replace(',', ' '));
                map.put("author", StrAuthor.replace(',', ' '));
                sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), yacyNewsPool.CATEGORY_BLOG_ADD, map);
View Full Code Here

public class RemoteCrawl_p {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
       
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
       
        if (post != null) {
           
            // store this call as api call
            sb.tables.recordAPICall(post, "RemoteCrawl_p.html", WorkTables.TABLE_API_TYPE_CONFIGURATION, "remote crawler configuration");
           
            if (post.containsKey("crawlResponse")) {
                boolean crawlResponse = post.get("crawlResponse", "off").equals("on");
               
                // read remote crawl request settings
                sb.setConfig("crawlResponse", crawlResponse);
            }

            if (post.containsKey("acceptCrawlLimit")) {
                // read remote crawl request settings
                int newppm = 1;
                try {
                    newppm = Math.max(1, post.getInt("acceptCrawlLimit", 1));
                } catch (final NumberFormatException e) {}
                sb.setRemotecrawlPPM(newppm);
            }
        }
       
        // write remote crawl request settings
        prop.put("crawlResponse", sb.getConfigBool("crawlResponse", false) ? "1" : "0");
        long RTCbusySleep = Math.max(1, env.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 100));
        final int RTCppm = (int) (60000L / RTCbusySleep);
        prop.put("acceptCrawlLimit", RTCppm);
       
        // set seed information directly
        sb.peers.mySeed().setFlagAcceptRemoteCrawl(sb.getConfigBool("crawlResponse", false));
       
        // -------------------------------------------------------------------------------------
        // write network list
        final String STR_TABLE_LIST = "list_";
        int conCount = 0;
View Full Code Here

// draw a picture of the yacy network

public class SearchEventPicture {

    public static RasterPlotter respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final String eventID = header.get("event", SearchEventCache.lastEventID);
        if (eventID == null) return null;
        final RasterPlotter yp = NetworkGraph.getSearchEventPicture(sb.peers, eventID, 0, 0);
        if (yp == null) return new RasterPlotter(1, 1, RasterPlotter.DrawMode.MODE_SUB, "000000"); // empty image
View Full Code Here

TOP

Related Classes of de.anomic.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.