コード例 #1
0
 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;
 }
コード例 #2
0
  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);
    }
  }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: EditResponder.java プロジェクト: lewiswang/fitnesse
  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;
  }
コード例 #5
0
 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();
 }
コード例 #6
0
 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);
   }
 }
コード例 #7
0
  @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;
  }
コード例 #8
0
 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);
 }
コード例 #9
0
  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);
  }
コード例 #10
0
  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);
  }
コード例 #11
0
  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;
  }
コード例 #12
0
  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);
    }
  }
コード例 #13
0
  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);
    }
  }
コード例 #14
0
  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;
  }
コード例 #15
0
 private Response tryToMakeTestExecutionReport(Request request) {
   Date resultDate;
   String date = (String) request.getInput("resultDate");
   if ("latest".equals(date)) {
     resultDate = pageHistory.getLatestDate();
   } else {
     try {
       resultDate = dateFormat.parse(date);
     } catch (ParseException e) {
       throw new RuntimeException("Invalid date format provided", e);
     }
   }
   TestResultRecord testResultRecord = pageHistory.get(resultDate);
   try {
     return makeTestExecutionReportResponse(request, resultDate, testResultRecord);
   } catch (Exception e) {
     return makeCorruptFileResponse(request);
   }
 }
コード例 #16
0
ファイル: MergeResponder.java プロジェクト: inkblot/fitnesse
 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();
 }
コード例 #17
0
 private String getPageType(Request request) {
   return (String) request.getInput(PageData.PAGE_TYPE_ATTRIBUTE);
 }
コード例 #18
0
 private static String getAndTagFilters(Request request) {
   return request != null ? (String) request.getInput(AND_FILTER_ARG) : null;
 }
コード例 #19
0
 private static String getNotSuiteFilter(Request request) {
   return request != null ? (String) request.getInput(NOT_FILTER_ARG) : null;
 }
コード例 #20
0
 private boolean isChecked(Request request, String name) {
   return (request.getInput(name) != null);
 }
コード例 #21
0
 private boolean formatIsXML(Request request) {
   return (request.getInput("format") != null
       && request.getInput("format").toString().toLowerCase().equals("xml"));
 }