Package cu.settings

Examples of cu.settings.ConfigurationException


    public void initialize(XMLSettings settings) throws ConfigurationException {
        switch(settings.getInt("/zipscript/type")) {
            case 4: // custom java class
                String classname = settings.get("/zipscript/custom/classname");
                if (classname == null || "".equals(classname)) {
                    throw new ConfigurationException("Please specify a classname for this tupe of zipscript");
                }
                try {
                    Class c = ServiceManager.getServices().getCustomClassLoader().loadClass(classname);
                    if (Zipscript.class.isAssignableFrom(c)) {
                        zipscript = (Zipscript)c.newInstance();
                    } else {
                        throw new ConfigurationException("Class " + c + " does not implement interface " + Zipscript.class.toString());
                    }
                } catch (ClassNotFoundException e) {
                    throw new ConfigurationException("Could not find custom zipscript class", e);
                } catch (IllegalAccessException e) {
                    throw new ConfigurationException("Could not create custom zipscript class", e);
                } catch (InstantiationException e) {
                    throw new ConfigurationException("Could not create custom zipscript class", e);
                }
                break;
            case 3: // shell
                zipscript = new ShellZipscript(settings.get("/zipscript/shell/rescan"), settings.get("/zipscript/shell/upload"), settings.get("/zipscript/shell/delete"));

            case 2: // pzs-ng
                String zipscriptPath = settings.get("/zipscript/pzs_ng/path");
                File f = new File(zipscriptPath);
                if (!f.exists() || !f.isDirectory()) {
                    throw new ConfigurationException("Must specify an existing directory for /zipscript/pzs_ng/path");
                }
                zipscript = new PzsNgZipscript(zipscriptPath);
                break;
            case 1: // internal
                zipscript = new CuftpdZipscript(settings.get("/zipscript/cuftpd/files"), new File(settings.get("/zipscript/cuftpd/template")), settings.get("/zipscript/cuftpd/short_name"));
View Full Code Here


    private RequestLog requestLog = null;
    public void initialize(XMLSettings settings) throws ConfigurationException {
        try {
            requestLog = new RequestLog(settings.get("/requests/log"), settings.getBoolean("/requests/auto_approve"));
        } catch (IOException e) {
            throw new ConfigurationException("Failed to load requestlog: " + e.getMessage(), e);
        }
    }
View Full Code Here

    public void initialize(XMLSettings settings) throws ConfigurationException {
        try {
            nukeHandler = new NukeHandler(settings.get("/nukehandler/log"));
        } catch (IOException e) {
            throw new ConfigurationException("Failed to load nukelog: " + e.getMessage(), e);
        }
    }
View Full Code Here

            xferlog = new DummyXferlog();
        } else {
            try {
                xferlog = new Xferlog(log);
            } catch (IOException e) {
                throw new ConfigurationException("Could not load xferlog: " + e.getMessage(), e);
            }
        }
    }
View Full Code Here

                    String dirscriptExclusions = settings.get("/dirlog/dirscript_exclusions");
                    dirscript = new Dirscript(dirlog, dirscriptExclusions);
                }

            } catch (IOException e) {
                throw new ConfigurationException("Failed to load dirlog: " + e.getMessage(), e);
            }
        }
    }
View Full Code Here

                dupelog = new Dupelog(log, settings.getInt("/dupecheck/days"), settings.getBoolean("/dupecheck/case_sensitive"), settings.get("/dupecheck/files"));
                dupelog.load();
                // save and clean out old dupes every hour (it is also done on load and 'site undupe'
                Server.getInstance().getTimer().schedule(new Saver(dupelog), 3600*1000, 3600*1000);
            } catch (IOException e) {
                throw new ConfigurationException("Failed to load dupelog: " + e.getMessage(), e);
            }
        }
    }
