Files
alfresco-community-repo/source/java/de/fmui/cmis/fileshare/info/InfoUtil.java
David Caruana 360354fef5 Merged CMIS063 to HEAD
15943: Addition of CMIS FileShare to cmis.html front page.
  15974: Merge content type to stylesheet change from latest CMIS FileShare.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17238 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2009-10-29 17:32:24 +00:00

76 lines
2.0 KiB
Java

package de.fmui.cmis.fileshare.info;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
public class InfoUtil {
private InfoUtil() {
}
public static String getContextUrl(HttpServletRequest request) {
String scheme = request.getScheme();
int port = request.getServerPort();
if ("http".equals(scheme) && (port == 80)) {
port = -1;
}
if ("https".equals(scheme) && (port == 443)) {
port = -1;
}
return scheme + "://" + request.getServerName() + (port > 0 ? ":" + port : "") + request.getContextPath();
}
public static String getServletUrl(HttpServletRequest request) {
return getContextUrl(request) + request.getServletPath();
}
public static void printHeader(PrintWriter pw, String title) {
pw.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
pw.println("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
pw.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
pw.println("<head>");
pw.println("<title>" + title + "</title>");
pw.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
pw.println("<style type=\"text/css\">");
pw.println("body { font-family: arial,sans-serif; font-size: 10pt; }");
pw.println("</style>");
pw.println("</head>");
pw.println("<body>");
}
public static void printFooter(PrintWriter pw) {
pw.println("</body>");
pw.println("</html>");
}
public static void printStartSection(PrintWriter pw, String header) {
pw.println("<div style=\"background-color:#eeeeee; margin:15px; padding:5px;\">");
pw.println("<h3>" + header + "</h3>");
}
public static void printEndSection(PrintWriter pw) {
pw.println("</div>");
}
public static void printStartTable(PrintWriter pw) {
pw.println("<table>");
}
public static void printEndTable(PrintWriter pw) {
pw.println("</table>");
}
public static void printRow(PrintWriter pw, String... cols) {
pw.print("<tr>");
for (String col : cols) {
pw.print("<td>" + col + "</td>");
}
pw.println("</tr>");
}
}