added isSupported method for repository features to RepositoryService

This commit is contained in:
Sebastian Sdorra
2012-12-16 19:36:47 +01:00
parent 9b67423203
commit 739318699b
4 changed files with 50 additions and 13 deletions

View File

@@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Feature;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.spi.RepositoryServiceProvider;
@@ -295,6 +296,19 @@ public final class RepositoryService implements Closeable
return provider.getSupportedCommands().contains(command);
}
/**
* Returns true if the feature is supported by the repository service.
*
*
* @param feature feature
*
* @return true if the feature is supported
*/
public boolean isSupported(Feature feature)
{
return provider.getSupportedFeatures().contains(feature);
}
//~--- fields ---------------------------------------------------------------
/** cache manager */

View File

@@ -35,6 +35,7 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Feature;
import sonia.scm.repository.api.Command;
import sonia.scm.repository.api.CommandNotSupportedException;
@@ -43,6 +44,7 @@ import sonia.scm.repository.api.CommandNotSupportedException;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
/**
@@ -146,6 +148,17 @@ public abstract class RepositoryServiceProvider implements Closeable
throw new CommandNotSupportedException(Command.LOG);
}
/**
* Method description
*
*
* @return
*/
public Set<Feature> getSupportedFeatures()
{
return Collections.EMPTY_SET;
}
/**
* Method description
*

View File

@@ -72,9 +72,6 @@ import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.EnumSet;
import java.util.Set;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -101,15 +98,11 @@ public class HgRepositoryHandler
/** Field description */
public static final String TYPE_NAME = "hg";
/** Field description */
private static final Set<Feature> SUPPORTED_FEATURES =
EnumSet.of(Feature.COMBINED_DEFAULT_BRANCH);
/** Field description */
public static final Type TYPE = new RepositoryType(TYPE_NAME,
TYPE_DISPLAYNAME,
HgRepositoryServiceProvider.COMMANDS,
SUPPORTED_FEATURES);
HgRepositoryServiceProvider.FEATURES);
/** the logger for HgRepositoryHandler */
private static final Logger logger =

View File

@@ -39,6 +39,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.io.Closeables;
import com.google.inject.Provider;
import sonia.scm.repository.Feature;
import sonia.scm.repository.HgContext;
import sonia.scm.repository.HgRepositoryHandler;
import sonia.scm.repository.Repository;
@@ -49,6 +50,7 @@ import sonia.scm.repository.api.Command;
import java.io.File;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;
/**
@@ -59,11 +61,14 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
{
/** Field description */
public static final Set<Command> COMMANDS = ImmutableSet.of(Command.BLAME,
public static final Set<Command> COMMANDS = EnumSet.of(Command.BLAME,
Command.BROWSE, Command.CAT,
Command.DIFF, Command.LOG,
Command.TAGS,
Command.BRANCHES);
Command.TAGS, Command.BRANCHES);
/** Field description */
public static final Set<Feature> FEATURES =
EnumSet.of(Feature.COMBINED_DEFAULT_BRANCH);
//~--- constructors ---------------------------------------------------------
@@ -187,6 +192,18 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
return COMMANDS;
}
/**
* Method description
*
*
* @return
*/
@Override
public Set<Feature> getSupportedFeatures()
{
return FEATURES;
}
/**
* Method description
*