Author: glorieux Date: 2009-12-15 10:41:48 +0100 (Tue, 15 Dec 2009) New Revision: 53 Added: trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java Log: Add SearchServlet. Added: trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java (rev 0) +++ trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2009-12-15 09:41:48 UTC (rev 53) @@ -0,0 +1,81 @@ +/* *##% ScmWebEditor + * Copyright (C) 2004 - 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ + +package org.nuiton.scmwebeditor; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.tmatesoft.svn.core.ISVNDirEntryHandler; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; +import org.tmatesoft.svn.core.wc.SVNLogClient; +import org.tmatesoft.svn.core.wc.SVNRevision; +import org.tmatesoft.svn.core.wc.SVNWCUtil; + +public class SearchServlet extends AbstractScmWebEditorServlet { + + private static final Log log = LogFactory.getLog(SearchServlet.class); + + /** + * Handles the HTTP <code>POST</code> method. + * Search files list on scm repository + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException{ + try { + String adresse = request.getParameter(PARAMETER_ADRESSE); + if (log.isDebugEnabled()) { + log.debug("Search for files on " + adresse + " repository"); + } + //Create default access + DefaultSVNOptions svnOption = SVNWCUtil.createDefaultOptions(false); + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(); + //Convert url to SVNUrl + SVNURL svnUrl; + svnUrl = SVNURL.parseURIEncoded(adresse); + //get a SVNLogClient + SVNLogClient logClient = new SVNLogClient(authManager, svnOption); + //recup info about svn repository + ISVNDirEntryHandler dirEntryHandler = new ISVNDirEntryHandler() { + + @Override + public void handleDirEntry(SVNDirEntry arg0) throws SVNException { + log.debug("le fichier est: " + arg0.getName()); + throw new UnsupportedOperationException("Not supported yet."); + } + }; + logClient.doList(svnUrl, SVNRevision.WORKING, SVNRevision.HEAD, true, true, dirEntryHandler); + } catch (SVNException ex) { + response.setStatus(401); + Logger.getLogger(SearchServlet.class.getName()).log(Level.SEVERE, null, ex); + } + + + } +} \ No newline at end of file