%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.utils.Sessions" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.RightsAndRoles" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Document" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Feature" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Document.SearchFilter" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Page" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.webtools.*" %>
<%@ page import="javax.validation.constraints.Pattern" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.Comparator" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.DataOutputStream" %>
<%@ page import="java.io.StringWriter" %>
<%@ page import="com.github.opendevl.JFlat" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.File" %>
<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.FileWriter" %>
<%@ page import="java.nio.charset.Charset" %>
<%@ page import="org.apache.log4j.Logger" %>
<%!
@Description(value = "Show VMR-CRE commit log", name = "log")
public static class MyParameters extends Parameters {
@Description(value = "exclude style for XML")
public Boolean noStyle = false;
@Override
protected void afterLoad() {
}
protected boolean permissionValidation(HttpServletRequest request, HttpServletResponse response) { return true; }
}
static SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response);
if (params.getErrors().size() == 0) {
String args[] = new String[] {
"svn",
"log",
"-v",
"--xml"
};
String toStdIn = "";
StringBuffer resultBuf = new StringBuffer();
StringBuffer errorBuf = new StringBuffer();
runCommand(args, resultBuf, errorBuf, toStdIn, params.getLogger());
out.println("");
XMLBlock result = XMLBlock.createXMLBlock(resultBuf.toString());
Serializer.output(response, out, params, result);
return;
}
else {
((Parameters)params).format = "html";
}
Serializer.reportErrors(request, response, out, params, true);
%>
<%!
public static Thread startSlurpStreamThreaded(final InputStream is, final StringBuffer outBuf) {
Thread t = new Thread() {
InputStream myIS = is;
StringBuffer myOutBuf = outBuf;
public void run() {
try {
InputStreamReader isr = new InputStreamReader(myIS);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
myOutBuf.append(line + "\n");
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
};
t.start();
return t;
}
public static int runCommand(String command[], StringBuffer result, StringBuffer error, String toStdIn, Logger logger) {
int retVal = -1;
try {
File cwd = new File("/home/ntvmr/src/community");
String cmd = "";
for (String s: command) {
cmd += " [" + s + "]";
}
logger.info("executing from cwd ("+cwd.getAbsolutePath()+"):" + cmd);
java.lang.Process p = Runtime.getRuntime().exec(command, new String[] { "HOME=/home/ntvmr" }, cwd);
p.getOutputStream().write(toStdIn.getBytes(Charset.forName("UTF-8")));
Thread o = startSlurpStreamThreaded(p.getInputStream(), result);
Thread e = startSlurpStreamThreaded(p.getErrorStream(), error);
p.getOutputStream().close();
retVal = p.waitFor();
o.join();
e.join();
if (error.length() > 0) {
logger.warn("error: " + error.toString());
}
}
catch (Exception e) {e.printStackTrace();}
//logger.debug("returned: " + retVal + "; stdout: " + result);
return retVal;
}
%>