Package com.nardoz.restopengov.standalone.models

Examples of com.nardoz.restopengov.standalone.models.RemoteFile


    public void handle(String[] args) {

        if(args[1].equals("fetch-url") && args.length > 2) {

            RemoteFile file = new RemoteFile(args[2]);

            if(file.format.toLowerCase().equals("zip")) {
                zipFileFetcher.tell(file);
            } else {
                fileFetcher.tell(file);
View Full Code Here


    public void onReceive(Object message) {

        if(message instanceof RemoteFile) {

            RemoteFile zipfile = (RemoteFile) message;

            try {
                URL url = new URL(zipfile.url.toString().replace("https", "http"));
                InputStream stream = url.openStream();

                byte[] buf = new byte[1024];
                ZipInputStream zipinputstream = null;
                ZipEntry entry;
                zipinputstream = new ZipInputStream(stream);

                Integer id = 0;

                while((entry = zipinputstream.getNextEntry()) != null) {

                    id++;

                    Crawler.logger.info("Extracting: " + entry);

                    String format = entry.getName().substring(entry.getName().lastIndexOf('.') + 1);

                    if(!FileReader.handles(format)) {
                        continue;
                    }

                    File tmpFile = new File("tmp/" + entry.getName().replace("/", "-"));
                    FileOutputStream fos = new FileOutputStream(tmpFile);

                    int data;
                    while (0 < (data = zipinputstream.read(buf))){
                        fos.write(buf, 0, data);
                    }

                    fos.close();
                    zipinputstream.closeEntry();

                    Crawler.logger.info("Completed extraction for: " + entry);

                    RemoteFile file = new RemoteFile("file://" + tmpFile.getAbsolutePath());

                    ICSVFetcherResult callback = new ElasticIndexer(client, file.type, file.id + "-" + id);
                    IFormatReader fileReader = FileReader.read(file, callback);

                    if(fileReader != null) {
View Full Code Here

    public void onReceive(Object message) {

        if(message instanceof RemoteFile) {

            RemoteFile file = (RemoteFile) message;

            ICSVFetcherResult callback = new ElasticIndexer(client, file.type, file.id);

            try {
View Full Code Here

TOP

Related Classes of com.nardoz.restopengov.standalone.models.RemoteFile

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.