Package org.w3c.jigsaw.html

Examples of org.w3c.jigsaw.html.HtmlGenerator


      String diff = null ;
      try {
    diff = getCvsManager().diff(name);
      } catch (CvsException cvs_ex) {
    Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
    HtmlGenerator g = getHtmlGenerator("CVS diff command failed") ;
    g.append ("<p>The CVS <strong>diff</strong> command failed "
        + " on " + name
        + " with the following error message: "
        + "<em>" + cvs_ex.getMessage() + "</em>"
        + "<hr> from class: " + this.getClass().getName()) ;
    error.setStream (g) ;
    throw new HTTPException (error) ;
      } catch (InvalidResourceException ex) {
    Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
    HtmlGenerator g = getHtmlGenerator("CVS diff command failed") ;
    g.append ("<p>The CVS <strong>diff</strong> command failed "
        + " on " + name
        + " with the following error message: "
        + "<em>" + ex.getMessage() + "</em>"
        + "<hr> from class: " + this.getClass().getName()) ;
    error.setStream (g) ;
    throw new HTTPException (error) ;
      } finally {
    rr_cvsframe.unlock();
      }
      // if there are no differences, generate a dummy report
      Reply         reply = request.makeReply(HTTP.OK) ;
      if((diff == null) || (diff.length() == 0)) {
    HtmlGenerator g = getHtmlGenerator("CVS diff command results");
    g.append("<P>No differences between " + name
       + " and the repository</P>");
    reply.setStream(g);
      } else {
    HtmlGenerator g = getHtmlGenerator("Diff result");
    g.append ("<center>");
    g.append (" [ <a href=\"../\">Up to directory</A> ] &middot;");
    g.append (" [ <a href=\""+getCvsURL(),
        "\">Back to CVS</A> ] \n");
    g.append ("</center>");
    g.append ("<hr noshade width=\"80%\"><p>");
    g.append ("<span class=\"title\"> CVS diff of ",
        name,"</span>\n");
    g.append ("<pre>",parseDiff(diff),"</pre>\n");
    g.append ("<p><hr noshade width=\"80%\">");
    g.append ("<center>");
    g.append (" [ <a href=\"../\">Up to directory</A> ] &middot;");
    g.append (" [ <a href=\""+getCvsURL(),
        "\">Back to CVS</A> ] \n");
    g.append ("</center>");
    reply.setStream(g);
      }
      return reply ;
  }
View Full Code Here


    protected Reply getOtherResource(Request request)
  throws ProtocolException, ResourceException
    // get our associated Resource
  FramedResource res = getResource();
  // Create the HTML generator, and set titles:
  HtmlGenerator g = new HtmlGenerator("FancyFrame");
  g.append("<h1>FancyFrame output</h1>");
  // emit the message
  g.append("<p>",getMessage(),"</p>");
  // display information about our Resource
  g.append("<h2> Resource associated : </h2>");
  g.append("<ul><li>Identifier : ",res.getIdentifier());
  g.append("<li>Last Modified Time : ",
     new Date(res.getLastModified()).toString(),
     "</ul>");
  // now emit the reply
  Reply reply = createDefaultReply(request, HTTP.OK) ;
  reply.setStream(g) ;
