Package com.innavace.ds.upload

Examples of com.innavace.ds.upload.XMLConnectionUploader


        else if (dsPath.equalsIgnoreCase("/_system/connections/upload")) {
            try {
                // read in and parse the body content
                SAXParserFactory factory = SAXParserFactory.newInstance();
                 SAXParser saxParser = factory.newSAXParser();
                 XMLConnectionUploader handler = new XMLConnectionUploader();
                String xml = request.getParameter("file");
//                log.debug("using string: " + xml);
                InputSource is = new InputSource(new StringReader(xml));
                is.setEncoding("UTF-8");
                saxParser.parse(is, handler);
                response.getOutputStream().print(handler.getStatus());
                response.flushBuffer();
            }
            catch (SAXParseException err) {
                err.printStackTrace();
                response.sendError(500, "Exception parsing connections upload file: " + err);
            }
            catch (Throwable t) {
                t.printStackTrace();
                response.sendError(500, "Exception uploading connections: " + t);
            }
        }
        else if (dsPath.equalsIgnoreCase("/_system/configurations")) {
            Configuration configuration = ConfigurationHandler.getConfiguration("/configurations");
            if (configuration == null) {
                response.sendError(404, "Configuration error: /configurations configuration was not found!");
                return;
            }
            try {response.getOutputStream().println(configuration.execute(request, _action));}
            catch (Throwable ex)
            {
                ex.printStackTrace();
                response.sendError(500, ex.toString());
            }
        }
        else if (dsPath.equalsIgnoreCase("/_system/configurations/refresh")) {
            try {ConfigurationHandler.init();}
            catch (Exception ex) {log.fatal("Exception trying to refresh configuration list: " + ex);}
            response.getOutputStream().print("refreshed");
            response.flushBuffer();
        }
        else if (dsPath.equalsIgnoreCase("/_system/configurations/download")) {
            try {
                String filter = request.getParameter("filter");
                response.setContentType("application/xml");
                String xml = ConfigurationHandler.toXML(filter);
                if (filter == null || filter.equalsIgnoreCase("*") || filter.equalsIgnoreCase("all"))
                    filter = "";
                if (filter.length() > 0)
                    filter = "-" + filter;
                response.setHeader("Content-Disposition", "attachment; filename=\"configurations" + filter + ".xml\"");
                response.setContentLength(xml.length());
                response.getOutputStream().print(xml);
                response.flushBuffer();
            }
            catch (Exception ex) {
                ex.printStackTrace();
                response.sendError(500, "Exception downloading configurations: " + ex);
            }
        }
        else if (dsPath.equalsIgnoreCase("/_system/configurations/upload")) {
            try {
                // read in and parse the body content
                SAXParserFactory factory = SAXParserFactory.newInstance();
                 SAXParser saxParser = factory.newSAXParser();
                 XMLConfigurationUploader handler = new XMLConfigurationUploader();
                String xml = request.getParameter("file");
//                log.debug("using string: " + xml);
                InputSource is = new InputSource(new StringReader(xml));
                is.setEncoding("UTF-8");
                saxParser.parse(is, handler);
                response.getOutputStream().print(handler.getStatus());
                response.flushBuffer();
            }
            catch (SAXParseException err) {
                err.printStackTrace();
                response.sendError(500, "Exception parsing configurations: " + err);
View Full Code Here

TOP

Related Classes of com.innavace.ds.upload.XMLConnectionUploader

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.