@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;
  }
Beispiel #3
0
  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;
  }
 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);
 }
Beispiel #5
0
 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();
 }
  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);
    }
  }
Beispiel #7
0
 public Response makeResponse(FitNesseContext context, Request request) throws Exception {
   boolean nonExistent = request.hasInput("nonExistent") ? true : false;
   return doMakeResponse(context, request, nonExistent);
 }