View Full Code Here

  }

  protected Reply doEditRev (Request request, String revision)
      throws HTTPException
  {
      HtmlGenerator g = getHtmlGenerator("Edit log");
      g.append ("<center>");
      g.append (" [ <a href=\"../\">Up to directory</A> ] &middot; ");
      g.append (" [ <a href=\""+getCvsURL()+
          "\">Back to CVS</A> ] &middot; ");
      g.append (" [ <a href=\"./",name+"?log\">Back to log</A> ] ");
      g.append ("<hr noshade width=\"80%\"><p>");
      g.append ("<span class=\"title\"> Edit log comment of ",
          name,
          " (revision "+revision+")</span>\n");
      g.append ("<form  method=\"post\">\n");
      g.append ("<input type=\"hidden\" name=\"revision\" value=\"",
          revision,"\">\n");
      g.append ("<table border=\"0\">\n");
      g.append ("<tr><td align=\"left\">");
      g.append ("<textarea name=\"comment\" rows=\"3\" cols=\"50\">\n") ;
      g.append ("</textarea></td></tr>\n") ;
      g.append ("</td></tr><tr><td align=\"center\">");
      g.append ("<input type=\"submit\" name=\"submit\" " +
          "value=\" Save Comment \">" );
      g.append ("</td></tr>");
      g.append ("</table></center></form>\n");
      g.append ("<hr noshade width=\"80%\">");
      Reply reply = request.makeReply(HTTP.OK) ;
      reply.setStream(g);
      return reply;
  }
View Full Code Here

    command[0] = "-m"+revision+":\""+comment+"\"";
    command[1] = name;
    getCvsManager().admin(command);
      } catch (CvsException ex) {
    Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
    HtmlGenerator g =
        getHtmlGenerator("CVS admin command failed") ;
    g.append ("<p>The CVS <strong>admin</strong> command failed "
        + " on " + name
        + " with the following error message: "
        + "<em>" + ex.getMessage() + "</em>");
    error.setStream (g) ;
    throw new HTTPException (error) ;
View Full Code Here

         int status,
         String title,
         String msg)
    {
  Reply error = request.makeReply(status);
  HtmlGenerator g = CvsFrame.getHtmlGenerator(title);
  g.append("<span class=\"title\">",title,"</span>\n");
  g.append("<p>",msg);
  error.setStream(g);
  return error;
    }
View Full Code Here

    CvsDirectory cvs = null ;

    protected Reply badAction(Request request, String action) {
  Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
  HtmlGenerator g = CvsFrame.getHtmlGenerator ("Bad CVS command") ;
  g.append ("<center>");
  g.append ("[ <A HREF=\"./CVS\">Back</A> ]<hr noshade width=\"80%\">");
  g.append ("<p>Your command "
      + "<strong>"+ action + "</strong>"
      + " wasn't undesrtood.<p>");
  g.append ("<hr noshade width=\"80%\"></center>");
  error.setStream (g) ;
  return error;
    }
View Full Code Here

  Reply reply = request.makeReply(HTTP.SEE_OTHER);
  URL loc = null;
  String target = (String) getValue(ATTR_TARGET_URL, null) ;
  if (target == null) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      HtmlGenerator g = new HtmlGenerator("Error");
      g.append("The target RelocateResource doesn't define the"
         + " relocation location. The server is "
         + " misconfigured.") ;
      error.setStream(g);
      return error ;
  }
  try {
      loc = new URL(getURL(request), target);
  } catch (MalformedURLException ex) {
      // still not well configured :)
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      HtmlGenerator g = new HtmlGenerator("Error");
      g.append("The target RelocateResource doesn't define the"
         + " relocation location. The server is "
         + " misconfigured.") ;
      error.setStream(g);
      return error ;
  }
  reply.setLocation(loc);
  HtmlGenerator g = new HtmlGenerator("Moved");
  g.append("<P>You should see the following resource, with a GET"+
     ", click on the link if your"
     + " browser doesn't support automatic redirection<BR>"+
     "<A HREF=\""+loc.toExternalForm()+"\">"+
     loc.toExternalForm()+"</A>");
  reply.setStream(g);
View Full Code Here

      }
      if (lmbest != 0) {
    // always temporary and no good support for 307 :(
    Reply reply = request.makeReply(HTTP.FOUND);
    reply.setLocation(best+"/");
    HtmlGenerator g = new HtmlGenerator("Moved");
    g.append("<P>The freshest child is available from "+
       "<A HREF=\""+best+"/\">"+best
       +"</A>");
    reply.setStream(g);
    return reply ;
      }
  }
  Reply reply = request.makeReply(HTTP.FOUND);
  reply.setLocation("./");
  HtmlGenerator g = new HtmlGenerator("Moved");
  g.append("<P>No child available, see parent: "+
     "<A HREF=\"./\">parent</A>");
  reply.setStream(g);
  return reply ;
    }