View Full Code Here

    public void initialize(XMLSettings settings) throws ConfigurationException {
        try {
            log = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(settings.get("/site_command_logger/log")), true)), true);
            scleh = new SiteCommandLoggerEventHandler(log, settings.get("/site_command_logger/commands"));
        } catch (FileNotFoundException e) {
            throw new ConfigurationException("Could not open log for writing", e);
        }
    }
View Full Code Here

        switch(settings.getInt("/user/authentication/type")) {
            case Userbase.SQL:
            case Userbase.RMI:
                System.out.println("Initializing REMOTE userbase");
                if (settings.get("/user/authentication/remote/host") == null || settings.get("/user/authentication/remote/port") == null || settings.get("/user/authentication/remote/retry_interval") == null) {
                    throw new ConfigurationException("must specify {host, port, retry_interval} when using remote statistics");
                }
                userbase = new RmiRemoteUserbase(settings.get("/user/authentication/remote/host"), settings.getInt("/user/authentication/remote/port"), settings.getInt("/user/authentication/remote/retry_interval"));
                initializeCuftpdUserbaseActions();
                break;
            case Userbase.ANONYMOUS:
                System.out.println("Initializing ANONYMOUS userbase");
                userbase = new AnonymousUserbase();
                break;
            case Userbase.ASYNCHRONOUS:
                System.out.println("Initializing ASYNCHRONOUS userbase");
                try {
                    String name = settings.get("/user/authentication/asynchronous/name");
                    String uri = settings.get("/user/authentication/asynchronous/uri");

                    AsynchronousMessageQueueChangeTracker changeTracker = new AsynchronousMessageQueueChangeTracker(URI.create(uri), name);
                    this.changeTracker = changeTracker;
                    userbase = new LocalUserbase(settings.getDataDirectory(), true, changeTracker);
                    ChangeApplicator changeApplicator = new ChangeApplicator((LocalUserbase)userbase);

                    int i = 1;
                    String peerName;
                    String peerUri;
                    while(true) {
                        // loop over the sections in the file
                        peerName = settings.get("/user/authentication/asynchronous/peers/peer[" + i + "]/name");
                        if (peerName == null || "".equals(peerName)) {
                            break;
                        }
                        peerUri = settings.get("/user/authentication/asynchronous/peers/peer[" + i + "]/uri");
                        i++;
                        if (!peerUri.startsWith("failover:")) {
                            peerUri = "failover:" + peerUri;
                        }
                        changeTracker.addPeer(peerName, URI.create(peerUri), changeApplicator);
                        // todo: log each peer we connect to

                    }
                    initializeCuftpdUserbaseActions();
                    break;
                } catch (Exception e) {
                    shutdown();
                    throw new ConfigurationException("Asynchronous userbase failure", e);
                }
            case Userbase.DEFAULT:
            default:
                System.out.println("Initializing LOCAL userbase");
                userbase = new LocalUserbase(settings.getDataDirectory(), true, new ChangeTracker() {
View Full Code Here

              registerStatisticsCommands = false;
                userStatistics = new NoUserStatistics();
                break;
            case 2:
                if (settings.get("/user/statistics/remote/host") == null || settings.get("/user/statistics/remote/port") == null || settings.get("/user/statistics/remote/retry_interval") == null) {
                    throw new ConfigurationException("must specify {host, port, retry_interval} when using remote statistics");
                }
                userStatistics = new RmiUserStatisticsClient(settings.get("/user/statistics/remote/host"), settings.getInt("/user/statistics/remote/port"), settings.getInt("/user/statistics/remote/retry_interval"));
                break;
            case 1:
            default:
View Full Code Here

                        module.initialize(new XMLSettings(settings.getNode("/modules/module[" + i + "]/settings")));
                        module.registerActions(siteCommandHandler);
                        module.registerEventHandlers(eventHandler);
                        modules.put(moduleName, module);
                    } else {
                        throw new ConfigurationException("Class " + clazz + " does not implement interface " + Module.class.toString());
                    }
                }
                i++;
            }
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
            throw new ConfigurationException("Could not load class: " + e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of cu.settings.ConfigurationException

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.