Search in sources :

Example 6 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class EVReport method writeContents.

/** Generate CGI output. */
protected void writeContents() throws IOException {
    // load settings information for the report
    settings = new EVReportSettings(getDataRepository(), parameters, getPrefix());
    // possibly store settings data if requested.
    if (parameters.get(CUSTOMIZE_PARAM) != null) {
        storeCustomizationSettings();
        return;
    }
    // load the user requested earned value model.
    getEVModel();
    String chartType = getParameter(CHART_PARAM);
    if (chartType == null) {
        String tableType = getParameter(TABLE_PARAM);
        if (tableType == null) {
            if (parameters.get(XML_PARAM) != null)
                writeXML();
            else if (parameters.get(XLS_PARAM) != null)
                writeXls();
            else if (parameters.get(CSV_PARAM) != null)
                writeCsv();
            else if (parameters.get(MS_PROJ_XML_PARAM) != null)
                writeMSProjXml();
            else if (parameters.get(CHARTS_PARAM) != null)
                writeChartsPage();
            else if (parameters.get(CHART_OPTIONS_PARAM) != null)
                writeChartOptions();
            else
                writeHTML();
        } else if (TIME_CHART.equals(tableType))
            writeTimeTable();
        else if (VALUE_CHART2.equals(tableType))
            writeValueTable2();
        else if (VALUE_CHART.equals(tableType))
            writeValueTable();
        else if (COMBINED_CHART.equals(tableType))
            writeCombinedTable();
        else
            throw new TinyCGIException(400, "unrecognized table type parameter");
    } else if (TIME_CHART.equals(chartType))
        writeTimeChart();
    else if (VALUE_CHART.equals(chartType))
        writeValueChart();
    else if (COMBINED_CHART.equals(chartType))
        writeCombinedChart();
    else
        throw new TinyCGIException(400, "unrecognized chart type parameter");
}
Also used : TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 7 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class PngCache method doGet.

@Override
protected void doGet() throws IOException {
    int streamID = Integer.parseInt(getParameter("id"));
    InputStream pngData = PngCache.PNG_CACHE.getInputStream(streamID);
    if (pngData == null)
        throw new TinyCGIException(HttpURLConnection.HTTP_NOT_FOUND, "Not Found", "Not Found");
    out.print("Content-type: image/png\r\n\r\n");
    out.flush();
    FileUtils.copyFile(pngData, outStream);
    outStream.flush();
    outStream.close();
}
Also used : InputStream(java.io.InputStream) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 8 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class TinyCGIBase method retrieveParamsFromServlet.

protected void retrieveParamsFromServlet(String servletUriParamName) throws IOException {
    String servletUri = getParameter(servletUriParamName);
    if (StringUtils.hasValue(servletUri)) {
        try {
            HttpServletRequest req = (HttpServletRequest) env.get(HttpServletRequest.class);
            HttpServletResponse resp = (HttpServletResponse) env.get(HttpServletResponse.class);
            if (!servletUri.startsWith("/"))
                servletUri = resolveRelativeURI(servletUri);
            RequestDispatcher disp = req.getRequestDispatcher(servletUri);
            disp.include(req, resp);
            Object params = req.getAttribute("REQUEST_PARAMS");
            if (params instanceof Map)
                parameters.putAll((Map) params);
            else
                throw new TinyCGIException(404, "Could not retrieve " + servletUri);
            req.removeAttribute("REQUEST_PARAMS");
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) RequestDispatcher(javax.servlet.RequestDispatcher) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) MalformedURLException(java.net.MalformedURLException) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 9 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class OpenDefectDialog method writeContents.

@Override
protected void writeContents() throws IOException {
    DashController.checkIP(env.get("REMOTE_ADDR"));
    String path = getPath();
    DefectLogID defectLog = getDefectLog(path);
    if (defectLog == null)
        throw new TinyCGIException(404, "No defect log found for " + path);
    String id = getParameter("id");
    if (StringUtils.hasValue(id))
        openExistingDefectDialog(defectLog, id);
    else
        openNewDefectDialog(defectLog, path);
    DashController.printNullDocument(out);
}
Also used : DefectLogID(net.sourceforge.processdash.log.defects.DefectLogID) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 10 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class HierarchySynchronizer method openWBS.

private void openWBS(URL wbsLocation) throws IOException {
    URLConnection conn = null;
    InputStream in = null;
    try {
        conn = wbsLocation.openConnection();
        in = new BufferedInputStream(conn.getInputStream());
        Document doc = XMLUtils.parse(in);
        projectXML = doc.getDocumentElement();
        prunedChildren = new HashMap<Element, List<Element>>();
        String projectTaskID = projectXML.getAttribute(TASK_ID_ATTR);
        projectTaskID = cleanupProjectIDs(projectTaskID);
        projectXML.setAttribute(TASK_ID_ATTR, projectTaskID);
        projectXML.setAttribute(ID_ATTR, ROOT_NODE_PSEUDO_ID);
        dumpFileVersion = projectXML.getAttribute(VERSION_ATTR);
        if (!StringUtils.hasValue(dumpFileVersion))
            dumpFileVersion = "0";
        dumpFileTimestamp = XMLUtils.getXMLDate(projectXML, SAVE_DATE_ATTR);
        if (dumpFileTimestamp == null) {
            long dumpTime = conn.getLastModified();
            if (dumpTime > 0)
                dumpFileTimestamp = new Date(dumpTime);
        }
        String projClosedAttr = projectXML.getAttribute("projectClosed");
        projectClosed = XMLUtils.hasValue(projClosedAttr);
    } catch (Exception e) {
        if (in == null && conn instanceof HttpURLConnection) {
            HttpURLConnection hConn = (HttpURLConnection) conn;
            if (hConn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
                throw new TinyCGIException(500, SyncWBS.WBS_FILE_MISSING);
        }
        throw new IOException("The dashboard could not read the file containing the work " + "breakdown structure for this team project.  The file may " + "be corrupt.");
    } finally {
        if (in != null)
            try {
                in.close();
            } catch (Exception e) {
            }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) IOException(java.io.IOException) Document(org.w3c.dom.Document) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) Date(java.util.Date) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) HierarchyAlterationException(net.sourceforge.processdash.hier.HierarchyAlterer.HierarchyAlterationException) IOException(java.io.IOException) HttpURLConnection(java.net.HttpURLConnection) BufferedInputStream(java.io.BufferedInputStream) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) NodeList(org.w3c.dom.NodeList) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Aggregations

TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)22 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Date (java.util.Date)3 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)3 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)3 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)3 Map (java.util.Map)2 DefaultTaskLabeler (net.sourceforge.processdash.ev.DefaultTaskLabeler)2 EVDependencyCalculator (net.sourceforge.processdash.ev.EVDependencyCalculator)2 EVTaskListGroupFilter (net.sourceforge.processdash.ev.EVTaskListGroupFilter)2 EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)2 UserFilter (net.sourceforge.processdash.team.group.UserFilter)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URLConnection (java.net.URLConnection)1 ArrayList (java.util.ArrayList)1