View Full Code Here

     * Dump the current memory status.
     * @param request The request we are to reply to.
     */

    protected Reply dumpMemoryStatus (Request request) {
  HtmlGenerator g = new HtmlGenerator ("Memory Status") ;
  int refresh = getInt(ATTR_REFRESH, REFRESH_DEFAULT);
  if (refresh > 0) {
      g.addMeta("Refresh", Integer.toString(refresh));
  }
  addStyleSheet(g);
  g.append("<h1>Memory status</h1>") ;
  long bytes = runtime.freeMemory();
  long kbytes = bytes / 1024;
  long mbytes = kbytes / 1024;
  if (mbytes != 0) {
      g.append("<p>Free Memory: " +mbytes+ "Mb, " +kbytes % 1024+ "Kb, "
         + bytes % 1024 + " (" + Long.toString(bytes) +")");
  } else if (kbytes != 0) {
      g.append("<p>Free Memory: " + kbytes + "Kb, " + bytes % 1024 +
         " (" + Long.toString(bytes) +")");
  } else {
      g.append("<p>Free Memory:" + Long.toString(bytes));
  }
  bytes = runtime.totalMemory();
  kbytes = bytes / 1024;
  mbytes = kbytes / 1024;
  if (mbytes != 0) {
      g.append("<p>Total Memory: "+mbytes+"Mb, " +kbytes % 1024+ "Kb, "
         + bytes % 1024 + " (" + Long.toString(bytes) +")");
  } else if (kbytes != 0) {
      g.append("<p>Total Memory: " + kbytes + "Kb, " + bytes % 1024
         + " (" + Long.toString(bytes) +")");
  } else {
      g.append("<p>Total Memory:", Long.toString(bytes));
  }
  g.append("<p>GC count: "+GcCounter.getGcCount()) ;
  g.append("<hr>") ;
  // Reply back:
  Reply  reply = request.makeReply(HTTP.OK) ;
  reply.setNoCache();
  reply.setStream (g) ;
  reply.setDynamic(true);
View Full Code Here

     * @param request The request we are to reply to.
     */
    public Reply listThreads (Request request) {
  // enumerate all thread, and return a full thread listing:
  int    tcount   = Thread.activeCount() ;
  HtmlGenerator g = new HtmlGenerator ("Thread status") ;
  g.meta ("Refresh", getValue(ATTR_REFRESH, REFRESH_DEFAULT).toString());
  addStyleSheet(g);
  // Dump thread informations:
  Thread tarray[] = new Thread[tcount] ;
  Thread.enumerate (tarray) ;
  g.append ("<h1>Thread dump</h1>") ;
  g.append ("<ul>") ;
  String rname = getResource().getIdentifier();
  for (int i = 0 ; i < tcount ; i++) {
      String name = tarray[i].getName() ;
      g.append ("<li>"
          + "<a href=\""+rname+"?" + name + "\">" + name + "</a>"
          + (tarray[i].isDaemon() ? "D " : "  ")
          + (tarray[i].isAlive()  ? "R " : "  ")
          + " Prio: " +(tarray[i].getPriority())) ;
  }
  g.append ("</ul>") ;
  // Dark features:
  g.append ("<p>To kill a thread, add a <b>?</b><em>thread-name</em> "
      + "to the current URL.</p>") ;
  // Add global java process informations:
  g.append ("<h2>Misc informations</h2>") ;
  g.append ("<p>Total free memory: " + runtime.freeMemory());
  g.append ("<p>Toal memory      : " + runtime.totalMemory()) ;
  g.close() ;
  // Reply back:
  Reply  reply = request.makeReply(HTTP.OK) ;
  reply.setStream (g) ;
  return reply ;
    }
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.html.HtmlGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.