Package com.innavace.ds.config

Examples of com.innavace.ds.config.Configuration


            return;
        }

        // we have a good action and path so lets load the sql based on path and then call the appropriate sql action
        if (dsPath.equalsIgnoreCase("/_system/connections")) {
            Configuration configuration = ConfigurationHandler.getConfiguration("/connections");
            if (configuration == null) {
                response.sendError(404, "Configuration error: /connections configuration was not found!");
                return;
            }
            if (action.equalsIgnoreCase("query"))
                response.getOutputStream().println(ConnectionHandler.toJSON());
            else {
                // attempt to execute the connection requested action
                try {response.getOutputStream().println(configuration.execute(request, _action));}
                catch (Throwable ex)
                {
                    ex.printStackTrace();
                    response.sendError(500, ex.toString());
                }
            }
        }
        else if (dsPath.equalsIgnoreCase("/_system/connections/test")) {
            // attempt to get the parameters (assume always GET)
            try {
                String name = request.getParameter("name");
                String type = request.getParameter("type");
                if (name == null || name.length() == 0 || type == null || type.length() == 0)
                    throw new RuntimeException("name or type parameter was not passed!  connection is invalid!");
                ConnectionHandler.test(name, type, request.getParameter("jndi-context"),
                        request.getParameter("jndi-name"), request.getParameter("driver"), request.getParameter("url"),
                        request.getParameter("login"), request.getParameter("password"));
            }
            catch (Exception ex) {throw new ServletException(ex);}
            response.getOutputStream().print("true");
            response.flushBuffer();
        }
        else if (dsPath.equalsIgnoreCase("/_system/connections/refresh")) {
            try {ConnectionHandler.destroy(); ConnectionHandler.init();}
            catch (Exception ex) {log.fatal("Exception trying to refresh connection list: " + ex);}
            response.getOutputStream().print("refreshed");
            response.flushBuffer();
        }
        else if (dsPath.equalsIgnoreCase("/_system/connections/download")) {
            try {
                response.setContentType("application/xml");
                String xml = ConnectionHandler.toXML();
                response.setHeader("Content-Disposition", "attachment; filename=\"connections.xml\"");
                response.setContentLength(xml.length());
                response.getOutputStream().print(xml);
                response.flushBuffer();
            }
            catch (Exception ex) {
                ex.printStackTrace();
                response.sendError(500, "Exception downloading connections: " + ex);
            }
        }
        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());
            }
View Full Code Here


        if (dsPath == null || dsPath.length() == 0) {
            response.sendError(404);
            return;
        }

        Configuration configuration = ConfigurationHandler.getConfiguration(dsPath);
        if (configuration == null) {
            response.sendError(404, "[" + dsPath + "] configuration was not found!");
        }
        else {
            if (configuration.isSystem())
                response.sendError(403, "[" + dsPath + "] requires system privileges; try adding /_system/ prefix instead.");
            else {
            // attempt to execute the configuration requested action
                try {response.getOutputStream().println(configuration.execute(request, _action));}
                catch (Throwable ex)
                {
                    ex.printStackTrace();
                    // we want to return the update statement for pre-population of table fields if the error was
                    //  no table found
View Full Code Here

    @Override
    public void startElement(String s, String s2, String elementName, Attributes attributes) throws SAXException {
        if (elementName.equalsIgnoreCase("configurations"))
            imported = 0;
        else if (elementName.equalsIgnoreCase("configuration"))
            configuration = new Configuration();
        else
            characters.setLength(0);

    }
View Full Code Here

TOP

Related Classes of com.innavace.ds.config.Configuration

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.