public Response makeResponse(FitNesseContext context, Request request) throws Exception { SimpleResponse response = new SimpleResponse(); resource = request.getResource(); String filename = (String) request.getInput("filename"); response.setContent(makePageContent(filename, context)); return response; }
private HtmlTag makeEditForm( String resource, boolean firstTimeForNewPage, String defaultNewPageContent) throws Exception { HtmlTag form = new HtmlTag("form"); form.addAttribute("name", "f"); form.addAttribute("action", resource); form.addAttribute("method", "post"); form.add(HtmlUtil.makeInputTag("hidden", "responder", "saveData")); form.add(HtmlUtil.makeInputTag("hidden", SAVE_ID, String.valueOf(SaveRecorder.newIdNumber()))); form.add( HtmlUtil.makeInputTag("hidden", TICKET_ID, String.valueOf((SaveRecorder.newTicket())))); if (request.hasInput("redirectToReferer") && request.hasHeader("Referer")) { String redirectUrl = request.getHeader("Referer").toString(); int questionMarkIndex = redirectUrl.indexOf("?"); if (questionMarkIndex > 0) redirectUrl = redirectUrl.substring(0, questionMarkIndex); redirectUrl += "?" + request.getInput("redirectAction").toString(); form.add(HtmlUtil.makeInputTag("hidden", "redirect", redirectUrl)); } form.add(createTextarea(firstTimeForNewPage, defaultNewPageContent)); form.add(createButtons()); form.add( "<br/>Hints:\n<ul>" + "<li>Use alt+s (Windows) or control+s (Mac OS X) to save your changes. Or, tab from the text area to the \"Save\" button!</li>\n" + "<li>Grab the lower-right corner of the text area to increase its size (works with some browsers).</li>\n" + "</ul>"); TagGroup group = new TagGroup(); group.add(form); return group; }
@Override public Response makeResponse(FitNesseContext context, Request request) throws Exception { String resource = request.getResource(); String content = request.getInput(EditResponder.CONTENT_INPUT_NAME); if (!contentFilter.isContentAcceptable(content, resource)) return makeBannedContentResponse(context, resource); return null; }
public Response makeResponse(FitNesseContext context, Request request) { this.context = context; crawler = context.root.getPageCrawler(); crawler.setDeadEndStrategy(new VirtualEnabledPageCrawler()); resource = request.getResource(); shouldIncludePaths = request.hasInput("includePaths"); suiteFilter = (String) request.getInput("suiteFilter"); return new PuppetResponse(this); }
public Response makeResponse(FitNesseContext context, Request request) throws Exception { WikiPage contextPage = getContextPage(context, request.getResource()); WikiPage recentChangesPage = context.root.getChildPage(RecentChanges.RECENT_CHANGES); feed = new RssFeed(getConfiguredRssLinkPrefixFrom(contextPage)); buildItemReportIfRecentChangesExists(recentChangesPage, request.getResource()); return feed.asResponse(); }
private static String getOrFilterString(Request request) { // request already confirmed not-null String orFilterString = null; if (request.getInput(OR_FILTER_ARG_1) != null) { orFilterString = (String) request.getInput(OR_FILTER_ARG_1); } else { orFilterString = (String) request.getInput(OR_FILTER_ARG_2); } return orFilterString; }
@Override public Response makeResponse(FitNesseContext context, Request request) throws Exception { resource = request.getResource(); this.context = context; PageCrawler crawler = context.getRootPage().getPageCrawler(); page = crawler.getPage(PathParser.parse(resource)); if (page == null) return new NotFoundResponder().makeResponse(context, request); response = new SimpleResponse(); if (request.hasInput("removal")) removeSymbolicLink(request, page); else if (request.hasInput("rename")) renameSymbolicLink(request, page); else addSymbolicLink(request, page); return response; }
public Response makeResponse(FitNesseContext context, Request request) throws Exception { if (!getAndValidateRefactoredPage(context, request)) { return new NotFoundResponder().makeResponse(context, request); } if (!getAndValidateNewParentPage(context, request)) { return makeErrorMessageResponder(newParentPath.toString() + " does not exist.") .makeResponse(context, request); } if (!getAndValidateRefactoringParameters(request)) { return makeErrorMessageResponder("").makeResponse(context, request); } if (targetPageExists()) { return makeErrorMessageResponder(makeLink(getNewPageName()) + " already exists") .makeResponse(context, request); } if (request.hasInput("refactorReferences")) { getReferenceRenamer(context).renameReferences(); } execute(); SimpleResponse response = new SimpleResponse(); response.redirect(createRedirectionUrl(newParentPage, getNewPageName())); return response; }
private void renameSymbolicLink(Request request, WikiPage page) throws Exception { String linkToRename = (String) request.getInput("rename"), newName = (String) request.getInput("newname"); PageData data = page.getData(); WikiPageProperty properties = data.getProperties(); WikiPageProperty symLinks = getSymLinkProperty(properties); if (isValidWikiPageName(newName, symLinks)) { String currentPath = symLinks.get(linkToRename); symLinks.remove(linkToRename); symLinks.set(newName, currentPath); page.commit(data); setRedirect(resource); } }
private Response makePageHistoryResponse(Request request) { page.setTitle("Page History"); page.put("pageHistory", pageHistory); page.setNavTemplate("viewNav"); page.put("viewLocation", request.getResource()); page.setMainTemplate("pageHistory"); return makeResponse(); }
public ResultFormatter makeFormatter(Request request) throws IOException { String format = (String) request.getInput("format"); if (format != null) { if ("html".equals(format)) return new HtmlResultFormatter(context, baseUrl, rootPath); if ("xml".equals(format)) return new XmlResultFormatter(baseUrl, rootPath); } return new MockResultFormatter(); }
private void makeContent(FitNesseContext context, Request request) throws Exception { if ("json".equals(request.getInput("format"))) { JSONObject jsonObject = makeJson(); response.setContent(jsonObject.toString(1)); } else { String html = makeHtml(context); response.setContent(html); } }
private Response generateHtmlSuiteExecutionResponse(Request request, SuiteExecutionReport report) throws Exception { page.setTitle("Suite Execution Report"); page.setNavTemplate("viewNav"); page.put("viewLocation", request.getResource()); page.put("suiteExecutionReport", report); page.put("ExecutionResult", ExecutionResult.class); page.setMainTemplate("suiteExecutionReport"); return makeResponse(); }
public Response makeResponse(FitNesseContext context, Request request) { this.context = context; WikiPage root = context.root; WikiPage page = root.getPageCrawler().getPage(PathParser.parse(request.getResource())); SuiteFilter filter = TestResponder.createSuiteFilter(request, page.getPageCrawler().getFullPath().toString()); SuiteContentsFinder suiteTestFinder = new SuiteContentsFinder(page, filter, root); List<WikiPage> pagelist = suiteTestFinder.makePageList(); SuiteOverviewTree treeview = new SuiteOverviewTree(pagelist); treeview.findLatestResults(context.getTestHistoryDirectory()); treeview.countResults(); WikiPagePath path = PathParser.parse(request.getResource()); SimpleResponse response = makeResponse(treeview, path, request); return response; }
protected boolean getAndValidateRefactoredPage(FitNesseContext context, Request request) throws Exception { PageCrawler crawler = context.root.getPageCrawler(); oldNameOfPageToBeMoved = request.getResource(); WikiPagePath path = PathParser.parse(oldNameOfPageToBeMoved); oldRefactoredPage = crawler.getPage(context.root, path); return (oldRefactoredPage != null); }
private void saveAttributes(Request request, PageData data) { setPageTypeAttribute(request, data); List<String> attrs = new LinkedList<String>(); attrs.addAll(Arrays.asList(PageData.NON_SECURITY_ATTRIBUTES)); attrs.addAll(Arrays.asList(PageData.SECURITY_ATTRIBUTES)); attrs.add(PageData.PropertyPRUNE); for (Iterator<String> i = attrs.iterator(); i.hasNext(); ) { String attribute = i.next(); if (isChecked(request, attribute)) data.setAttribute(attribute); else data.removeAttribute(attribute); } String suites = (String) request.getInput("Suites"); data.setAttribute(PageData.PropertySUITES, suites); String helpText = (String) request.getInput("HelpText"); data.setAttribute(PageData.PropertyHELP, helpText); }
private void removeSymbolicLink(Request request, WikiPage page) { String linkToRemove = request.getInput("removal"); PageData data = page.getData(); WikiPageProperty properties = data.getProperties(); WikiPageProperty symLinks = getSymLinkProperty(properties); symLinks.remove(linkToRemove); if (symLinks.keySet().isEmpty()) properties.remove(SymbolicPage.PROPERTY_NAME); page.commit(data); setRedirect(resource); }
public Response makeResponse(FitNesseContext context, Request request) throws Exception { init(context, request); String results = (String) request.getInput("results"); byte[] bytes = results.getBytes("UTF-8"); processResults(new ByteArrayInputStream(bytes)); InputStreamResponse response = new InputStreamResponse(); response.setBody(formatter.getResultStream(), formatter.getByteCount()); return response; }
private String addHiddenAttributes() { StringBuilder buffer = new StringBuilder(); if (request.hasInput(PageData.PAGE_TYPE_ATTRIBUTE)) { String pageType = (String) request.getInput(PageData.PAGE_TYPE_ATTRIBUTE); buffer .append("<input type=\"hidden\" name=\"") .append(PageData.PAGE_TYPE_ATTRIBUTE) .append("\" value=\"") .append(pageType) .append("\" checked=\"checked\">"); } for (int i = 0; i < PageData.NON_SECURITY_ATTRIBUTES.length; i++) { String attribute = PageData.NON_SECURITY_ATTRIBUTES[i]; if (request.hasInput(attribute)) buffer .append("<input type=\"hidden\" name=\"") .append(attribute) .append("\" value=\"On\">"); } return buffer.toString(); }
private Response generateHtmlTestExecutionResponse(Request request, TestExecutionReport report) throws Exception { page.setTitle("Test Execution Report"); page.setNavTemplate("viewNav"); page.put("viewLocation", request.getResource()); page.put("testExecutionReport", report); page.put("ExecutionResult", ExecutionResult.class); page.setMainTemplate("testExecutionReport"); page.setErrorNavTemplate("errorNavigator"); page.put("errorNavOnDocumentReady", true); return makeResponse(); }
public Response makeResponse(FitNesseContext context, Request request) { this.context = context; prepareResponse(request); if (request.hasInput("resultDate")) { return tryToMakeTestExecutionReport(request); } else if (formatIsXML(request)) { return makePageHistoryXmlResponse(request); } else { return makePageHistoryResponse(request); } }
public Response makeResponse(FitNesseContext context, Request request) { response = new SimpleResponse(); resource = request.getResource(); path = PathParser.parse(resource); PageCrawler crawler = context.root.getPageCrawler(); page = crawler.getPage(path, new MockingPageCrawler()); if (page == null) return new NotFoundResponder().makeResponse(context, request); pageData = page.getData(); makeContent(context, request); response.setMaxAge(0); return response; }
private void addSymbolicLink(Request request, WikiPage page) throws Exception { String linkName = StringUtils.trim(request.getInput("linkName")); String linkPath = StringUtils.trim(request.getInput("linkPath")); PageData data = page.getData(); WikiPageProperty properties = data.getProperties(); WikiPageProperty symLinks = getSymLinkProperty(properties); if (isValidLinkPathName(linkPath) && isValidWikiPageName(linkName, symLinks)) { symLinks.set(linkName, linkPath); page.commit(data); setRedirect(resource); } }
private SimpleResponse makeResponse( SuiteOverviewTree treeview, WikiPagePath path, Request request) { SimpleResponse response = new SimpleResponse(); HtmlPage page = context.pageFactory.newPage(); page.setTitle("Suite Overview"); page.setPageTitle(new PageTitle("Suite Overview", path)); page.put("treeRoot", treeview.getTreeRoot()); page.put("viewLocation", request.getResource()); page.setMainTemplate("suiteOverview"); response.setContent(page.html()); return response; }
private void makeContent(FitNesseContext context, Request request) { if ("json".equals(request.getInput("format"))) { JSONObject jsonObject = makeJson(); try { response.setContent(jsonObject.toString(1)); } catch (JSONException e) { throw new RuntimeException(e); } } else { String html = makeHtml(context, request); response.setContent(html); } }
private static String getSuiteFirstTest(Request request, String suiteName) { String startTest = null; if (request != null) { startTest = (String) request.getInput("firstTest"); } if (startTest != null) { if (startTest.indexOf(suiteName) != 0) { startTest = suiteName + "." + startTest; } } return startTest; }
private void prepareResponse(Request request) { response = new SimpleResponse(); if (resultsDirectory == null) resultsDirectory = context.getTestHistoryDirectory(); history = new TestHistory(); pageName = request.getResource(); history.readPageHistoryDirectory(resultsDirectory, pageName); pageHistory = history.getPageHistory(pageName); page = context.pageFactory.newPage(); String tags = ""; if (context.root != null) { WikiPagePath path = PathParser.parse(pageName); PageCrawler crawler = context.root.getPageCrawler(); WikiPage wikiPage = crawler.getPage(path); if (wikiPage != null) { PageData pageData = wikiPage.getData(); tags = pageData.getAttribute(PageData.PropertySUITES); } } pageTitle = new PageTitle("Test History", PathParser.parse(request.getResource()), tags); page.setPageTitle(pageTitle); }
public Response makeResponse(FitNesseContext context, Request request) { SimpleResponse response = new SimpleResponse(); String resource = request.getResource(); WikiPagePath path = PathParser.parse(resource); WikiPage page = context.root.getPageCrawler().getPage(path); if (page == null) return new NotFoundResponder().makeResponse(context, request); PageData data = page.getData(); saveAttributes(request, data); VersionInfo commitRecord = page.commit(data); response.addHeader("Current-Version", commitRecord.getName()); context.recentChanges.updateRecentChanges(data); response.redirect(resource); return response; }
public Response makeResponse(FitNesseContext context, Request request) throws Exception { response = new SimpleResponse(); resource = request.getResource(); path = PathParser.parse(resource); PageCrawler crawler = context.root.getPageCrawler(); if (!crawler.pageExists(context.root, path)) crawler.setDeadEndStrategy(new MockingPageCrawler()); page = crawler.getPage(context.root, path); if (page == null) return new NotFoundResponder().makeResponse(context, request); pageData = page.getData(); makeContent(context, request); response.setMaxAge(0); return response; }
private String makeHtml(FitNesseContext context, Request request) { html = context.pageFactory.newPage(); html.setNavTemplate("viewNav"); html.put("viewLocation", request.getResource()); html.setTitle("Properties: " + resource); String tags = ""; if (pageData != null) { tags = pageData.getAttribute(PageData.PropertySUITES); } html.setPageTitle(new PageTitle("Page Properties", path, tags)); html.put("pageData", pageData); html.setMainTemplate("propertiesPage"); makeLastModifiedTag(); makeFormSections(); return html.html(); }