X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.server%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fweb%2Fajaxplorer%2Fsvn%2FSvnLogAction.java;fp=runtime%2Forg.argeo.slc.server%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fweb%2Fajaxplorer%2Fsvn%2FSvnLogAction.java;h=0000000000000000000000000000000000000000;hb=651d33e13bfa9a7b46464be412023ee747e612e8;hp=24c12bc06d8b921dbfa2db3b06fdbfcca416cc1d;hpb=868102c0f0220e12eca836b6ec9b3a2b9a3441e4;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/ajaxplorer/svn/SvnLogAction.java b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/ajaxplorer/svn/SvnLogAction.java deleted file mode 100644 index 24c12bc06..000000000 --- a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/ajaxplorer/svn/SvnLogAction.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.web.ajaxplorer.svn; - -import java.io.File; -import java.io.PrintWriter; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.web.ajaxplorer.AjxpAction; -import org.argeo.slc.web.ajaxplorer.AjxpAnswer; -import org.argeo.slc.web.ajaxplorer.AjxpDriverException; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; -import org.tmatesoft.svn.core.wc.SVNRevision; - -public class SvnLogAction implements AjxpAction { - private final SimpleDateFormat sdfIso = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss"); - private final Log log = LogFactory.getLog(getClass()); - - public AjxpAnswer execute(SvnDriver driver, HttpServletRequest request) { - String fileStr = request.getParameter("file"); - log.debug("Log file " + fileStr); - if (fileStr == null) { - throw new AjxpDriverException("A file needs to be provided."); - } - File file = new File(driver.getBasePath() + fileStr); - return new SvnLogAnswer(driver, file); - } - - protected class SvnLogAnswer implements AjxpAnswer { - private final SvnDriver driver; - private final File file; - - public SvnLogAnswer(SvnDriver driver, File file) { - this.driver = driver; - this.file = file; - } - - public void updateResponse(HttpServletResponse response) { - PrintWriter writer = null; - try { - writer = response.getWriter(); - writer.append(""); - writer.append(""); - - final List logEntries = new Vector(); - ISVNLogEntryHandler logHandler = new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) - throws SVNException { - logEntries.add(logEntry); - } - }; - - driver.getManager().getLogClient().doLog(new File[] { file }, - SVNRevision.create(0), SVNRevision.HEAD, true, true, - 100, logHandler); - - for (int i = logEntries.size() - 1; i >= 0; i--) { - String xml = logEntryAsXml(logEntries.get(i), file); - if(log.isTraceEnabled()) - log.trace(xml); - writer.append(xml); - } - - writer.append(""); - writer.append(""); - } catch (Exception e) { - throw new AjxpDriverException( - "Cannot retrieve log for " + file, e); - } finally { - IOUtils.closeQuietly(writer); - } - } - - } - - protected String logEntryAsXml(SVNLogEntry entry, File file) { - StringBuffer buf = new StringBuffer(); - buf.append(""); - - buf.append("").append(entry.getAuthor()).append(""); - buf.append("").append(sdfIso.format(entry.getDate())).append( - ""); - - buf.append(""); - Map paths = entry.getChangedPaths(); - for (SVNLogEntryPath path : paths.values()) { - buf.append("").append(path.getPath()).append(""); - } - buf.append(""); - - buf.append("").append(entry.getMessage()).append(""); - - buf.append(""); - return buf.toString(); - } - -}