mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-11-03 20:15:52 +01:00 
			
		
		
		
	Cleanup Code
Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com> Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
		@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.logging;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.collect.Maps;
 | 
			
		||||
 | 
			
		||||
@@ -34,58 +33,33 @@ import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.tmatesoft.svn.util.SVNDebugLogAdapter;
 | 
			
		||||
import org.tmatesoft.svn.util.SVNLogType;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SVNKitLogger extends SVNDebugLogAdapter
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final int MAX_SIZE = 128 * 1024;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final int TRACE_LEVEL_THRESHOLD = Level.FINEST.intValue();
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final int INFO_LEVEL_THRESHOLD = Level.INFO.intValue();
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final int DEBUG_LEVEL_THRESHOLD = Level.FINE.intValue();
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final int WARN_LEVEL_THRESHOLD = Level.WARNING.intValue();
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String LINE_SEPARATOR =
 | 
			
		||||
    System.getProperty("line.separator");
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private Map<SVNLogType, Logger> loggerMap;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  public SVNKitLogger()
 | 
			
		||||
  {
 | 
			
		||||
    loggerMap = Maps.newHashMap();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param logType
 | 
			
		||||
   * @param th
 | 
			
		||||
   * @param logLevel
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
  public void log(SVNLogType logType, Throwable th, Level logLevel)
 | 
			
		||||
  {
 | 
			
		||||
@@ -113,14 +87,7 @@ public class SVNKitLogger extends SVNDebugLogAdapter
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param logType
 | 
			
		||||
   * @param message
 | 
			
		||||
   * @param logLevel
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public void log(SVNLogType logType, String message, Level logLevel)
 | 
			
		||||
  {
 | 
			
		||||
@@ -148,14 +115,7 @@ public class SVNKitLogger extends SVNDebugLogAdapter
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param logType
 | 
			
		||||
   * @param message
 | 
			
		||||
   * @param data
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  @Override
 | 
			
		||||
  public void log(SVNLogType logType, String message, byte[] data)
 | 
			
		||||
  {
 | 
			
		||||
@@ -178,36 +138,17 @@ public class SVNKitLogger extends SVNDebugLogAdapter
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param name
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  private String parseName(String name)
 | 
			
		||||
  {
 | 
			
		||||
    return name.replace('-', '.');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param type
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  private Logger getLogger(SVNLogType type)
 | 
			
		||||
  {
 | 
			
		||||
    return loggerMap.computeIfAbsent(type, t -> LoggerFactory.getLogger(parseName(t.getName())));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private Map<SVNLogType, Logger> loggerMap;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,10 +24,7 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public enum Compatibility
 | 
			
		||||
{
 | 
			
		||||
  NONE(false, false, false, false, false),
 | 
			
		||||
@@ -36,15 +33,16 @@ public enum Compatibility
 | 
			
		||||
  PRE17(false, false, false, true, false),
 | 
			
		||||
  WITH17(false, false, false, false, true);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Field description
 | 
			
		||||
   *
 | 
			
		||||
   * @param pre14Compatible
 | 
			
		||||
   * @param pre15Compatible
 | 
			
		||||
   * @param pre16Compatible
 | 
			
		||||
   * @param pre17Compatible
 | 
			
		||||
   * @param with17Compatible
 | 
			
		||||
   */
 | 
			
		||||
  private boolean pre14Compatible;
 | 
			
		||||
 | 
			
		||||
  private boolean pre15Compatible;
 | 
			
		||||
 | 
			
		||||
  private boolean pre16Compatible;
 | 
			
		||||
 | 
			
		||||
  private boolean pre17Compatible;
 | 
			
		||||
 | 
			
		||||
  private boolean with17Compatible;
 | 
			
		||||
 | 
			
		||||
  private Compatibility(boolean pre14Compatible, boolean pre15Compatible,
 | 
			
		||||
                        boolean pre16Compatible, boolean pre17Compatible,
 | 
			
		||||
                        boolean with17Compatible)
 | 
			
		||||
@@ -56,77 +54,35 @@ public enum Compatibility
 | 
			
		||||
    this.with17Compatible = with17Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isPre14Compatible()
 | 
			
		||||
  {
 | 
			
		||||
    return pre14Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isPre15Compatible()
 | 
			
		||||
  {
 | 
			
		||||
    return pre15Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isPre16Compatible()
 | 
			
		||||
  {
 | 
			
		||||
    return pre16Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isPre17Compatible()
 | 
			
		||||
  {
 | 
			
		||||
    return pre17Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isWith17Compatible()
 | 
			
		||||
  {
 | 
			
		||||
    return with17Compatible;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private boolean pre14Compatible;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private boolean pre15Compatible;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private boolean pre16Compatible;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private boolean pre17Compatible;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private boolean with17Compatible;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Charsets;
 | 
			
		||||
import com.google.common.collect.ImmutableSet;
 | 
			
		||||
@@ -42,81 +41,53 @@ import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
 | 
			
		||||
 | 
			
		||||
import sonia.scm.plugin.Extension;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Extension
 | 
			
		||||
public class DBFormatHealthCheck extends DirectoryHealthCheck
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * the logger for DBFormatHealthCheck
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(DBFormatHealthCheck.class);
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final Set<String> INVALID_DBFORMAT = ImmutableSet.of("5");
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final HealthCheckFailure INCOMPATIBLE_DB_FORMAT =
 | 
			
		||||
    new HealthCheckFailure("AnOTx99ex1", "Incompatible DB Format",
 | 
			
		||||
      "https://github.com/scm-manager/scm-manager/blob/develop/docs/healthchecks/svn-incompatible-dbformat.md",
 | 
			
		||||
      "The subversion db format is incompatible with the svn version used within scm-manager.");
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String DBFORMAT =
 | 
			
		||||
    "db".concat(File.separator).concat("format");
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final HealthCheckFailure COULD_NOT_READ_DB_FILE =
 | 
			
		||||
    new HealthCheckFailure("4IOTx8pvv1", "Could not read db/format file",
 | 
			
		||||
      "The db/format file of the repository was not readable.");
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final HealthCheckFailure COULD_NOT_OPEN_REPOSITORY =
 | 
			
		||||
    new HealthCheckFailure("6TOTx9RLD1", "Could not open svn repository",
 | 
			
		||||
      "The repository is not openable.");
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final HealthCheckFailure COULD_NOT_FIND_DB_FILE =
 | 
			
		||||
    new HealthCheckFailure("A9OTx8leC1", "Could not find db/format file",
 | 
			
		||||
      "The subversion repository does not contain the db/format file.");
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repositoryManager
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  @Inject
 | 
			
		||||
  public DBFormatHealthCheck(RepositoryManager repositoryManager)
 | 
			
		||||
  {
 | 
			
		||||
    super(repositoryManager);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repository
 | 
			
		||||
   * @param directory
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  protected HealthCheckResult check(Repository repository, File directory)
 | 
			
		||||
  {
 | 
			
		||||
@@ -130,16 +101,8 @@ public class DBFormatHealthCheck extends DirectoryHealthCheck
 | 
			
		||||
      : HealthCheckResult.unhealthy(failures);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repository
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  protected boolean isCheckResponsible(Repository repository)
 | 
			
		||||
  {
 | 
			
		||||
@@ -147,16 +110,8 @@ public class DBFormatHealthCheck extends DirectoryHealthCheck
 | 
			
		||||
      repository.getType());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param failures
 | 
			
		||||
   * @param repository
 | 
			
		||||
   * @param directory
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private void checkForBadDBVersion(List<HealthCheckFailure> failures,
 | 
			
		||||
    Repository repository, File directory)
 | 
			
		||||
  {
 | 
			
		||||
@@ -188,14 +143,7 @@ public class DBFormatHealthCheck extends DirectoryHealthCheck
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param failures
 | 
			
		||||
   * @param repository
 | 
			
		||||
   * @param directory
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private void checkIfRepositoryIsOpenable(List<HealthCheckFailure> failures,
 | 
			
		||||
    Repository repository, File directory)
 | 
			
		||||
  {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,45 +24,22 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.tmatesoft.svn.core.SVNErrorCode;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public final class ScmSvnErrorCode extends SVNErrorCode
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final long serialVersionUID = -6864996390796610410L;
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param category
 | 
			
		||||
   * @param index
 | 
			
		||||
   * @param description
 | 
			
		||||
   */
 | 
			
		||||
  protected ScmSvnErrorCode(int category, int index, String description)
 | 
			
		||||
  {
 | 
			
		||||
    super(category, index, description);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param description
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static ScmSvnErrorCode authzNotEnoughPrivileges(String description)
 | 
			
		||||
  {
 | 
			
		||||
    return new ScmSvnErrorCode(AUTHZ_CATEGORY, 4, description);
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
@@ -36,8 +35,6 @@ import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler;
 | 
			
		||||
 | 
			
		||||
import sonia.scm.util.Util;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
@@ -46,29 +43,21 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("deprecation")
 | 
			
		||||
public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** the logger for SvnBlameHandler */
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnBlameHandler.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private final List<BlameLine> blameLines;
 | 
			
		||||
 | 
			
		||||
  private final Map<Long, String> descriptionCache = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
  private final String path;
 | 
			
		||||
 | 
			
		||||
  private final SVNRepository svnRepository;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param svnRepository
 | 
			
		||||
   * @param path
 | 
			
		||||
   * @param blameLines
 | 
			
		||||
   */
 | 
			
		||||
  public SvnBlameHandler(SVNRepository svnRepository, String path,
 | 
			
		||||
                         List<BlameLine> blameLines)
 | 
			
		||||
  {
 | 
			
		||||
@@ -77,30 +66,14 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
    this.blameLines = blameLines;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
   @Override
 | 
			
		||||
  public void handleEOF()
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
    // do nothing
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param date
 | 
			
		||||
   * @param revision
 | 
			
		||||
   * @param author
 | 
			
		||||
   * @param line
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNException
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
  public void handleLine(Date date, long revision, String author, String line)
 | 
			
		||||
          throws SVNException
 | 
			
		||||
@@ -108,22 +81,6 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
    handleLine(date, revision, author, line, null, -1, null, null, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param date
 | 
			
		||||
   * @param revision
 | 
			
		||||
   * @param author
 | 
			
		||||
   * @param line
 | 
			
		||||
   * @param mergedDate
 | 
			
		||||
   * @param mergedRevision
 | 
			
		||||
   * @param mergedAuthor
 | 
			
		||||
   * @param mergedPath
 | 
			
		||||
   * @param lineNumber
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNException
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
  public void handleLine(Date date, long revision, String author, String line,
 | 
			
		||||
                         Date mergedDate, long mergedRevision,
 | 
			
		||||
@@ -150,19 +107,6 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
                                 when, authorPerson, description, line));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param date
 | 
			
		||||
   * @param revision
 | 
			
		||||
   * @param author
 | 
			
		||||
   * @param contents
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNException
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean handleRevision(Date date, long revision, String author,
 | 
			
		||||
                                File contents)
 | 
			
		||||
@@ -171,16 +115,8 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param revision
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @SuppressWarnings("unchecked")
 | 
			
		||||
  private String getDescription(long revision)
 | 
			
		||||
  {
 | 
			
		||||
@@ -216,17 +152,4 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
 | 
			
		||||
    return description;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final List<BlameLine> blameLines;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final Map<Long, String> descriptionCache = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final String path;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final SVNRepository svnRepository;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,10 +31,7 @@ import jakarta.xml.bind.annotation.XmlRootElement;
 | 
			
		||||
import jakarta.xml.bind.annotation.XmlTransient;
 | 
			
		||||
import sonia.scm.auditlog.AuditEntry;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@XmlRootElement(name = "config")
 | 
			
		||||
@XmlAccessorType(XmlAccessType.FIELD)
 | 
			
		||||
@AuditEntry(labels = {"svn", "config"})
 | 
			
		||||
@@ -44,12 +41,11 @@ public class SvnConfig extends RepositoryConfig
 | 
			
		||||
  @SuppressWarnings("WeakerAccess") // This might be needed for permission checking
 | 
			
		||||
  public static final String PERMISSION = "svn";
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  @XmlElement(name = "enable-gzip")
 | 
			
		||||
  private boolean enabledGZip = false;
 | 
			
		||||
 | 
			
		||||
  private Compatibility compatibility = Compatibility.NONE;
 | 
			
		||||
 | 
			
		||||
  public Compatibility getCompatibility()
 | 
			
		||||
  {
 | 
			
		||||
    if (compatibility == null)
 | 
			
		||||
@@ -60,50 +56,25 @@ public class SvnConfig extends RepositoryConfig
 | 
			
		||||
    return compatibility;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  public boolean isEnabledGZip()
 | 
			
		||||
  {
 | 
			
		||||
    return enabledGZip;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- set methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param compatibility
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public void setCompatibility(Compatibility compatibility)
 | 
			
		||||
  {
 | 
			
		||||
    this.compatibility = compatibility;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param enabledGZip
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public void setEnabledGZip(boolean enabledGZip)
 | 
			
		||||
  {
 | 
			
		||||
    this.enabledGZip = enabledGZip;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  @XmlElement(name = "enable-gzip")
 | 
			
		||||
  private boolean enabledGZip = false;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private Compatibility compatibility = Compatibility.NONE;
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  @XmlTransient // Only for permission checks, don't serialize to XML
 | 
			
		||||
  public String getId() {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,57 +26,34 @@ package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 * @deprecated
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public class SvnImportHandler extends AbstactImportHandler
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  public static final String SVN_DIR_LOCKS = "locks";
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param handler
 | 
			
		||||
   */
 | 
			
		||||
  private SvnRepositoryHandler handler;
 | 
			
		||||
 
 | 
			
		||||
  public SvnImportHandler(SvnRepositoryHandler handler)
 | 
			
		||||
  {
 | 
			
		||||
    this.handler = handler;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  protected String[] getDirectoryNames()
 | 
			
		||||
  {
 | 
			
		||||
    return new String[] { SVN_DIR_LOCKS };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  protected AbstractRepositoryHandler<?> getRepositoryHandler()
 | 
			
		||||
  {
 | 
			
		||||
    return handler;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private SvnRepositoryHandler handler;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -48,9 +48,7 @@ import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Singleton
 | 
			
		||||
@Extension
 | 
			
		||||
public class SvnRepositoryHandler extends AbstractSimpleRepositoryHandler<SvnConfig> {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
@@ -46,20 +45,16 @@ import sonia.scm.util.Util;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnRepositoryHook implements FSHook
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** the logger for SvnRepositoryHook */
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnRepositoryHook.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private HookEventFacade hookEventFacade;
 | 
			
		||||
 | 
			
		||||
  private final SvnRepositoryHandler handler;
 | 
			
		||||
 | 
			
		||||
  public SvnRepositoryHook(HookEventFacade hookEventFacade, SvnRepositoryHandler handler)
 | 
			
		||||
  {
 | 
			
		||||
@@ -67,16 +62,8 @@ public class SvnRepositoryHook implements FSHook
 | 
			
		||||
    this.handler = handler;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param event
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNException
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public void onHook(FSHookEvent event) throws SVNException
 | 
			
		||||
  {
 | 
			
		||||
@@ -130,15 +117,7 @@ public class SvnRepositoryHook implements FSHook
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param directory
 | 
			
		||||
   * @param changesetProvider
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNCancelException
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  private void fireHook(File directory,
 | 
			
		||||
    AbstractSvnHookChangesetProvider changesetProvider)
 | 
			
		||||
    throws SVNCancelException
 | 
			
		||||
@@ -167,28 +146,12 @@ public class SvnRepositoryHook implements FSHook
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param directory
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   *
 | 
			
		||||
   * @throws IOException
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  private String getRepositoryId(File directory)
 | 
			
		||||
  {
 | 
			
		||||
    AssertUtil.assertIsNotNull(directory);
 | 
			
		||||
    return handler.getRepositoryId(directory);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private HookEventFacade hookEventFacade;
 | 
			
		||||
 | 
			
		||||
  private final SvnRepositoryHandler handler;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Strings;
 | 
			
		||||
import com.google.common.collect.Lists;
 | 
			
		||||
@@ -59,19 +58,12 @@ import static sonia.scm.ContextEntry.ContextBuilder.entity;
 | 
			
		||||
import static sonia.scm.NotFoundException.notFound;
 | 
			
		||||
import static sonia.scm.repository.ConsolidatingModificationCollector.consolidate;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public final class SvnUtil
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  public static final String XML_CONTENT_TYPE = "text/xml; charset=\"utf-8\"";
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String ID_TRANSACTION_PREFIX = "-1:";
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
@@ -80,27 +72,17 @@ public final class SvnUtil
 | 
			
		||||
   */
 | 
			
		||||
  private static final char TYPE_UPDATED = 'U';
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String USERAGENT_SVN = "svn/";
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * the logger for SvnUtil
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String ID_TRANSACTION_PATTERN =
 | 
			
		||||
    ID_TRANSACTION_PREFIX.concat("%s");
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  private SvnUtil() {}
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  public static long parseRevision(String v, Repository repository) {
 | 
			
		||||
    long result = -1l;
 | 
			
		||||
@@ -169,12 +151,7 @@ public final class SvnUtil
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repository
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static void closeSession(SVNRepository repository)
 | 
			
		||||
  {
 | 
			
		||||
    if (repository != null)
 | 
			
		||||
@@ -190,14 +167,7 @@ public final class SvnUtil
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param entry
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @SuppressWarnings("unchecked")
 | 
			
		||||
  public static Changeset createChangeset(SVNLogEntry entry)
 | 
			
		||||
  {
 | 
			
		||||
@@ -214,14 +184,7 @@ public final class SvnUtil
 | 
			
		||||
    return changeset;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param entries
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static List<Changeset> createChangesets(List<SVNLogEntry> entries)
 | 
			
		||||
  {
 | 
			
		||||
    List<Changeset> changesets = Lists.newArrayList();
 | 
			
		||||
@@ -234,13 +197,6 @@ public final class SvnUtil
 | 
			
		||||
    return changesets;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   * @param errorCode
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  @SuppressWarnings("java:S1149") // we can not use StringBuild SVNXMLUtil requires StringBuffer
 | 
			
		||||
  public static String createErrorBody(SVNErrorCode errorCode)
 | 
			
		||||
  {
 | 
			
		||||
@@ -268,25 +224,13 @@ public final class SvnUtil
 | 
			
		||||
    return xmlBuffer.toString();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param transaction
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static String createTransactionEntryId(String transaction)
 | 
			
		||||
  {
 | 
			
		||||
    return String.format(ID_TRANSACTION_PATTERN, transaction);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param clientManager
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static void dispose(SVNClientManager clientManager)
 | 
			
		||||
  {
 | 
			
		||||
    if (clientManager != null)
 | 
			
		||||
@@ -302,17 +246,6 @@ public final class SvnUtil
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   * @param response
 | 
			
		||||
   * @param statusCode
 | 
			
		||||
   * @param errorCode
 | 
			
		||||
   *
 | 
			
		||||
   * @throws IOException
 | 
			
		||||
   */
 | 
			
		||||
  public static void sendError(HttpServletRequest request,
 | 
			
		||||
    HttpServletResponse response, int statusCode, SVNErrorCode errorCode)
 | 
			
		||||
    throws IOException
 | 
			
		||||
@@ -354,40 +287,19 @@ public final class SvnUtil
 | 
			
		||||
    return revisionNumber;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param id
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static String getTransactionId(String id)
 | 
			
		||||
  {
 | 
			
		||||
    return id.substring(ID_TRANSACTION_PREFIX.length());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static boolean isSvnClient(HttpServletRequest request)
 | 
			
		||||
  {
 | 
			
		||||
    return HttpUtil.userAgentStartsWith(request, USERAGENT_SVN);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param id
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public static boolean isTransactionEntryId(String id)
 | 
			
		||||
  {
 | 
			
		||||
    return Strings.nullToEmpty(id).startsWith(ID_TRANSACTION_PREFIX);
 | 
			
		||||
 
 | 
			
		||||
@@ -24,53 +24,30 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.tmatesoft.svn.core.SVNException;
 | 
			
		||||
import org.tmatesoft.svn.core.io.SVNRepository;
 | 
			
		||||
 | 
			
		||||
import sonia.scm.repository.Repository;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class AbstractSvnCommand
 | 
			
		||||
{
 | 
			
		||||
  protected SvnContext context;
 | 
			
		||||
 | 
			
		||||
  protected Repository repository;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param context
 | 
			
		||||
   */
 | 
			
		||||
  protected AbstractSvnCommand(SvnContext context)
 | 
			
		||||
  {
 | 
			
		||||
    this.context = context;
 | 
			
		||||
    this.repository = context.getRepository();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   *
 | 
			
		||||
   * @throws SVNException
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public SVNRepository open() throws SVNException
 | 
			
		||||
  {
 | 
			
		||||
    return context.open();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  protected SvnContext context;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  protected Repository repository;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,40 +31,19 @@ import sonia.scm.repository.api.HookChangesetProvider;
 | 
			
		||||
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public abstract class AbstractSvnHookChangesetProvider
 | 
			
		||||
  implements HookChangesetProvider
 | 
			
		||||
{
 | 
			
		||||
  private HookChangesetResponse response;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  public abstract RepositoryHookType getType();
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  protected abstract Changeset fetchChangeset();
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  @SuppressWarnings("unchecked")
 | 
			
		||||
  public synchronized HookChangesetResponse handleRequest(
 | 
			
		||||
@@ -90,8 +69,4 @@ public abstract class AbstractSvnHookChangesetProvider
 | 
			
		||||
    return response;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private HookChangesetResponse response;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.collect.Lists;
 | 
			
		||||
import org.tmatesoft.svn.core.SVNException;
 | 
			
		||||
@@ -43,12 +42,7 @@ import sonia.scm.util.Util;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnBlameCommand extends AbstractSvnCommand implements BlameCommand
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Strings;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
@@ -50,17 +49,11 @@ import static org.tmatesoft.svn.core.SVNErrorCode.FS_NO_SUCH_REVISION;
 | 
			
		||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
 | 
			
		||||
import static sonia.scm.NotFoundException.notFound;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnBrowseCommand extends AbstractSvnCommand
 | 
			
		||||
  implements BrowseCommand {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * the logger for SvnBrowseCommand
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnBrowseCommand.class);
 | 
			
		||||
 | 
			
		||||
@@ -111,7 +104,6 @@ public class SvnBrowseCommand extends AbstractSvnCommand
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  @SuppressWarnings("unchecked")
 | 
			
		||||
  private void traverse(SVNRepository svnRepository, long revisionNumber, BrowseCommandRequest request,
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.io.ByteSink;
 | 
			
		||||
import com.google.common.io.Closeables;
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
@@ -45,26 +44,18 @@ import java.io.OutputStream;
 | 
			
		||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
 | 
			
		||||
import static sonia.scm.NotFoundException.notFound;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnCatCommand extends AbstractSvnCommand implements CatCommand {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * the logger for SvnCatCommand
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnCatCommand.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  SvnCatCommand(SvnContext context) {
 | 
			
		||||
    super(context);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public void getCatResult(CatCommandRequest request, OutputStream output) {
 | 
			
		||||
 
 | 
			
		||||
@@ -37,10 +37,7 @@ import sonia.scm.repository.SvnUtil;
 | 
			
		||||
import java.io.Closeable;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnContext implements Closeable, RepositoryProvider {
 | 
			
		||||
 | 
			
		||||
  private static final Logger LOG = LoggerFactory.getLogger(SvnContext.class);
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Preconditions;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
@@ -42,17 +41,10 @@ import sonia.scm.repository.api.DiffCommandBuilder;
 | 
			
		||||
import sonia.scm.repository.api.DiffFormat;
 | 
			
		||||
import sonia.scm.util.Util;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnDiffCommand extends AbstractSvnCommand implements DiffCommand {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * the logger for SvnDiffCommand
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnDiffCommand.class);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,68 +24,40 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import sonia.scm.repository.api.HookFeature;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.util.EnumSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnHookContextProvider extends HookContextProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final Set<HookFeature> SUPPORTED_FEATURES =
 | 
			
		||||
    EnumSet.of(HookFeature.CHANGESET_PROVIDER);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param changesetProvider
 | 
			
		||||
   */
 | 
			
		||||
  private AbstractSvnHookChangesetProvider changesetProvider;
 | 
			
		||||
 
 | 
			
		||||
  public SvnHookContextProvider(
 | 
			
		||||
    AbstractSvnHookChangesetProvider changesetProvider)
 | 
			
		||||
  {
 | 
			
		||||
    this.changesetProvider = changesetProvider;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public AbstractSvnHookChangesetProvider getChangesetProvider()
 | 
			
		||||
  {
 | 
			
		||||
    return changesetProvider;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public Set<HookFeature> getSupportedFeatures()
 | 
			
		||||
  {
 | 
			
		||||
    return SUPPORTED_FEATURES;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private AbstractSvnHookChangesetProvider changesetProvider;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
@@ -40,61 +39,39 @@ import sonia.scm.repository.RepositoryHookType;
 | 
			
		||||
import sonia.scm.repository.SvnUtil;
 | 
			
		||||
import sonia.scm.util.Util;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnPostReceiveHookChangesetProvier
 | 
			
		||||
  extends AbstractSvnHookChangesetProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** the logger for SvnPostReceiveHookChangesetProvier */
 | 
			
		||||
  
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnPostReceiveHookChangesetProvier.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private File repositoryDirectory;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repositoryDirectory
 | 
			
		||||
   * @param revision
 | 
			
		||||
   */
 | 
			
		||||
  private long revision;
 | 
			
		||||
 
 | 
			
		||||
  public SvnPostReceiveHookChangesetProvier(File repositoryDirectory, long revision)
 | 
			
		||||
  {
 | 
			
		||||
    this.repositoryDirectory = repositoryDirectory;
 | 
			
		||||
    this.revision = revision;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public RepositoryHookType getType()
 | 
			
		||||
  {
 | 
			
		||||
    return RepositoryHookType.POST_RECEIVE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  @SuppressWarnings("unchecked")
 | 
			
		||||
  protected Changeset fetchChangeset()
 | 
			
		||||
@@ -132,11 +109,4 @@ public class SvnPostReceiveHookChangesetProvier
 | 
			
		||||
    return changeset;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private File repositoryDirectory;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private long revision;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.repository.spi;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
@@ -39,29 +38,17 @@ import sonia.scm.repository.SvnUtil;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
public class SvnPreReceiveHookChangesetProvier
 | 
			
		||||
  extends AbstractSvnHookChangesetProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** the logger for SvnPreReceiveHookChangesetProvier */
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnPreReceiveHookChangesetProvier.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private File repositoryDirectory;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param repositoryDirectory
 | 
			
		||||
   * @param transaction
 | 
			
		||||
   */
 | 
			
		||||
  private String transaction;
 | 
			
		||||
 
 | 
			
		||||
  public SvnPreReceiveHookChangesetProvier(File repositoryDirectory,
 | 
			
		||||
    String transaction)
 | 
			
		||||
  {
 | 
			
		||||
@@ -69,28 +56,16 @@ public class SvnPreReceiveHookChangesetProvier
 | 
			
		||||
    this.transaction = transaction;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public RepositoryHookType getType()
 | 
			
		||||
  {
 | 
			
		||||
    return RepositoryHookType.PRE_RECEIVE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  protected Changeset fetchChangeset()
 | 
			
		||||
  {
 | 
			
		||||
@@ -130,11 +105,4 @@ public class SvnPreReceiveHookChangesetProvier
 | 
			
		||||
    return changeset;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private File repositoryDirectory;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private String transaction;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,9 +39,7 @@ import java.io.IOException;
 | 
			
		||||
import java.util.EnumSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnRepositoryServiceProvider extends RepositoryServiceProvider {
 | 
			
		||||
 | 
			
		||||
  public static final Set<Command> COMMANDS = ImmutableSet.of(
 | 
			
		||||
 
 | 
			
		||||
@@ -49,9 +49,7 @@ import java.io.IOException;
 | 
			
		||||
import java.io.StringWriter;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnCollectionRenderer implements CollectionRenderer {
 | 
			
		||||
 | 
			
		||||
  private final TemplateEngineFactory templateEngineFactory;
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.web;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import org.tmatesoft.svn.core.internal.server.dav.CollectionRenderer;
 | 
			
		||||
import org.tmatesoft.svn.core.internal.server.dav.DAVConfig;
 | 
			
		||||
@@ -34,14 +33,9 @@ import sonia.scm.repository.Repository;
 | 
			
		||||
import sonia.scm.repository.RepositoryProvider;
 | 
			
		||||
import sonia.scm.repository.SvnRepositoryHandler;
 | 
			
		||||
 | 
			
		||||
//~--- JDK imports ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnDAVConfig extends DAVConfig
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@@ -64,50 +58,29 @@ public class SvnDAVConfig extends DAVConfig
 | 
			
		||||
    this.repositoryProvider = repositoryProvider;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public String getActivitiesDBPath()
 | 
			
		||||
  {
 | 
			
		||||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public CollectionRenderer getCollectionRenderer()
 | 
			
		||||
  {
 | 
			
		||||
    return collectionRenderer;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public String getRepositoryName()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.getRepositoryName();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public String getRepositoryParentPath()
 | 
			
		||||
  {
 | 
			
		||||
@@ -126,12 +99,7 @@ public class SvnDAVConfig extends DAVConfig
 | 
			
		||||
    return path;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public String getRepositoryPath()
 | 
			
		||||
  {
 | 
			
		||||
@@ -150,132 +118,77 @@ public class SvnDAVConfig extends DAVConfig
 | 
			
		||||
    return path;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public SVNPathBasedAccess getSVNAccess()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.getSVNAccess();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public String getXSLTIndex()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.getXSLTIndex();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isAllowBulkUpdates()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isAllowBulkUpdates();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isAllowDepthInfinity()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isAllowDepthInfinity();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isAnonymousAllowed()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isAnonymousAllowed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isAutoVersioning()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isAutoVersioning();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isListParentPath()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isListParentPath();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isNoAuthIfAnonymousAllowed()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isNoAuthIfAnonymousAllowed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isUsingPBA()
 | 
			
		||||
  {
 | 
			
		||||
    return davConfig.isUsingPBA();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isUsingRepositoryPathDirective()
 | 
			
		||||
  {
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  private File getRepositoryDirectory()
 | 
			
		||||
  {
 | 
			
		||||
    File directory = null;
 | 
			
		||||
@@ -291,15 +204,11 @@ public class SvnDAVConfig extends DAVConfig
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final CollectionRenderer collectionRenderer;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final DAVConfig davConfig;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final SvnRepositoryHandler handler;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final RepositoryProvider repositoryProvider;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -44,35 +44,27 @@ import sonia.scm.util.HttpUtil;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Singleton
 | 
			
		||||
public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final String HEADER_CONTEXTPATH = "X-Forwarded-Ctx";
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final long serialVersionUID = -1462257085465785945L;
 | 
			
		||||
 | 
			
		||||
  /** the logger for SvnDAVServlet */
 | 
			
		||||
  
 | 
			
		||||
  private static final Logger logger =
 | 
			
		||||
    LoggerFactory.getLogger(SvnDAVServlet.class);
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
  private final SvnCollectionRenderer collectionRenderer;
 | 
			
		||||
 | 
			
		||||
  private final SvnRepositoryHandler handler;
 | 
			
		||||
 | 
			
		||||
  private final RepositoryProvider repositoryProvider;
 | 
			
		||||
 | 
			
		||||
  private final RepositoryRequestListenerUtil repositoryRequestListenerUtil;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param handler
 | 
			
		||||
   * @param collectionRenderer
 | 
			
		||||
   * @param repositoryProvider
 | 
			
		||||
   * @param repositoryRequestListenerUtil
 | 
			
		||||
   */
 | 
			
		||||
  @Inject
 | 
			
		||||
  public SvnDAVServlet(SvnRepositoryHandler handler,
 | 
			
		||||
    SvnCollectionRenderer collectionRenderer,
 | 
			
		||||
@@ -85,18 +77,7 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
    this.repositoryRequestListenerUtil = repositoryRequestListenerUtil;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   * @param response
 | 
			
		||||
   *
 | 
			
		||||
   * @throws IOException
 | 
			
		||||
   * @throws ServletException
 | 
			
		||||
   */
 | 
			
		||||
  @Override
 | 
			
		||||
  public void service(HttpServletRequest request, HttpServletResponse response, Repository repository)
 | 
			
		||||
    throws ServletException, IOException
 | 
			
		||||
@@ -113,14 +94,8 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  protected DAVConfig getDAVConfig()
 | 
			
		||||
  {
 | 
			
		||||
@@ -128,18 +103,13 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      repositoryProvider);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- inner classes --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Class description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @version        Enter version here..., 11/10/23
 | 
			
		||||
   * @author         Enter your name here...
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  private static class SvnHttpServletRequestWrapper
 | 
			
		||||
    extends HttpServletRequestWrapper
 | 
			
		||||
  {
 | 
			
		||||
    private final Repository repository;
 | 
			
		||||
 | 
			
		||||
    public SvnHttpServletRequestWrapper(HttpServletRequest request,
 | 
			
		||||
      Repository repository)
 | 
			
		||||
@@ -148,14 +118,7 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      this.repository = repository;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //~--- get methods --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Method description
 | 
			
		||||
     *
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
  
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getContextPath()
 | 
			
		||||
    {
 | 
			
		||||
@@ -169,12 +132,7 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      return header;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Method description
 | 
			
		||||
     *
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
  
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getPathInfo()
 | 
			
		||||
    {
 | 
			
		||||
@@ -195,12 +153,7 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      return pathInfo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Method description
 | 
			
		||||
     *
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
  
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getServletPath()
 | 
			
		||||
    {
 | 
			
		||||
@@ -219,14 +172,7 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      return servletPath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Method description
 | 
			
		||||
     *
 | 
			
		||||
     *
 | 
			
		||||
     * @param ctx
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    
 | 
			
		||||
    private boolean isValidContextPath(String ctx)
 | 
			
		||||
    {
 | 
			
		||||
      int length = ctx.length();
 | 
			
		||||
@@ -245,23 +191,6 @@ public class SvnDAVServlet extends DAVServlet implements ScmProviderHttpServlet
 | 
			
		||||
      return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //~--- fields -------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
    /** Field description */
 | 
			
		||||
    private final Repository repository;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- fields ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final SvnCollectionRenderer collectionRenderer;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final SvnRepositoryHandler handler;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final RepositoryProvider repositoryProvider;
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private final RepositoryRequestListenerUtil repositoryRequestListenerUtil;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,41 +37,23 @@ import sonia.scm.web.filter.PermissionFilter;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class SvnPermissionFilter extends PermissionFilter
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /** Field description */
 | 
			
		||||
  private static final Set<String> WRITEMETHOD_SET =
 | 
			
		||||
    ImmutableSet.of("MKACTIVITY", "PROPPATCH", "PUT", "CHECKOUT", "MKCOL",
 | 
			
		||||
      "MOVE", "COPY", "DELETE", "LOCK", "UNLOCK", "MERGE");
 | 
			
		||||
 | 
			
		||||
  //~--- constructors ---------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Constructs ...
 | 
			
		||||
   *
 | 
			
		||||
   * @param configuration
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  public SvnPermissionFilter(ScmConfiguration configuration, ScmProviderHttpServlet delegate)
 | 
			
		||||
  {
 | 
			
		||||
    super(configuration, delegate);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   * @param response
 | 
			
		||||
   *
 | 
			
		||||
   * @throws IOException
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  protected void sendNotEnoughPrivilegesError(HttpServletRequest request,
 | 
			
		||||
    HttpServletResponse response)
 | 
			
		||||
@@ -96,16 +78,8 @@ public class SvnPermissionFilter extends PermissionFilter
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //~--- get methods ----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param request
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isWriteRequest(HttpServletRequest request)
 | 
			
		||||
  {
 | 
			
		||||
 
 | 
			
		||||
@@ -32,10 +32,7 @@ import sonia.scm.plugin.Extension;
 | 
			
		||||
import sonia.scm.repository.SvnWorkingCopyFactory;
 | 
			
		||||
import sonia.scm.repository.spi.SimpleSvnWorkingCopyFactory;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @author Sebastian Sdorra
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Extension
 | 
			
		||||
public class SvnServletModule extends ServletModule {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@
 | 
			
		||||
    
 | 
			
		||||
package sonia.scm.web;
 | 
			
		||||
 | 
			
		||||
//~--- non-JDK imports --------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
import com.google.common.annotations.VisibleForTesting;
 | 
			
		||||
import com.google.common.base.Charsets;
 | 
			
		||||
@@ -57,16 +56,8 @@ public final class SvnUserAgentProvider implements UserAgentProvider
 | 
			
		||||
    UserAgent.scmClient("Subversion")
 | 
			
		||||
             .basicAuthenticationCharset(Charsets.UTF_8).build();
 | 
			
		||||
 | 
			
		||||
  //~--- methods --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Method description
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param userAgentString
 | 
			
		||||
   *
 | 
			
		||||
   * @return
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public UserAgent parseUserAgent(String userAgentString)
 | 
			
		||||
  {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user