use of net.sourceforge.processdash.api.PDashContext in project processdash by dtuma.
the class WorkflowReport method writeFrameForWorkflow.
private void writeFrameForWorkflow(HttpServletRequest req, HttpServletResponse resp, String workflowID) throws IOException {
PDashContext ctx = PDashServletUtils.getContext(req);
String workflowName = QueryUtils.singleValue(//
QueryUtils.pluckColumn(ctx.getQuery().query(WORKFLOW_LIST_QUERY, workflowID), 0));
if (workflowName == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "The requested workflow was not found.");
return;
}
PrintWriter out = resp.getWriter();
out.write("<html>\n<head><title>");
out.write(esc(res("Workflow.Analysis.Title")));
out.write(" - ");
out.write(esc(workflowName));
out.write("</title></head>\n");
String tocUri = HTMLUtils.appendQuery(SELF_URI, WORKFLOW_PARAM, workflowID);
String ppsUri = HTMLUtils.appendQuery(SUMMARY_URI, WORKFLOW_PARAM, workflowID);
out.write("<frameset cols='140,*'>\n");
out.write(" <frame name='toc' src='" + tocUri + "&toc'>\n");
out.write(" <frame name='contents' src='" + ppsUri + "'>\n");
out.write("</frameset></html>\n");
}
use of net.sourceforge.processdash.api.PDashContext in project processdash by dtuma.
the class WBSChangeHistoryReport method loadHistory.
private void loadHistory(HttpServletRequest req) throws ProjectHistoryException {
PDashContext ctx = PDashServletUtils.getContext(req);
PDashData data = ctx.getData();
ProjectHistory hist = ProjectHistoryFactory.getProjectHistory(data);
if (hist == null)
throw new ProjectHistoryException("Not_Team_Project_HTML_FMT", ctx.getProjectPath());
String dateParam = req.getParameter("before");
Date beforeDate = dateParam == null ? null : new Date(Long.parseLong(dateParam));
ProjectChangeList changes;
try {
changes = ProjectChangeListFactory.getChanges(hist, beforeDate, 10, true, true);
} catch (IOException ioe) {
throw hist.wrapException(ioe);
}
req.setAttribute("changes", changes);
req.setAttribute("followupTimestamp", changes.getFollowupTimestamp());
// compute the URI that will be used to open WBS hyperlinks
String processID = data.getString("Team_Process_PID");
String modeIndicator = Settings.isPersonalMode() ? "indiv" : "forteam";
String openWbsUri = "../" + processID + "/setup/openWBS.shtm?trigger&" + modeIndicator + "&showItem=";
req.setAttribute("openWbsUri", openWbsUri);
}
use of net.sourceforge.processdash.api.PDashContext in project processdash by dtuma.
the class RecentReviews method loadReviewData.
private void loadReviewData(HttpServletRequest req) throws IOException {
// retrieve metadata about the team process
PDashContext pdash = (PDashContext) req.getAttribute(PDashContext.REQUEST_ATTR);
PDashData data = pdash.getData();
String processID = data.getString(TeamDataConstants.PROCESS_ID);
List<String> reviewPhases = data.getList("/" + processID + "/Review_Phase_List");
// ensure the user has permission to view recent reviews
PDashQuery query = pdash.getQuery();
PersonFilter privacyFilter = new PersonFilter(PERMISSION, query);
if (privacyFilter.isBlock()) {
req.setAttribute("blocked", Boolean.TRUE);
return;
}
// query the database for data about recently completed reviews
String[] hql = getHql(req);
List<Object[]> taskData = query.query(hql[0], processID, reviewPhases);
List<Integer> planItemKeys = QueryUtils.pluckColumn(taskData, 0);
List<Object[]> defectCounts = query.query(hql[1], planItemKeys);
// build objects to hold the resulting data
List<ReviewRow> reviews = new ArrayList<RecentReviews.ReviewRow>();
for (Object[] oneRow : taskData) {
if (privacyFilter.include(oneRow[8]))
reviews.add(new ReviewRow(oneRow));
}
for (Object[] oneRow : defectCounts) storeDefectCounts(reviews, oneRow);
req.setAttribute("reviews", reviews);
// flag older reviews if necessary
if (!reviews.isEmpty()) {
Date newestDate = reviews.get(reviews.size() - 1).completionDate;
long cutoff = newestDate.getTime() - 2 * DateUtils.WEEKS;
boolean oneHidden = false;
for (ReviewRow review : reviews) {
if (review.setCutoff(cutoff))
oneHidden = true;
}
req.setAttribute("hasHiddenRows", oneHidden);
}
}
use of net.sourceforge.processdash.api.PDashContext in project processdash by dtuma.
the class PDashServletUtils method buildEnvironment.
/**
* Using the data in an HttpServletRequest, build the standard environment
* that TinyCGI scripts have traditionally expected for operation.
*/
public static Map buildEnvironment(HttpServletRequest req) {
Map env = new HashMap();
// if any extra environment was attached to the request, add it
Map extraEnv = (Map) req.getAttribute(LocalConnector.EXTRA_ENVIRONMENT_KEY);
if (extraEnv != null)
env.putAll(extraEnv);
// store all values from the server default environment.
Request baseRequest = Request.getRequest(req);
Map defaultEnv = (Map) baseRequest.getConnection().getServer().getAttribute(WebServer.DEFAULT_ENV_KEY);
env.putAll(defaultEnv);
env.put(PDashContext.REQUEST_ATTR, req.getAttribute(PDashContext.REQUEST_ATTR));
// store the method, and protocol from the original request
env.put("REQUEST_METHOD", req.getMethod());
env.put("SERVER_PROTOCOL", req.getProtocol());
// store the portion of the request URI that names the target resource
String scriptName = req.getServletPath();
if (req.getPathInfo() != null)
scriptName += req.getPathInfo();
env.put("SCRIPT_NAME", scriptName);
env.put("SCRIPT_PATH", req.getRequestURI());
// store information about the hierarchy prefix used on the request
PDashContext dash = getContext(req);
String uriPrefix = dash.getUriPrefix();
if (uriPrefix != null && uriPrefix.endsWith("/")) {
env.put("PATH_INFO", uriPrefix.substring(0, uriPrefix.length() - 1));
} else {
env.put("PATH_INFO", "");
}
env.put("PATH_TRANSLATED", dash.getProjectPath());
env.put("REQUEST_URI", uriPrefix + baseRequest.getUri());
// store the query string, if one was present
String queryString = req.getQueryString();
if (queryString != null && queryString.length() > 0)
env.put("QUERY_STRING", queryString);
// Store information about the inbound TCP/IP connection
if (req.getRemoteAddr() != null) {
env.put("REMOTE_PORT", req.getRemotePort());
env.put("REMOTE_HOST", new RemoteHostName(req));
env.put("REMOTE_ADDR", req.getRemoteAddr());
env.put("SERVER_NAME", new ServerName(req));
env.put("SERVER_ADDR", req.getLocalAddr());
}
// Copy HTTP headers into the environment.
Enumeration<String> headerNames = req.getHeaderNames();
while (headerNames.hasMoreElements()) {
String oneName = headerNames.nextElement();
String oneValue = req.getHeader(oneName);
String key = "HTTP_" + oneName.toUpperCase().replace('-', '_');
env.put(key, oneValue);
}
env.put("CONTENT_TYPE", req.getContentType());
env.put("CONTENT_LENGTH", Integer.toString(req.getContentLength()));
return env;
}
use of net.sourceforge.processdash.api.PDashContext in project processdash by dtuma.
the class DashboardUriPrefixFilter method getPrefix.
private String getPrefix(ServletRequest request) {
if (!(request instanceof HttpServletRequest))
return null;
PDashContext dash = PDashServletUtils.getContext(request);
if (dash == null)
return null;
String prefix = dash.getUriPrefix();
if (prefix == null || prefix.length() < 3)
return null;
HttpServletRequest hreq = (HttpServletRequest) request;
String uri = hreq.getRequestURI();
if (uri.startsWith(prefix) && (uri.contains("//") || uri.contains("/+/")))
return null;
return prefix;
}
Aggregations