Package gov.nysenate.util

Examples of gov.nysenate.util.Config


        props.setProperty("mail.store.protocol", "imaps");
        props.setProperty("mail.imaps.ssl.protocols", "SSLv3");
        Session session = Session.getDefaultInstance(props, null);
        //session.setDebug(true);
        Store store = session.getStore("imaps");
        Config config = Application.getConfig();

        store.connect(
            config.getValue("checkmail.host"),
            config.getValue("checkmail.user"),
            config.getValue("checkmail.pass")
        );

        String receivingFolder = config.getValue("checkmail.receiving");
        String processedFolder = config.getValue("checkmail.processed");

        Folder sourceFolder = navigateToFolder(receivingFolder, store);
        Folder archiveFolder = navigateToFolder(processedFolder, store);
        sourceFolder.open(Folder.READ_WRITE);

        // stores all daybreak emails in a set for each report
        DaybreakSetContainer daybreakSetContainer = new DaybreakSetContainer();

        // Add all emails
        for(Message message : sourceFolder.getMessages()) {
            daybreakSetContainer.addMessage(message);
        }

        List<DaybreakSet> completeSets = daybreakSetContainer.getCompleteSets();
        if(completeSets.size()>0) {
            logger.info("Detected " + completeSets.size() + " complete daybreak reports");

            for(DaybreakSet daybreakSet : completeSets){

                logger.info("Saving report " + daybreakSet.getPrefix() + ":");
                for(DaybreakDocType messageType : DaybreakDocType.values()){
                    Message message = daybreakSet.getMessage(messageType);
                    String filename = daybreakSet.getPrefix() + messageType.getLocalFileExt();

                    if (message.isMimeType("multipart/*")) {
                        Multipart content = (Multipart) message.getContent();
                        for (int i = 0; i < content.getCount(); i++) {
                            Part part = content.getBodyPart(i);
                            if (Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition())) {
                                logger.info("\tSaving " + part.getFileName() + " to " + filename);
                                String attachment = IOUtils.toString(part.getInputStream());
                                String lrsFileDir = config.getValue("checkmail.lrsFileDir");
                                FileUtils.write(new File(lrsFileDir, filename), attachment);
                            }
                        }
                    }

View Full Code Here


        QueryRunner runner = new QueryRunner(Application.getDB().getDataSource());

        String[] args = opts.getArgs();
        Storage storage = Application.getStorage();

        Config config = Application.getConfig();

        List<ReportObservation> observations = new ArrayList<ReportObservation>();
        HashMap<String, Integer> errorTotals = new HashMap<String, Integer>();
        for (String error_type : new String[] {"title", "summary", "sponsor", "cosponsors", "events", "pages", "amendments"}) {
            errorTotals.put(error_type, 0);
        }

        String prefix = args[0];
        Date date = dateFormat.parse(prefix);
        logger.info("Processing daybreak files for: "+date);
        File directory = new File(config.getValue("checkmail.lrsFileDir"));
        HashMap<String, SpotCheckBill> bills = new HashMap<String, SpotCheckBill>();
        logger.info("Reading " + prefix+".senate.low.html");
        bills.putAll(readDaybreak(new File(directory, prefix+".senate.low.html")));
        logger.info("Reading " + prefix+".senate.high.html");
        bills.putAll(readDaybreak(new File(directory, prefix+".senate.high.html")));
View Full Code Here

    private File unpublishFile;
    private Set<String> unpublishedBills;

    public UnpublishListManager(String pathToFile) {
        Config config = Application.getConfig();
        unpublishFile = new File(pathToFile);
        if(!unpublishFile.exists()) {
            try {
                unpublishFile.createNewFile();
            } catch (IOException e) {
View Full Code Here

    public static boolean bootstrap(String propertyFileName, boolean luceneReadOnly)
    {
        try
        {
            appInstance.config = new Config(propertyFileName);
            appInstance.db = new DB(appInstance.config, "mysqldb");
            appInstance.mailer = new Mailer(appInstance.config, "mailer");
            appInstance.environment = new Environment(appInstance.config, "env");
            appInstance.lucene = new Lucene(new File(appInstance.config.getValue("lucene.directory")), luceneReadOnly);
            appInstance.storage = new Storage(appInstance.environment.getStorageDirectory());
View Full Code Here

TOP

Related Classes of gov.nysenate.util.Config

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.