From f14e3ec7420c57246b585ab6f35b3ff7bea35108 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 5 Jul 2012 18:58:12 +0200 Subject: [PATCH] added tags command to repository api --- .../main/java/sonia/scm/repository/Tag.java | 163 +++++++++++ .../main/java/sonia/scm/repository/Tags.java | 232 ++++++++++++++++ .../sonia/scm/repository/api/Command.java | 7 +- .../scm/repository/api/RepositoryService.java | 39 ++- .../api/RepositoryServiceFactory.java | 48 ++-- .../repository/api/TagsCommandBuilder.java | 254 ++++++++++++++++++ .../spi/RepositoryServiceProvider.java | 11 + .../sonia/scm/repository/spi/TagsCommand.java | 56 ++++ .../src/main/resources/config/ehcache.xml | 9 + 9 files changed, 786 insertions(+), 33 deletions(-) create mode 100644 scm-core/src/main/java/sonia/scm/repository/Tag.java create mode 100644 scm-core/src/main/java/sonia/scm/repository/Tags.java create mode 100644 scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java create mode 100644 scm-core/src/main/java/sonia/scm/repository/spi/TagsCommand.java diff --git a/scm-core/src/main/java/sonia/scm/repository/Tag.java b/scm-core/src/main/java/sonia/scm/repository/Tag.java new file mode 100644 index 0000000000..3f8945a5f2 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/Tag.java @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.base.Objects; + +//~--- JDK imports ------------------------------------------------------------ + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a tag in repository. + * + * @author Sebastian Sdorra + * @since 1.18 + */ +@XmlRootElement(name = "tag") +@XmlAccessorType(XmlAccessType.FIELD) +public final class Tag +{ + + /** + * Constructs ... + * + */ + public Tag() {} + + /** + * Constructs a new tag. + * + * + * @param name name of the tag + * @param revision tagged revision + */ + public Tag(String name, String revision) + { + this.name = name; + this.revision = revision; + } + + //~--- methods -------------------------------------------------------------- + + /** + * {@inheritDoc} + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final Tag other = (Tag) obj; + + return Objects.equal(name, other.name) + && Objects.equal(revision, other.revision); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public int hashCode() + { + return Objects.hashCode(name, revision); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public String toString() + { + //J- + return Objects.toStringHelper(this) + .add("name", name) + .add("revision", revision) + .toString(); + //J+ + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Returns the name of the tag. + * + * + * @return name of the tag + */ + public String getName() + { + return name; + } + + /** + * Id of the tagged revision. + * + * + * @return tagged revision id + */ + public String getRevision() + { + return revision; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String name; + + /** Field description */ + private String revision; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/Tags.java b/scm-core/src/main/java/sonia/scm/repository/Tags.java new file mode 100644 index 0000000000..0a8ac5ffd8 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/Tags.java @@ -0,0 +1,232 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.base.Objects; +import com.google.common.collect.Lists; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.Iterator; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents all tags of a repository. + * + * @author Sebastian Sdorra + * @since 1.18 + */ +@XmlRootElement(name = "tags") +@XmlAccessorType(XmlAccessType.FIELD) +public final class Tags implements Iterable +{ + + /** + * Constructs a new instance of tags. + * This constructor should only be called from JAXB. + * + */ + public Tags() {} + + /** + * Constructs a new instance of tags. + * + * + * @param tags list of tags. + */ + public Tags(List tags) + { + this.tags = tags; + } + + //~--- methods -------------------------------------------------------------- + + /** + * {@inheritDoc} + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final Tags other = (Tags) obj; + + return Objects.equal(tags, other.tags); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public int hashCode() + { + return Objects.hashCode(tags); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public Iterator iterator() + { + return getTags().iterator(); + } + + /** + * {@inheritDoc} + * + * + * @return + */ + @Override + public String toString() + { + //J- + return Objects.toStringHelper(this) + .add("tags", tags) + .toString(); + //J+ + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Returns the {@link Tag} with the given name or null. + * + * + * @param name name of the tag + * + * @return {@link Tag} with the given name or null + */ + public Tag getTagByName(String name) + { + Tag tag = null; + + for (Tag t : getTags()) + { + if (name.equals(t.getName())) + { + tag = t; + + break; + } + } + + return tag; + } + + /** + * Returns the {@link Tag} with the given revision or null. + * + * + * @param revision revision of the tag + * + * @return {@link Tag} with the given revision or null + */ + public Tag getTagByRevision(String revision) + { + Tag tag = null; + + for (Tag t : getTags()) + { + if (revision.equals(t.getRevision())) + { + tag = t; + + break; + } + } + + return tag; + } + + /** + * Returns all tags of a repository. + * + * + * @return all tags + */ + public List getTags() + { + if (tags == null) + { + tags = Lists.newArrayList(); + } + + return tags; + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Sets all tags. + * + * + * @param tags tags + */ + public void setTags(List tags) + { + this.tags = tags; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + @XmlElement(name = "tag") + private List tags; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/api/Command.java b/scm-core/src/main/java/sonia/scm/repository/api/Command.java index 5caba59440..a2063a0cae 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/Command.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/Command.java @@ -41,5 +41,10 @@ package sonia.scm.repository.api; */ public enum Command { - LOG, BROWSE, CAT, DIFF, BLAME + LOG, BROWSE, CAT, DIFF, BLAME, + + /** + * @since 1.18 + */ + TAGS } diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java index 8c77eb83f8..9d243784db 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java @@ -96,8 +96,8 @@ public final class RepositoryService implements Closeable * @param preProcessorUtil */ RepositoryService(CacheManager cacheManager, - RepositoryServiceProvider provider, Repository repository, - PreProcessorUtil preProcessorUtil) + RepositoryServiceProvider provider, Repository repository, + PreProcessorUtil preProcessorUtil) { this.cacheManager = cacheManager; this.provider = provider; @@ -150,11 +150,11 @@ public final class RepositoryService implements Closeable if (logger.isDebugEnabled()) { logger.debug("create blame command for repository {}", - repository.getName()); + repository.getName()); } return new BlameCommandBuilder(cacheManager, provider.getBlameCommand(), - repository, preProcessorUtil); + repository, preProcessorUtil); } /** @@ -169,11 +169,11 @@ public final class RepositoryService implements Closeable if (logger.isDebugEnabled()) { logger.debug("create browse command for repository {}", - repository.getName()); + repository.getName()); } return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(), - repository, preProcessorUtil); + repository, preProcessorUtil); } /** @@ -188,7 +188,7 @@ public final class RepositoryService implements Closeable if (logger.isDebugEnabled()) { logger.debug("create cat command for repository {}", - repository.getName()); + repository.getName()); } return new CatCommandBuilder(provider.getCatCommand()); @@ -207,7 +207,7 @@ public final class RepositoryService implements Closeable if (logger.isDebugEnabled()) { logger.debug("create diff command for repository {}", - repository.getName()); + repository.getName()); } return new DiffCommandBuilder(provider.getDiffCommand()); @@ -225,11 +225,11 @@ public final class RepositoryService implements Closeable if (logger.isDebugEnabled()) { logger.debug("create log command for repository {}", - repository.getName()); + repository.getName()); } return new LogCommandBuilder(cacheManager, provider.getLogCommand(), - repository, preProcessorUtil); + repository, preProcessorUtil); } /** @@ -242,6 +242,25 @@ public final class RepositoryService implements Closeable return repository; } + /** + * The tags command list all repository tag. + * + * @return instance of {@link TagsCommandBuilder} + * @throws CommandNotSupportedException if the command is not supported + * by the implementation of the repository service provider. + */ + public TagsCommandBuilder getTagsCommand() + { + if (logger.isDebugEnabled()) + { + logger.debug("create tags command for repository {}", + repository.getName()); + } + + return new TagsCommandBuilder(cacheManager, provider.getTagsCommand(), + repository); + } + /** * Returns true if the command is supported by the repository service. * diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java index 0b42f0820b..b30dbd5794 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java @@ -60,6 +60,7 @@ import sonia.scm.repository.RepositoryHookEvent; import sonia.scm.repository.RepositoryListener; import sonia.scm.repository.RepositoryManager; import sonia.scm.repository.RepositoryNotFoundException; +import sonia.scm.repository.Tags; import sonia.scm.repository.spi.RepositoryServiceProvider; import sonia.scm.repository.spi.RepositoryServiceResolver; import sonia.scm.security.ScmSecurityException; @@ -106,7 +107,7 @@ import java.util.Set; * * @author Sebastian Sdorra * @since 1.17 - * + * * @apiviz.landmark * @apiviz.uses sonia.scm.repository.api.RepositoryService */ @@ -134,11 +135,10 @@ public final class RepositoryServiceFactory * @param preProcessorUtil helper object for pre processor handling */ @Inject - public RepositoryServiceFactory( - CacheManager cacheManager, RepositoryManager repositoryManager, - Provider securityContextProvider, - Set resolvers, - PreProcessorUtil preProcessorUtil) + public RepositoryServiceFactory(CacheManager cacheManager, + RepositoryManager repositoryManager, + Provider securityContextProvider, + Set resolvers, PreProcessorUtil preProcessorUtil) { this.cacheManager = cacheManager; this.repositoryManager = repositoryManager; @@ -172,17 +172,17 @@ public final class RepositoryServiceFactory * for that repository */ public RepositoryService create(String repositoryId) - throws RepositoryNotFoundException + throws RepositoryNotFoundException { Preconditions.checkArgument(!Strings.isNullOrEmpty(repositoryId), - "a non empty repositoryId is required"); + "a non empty repositoryId is required"); Repository repository = repositoryManager.get(repositoryId); if (repository == null) { throw new RepositoryNotFoundException( - "could not find a repository with id ".concat(repositoryId)); + "could not find a repository with id ".concat(repositoryId)); } return create(repository); @@ -207,12 +207,12 @@ public final class RepositoryServiceFactory * for that repository */ public RepositoryService create(String type, String name) - throws RepositoryNotFoundException + throws RepositoryNotFoundException { Preconditions.checkArgument(!Strings.isNullOrEmpty(type), - "a non empty type is required"); + "a non empty type is required"); Preconditions.checkArgument(!Strings.isNullOrEmpty(name), - "a non empty name is required"); + "a non empty name is required"); Repository repository = repositoryManager.get(type, name); @@ -250,7 +250,7 @@ public final class RepositoryServiceFactory // check for read permissions of current user PermissionUtil.assertPermission(repository, securityContextProvider, - PermissionType.READ); + PermissionType.READ); RepositoryService service = null; @@ -263,12 +263,12 @@ public final class RepositoryServiceFactory if (logger.isDebugEnabled()) { logger.debug( - "create new repository service for repository {} of type {}", - repository.getName(), repository.getType()); + "create new repository service for repository {} of type {}", + repository.getName(), repository.getType()); } service = new RepositoryService(cacheManager, provider, repository, - preProcessorUtil); + preProcessorUtil); break; } @@ -292,7 +292,7 @@ public final class RepositoryServiceFactory * @author Enter your name here... */ private static class CacheClearHook extends PostReceiveRepositoryHook - implements RepositoryListener + implements RepositoryListener { /** @@ -305,14 +305,14 @@ public final class RepositoryServiceFactory { this.blameCache = cacheManager.getCache(BlameCommandBuilder.CacheKey.class, - BlameResult.class, - BlameCommandBuilder.CACHE_NAME); + BlameResult.class, BlameCommandBuilder.CACHE_NAME); this.browseCache = cacheManager.getCache(BrowseCommandBuilder.CacheKey.class, - BrowserResult.class, - BrowseCommandBuilder.CACHE_NAME); + BrowserResult.class, BrowseCommandBuilder.CACHE_NAME); this.logCache = cacheManager.getCache(LogCommandBuilder.CacheKey.class, - ChangesetPagingResult.class, LogCommandBuilder.CACHE_NAME); + ChangesetPagingResult.class, LogCommandBuilder.CACHE_NAME); + this.tagsCache = cacheManager.getCache(TagsCommandBuilder.CacheKey.class, + Tags.class, TagsCommandBuilder.CACHE_NAME); } //~--- methods ------------------------------------------------------------ @@ -372,6 +372,7 @@ public final class RepositoryServiceFactory blameCache.removeAll(filter); browseCache.removeAll(filter); logCache.removeAll(filter); + tagsCache.removeAll(filter); } //~--- fields ------------------------------------------------------------- @@ -384,6 +385,9 @@ public final class RepositoryServiceFactory /** Field description */ private Cache logCache; + + /** Field description */ + private Cache tagsCache; } diff --git a/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java new file mode 100644 index 0000000000..2751bd4bdb --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java @@ -0,0 +1,254 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.api; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.base.Objects; + +import sonia.scm.cache.Cache; +import sonia.scm.cache.CacheManager; +import sonia.scm.repository.Repository; +import sonia.scm.repository.RepositoryCacheKey; +import sonia.scm.repository.Tag; +import sonia.scm.repository.Tags; +import sonia.scm.repository.spi.TagsCommand; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.List; + +/** + * The tags command list all repository tag.
+ *
+ * Samples: + *
+ *
+ * Return all tags of a repository:
+ *

