diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java index 5a6b70857b..b7b8282755 100644 --- a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java +++ b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java @@ -211,6 +211,21 @@ public abstract class AbstractRepositoryHandler +{ + + /** + * Method description + * + * + * @return + */ + @Override + public Iterator iterator() + { + Iterator iterator = null; + + if (children != null) + { + iterator = children.iterator(); + } + + return iterator; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public List getChildren() + { + return children; + } + + /** + * Method description + * + * + * @return + */ + @Override + public Long getLastModified() + { + return lastModified; + } + + /** + * Method description + * + * + * @return + */ + public long getLength() + { + return length; + } + + /** + * Method description + * + * + * @return + */ + public String getName() + { + return name; + } + + /** + * Method description + * + * + * @return + */ + public String getPath() + { + return path; + } + + /** + * Method description + * + * + * @return + */ + public boolean isDirectory() + { + return directory; + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @param children + */ + public void setChildren(List children) + { + this.children = children; + } + + /** + * Method description + * + * + * @param directory + */ + public void setDirectory(boolean directory) + { + this.directory = directory; + } + + /** + * Method description + * + * + * @param lastModified + */ + public void setLastModified(Long lastModified) + { + this.lastModified = lastModified; + } + + /** + * Method description + * + * + * @param length + */ + public void setLength(long length) + { + this.length = length; + } + + /** + * Method description + * + * + * @param name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * Method description + * + * + * @param path + */ + public void setPath(String path) + { + this.path = path; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private List children; + + /** Field description */ + private boolean directory; + + /** Field description */ + private Long lastModified; + + /** Field description */ + private long length; + + /** Field description */ + private String name; + + /** Field description */ + private String path; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowser.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowser.java new file mode 100644 index 0000000000..d103f12b1a --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowser.java @@ -0,0 +1,65 @@ +/** + * 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; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.IOException; + +/** + * + * @author Sebastian Sdorra + * @since 1.5 + */ +public interface RepositoryBrowser +{ + + /** + * Method description + * + * + * @param revision + * @param tag + * @param branch + * @param path + * + * @return + * + * @throws IOException + * @throws RepositoryException + */ + public BrowserResult getResult(String revision, String tag, String branch, + String path) + throws IOException, RepositoryException; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowserProvider.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowserProvider.java new file mode 100644 index 0000000000..b87d3481d0 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryBrowserProvider.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; + +/** + * + * @author Sebastian Sdorra + * @since 1.5 + */ +public interface RepositoryBrowserProvider +{ + + /** + * Method description + * + * + * @param repository + * + * @return null if RepositoryBrowser is not supported + * + * @throws RepositoryException + */ + public RepositoryBrowser getRepositoryBrowser(Repository repository) + throws RepositoryException; +} diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java index e92bdd9acf..c9142d3b7e 100644 --- a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java +++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java @@ -47,7 +47,8 @@ import sonia.scm.plugin.ExtensionPoint; @ExtensionPoint public interface RepositoryHandler extends Handler, - ListenerSupport + ListenerSupport, + RepositoryBrowserProvider { /** diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java index ee0621b7b7..9a81c26be6 100644 --- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java +++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java @@ -49,7 +49,7 @@ import java.util.Collection; */ public interface RepositoryManager extends TypeManager, - ListenerSupport + ListenerSupport, RepositoryBrowserProvider { /** diff --git a/scm-webapp/src/main/java/sonia/scm/repository/xml/XmlRepositoryManager.java b/scm-webapp/src/main/java/sonia/scm/repository/xml/XmlRepositoryManager.java index 8df01ea38a..888eed97f8 100644 --- a/scm-webapp/src/main/java/sonia/scm/repository/xml/XmlRepositoryManager.java +++ b/scm-webapp/src/main/java/sonia/scm/repository/xml/XmlRepositoryManager.java @@ -52,6 +52,7 @@ import sonia.scm.repository.PermissionType; import sonia.scm.repository.PermissionUtil; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryAllreadyExistExeption; +import sonia.scm.repository.RepositoryBrowser; import sonia.scm.repository.RepositoryException; import sonia.scm.repository.RepositoryHandler; import sonia.scm.repository.RepositoryHandlerNotFoundException; @@ -525,6 +526,26 @@ public class XmlRepositoryManager extends AbstractRepositoryManager return repositoryDB.getLastModified(); } + /** + * Method description + * + * + * @param repository + * + * @return + * + * @throws RepositoryException + */ + @Override + public RepositoryBrowser getRepositoryBrowser(Repository repository) + throws RepositoryException + { + AssertUtil.assertIsNotNull(repository); + isReader(repository); + + return getHandler(repository).getRepositoryBrowser(repository); + } + /** * Method description *