+ * TagsCommandBuilder tagsCommand = repositoryService.getLogCommand();
+ * Tags tags = tagsCommand.getTags();
+ * 
+ * @author Sebastian Sdorra + */ +public final class TagsCommandBuilder +{ + + /** name of the cache */ + static final String CACHE_NAME = "sonia.cache.cmd.tags"; + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs a new {@link TagsCommandBuilder}, this constructor should + * only be called from the {@link RepositoryService}. + * + * @param cacheManager cache manager + * @param logCommand implementation of the {@link TagsCommand} + * @param repository repository + */ + TagsCommandBuilder(CacheManager cacheManager, TagsCommand command, + Repository repository) + { + this.cache = cacheManager.getCache(CacheKey.class, Tags.class, CACHE_NAME); + this.command = command; + this.repository = repository; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Returns all tags from the repository. + * + * + * @return tags from the repository + */ + public Tags getTags() + { + Tags tags = null; + + if (disableCache) + { + tags = getTagsFromCommand(); + } + else + { + CacheKey key = new CacheKey(repository); + + tags = cache.get(key); + + if (tags == null) + { + tags = getTagsFromCommand(); + + if (tags != null) + { + cache.put(key, tags); + } + } + } + + return tags; + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Disables the cache for tags. This means that every {@link Tag} + * is directly retrieved from the {@link Repository}. Note: Disabling + * the cache cost a lot of performance and could be much more slower. + * + * + * @param disableCache true to disable the cache + * + * @return {@code this} + */ + public TagsCommandBuilder setDisableCache(boolean disableCache) + { + this.disableCache = disableCache; + + return this; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + private Tags getTagsFromCommand() + { + List tagList = command.getTags(); + + return new Tags(tagList); + } + + //~--- inner classes -------------------------------------------------------- + + /** + * Class description + * + * + * @version Enter version here..., 12/07/05 + * @author Enter your name here... + */ + static class CacheKey implements RepositoryCacheKey + { + + /** + * Constructs ... + * + * + * @param repository + */ + public CacheKey(Repository repository) + { + this.repositoryId = repository.getId(); + } + + //~--- methods ------------------------------------------------------------ + + /** + * Method description + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final CacheKey other = (CacheKey) obj; + + return Objects.equal(repositoryId, other.repositoryId); + } + + /** + * Method description + * + * + * @return + */ + @Override + public int hashCode() + { + return Objects.hashCode(repositoryId); + } + + //~--- get methods -------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + @Override + public String getRepositoryId() + { + return repositoryId; + } + + //~--- fields ------------------------------------------------------------- + + /** Field description */ + private String repositoryId; + } + + + //~--- fields --------------------------------------------------------------- + + /** cache for changesets */ + private Cache cache; + + /** Field description */ + private TagsCommand command; + + /** Field description */ + private boolean disableCache = false; + + /** Field description */ + private Repository repository; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java index 8fbc820d04..1ac925c706 100644 --- a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java +++ b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java @@ -134,4 +134,15 @@ public abstract class RepositoryServiceProvider implements Closeable { throw new CommandNotSupportedException(Command.LOG); } + + /** + * Method description + * + * + * @return + */ + public TagsCommand getTagsCommand() + { + throw new CommandNotSupportedException(Command.TAGS); + } } diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/TagsCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/TagsCommand.java new file mode 100644 index 0000000000..935dfae0ad --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/spi/TagsCommand.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.spi; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.repository.Tag; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public interface TagsCommand +{ + + /** + * Method description + * + * + * @return + */ + public List getTags(); +} diff --git a/scm-webapp/src/main/resources/config/ehcache.xml b/scm-webapp/src/main/resources/config/ehcache.xml index beb3b7f862..ec479431b3 100644 --- a/scm-webapp/src/main/resources/config/ehcache.xml +++ b/scm-webapp/src/main/resources/config/ehcache.xml @@ -193,4 +193,13 @@ copyOnRead="true" /> + +