diff --git a/pom.xml b/pom.xml index 3c84ce2535..05e23d0831 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,6 @@ scm-dao-xml scm-webapp scm-server - scm-plugin-backend scm-clients diff --git a/scm-plugin-backend/pom.xml b/scm-plugin-backend/pom.xml deleted file mode 100644 index 08ce0b2493..0000000000 --- a/scm-plugin-backend/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - 4.0.0 - - - scm - sonia.scm - 2.0.0-SNAPSHOT - - - sonia.scm - scm-plugin-backend - war - 2.0.0-SNAPSHOT - ${project.artifactId} - - - - - javax.servlet - servlet-api - ${servlet.version} - provided - - - - - - javax.transaction - jta - 1.1 - provided - - - - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${slf4j.version} - - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.freemarker - freemarker - ${freemarker.version} - - - - sonia.scm - scm-core - 2.0.0-SNAPSHOT - - - - com.sun.jersey.contribs - jersey-guice - ${jersey.version} - - - - rome - rome - 1.0 - - - - net.sf.ehcache - ehcache-core - ${ehcache.version} - - - - org.imgscalr - imgscalr-lib - 4.2 - - - - - - org.apache.shiro - shiro-web - ${shiro.version} - - - - org.apache.shiro - shiro-guice - ${shiro.version} - - - - org.apache.shiro - shiro-ehcache - ${shiro.version} - - - - - - - - - - com.mycila.maven-license-plugin - maven-license-plugin - 1.9.0 - -
http://download.scm-manager.org/licenses/mvn-license.txt
- - src/** - **/test/** - - - target/** - .hg/** - **/html5.js - **/*.html - **/fancybox/** - - true -
-
- - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - 8004 - STOP - - /scm-plugin-backend - - 0 - - - -
- - scm-plugin-backend -
- - - 2.6.6 - - -
diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/AbstractPluginBackend.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/AbstractPluginBackend.java deleted file mode 100644 index 09ed16d380..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/AbstractPluginBackend.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * - * @author Sebastian Sdorra - */ -public abstract class AbstractPluginBackend implements PluginBackend -{ - - /** - * Method description - * - * - * @param listener - */ - public void addListener(PluginBackendListener listener) - { - listenerSet.add(listener); - } - - /** - * Method description - * - * - * @param listeners - */ - public void addListeners(Collection listeners) - { - listenerSet.addAll(listeners); - } - - /** - * Method description - * - * - * @param plugins - */ - @Override - public void addPlugins(PluginInformation... plugins) - { - if (Util.isNotEmpty(plugins)) - { - addPlugins(Arrays.asList(plugins)); - } - } - - /** - * Method description - * - * - * @param scannedFiles - */ - @Override - public void addScannedFiles(File... scannedFiles) - { - if (Util.isNotEmpty(scannedFiles)) - { - addScannedFiles(Arrays.asList(scannedFiles)); - } - } - - /** - * Method description - * - * - * @param listener - */ - public void removeListener(PluginBackendListener listener) - { - listenerSet.remove(listener); - } - - /** - * Method description - * - * - * - * @param plugins - */ - protected void fireEvent(Collection plugins) - { - for (PluginBackendListener listener : listenerSet) - { - listener.addedNewPlugins(plugins); - } - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Set listenerSet = - new HashSet(); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/AdminAccountConfiguration.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/AdminAccountConfiguration.java deleted file mode 100644 index 1b30b1228d..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/AdminAccountConfiguration.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Objects; - -import org.apache.shiro.authc.SaltedAuthenticationInfo; -import org.apache.shiro.codec.Base64; -import org.apache.shiro.subject.PrincipalCollection; -import org.apache.shiro.subject.SimplePrincipalCollection; -import org.apache.shiro.util.ByteSource; - -//~--- JDK imports ------------------------------------------------------------ - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @author Sebastian Sdorra - */ -@XmlRootElement(name = "admin-account") -@XmlAccessorType(XmlAccessType.FIELD) -public class AdminAccountConfiguration implements SaltedAuthenticationInfo -{ - - /** Field description */ - private static final long serialVersionUID = -8678832281151044462L; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - public AdminAccountConfiguration() {} - - /** - * Constructs ... - * - * - * @param username - * @param salt - * @param password - */ - public AdminAccountConfiguration(String username, String salt, - String password) - { - this.username = username; - this.salt = salt; - this.password = password; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final AdminAccountConfiguration other = (AdminAccountConfiguration) obj; - - return Objects.equal(username, other.username) - && Objects.equal(salt, other.salt) - && Objects.equal(password, other.password); - } - - /** - * Method description - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(username, salt, password); - } - - /** - * Method description - * - * - * @return - */ - @Override - public String toString() - { - //J- - return Objects.toStringHelper(this) - .add("username", username) - .add("salt", "xxx") - .add("password", "xxx") - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - public Object getCredentials() - { - return password; - } - - /** - * Method description - * - * - * @return - */ - @Override - public ByteSource getCredentialsSalt() - { - return ByteSource.Util.bytes(Base64.decode(salt)); - } - - /** - * Method description - * - * - * @return - */ - public String getPassword() - { - return password; - } - - /** - * Method description - * - * - * @return - */ - @Override - public PrincipalCollection getPrincipals() - { - - // TODO - return new SimplePrincipalCollection(username, "scm-backend"); - } - - /** - * Method description - * - * - * @return - */ - public String getSalt() - { - return salt; - } - - /** - * Method description - * - * - * @return - */ - public String getUsername() - { - return username; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private String password; - - /** Field description */ - private String salt; - - /** Field description */ - private String username; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendConfiguration.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendConfiguration.java deleted file mode 100644 index d30b781433..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendConfiguration.java +++ /dev/null @@ -1,187 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.web.proxy.ProxyConfiguration; -import sonia.scm.xml.XmlIntervalAdapter; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -/** - * - * @author Sebastian Sdorra - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "configuration") -public class BackendConfiguration -{ - - /** - * Method description - * - * - * @return - */ - public AdminAccountConfiguration getAdminAccount() - { - return adminAccount; - } - - /** - * Method description - * - * - * @return - */ - public Set getDirectories() - { - return directories; - } - - /** - * Method description - * - * - * @return - */ - public Set getExcludes() - { - return excludes; - } - - /** - * Method description - * - * - * @return - */ - public ProxyConfiguration getNewsConfiguration() - { - return newsConfiguration; - } - - /** - * Method description - * - * - * @return - */ - public Set getRepositories() - { - return repositories; - } - - /** - * Method description - * - * - * @return - */ - public long getScannInterval() - { - return scannInterval; - } - - /** - * Method description - * - * - * @return - */ - public String getTrackingCode() - { - return trackingCode; - } - - /** - * Method description - * - * - * @return - */ - public boolean isMultithreaded() - { - return multithreaded; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - @XmlElement(name = "admin-account") - private AdminAccountConfiguration adminAccount; - - /** Field description */ - @XmlElement(name = "directory") - @XmlElementWrapper(name = "directories") - private Set directories; - - /** Field description */ - @XmlElement(name = "exclude") - @XmlElementWrapper(name = "excludes") - private Set excludes; - - /** Field description */ - private boolean multithreaded = true; - - /** Field description */ - @XmlElement(name = "news-settings") - private ProxyConfiguration newsConfiguration; - - /** Field description */ - @XmlElement(name = "repository") - @XmlElementWrapper(name = "repositories") - private Set repositories; - - /** Field description */ - @XmlElement(name = "scann-interval") - @XmlJavaTypeAdapter(XmlIntervalAdapter.class) - private Long scannInterval; - - /** Field description */ - @XmlElement(name = "tracking-code") - private String trackingCode; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendContextListener.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendContextListener.java deleted file mode 100644 index efa88255f7..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BackendContextListener.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.servlet.GuiceServletContextListener; - -import org.apache.shiro.guice.web.ShiroWebModule; - -import sonia.scm.plugin.scanner.PluginScannerScheduler; -import sonia.scm.plugin.security.SecurityModule; - -//~--- JDK imports ------------------------------------------------------------ - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; - -/** - * - * @author Sebastian Sdorra - */ -public class BackendContextListener extends GuiceServletContextListener -{ - - /** - * Method description - * - * - * @param servletContextEvent - */ - @Override - public void contextDestroyed(ServletContextEvent servletContextEvent) - { - scheduler.shutdown(); - super.contextDestroyed(servletContextEvent); - } - - /** - * Method description - * - * - * @param servletContextEvent - */ - @Override - public void contextInitialized(ServletContextEvent servletContextEvent) - { - this.servletContext = servletContextEvent.getServletContext(); - super.contextInitialized(servletContextEvent); - scheduler = injector.getInstance(PluginScannerScheduler.class); - scheduler.start(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - protected Injector getInjector() - { - injector = Guice.createInjector(ShiroWebModule.guiceFilterModule(), - new SecurityModule(servletContext), new ScmBackendModule()); - - return injector; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Injector injector; - - /** Field description */ - private PluginScannerScheduler scheduler; - - /** Field description */ - private ServletContext servletContext; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BaseDirectory.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/BaseDirectory.java deleted file mode 100644 index fd03f6027c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/BaseDirectory.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.util.IOUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -/** - * - * @author Sebastian Sdorra - */ -public final class BaseDirectory -{ - - /** Field description */ - static final String DIRECTORY_PROPERTY = "scm-backend.home"; - - /** Field description */ - private static final String DIRECTORY_DEFAULT = ".scm-backend"; - - /** Field description */ - private static final String DIRECTORY_ENVIRONMENT = "SCMBACKEND_HOME"; - - /** Field description */ - private static BaseDirectory instance; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - private BaseDirectory() - { - baseDirectory = findBaseDirectory(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param name - * - * @return - */ - public static File getDirectory(String name) - { - File directory = getFile(name); - - IOUtil.mkdirs(directory); - - return directory; - } - - /** - * Method description - * - * - * @param name - * - * @return - */ - public static File getFile(String name) - { - return new File(getInstance().baseDirectory, name); - } - - /** - * Method description - * - * - * @return - */ - private static BaseDirectory getInstance() - { - if (instance == null) - { - instance = new BaseDirectory(); - } - - return instance; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - private File findBaseDirectory() - { - String path = System.getProperty(DIRECTORY_PROPERTY); - - if (Util.isEmpty(path)) - { - path = System.getenv(DIRECTORY_ENVIRONMENT); - - if (Util.isEmpty(path)) - { - path = System.getProperty("user.home").concat(File.separator).concat( - DIRECTORY_DEFAULT); - } - } - - File directory = new File(path); - - if (!directory.exists() &&!directory.mkdirs()) - { - throw new IllegalStateException("could not create directory"); - } - - return directory; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private File baseDirectory; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/Category.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/Category.java deleted file mode 100644 index 57dbed6399..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/Category.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * 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.plugin; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Arrays; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * - * @author Sebastian Sdorra - */ -public class Category -{ - - /** - * Constructs ... - * - * - * @param name - * @param plugins - */ - public Category(String name, PluginInformation... plugins) - { - this.name = name; - this.plugins = - new TreeSet(PluginInformationNameComparator.INSTANCE); - - if (plugins != null) - { - this.plugins.addAll(Arrays.asList(plugins)); - } - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public String getName() - { - return name; - } - - /** - * Method description - * - * - * @return - */ - public SortedSet getPlugins() - { - if (plugins == null) - { - plugins = new TreeSet(); - } - - return plugins; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param name - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Method description - * - * - * @param plugins - */ - public void setPlugins(SortedSet plugins) - { - this.plugins = plugins; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private String name; - - /** Field description */ - private SortedSet plugins; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/CategoryNameComaparator.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/CategoryNameComaparator.java deleted file mode 100644 index 26f560e41a..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/CategoryNameComaparator.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Comparator; - -/** - * - * @author Sebastian Sdorra - */ -public class CategoryNameComaparator implements Comparator -{ - - /** Field description */ - public static final CategoryNameComaparator INSTANCE = - new CategoryNameComaparator(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param c1 - * @param c2 - * - * @return - */ - @Override - public int compare(Category c1, Category c2) - { - return Util.compare(c1.getName(), c2.getName()); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/DefaultPluginBackend.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/DefaultPluginBackend.java deleted file mode 100644 index 80a1b1e4e7..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/DefaultPluginBackend.java +++ /dev/null @@ -1,371 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Predicate; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.ConfigurationException; -import sonia.scm.util.IOUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintWriter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -public class DefaultPluginBackend extends AbstractPluginBackend -{ - - /** Field description */ - public static final String FILE_SCANNED = "scanned-files"; - - /** Field description */ - public static final String FILE_STORE = "store.xml"; - - /** Field description */ - private static final Object LOCK_PLUGINS = new Object(); - - /** the logger for DefaultPluginBackend */ - private static final Logger logger = - LoggerFactory.getLogger(DefaultPluginBackend.class); - - /** Field description */ - private static final Object LOCK_SCANNEDFILE = new Object(); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param configuration - */ - @Inject - public DefaultPluginBackend(BackendConfiguration configuration) - { - this.configuration = configuration; - this.storeFile = BaseDirectory.getFile(FILE_STORE); - - try - { - storeContext = JAXBContext.newInstance(PluginBackendStore.class); - - if (storeFile.exists()) - { - pluginStore = - (PluginBackendStore) storeContext.createUnmarshaller().unmarshal( - storeFile); - } - else - { - pluginStore = new PluginBackendStore(); - } - - readScannedFiles(); - } - catch (JAXBException ex) - { - throw new ConfigurationException("could not read store", ex); - } - catch (IOException ex) - { - throw new ConfigurationException("could not read scanned files", ex); - } - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * - * @param plugins - */ - @Override - public void addPlugins(Collection plugins) - { - synchronized (LOCK_PLUGINS) - { - boolean changed = false; - - for (PluginInformation plugin : plugins) - { - if (!pluginStore.contains(plugin)) - { - pluginStore.add(plugin); - changed = true; - } - } - - if (changed) - { - fireEvent(plugins); - store(); - } - } - } - - /** - * Method description - * - * - * @param scannedFiles - */ - @Override - public void addScannedFiles(Collection scannedFiles) - { - synchronized (LOCK_SCANNEDFILE) - { - boolean changed = false; - - for (File file : scannedFiles) - { - if (!this.scannedFiles.contains(file)) - { - changed = true; - this.scannedFiles.add(file); - } - } - - if (changed) - { - writeScannedFiles(); - } - } - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - public Set getExcludes() - { - return configuration.getExcludes(); - } - - /** - * Method description - * - * - * @return - */ - @Override - public List getPlugins() - { - return pluginStore.getPlugins(); - } - - /** - * Method description - * - * - * @param predicate - * - * @return - */ - @Override - public List getPlugins(Predicate predicate) - { - List filteredPlugins = - new ArrayList(); - - for (PluginInformation plugin : pluginStore) - { - if (predicate.apply(plugin)) - { - filteredPlugins.add(plugin); - } - } - - return filteredPlugins; - } - - /** - * Method description - * - * - * @return - */ - @Override - public Set getScannedFiles() - { - return scannedFiles; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * - * @throws IOException - */ - private void readScannedFiles() throws IOException - { - File file = BaseDirectory.getFile(FILE_SCANNED); - - if (file.exists()) - { - BufferedReader reader = null; - - try - { - reader = new BufferedReader(new FileReader(file)); - - String line = reader.readLine(); - - while (line != null) - { - if (Util.isNotEmpty(line)) - { - File jar = new File(line); - - if (jar.exists()) - { - scannedFiles.add(jar); - } - } - - line = reader.readLine(); - } - } - finally - { - IOUtil.close(reader); - } - } - } - - /** - * Method description - * - */ - private void store() - { - if (logger.isInfoEnabled()) - { - logger.info("store plugins"); - } - - try - { - storeContext.createMarshaller().marshal(pluginStore, storeFile); - } - catch (JAXBException ex) - { - logger.error("could not store pluginStore", ex); - } - } - - /** - * Method description - * - */ - private void writeScannedFiles() - { - if (logger.isInfoEnabled()) - { - logger.info("store scanned files"); - } - - File file = BaseDirectory.getFile(FILE_SCANNED); - PrintWriter writer = null; - - try - { - writer = new PrintWriter(file); - - for (File f : scannedFiles) - { - writer.println(f.getAbsolutePath()); - } - } - catch (IOException ex) - { - logger.error("could not write scanned files", ex); - } - finally - { - IOUtil.close(writer); - } - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private BackendConfiguration configuration; - - /** Field description */ - private PluginBackendStore pluginStore; - - /** Field description */ - private Set scannedFiles = new HashSet(); - - /** Field description */ - private JAXBContext storeContext; - - /** Field description */ - private File storeFile; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/NewsProxyURLProvider.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/NewsProxyURLProvider.java deleted file mode 100644 index c765c681e0..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/NewsProxyURLProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import sonia.scm.web.proxy.ProxyConfiguration; -import sonia.scm.web.proxy.ProxyConfigurationProvider; - -//~--- JDK imports ------------------------------------------------------------ - -import javax.servlet.http.HttpServletRequest; - -/** - * - * @author Sebastian Sdorra - */ -public class NewsProxyURLProvider implements ProxyConfigurationProvider -{ - - /** - * Constructs ... - * - * - * @param configuration - */ - @Inject - public NewsProxyURLProvider(BackendConfiguration configuration) - { - this.configuration = configuration; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param request - * - * @return - */ - @Override - public ProxyConfiguration getConfiguration(HttpServletRequest request) - { - return configuration.getNewsConfiguration(); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private BackendConfiguration configuration; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackend.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackend.java deleted file mode 100644 index 6ca690ddaf..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackend.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Predicate; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * - * @author Sebastian Sdorra - */ -public interface PluginBackend -{ - - /** - * Method description - * - * - * @param listener - * - * @since 2.0.0 - */ - public void addListener(PluginBackendListener listener); - - /** - * Method description - * - * - * @param listeners - * - * @since 2.0.0 - */ - public void addListeners(Collection listeners); - - /** - * Method description - * - * - * - * @param plugins - */ - public void addPlugins(PluginInformation... plugins); - - /** - * Method description - * - * - * @param plugins - */ - public void addPlugins(Collection plugins); - - /** - * Method description - * - * - * @param scannedFiles - */ - public void addScannedFiles(Collection scannedFiles); - - /** - * Method description - * - * - * - * @param scannedFiles - */ - public void addScannedFiles(File... scannedFiles); - - /** - * Method description - * - * - * @param listener - * - * @since 2.0.0 - */ - public void removeListener(PluginBackendListener listener); - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public Set getExcludes(); - - /** - * Method description - * - * - * @return - */ - public List getPlugins(); - - /** - * Method description - * - * @param predicate - * - * @return - */ - public List getPlugins( - Predicate predicate); - - /** - * Method description - * - * - * @return - */ - public Set getScannedFiles(); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendListener.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendListener.java deleted file mode 100644 index d5c76cbeff..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendListener.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.plugin; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Collection; - -/** - * - * @author Sebastian Sdorra - */ -public interface PluginBackendListener -{ - - /** - * Method description - * - * - * @param plugins - */ - public void addedNewPlugins(Collection plugins); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendStore.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendStore.java deleted file mode 100644 index 4fccfb7ffe..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginBackendStore.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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.plugin; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.ArrayList; -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.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @author Sebastian Sdorra - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "plugin-backend") -public class PluginBackendStore implements Iterable -{ - - /** - * Method description - * - * - * @param e - * - * @return - */ - public boolean add(PluginInformation e) - { - return plugins.add(e); - } - - /** - * Method description - * - * - * @param plugin - * - * @return - */ - public boolean contains(PluginInformation plugin) - { - return plugins.contains(plugin); - } - - /** - * Method description - * - * - * @return - */ - @Override - public Iterator iterator() - { - return plugins.iterator(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public List getPlugins() - { - return plugins; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param plugins - */ - public void setPlugins(List plugins) - { - this.plugins = plugins; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - @XmlElement(name = "plugin") - @XmlElementWrapper(name = "plugins") - private List plugins = new ArrayList(); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationNameComparator.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationNameComparator.java deleted file mode 100644 index 95f33a2e0e..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationNameComparator.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Comparator; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginInformationNameComparator - implements Comparator -{ - - /** Field description */ - public static final PluginInformationNameComparator INSTANCE = - new PluginInformationNameComparator(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param p1 - * @param p2 - * - * @return - */ - @Override - public int compare(PluginInformation p1, PluginInformation p2) - { - return Util.compare(p1.getName(), p2.getName()); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationVersionComparator.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationVersionComparator.java deleted file mode 100644 index 4d8af895aa..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginInformationVersionComparator.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.version.Version; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Comparator; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginInformationVersionComparator - implements Comparator -{ - - /** Field description */ - public static final PluginInformationVersionComparator INSTANCE = - new PluginInformationVersionComparator(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param p1 - * @param p2 - * - * @return - */ - @Override - public int compare(PluginInformation p1, PluginInformation p2) - { - int result = 0; - String v1 = p1.getVersion(); - String v2 = p2.getVersion(); - - if (Util.isNotEmpty(v1) && Util.isNotEmpty(v2)) - { - if (Version.parse(v1).isNewer( - Version.parse(v2))) - { - result = -1; - } - else - { - result = 1; - } - } - else if (Util.isEmpty(v1) && Util.isNotEmpty(v2)) - { - result = 1; - } - else if (Util.isNotEmpty(v1) && Util.isEmpty(v2)) - { - result = -1; - } - - return result; - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginUtil.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginUtil.java deleted file mode 100644 index 63d5ea1757..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/PluginUtil.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Predicate; -import sonia.scm.util.LinkTextParser; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Sebastian Sdorra - */ -public final class PluginUtil -{ - - /** - * Constructs ... - * - */ - private PluginUtil() {} - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param plugins - * - * @return - */ - public static List filterSameVersions( - List plugins) - { - List filteredPlugins = - new ArrayList(); - String version = ""; - - for (PluginInformation plugin : plugins) - { - if (!version.equals(plugin.getVersion())) - { - version = plugin.getVersion(); - filteredPlugins.add(plugin); - } - } - - return filteredPlugins; - } - - /** - * Method description - * - * - * @param allVersions - * - * @return - */ - public static List filterSnapshots( - List allVersions) - { - List filtered = new ArrayList(); - - for (PluginInformation plugin : allVersions) - { - if (!plugin.getVersion().contains("SNAPSHOT")) - { - filtered.add(plugin); - } - } - - return filtered; - } - - /** - * Method description - * - * - * @param plugin - * - * @return - */ - public static PluginInformation prepareForView(PluginInformation plugin) - { - String description = plugin.getDescription(); - - if (Util.isNotEmpty(description)) - { - plugin = plugin.clone(); - description = LinkTextParser.parseText(description); - plugin.setDescription(description); - } - - return plugin; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param backend - * @param groupId - * @param artifactId - * - * @return - */ - public static List getFilteredPluginVersions( - PluginBackend backend, String groupId, String artifactId) - { - List pluginVersions = - PluginUtil.getPluginVersions(backend, groupId, artifactId); - - if (Util.isNotEmpty(pluginVersions)) - { - Collections.sort(pluginVersions, - PluginInformationNameComparator.INSTANCE); - pluginVersions = PluginUtil.filterSameVersions(pluginVersions); - } - - return pluginVersions; - } - - /** - * Method description - * - * - * @param backend - * @param groupId - * @param artifactId - * - * @return - */ - public static PluginInformation getLatestPluginVersion(PluginBackend backend, - String groupId, String artifactId) - { - return getFilteredPluginVersions(backend, groupId, artifactId).get(0); - } - - /** - * Method description - * - * - * - * @param backend - * @param groupId - * @param artifactId - * - * @return - */ - public static List getPluginVersions( - PluginBackend backend, final String groupId, final String artifactId) - { - List pluginVersions = - backend.getPlugins(new Predicate() - { - @Override - public boolean apply(PluginInformation plugin) - { - return groupId.equals(plugin.getGroupId()) - && artifactId.equals(plugin.getArtifactId()); - } - }); - - return pluginVersions; - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/RedirectFilter.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/RedirectFilter.java deleted file mode 100644 index 192ccd351c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/RedirectFilter.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Singleton; - -import sonia.scm.web.filter.HttpFilter; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -public class RedirectFilter extends HttpFilter -{ - - /** Field description */ - private static final String STARTPAGE = "/page/index.html"; - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param request - * @param response - * @param chain - * - * @throws IOException - * @throws ServletException - */ - @Override - protected void doFilter(HttpServletRequest request, - HttpServletResponse response, FilterChain chain) - throws IOException, ServletException - { - String url = - request.getRequestURI().substring(request.getContextPath().length()); - - if (url.equals("") || url.equals("/")) - { - response.sendRedirect(request.getContextPath() + STARTPAGE); - } - else - { - chain.doFilter(request, response); - } - - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/Roles.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/Roles.java deleted file mode 100644 index 160d5144aa..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/Roles.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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.plugin; - -/** - * - * @author Sebastian Sdorra - */ -public final class Roles -{ - - /** Field description */ - public static final String ADMIN = "admin"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - private Roles() {} -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/ScmBackendModule.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/ScmBackendModule.java deleted file mode 100644 index cf0b6f6aa2..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/ScmBackendModule.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * 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.plugin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.multibindings.Multibinder; -import com.google.inject.servlet.ServletModule; - -import net.sf.ehcache.CacheManager; - -import sonia.scm.ConfigurationException; -import sonia.scm.plugin.rest.api.PluginResource; -import sonia.scm.plugin.scanner.DefaultPluginScannerFactory; -import sonia.scm.plugin.scanner.PluginScannerFactory; -import sonia.scm.plugin.scanner.PluginScannerScheduler; -import sonia.scm.plugin.scanner.TimerPluginScannerScheduler; -import sonia.scm.plugin.url.BitbucketUrlBuilder; -import sonia.scm.plugin.url.GithubUrlBuilder; -import sonia.scm.plugin.url.UrlBuilder; -import sonia.scm.plugin.url.UrlBuilderFactory; -import sonia.scm.web.proxy.ProxyConfigurationProvider; -import sonia.scm.web.proxy.ProxyServlet; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.core.PackagesResourceConfig; -import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; -import com.sun.jersey.spi.container.servlet.ServletContainer; - -import java.io.File; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXB; - -/** - * - * @author Sebastian Sdorra - */ -public class ScmBackendModule extends ServletModule -{ - - /** Field description */ - public static final String CACHE_CONFIG = "/config/ehcache.xml"; - - /** Field description */ - public static final String FILE_CONFIG = "config.xml"; - - /** Field description */ - public static final String PACKAGE = "sonia.scm.plugin.rest"; - - /** Field description */ - public static final String PATTERN_NEWS = "/news*"; - - /** Field description */ - public static final String PATTERN_REST_API = "/*"; - - /** Field description */ - public static final String PATTERN_REST_EXCLUDE = "/(template/|news).*"; - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - */ - @Override - protected void configureServlets() - { - File configurationFile = BaseDirectory.getFile(FILE_CONFIG); - - if (!configurationFile.exists()) - { - throw new ConfigurationException( - "could not find configuration at ".concat(configurationFile.getPath())); - } - - BackendConfiguration configuration = JAXB.unmarshal(configurationFile, - BackendConfiguration.class); - - bind(BackendConfiguration.class).toInstance(configuration); - bind(PluginBackend.class).to(DefaultPluginBackend.class); - bind(PluginScannerFactory.class).to(DefaultPluginScannerFactory.class); - bind(PluginScannerScheduler.class).to(TimerPluginScannerScheduler.class); - - // cache manager - CacheManager cacheManager = - new CacheManager(PluginResource.class.getResource(CACHE_CONFIG)); - - bind(CacheManager.class).toInstance(cacheManager); - - // compare url builder - Multibinder compareUrlBuilderBinder = - Multibinder.newSetBinder(binder(), UrlBuilder.class); - - compareUrlBuilderBinder.addBinding().to(BitbucketUrlBuilder.class); - compareUrlBuilderBinder.addBinding().to(GithubUrlBuilder.class); - - // compare url builder factory - bind(UrlBuilderFactory.class); - - // news proxy - bind(ProxyConfigurationProvider.class).to(NewsProxyURLProvider.class); - serve(PATTERN_NEWS).with(ProxyServlet.class); - - // redirect for start page - filter(PATTERN_REST_API).through(RedirectFilter.class); - - // rest - Map params = new HashMap(); - - params.put(PackagesResourceConfig.PROPERTY_PACKAGES, PACKAGE); - params.put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, - PATTERN_REST_EXCLUDE); - filter(PATTERN_REST_API).through(GuiceContainer.class, params); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/CachedViewableResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/CachedViewableResource.java deleted file mode 100644 index 4f4957555e..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/CachedViewableResource.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * 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.plugin.rest; - -//~--- non-JDK imports -------------------------------------------------------- - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginBackendListener; -import sonia.scm.plugin.PluginInformation; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.Collection; - -import javax.servlet.ServletContext; - -/** - * - * @author Sebastian Sdorra - */ -public class CachedViewableResource extends ViewableResource - implements PluginBackendListener -{ - - /** the logger for CachedViewableResource */ - private static final Logger logger = - LoggerFactory.getLogger(CachedViewableResource.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param context - * @param configuration - * @param backend - * @param cacheManager - * @param cacheName - */ - public CachedViewableResource(ServletContext context, PluginBackend backend, - BackendConfiguration configuration, CacheManager cacheManager, - String cacheName) - { - super(context, configuration); - this.cacheName = cacheName; - this.cache = cacheManager.getCache(cacheName); - - // register backend listener - backend.addListener(this); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param plugins - */ - @Override - public void addedNewPlugins(Collection plugins) - { - if (logger.isDebugEnabled()) - { - logger.debug("clear cache {}", cacheName); - } - - cache.removeAll(); - } - - /** - * Method description - * - * - * @param key - * @param viewable - */ - protected void putToCache(String key, Viewable viewable) - { - if (logger.isTraceEnabled()) - { - logger.trace("put viewable to cache with key {}", key); - } - - cache.put(new Element(key, viewable)); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param key - * - * @return - */ - protected Viewable getFromCache(String key) - { - if (logger.isTraceEnabled()) - { - logger.trace("retrive viewable from cache with key {}", key); - } - - Viewable viewable = null; - Element el = cache.get(key); - - if (el != null) - { - viewable = (Viewable) el.getObjectValue(); - } - - return viewable; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Cache cache; - - /** Field description */ - private String cacheName; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/FreemarkerTemplateProvider.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/FreemarkerTemplateProvider.java deleted file mode 100644 index 93e1e2084c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/FreemarkerTemplateProvider.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * 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.plugin.rest; - -//~--- non-JDK imports -------------------------------------------------------- - -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.container.ContainerException; -import com.sun.jersey.api.view.Viewable; -import com.sun.jersey.spi.template.ViewProcessor; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import javax.servlet.ServletContext; - -import javax.ws.rs.core.Context; -import javax.ws.rs.ext.Provider; - -/** - * - * @author Sebastian Sdorra - */ -@Provider -public class FreemarkerTemplateProvider implements ViewProcessor -{ - - /** Field description */ - public static final String DIRECTORY_TEMPLATES = "/WEB-INF/ftl"; - - /** Field description */ - private static final String EXTENSION = ".html"; - - /** the logger for FreemarkerTemplateProvider */ - private static final Logger logger = - LoggerFactory.getLogger(FreemarkerTemplateProvider.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param servletContext - */ - public FreemarkerTemplateProvider(@Context ServletContext servletContext) - { - configuration = new Configuration(); - configuration.setServletContextForTemplateLoading(servletContext, - DIRECTORY_TEMPLATES); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param path - * - * @return - */ - @Override - public String resolve(String path) - { - if (!path.endsWith(EXTENSION)) - { - path = path.concat(EXTENSION); - } - - return path; - } - - /** - * Method description - * - * - * - * @param resolvedPath - * @param viewable - * @param out - * - * @throws IOException - */ - @Override - public void writeTo(String resolvedPath, Viewable viewable, OutputStream out) - throws IOException - { - if (logger.isDebugEnabled()) - { - logger.debug("render template {}", resolvedPath); - } - - // Commit the status and headers to the HttpServletResponse - out.flush(); - - final Template template = configuration.getTemplate(resolvedPath); - - try - { - template.process(viewable.getModel(), new OutputStreamWriter(out)); - } - catch (TemplateException te) - { - throw new ContainerException(te); - } - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private final Configuration configuration; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/PluginInformationComparator.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/PluginInformationComparator.java deleted file mode 100644 index 487dfb98e8..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/PluginInformationComparator.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * 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.plugin.rest; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.PluginInformation; -import sonia.scm.version.Version; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Comparator; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginInformationComparator - implements Comparator -{ - - /** Field description */ - public static final PluginInformationComparator INSTANCE = - new PluginInformationComparator(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param plugin - * @param otherPlugin - * - * @return - */ - @Override - public int compare(PluginInformation plugin, PluginInformation otherPlugin) - { - int c = plugin.getGroupId().compareTo(otherPlugin.getGroupId()); - - if (c == 0) - { - c = plugin.getArtifactId().compareTo(otherPlugin.getArtifactId()); - - if (c == 0) - { - Version version = - Version.parse(plugin.getVersion()); - Version otherVersion = - Version.parse(otherPlugin.getVersion()); - - c = version.compareTo(otherVersion); - } - } - - return c; - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/SubjectWrapper.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/SubjectWrapper.java deleted file mode 100644 index 2b04262ec0..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/SubjectWrapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * 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.plugin.rest; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.apache.shiro.subject.Subject; - -import sonia.scm.plugin.Roles; - -/** - * - * @author Sebastian Sdorra - */ -public class SubjectWrapper -{ - - /** Field description */ - private static final String ANONYMOUS = "anonymous"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param subject - */ - public SubjectWrapper(Subject subject) - { - this.subject = subject; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public String getName() - { - String name; - - if (subject.isAuthenticated() || subject.isRemembered()) - { - name = (String) subject.getPrincipal(); - } - else - { - name = ANONYMOUS; - } - - return name; - } - - /** - * Method description - * - * - * @return - */ - public boolean isAdmin() - { - return subject.hasRole(Roles.ADMIN); - } - - /** - * Method description - * - * - * @return - */ - public boolean isAuthenticated() - { - return subject.isAuthenticated() || subject.isRemembered(); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Subject subject; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/ViewableResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/ViewableResource.java deleted file mode 100644 index d96eb06b53..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/ViewableResource.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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.plugin.rest; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.apache.shiro.SecurityUtils; - -import sonia.scm.plugin.BackendConfiguration; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletContext; - -/** - * - * @author Sebastian Sdorra - */ -public class ViewableResource -{ - - /** - * Constructs ... - * - * - * @param context - * @param configuration - */ - public ViewableResource(ServletContext context, - BackendConfiguration configuration) - { - this.contextPath = context.getContextPath(); - this.configuration = configuration; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * - * @param title - * @return - */ - protected Map createVarMap(String title) - { - Map vars = new HashMap(); - - vars.put("contextPath", contextPath); - vars.put("configuration", configuration); - vars.put("title", title); - vars.put("subject", new SubjectWrapper(SecurityUtils.getSubject())); - - return vars; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - protected BackendConfiguration configuration; - - /** Field description */ - private String contextPath; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/admin/AdminResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/admin/AdminResource.java deleted file mode 100644 index b10e1be558..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/admin/AdminResource.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 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.plugin.rest.admin; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.rest.ViewableResource; -import sonia.scm.plugin.scanner.PluginScannerFactory; -import sonia.scm.plugin.scanner.PluginScanners; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.Map; - -import javax.servlet.ServletContext; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -/** - * - * @author Sebastian Sdorra - */ -@Path("admin") -public class AdminResource extends ViewableResource -{ - - /** Field description */ - private static final String PAGE_OVERVIEW = "/admin/index"; - - /** - * the logger for AdminResource - */ - private static final Logger logger = - LoggerFactory.getLogger(AdminResource.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param context - * @param configuration - * @param backend - * @param scannerFactory - */ - @Inject - public AdminResource(ServletContext context, - BackendConfiguration configuration, PluginBackend backend, - PluginScannerFactory scannerFactory) - { - super(context, configuration); - this.backend = backend; - this.scannerFactory = scannerFactory; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @GET - @Path("index.html") - @Produces(MediaType.TEXT_HTML) - public Viewable overview() - { - Map env = createVarMap("Administration"); - - return new Viewable(PAGE_OVERVIEW, env); - } - - /** - * Method description - * - * - * @return - */ - @POST - @Path("action/scann") - public void scann() - { - new Thread(new Runnable() - { - - @Override - public void run() - { - logger.trace("strat scanner manually"); - PluginScanners.scannDirectory(configuration, backend, scannerFactory); - } - }).start(); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private PluginScannerFactory scannerFactory; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/DefaultPluginPredicate.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/DefaultPluginPredicate.java deleted file mode 100644 index 8b1dd4ee8c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/DefaultPluginPredicate.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * 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.plugin.rest.api; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Predicate; -import sonia.scm.plugin.PluginCondition; -import sonia.scm.plugin.PluginInformation; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultPluginPredicate implements Predicate -{ - - /** Field description */ - public static final String VERSION_SNAPSHOT = "SNAPSHOT"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param version - * @param os - * @param arch - * @param snapshot - */ - public DefaultPluginPredicate(String version, String os, String arch, - boolean snapshot) - { - this.version = version; - this.os = os; - this.arch = arch; - this.snapshot = snapshot; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param plugin - * - * @return - */ - @Override - public boolean apply(PluginInformation plugin) - { - PluginCondition condition = plugin.getCondition(); - - return (snapshot - ||!plugin.getVersion().toUpperCase().contains( - VERSION_SNAPSHOT)) && ((condition != null) - && condition.isSupported(version, os, arch) || (condition == null)); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private String arch; - - /** Field description */ - private String os; - - /** Field description */ - private boolean snapshot; - - /** Field description */ - private String version; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/PluginResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/PluginResource.java deleted file mode 100644 index 86a95eed50..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/api/PluginResource.java +++ /dev/null @@ -1,296 +0,0 @@ -/** - * 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.plugin.rest.api; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginBackendListener; -import sonia.scm.plugin.PluginCenter; -import sonia.scm.plugin.PluginInformation; -import sonia.scm.version.Version; -import sonia.scm.plugin.rest.PluginInformationComparator; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -@Path("/api/{version}/plugins") -public class PluginResource implements PluginBackendListener -{ - - /** Field description */ - public static final String CACHE = "sonia.cache.plugin-backend"; - - /** the logger for PluginResource */ - private static final Logger logger = - LoggerFactory.getLogger(PluginResource.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param backend - * @param configuration - * @param cacheManager - */ - @Inject - public PluginResource(PluginBackend backend, - BackendConfiguration configuration, CacheManager cacheManager) - { - this.backend = backend; - this.configuration = configuration; - cache = cacheManager.getCache(CACHE); - - // added listener to clear the cache on a event - this.backend.addListener(this); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param plugins - */ - @Override - public void addedNewPlugins(Collection plugins) - { - if (logger.isDebugEnabled()) - { - logger.debug("clear cache {}", CACHE); - } - - cache.removeAll(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param version - * @param os - * @param arch - * @param snapshot - * - * @return - */ - @GET - @Produces(MediaType.APPLICATION_XML) - public Response getPlugins(@PathParam("version") String version, - @QueryParam("os") String os, @QueryParam("arch") String arch, - @DefaultValue("false") - @QueryParam("snapshot") boolean snapshot) - { - if (logger.isDebugEnabled()) - { - logger.debug("load plugins for version {}, include snapshots: {}", - version, Boolean.toString(snapshot)); - } - - PluginCenter pc = null; - String key = createCacheKey(version, os, arch, snapshot); - Element el = cache.get(key); - - if (el != null) - { - if (logger.isDebugEnabled()) - { - logger.debug("load plugin center from cache"); - } - - pc = (PluginCenter) el.getObjectValue(); - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("load plugin center from backend"); - } - - List plugins = - backend.getPlugins(new DefaultPluginPredicate(version, os, arch, - snapshot)); - - pc = new PluginCenter(); - pc.setPlugins(getNewestPlugins(plugins)); - pc.setRepositories(configuration.getRepositories()); - cache.put(new Element(key, pc)); - } - - return Response.ok(pc).build(); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param version - * @param os - * @param arch - * @param snapshot - * - * @return - */ - private String createCacheKey(String version, String os, String arch, - boolean snapshot) - { - StringBuilder key = new StringBuilder(version); - - key.append(":").append(os).append(":").append(arch).append(":"); - key.append(Boolean.toString(snapshot)); - - return key.toString(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param plugins - * - * @return - */ - private Set getNewestPlugins( - List plugins) - { - Collections.sort(plugins, PluginInformationComparator.INSTANCE); - - Set pluginSet = new HashSet(); - PluginInformation newest = null; - - for (PluginInformation plugin : plugins) - { - if (newest == null) - { - newest = plugin; - } - else if (isSamePlugin(plugin, newest)) - { - if (isNewer(plugin, newest)) - { - newest = plugin; - } - } - else - { - pluginSet.add(newest); - newest = plugin; - } - } - - pluginSet.add(newest); - - return pluginSet; - } - - /** - * Method description - * - * - * @param plugin - * @param newest - * - * @return - */ - private boolean isNewer(PluginInformation plugin, PluginInformation newest) - { - return Version.parse(plugin.getVersion()).isNewer(newest.getVersion()); - } - - /** - * Method description - * - * - * @param plugin - * @param otherPlugin - * - * @return - */ - private boolean isSamePlugin(PluginInformation plugin, - PluginInformation otherPlugin) - { - return plugin.getGroupId().equals(otherPlugin.getGroupId()) - && plugin.getArtifactId().equals(otherPlugin.getArtifactId()); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private Cache cache; - - /** Field description */ - private BackendConfiguration configuration; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/error/ErrorResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/error/ErrorResource.java deleted file mode 100644 index b3d3b7697c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/error/ErrorResource.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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.plugin.rest.error; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.rest.ViewableResource; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.Map; - -import javax.servlet.ServletContext; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -/** - * - * @author Sebastian Sdorra - */ -@Path("error") -public class ErrorResource extends ViewableResource -{ - - /** Field description */ - private static final String PAGE_UNAUTHORIZED = "/error/Unauthorized.html"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param context - * @param configuration - */ - @Inject - public ErrorResource(ServletContext context, - BackendConfiguration configuration) - { - super(context, configuration); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @GET - @Path("unauthorized.html") - @Produces(MediaType.TEXT_HTML) - public Viewable unauthorized() - { - Map env = createVarMap("Unauthorized"); - - return new Viewable(PAGE_UNAUTHORIZED, env); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/DetailResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/DetailResource.java deleted file mode 100644 index de7c1eada7..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/DetailResource.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * 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.plugin.rest.page; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import net.sf.ehcache.CacheManager; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginInformation; -import sonia.scm.plugin.PluginInformationVersionComparator; -import sonia.scm.plugin.PluginUtil; -import sonia.scm.plugin.rest.CachedViewableResource; -import sonia.scm.plugin.url.UrlBuilder; -import sonia.scm.plugin.url.UrlBuilderFactory; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletContext; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response.Status; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -@Path("/page/detail/{groupId}/{artifactId}.html") -public class DetailResource extends CachedViewableResource -{ - - /** Field description */ - public static final String CACHE = "sonia.cache.plugin-detail"; - - /** the logger for DetailResource */ - private static final Logger logger = - LoggerFactory.getLogger(DetailResource.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * - * @param context - * @param backend - * @param configuration - * @param urlFactory - * @param cacheManager - */ - @Inject - public DetailResource(ServletContext context, PluginBackend backend, - BackendConfiguration configuration, UrlBuilderFactory urlFactory, - CacheManager cacheManager) - { - super(context, backend, configuration, cacheManager, CACHE); - this.backend = backend; - this.urlFactory = urlFactory; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param groupId - * @param artifactId - * @param snapshot - * - * @return - */ - @GET - public Viewable getPluginDetails(@PathParam("groupId") String groupId, - @PathParam("artifactId") String artifactId, @DefaultValue("false") - @QueryParam("snapshot") boolean snapshot) - { - String cacheKey = createCacheKey(groupId, artifactId, snapshot); - Viewable viewable = getFromCache(cacheKey); - - if (viewable == null) - { - if (logger.isDebugEnabled()) - { - logger.debug("create viewable from backend"); - } - - List pluginVersions = - PluginUtil.getFilteredPluginVersions(backend, groupId, artifactId); - - if (Util.isEmpty(pluginVersions)) - { - throw new WebApplicationException(Status.NOT_FOUND); - } - - PluginInformation latest = pluginVersions.get(0); - - if (!snapshot) - { - pluginVersions = PluginUtil.filterSnapshots(pluginVersions); - } - - List detailList = createDetailList(latest, - pluginVersions); - Map vars = createVarMap(latest.getName()); - - vars.put("latest", PluginUtil.prepareForView(latest)); - vars.put("versions", detailList); - viewable = new Viewable("/page/detail", vars); - putToCache(cacheKey, viewable); - } - else if (logger.isDebugEnabled()) - { - logger.debug("create viewable from cache"); - } - - return viewable; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param groupId - * @param artifactId - * @param snapshot - * - * @return - */ - private String createCacheKey(String groupId, String artifactId, - boolean snapshot) - { - return new StringBuilder(Util.nonNull(groupId)).append( - Util.nonNull(artifactId)).append(Boolean.toString(snapshot)).toString(); - } - - /** - * Method description - * - * - * @param latest - * @param pluginVersions - * - * @return - */ - private List createDetailList(PluginInformation latest, - List pluginVersions) - { - List detailList = new ArrayList(); - - Collections.sort(pluginVersions, - PluginInformationVersionComparator.INSTANCE); - - Iterator pluginIterator = pluginVersions.iterator(); - UrlBuilder urlBuilder = urlFactory.createCompareUrlBuilder(latest); - PluginInformation last = null; - - while (pluginIterator.hasNext()) - { - PluginInformation current = pluginIterator.next(); - - if (last != null) - { - String url = null; - - if (urlBuilder != null) - { - url = urlBuilder.createCompareUrl(latest, last, current); - } - - detailList.add(new PluginDetailWrapper(last, url)); - } - - last = current; - } - - if (last != null) - { - detailList.add(new PluginDetailWrapper(last)); - } - - return detailList; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private UrlBuilderFactory urlFactory; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/LoginResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/LoginResource.java deleted file mode 100644 index 156bf8faa3..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/LoginResource.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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.plugin.rest.page; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.rest.ViewableResource; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.Map; - -import javax.servlet.ServletContext; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -/** - * - * @author Sebastian Sdorra - */ -@Path("/page/login.html") -public class LoginResource extends ViewableResource -{ - - /** Field description */ - private static final String PAGE_LOGIN = "/page/login"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param context - * @param configuration - */ - @Inject - public LoginResource(ServletContext context, - BackendConfiguration configuration) - { - super(context, configuration); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @POST - @Produces(MediaType.TEXT_HTML) - public Viewable loginFailed() - { - Map vars = createVarMap("Login"); - - vars.put("error", "Login failed"); - - return new Viewable(PAGE_LOGIN, vars); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @GET - @Produces(MediaType.TEXT_HTML) - public Viewable getForm() - { - Map vars = createVarMap("Login"); - - return new Viewable(PAGE_LOGIN, vars); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/OverviewResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/OverviewResource.java deleted file mode 100644 index 7537cf1a26..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/OverviewResource.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * 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.plugin.rest.page; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.Category; -import sonia.scm.plugin.CategoryNameComaparator; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginInformation; -import sonia.scm.plugin.PluginUtil; -import sonia.scm.plugin.rest.PluginInformationComparator; -import sonia.scm.plugin.rest.ViewableResource; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import com.sun.jersey.api.view.Viewable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletContext; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -/** - * - * @author Sebastian Sdorra - */ -@Path("/page/index.html") -public class OverviewResource extends ViewableResource -{ - - /** Field description */ - public static final String DEFAULT_CATEGORY = "Miscellaneous"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * - * @param context - * @param backend - * @param configuration - */ - @Inject - public OverviewResource(ServletContext context, PluginBackend backend, - BackendConfiguration configuration) - { - super(context, configuration); - this.backend = backend; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @GET - public Viewable overview() - { - List categories = getPluginOverview(); - Map vars = createVarMap("Plugin Overview"); - - vars.put("categories", categories); - - return new Viewable("/page/index", vars); - } - - /** - * Method description - * - * - * @param categories - * @param plugin - */ - private void append(Map categories, - PluginInformation plugin) - { - String name = plugin.getCategory(); - - if (Util.isEmpty(name)) - { - name = DEFAULT_CATEGORY; - } - - Category category = categories.get(name); - - if (category == null) - { - category = new Category(name, plugin); - categories.put(name, category); - } - - category.getPlugins().add(PluginUtil.prepareForView(plugin)); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - private List getPluginOverview() - { - List allPlugins = backend.getPlugins(); - - Collections.sort(allPlugins, PluginInformationComparator.INSTANCE); - - String pid = ""; - Map categoryMap = new HashMap(); - - for (PluginInformation p : allPlugins) - { - String currentPid = p.getGroupId().concat(":").concat(p.getArtifactId()); - - if (!currentPid.equals(pid)) - { - pid = currentPid; - append(categoryMap, p); - } - } - - List categories = new ArrayList(categoryMap.values()); - - Collections.sort(categories, CategoryNameComaparator.INSTANCE); - - return categories; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/PluginDetailWrapper.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/PluginDetailWrapper.java deleted file mode 100644 index b2c286d577..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/PluginDetailWrapper.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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.plugin.rest.page; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.PluginInformation; -import sonia.scm.plugin.PluginUtil; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginDetailWrapper -{ - - /** - * Constructs ... - * - * - * @param plugin - */ - public PluginDetailWrapper(PluginInformation plugin) - { - this(plugin, null); - } - - /** - * Constructs ... - * - * - * @param plugin - * @param compareUrl - */ - public PluginDetailWrapper(PluginInformation plugin, String compareUrl) - { - this.plugin = PluginUtil.prepareForView(plugin); - this.compareUrl = compareUrl; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public String getCompareUrl() - { - return compareUrl; - } - - /** - * Method description - * - * - * @return - */ - public PluginInformation getPlugin() - { - return plugin; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param compareUrl - */ - public void setCompareUrl(String compareUrl) - { - this.compareUrl = compareUrl; - } - - /** - * Method description - * - * - * @param plugin - */ - public void setPlugin(PluginInformation plugin) - { - this.plugin = plugin; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private String compareUrl; - - /** Field description */ - private PluginInformation plugin; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/ScreenshotResource.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/ScreenshotResource.java deleted file mode 100644 index 712ea105c2..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/rest/page/ScreenshotResource.java +++ /dev/null @@ -1,234 +0,0 @@ -/** - * 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.plugin.rest.page; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import org.imgscalr.Scalr; - -import sonia.scm.plugin.BaseDirectory; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginInformation; -import sonia.scm.plugin.PluginUtil; -import sonia.scm.util.ChecksumUtil; -import sonia.scm.util.IOUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.awt.image.BufferedImage; - -import java.io.File; -import java.io.IOException; - -import java.net.URL; - -import java.util.List; - -import javax.imageio.ImageIO; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - -/** - * - * @author Sebastian Sdorra - */ -@Path("/page/screenshot/{groupId}/{artifactId}/{number}/{size}.jpg") -public class ScreenshotResource -{ - - /** Field description */ - public static final String EXTENSION_IMAGE = ".jpg"; - - /** Field description */ - public static final String FORMAT = "jpg"; - - /** Field description */ - public static final String PATH_IMAGE = "images"; - - /** Field description */ - public static final int SIZE_LARGE = 640; - - /** Field description */ - public static final int SIZE_MEDIUM = 320; - - /** Field description */ - public static final int SIZE_SMALL = 200; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param backend - */ - @Inject - public ScreenshotResource(PluginBackend backend) - { - this.backend = backend; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param groupId - * @param artifactId - * @param number - * @param size - * - * @return - * - * @throws IOException - */ - @GET - @Produces("image/jpeg") - public Response getScreenshot(@PathParam("groupId") String groupId, - @PathParam("artifactId") String artifactId, - @PathParam("number") int number, @PathParam("size") String size) - throws IOException - { - PluginInformation plugin = PluginUtil.getLatestPluginVersion(backend, - groupId, artifactId); - - if (plugin == null) - { - throw new WebApplicationException(Status.NOT_FOUND); - } - - List screenshots = plugin.getScreenshots(); - - if (Util.isEmpty(screenshots)) - { - throw new WebApplicationException(Status.NOT_FOUND); - } - - String screenshot = screenshots.get(number); - - if (Util.isEmpty(screenshot)) - { - throw new WebApplicationException(Status.NOT_FOUND); - } - - String checksum = ChecksumUtil.createChecksum(screenshot); - - File file = createThumbnailFile(groupId, artifactId, number, size, - checksum); - - if (!file.exists()) - { - createThumbnail(file, screenshot, size.toCharArray()[0]); - } - - return Response.ok(file).build(); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param file - * @param screenshot - * @param size - * - * @throws IOException - */ - private void createThumbnail(File file, String screenshot, char size) - throws IOException - { - IOUtil.mkdirs(file.getParentFile()); - - int width = SIZE_SMALL; - - switch (size) - { - case 'l' : - width = SIZE_LARGE; - - break; - - case 'm' : - width = SIZE_MEDIUM; - } - - BufferedImage image = ImageIO.read(new URL(screenshot)); - - image = Scalr.resize(image, Scalr.Method.QUALITY, width); - ImageIO.write(image, FORMAT, file); - } - - /** - * Method description - * - * - * @param groupId - * @param artifactId - * @param number - * @param size - * @param checksum - * - * @return - */ - private File createThumbnailFile(String groupId, String artifactId, - int number, String size, String checksum) - { - StringBuilder path = new StringBuilder(PATH_IMAGE); - - path.append(File.separator).append(groupId); - path.append(File.separator).append(artifactId).append(File.separator); - path.append(String.valueOf(number)).append(File.separator); - path.append(size).append(File.separator).append(checksum); - path.append(EXTENSION_IMAGE); - - return BaseDirectory.getFile(path.toString()); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultFileFilter.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultFileFilter.java deleted file mode 100644 index 1f1ea054f6..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultFileFilter.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileFilter; - -import java.util.Collection; -import java.util.Collections; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultFileFilter implements FileFilter -{ - - /** Field description */ - public static final String PLUGIN_EXTENSION = ".jar"; - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - public DefaultFileFilter() - { - this(null); - } - - /** - * Constructs ... - * - * - * @param excludes - */ - public DefaultFileFilter(Collection excludes) - { - if (excludes == null) - { - this.excludes = Collections.emptySet(); - } - else - { - this.excludes = excludes; - } - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param file - * - * @return - */ - @Override - public boolean accept(File file) - { - boolean accepted = false; - - if (file.isDirectory()) - { - accepted = true; - } - else - { - String name = file.getName(); - - if (name.endsWith(PLUGIN_EXTENSION)) - { - accepted = true; - - for (String exclude : excludes) - { - if (name.matches(exclude)) - { - accepted = false; - - break; - } - } - } - } - - return accepted; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Collection excludes; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScanner.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScanner.java deleted file mode 100644 index fbd891145e..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScanner.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.Plugin; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.plugin.PluginCondition; -import sonia.scm.plugin.PluginException; -import sonia.scm.plugin.PluginInformation; -import sonia.scm.util.IOUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.IOException; - -import java.util.HashSet; -import java.util.Set; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultPluginScanner implements PluginScanner -{ - - /** Field description */ - public static final String PLUGIN_DESCRIPTOR = "META-INF/scm/plugin.xml"; - - /** Field description */ - - /** the logger for DefaultPluginScanner */ - private static final Logger logger = - LoggerFactory.getLogger(DefaultPluginScanner.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - public DefaultPluginScanner() - { - try - { - pluginContext = JAXBContext.newInstance(Plugin.class); - } - catch (JAXBException ex) - { - throw new PluginException(ex); - } - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param backend - * @param directory - */ - @Override - public void scannDirectory(PluginBackend backend, File directory) - { - if (logger.isInfoEnabled()) - { - logger.info("start scann of basedirectory {}", directory.getPath()); - } - - Set scannedFiles = new HashSet(); - Set plugins = new HashSet(); - FileFilter filter = new DefaultFileFilter(backend.getExcludes()); - - scannDirectory(backend, scannedFiles, plugins, directory, filter); - - if (Util.isNotEmpty(plugins)) - { - backend.addPlugins(plugins); - } - - if (Util.isNotEmpty(scannedFiles)) - { - backend.addScannedFiles(scannedFiles); - } - - if (logger.isInfoEnabled()) - { - logger.info("finish scann of basedirectory {}", directory.getPath()); - } - } - - /** - * Method description - * - * - * @param backend - * @param scannedFiles - * @param plugins - * @param directory - * @param filter - */ - private void scannDirectory(PluginBackend backend, Set scannedFiles, - Set plugins, File directory, FileFilter filter) - { - if (logger.isTraceEnabled()) - { - logger.trace("scann directory {}", directory.getPath()); - } - - File[] files = directory.listFiles(filter); - - for (File file : files) - { - if (file.isDirectory()) - { - scannDirectory(backend, scannedFiles, plugins, file, filter); - } - else if (!backend.getScannedFiles().contains(file)) - { - try - { - scannFile(plugins, file); - scannedFiles.add(file); - } - catch (Exception ex) - { - logger.error( - "could not read plugin descriptor ".concat(file.getPath()), ex); - } - } - } - } - - /** - * Method description - * - * - * - * @param plugins - * @param file - * - * @throws IOException - * @throws JAXBException - */ - private void scannFile(Set plugins, File file) - throws IOException, JAXBException - { - if (logger.isDebugEnabled()) - { - logger.trace("scann file {}", file.getPath()); - } - - JarInputStream inputStream = null; - - try - { - inputStream = new JarInputStream(new FileInputStream(file)); - - JarEntry entry = inputStream.getNextJarEntry(); - - while (entry != null) - { - if (logger.isTraceEnabled()) - { - logger.trace("scann entry {}", entry.getName()); - } - - if (PLUGIN_DESCRIPTOR.equals(entry.getName())) - { - Plugin plugin = - (Plugin) pluginContext.createUnmarshaller().unmarshal(inputStream); - - if ((plugin != null) && (plugin.getInformation() != null) - && plugin.getInformation().isValid()) - { - logger.debug("analyze plugin: {}", plugin); - - PluginCondition condition = plugin.getCondition(); - - if (condition != null) - { - plugin.getInformation().setCondition(condition); - } - - if (logger.isInfoEnabled()) - { - logger.info("add plugin {} to backend", file.getPath()); - } - - plugins.add(plugin.getInformation()); - } - else if (logger.isWarnEnabled()) - { - logger.warn("plugin {} is not valid", file.getPath()); - } - - break; - } - else - { - inputStream.closeEntry(); - entry = inputStream.getNextJarEntry(); - } - } - } - finally - { - IOUtil.close(inputStream); - } - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private JAXBContext pluginContext; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScannerFactory.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScannerFactory.java deleted file mode 100644 index b54ae9566c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/DefaultPluginScannerFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.plugin.scanner; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultPluginScannerFactory implements PluginScannerFactory -{ - - /** - * Method description - * - * - * @return - */ - @Override - public PluginScanner createScanner() - { - return new DefaultPluginScanner(); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanner.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanner.java deleted file mode 100644 index d9577a5975..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanner.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.PluginBackend; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -/** - * - * @author Sebastian Sdorra - */ -public interface PluginScanner -{ - - /** - * Method description - * - * - * - * @param backend - * @param directory - */ - public void scannDirectory(PluginBackend backend, File directory); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerFactory.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerFactory.java deleted file mode 100644 index c5de3a14d2..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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.plugin.scanner; - -/** - * - * @author Sebastian Sdorra - */ -public interface PluginScannerFactory -{ - - /** - * Method description - * - * - * @return - */ - public PluginScanner createScanner(); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerRunnable.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerRunnable.java deleted file mode 100644 index 7c6b7bc96a..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerRunnable.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.PluginBackend; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginScannerRunnable implements Runnable -{ - - /** - * Constructs ... - * - * - * @param backend - * @param pluginScanner - * @param directory - */ - public PluginScannerRunnable(PluginBackend backend, - PluginScanner pluginScanner, File directory) - { - this.backend = backend; - this.pluginScanner = pluginScanner; - this.directory = directory; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - */ - @Override - public void run() - { - pluginScanner.scannDirectory(backend, directory); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private File directory; - - /** Field description */ - private PluginScanner pluginScanner; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerScheduler.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerScheduler.java deleted file mode 100644 index 86cc59b7a1..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerScheduler.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.plugin.scanner; - -/** - * - * @author Sebastian Sdorra - */ -public interface PluginScannerScheduler -{ - - /** - * Method description - * - */ - public void shutdown(); - - /** - * Method description - * - */ - public void start(); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerTimerTask.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerTimerTask.java deleted file mode 100644 index d1e118e349..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScannerTimerTask.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.TimerTask; - -/** - * - * @author Sebastian Sdorra - */ -public class PluginScannerTimerTask extends TimerTask -{ - - /** the logger for PluginScannerTimerTask */ - private static final Logger logger = - LoggerFactory.getLogger(PluginScannerTimerTask.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param backend - * @param configuration - * @param scannerFactory - */ - public PluginScannerTimerTask(PluginBackend backend, - BackendConfiguration configuration, PluginScannerFactory scannerFactory) - { - this.backend = backend; - this.configuration = configuration; - this.scannerFactory = scannerFactory; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - */ - @Override - public void run() - { - logger.trace("timer task started scann"); - PluginScanners.scannDirectory(configuration, backend, scannerFactory); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private BackendConfiguration configuration; - - /** Field description */ - private PluginScannerFactory scannerFactory; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanners.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanners.java deleted file mode 100644 index 818342af12..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/PluginScanners.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; - -/** - * - * @author Sebastian Sdorra - */ -public final class PluginScanners -{ - - /** - * the logger for PluginScanners - */ - private static final Logger logger = - LoggerFactory.getLogger(PluginScanners.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - private PluginScanners() {} - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param configuration - * @param backend - * @param scannerFactory - */ - public synchronized static void scannDirectory( - BackendConfiguration configuration, PluginBackend backend, - PluginScannerFactory scannerFactory) - { - if (logger.isInfoEnabled()) - { - logger.info("start scann"); - } - - for (File directory : configuration.getDirectories()) - { - if (logger.isDebugEnabled()) - { - logger.info("scann directory {}", directory.getPath()); - } - - PluginScanner scanner = scannerFactory.createScanner(); - - if (configuration.isMultithreaded()) - { - new Thread(new PluginScannerRunnable(backend, scanner, - directory)).start(); - } - else - { - scanner.scannDirectory(backend, directory); - } - } - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/TimerPluginScannerScheduler.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/TimerPluginScannerScheduler.java deleted file mode 100644 index 82d1e502de..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/scanner/TimerPluginScannerScheduler.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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.plugin.scanner; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.PluginBackend; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Timer; - -/** - * - * @author Sebastian Sdorra - */ -public class TimerPluginScannerScheduler implements PluginScannerScheduler -{ - - /** Field description */ - public static final String TIMER_NAME = "ScmPluginScanner"; - - /** the logger for TimerPluginScannerScheduler */ - private static final Logger logger = - LoggerFactory.getLogger(TimerPluginScannerScheduler.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param backend - * @param configuration - * @param scannerFactory - */ - @Inject - public TimerPluginScannerScheduler(PluginBackend backend, - BackendConfiguration configuration, PluginScannerFactory scannerFactory) - { - this.backend = backend; - this.configuration = configuration; - this.scannerFactory = scannerFactory; - timer = new Timer(TIMER_NAME); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - */ - @Override - public void shutdown() - { - timer.cancel(); - } - - /** - * Method description - * - */ - @Override - public void start() - { - if (logger.isInfoEnabled()) - { - logger.info("start scanner task with an interval of {}", - Util.convertTime(configuration.getScannInterval())); - } - - PluginScannerTimerTask task = new PluginScannerTimerTask(backend, - configuration, scannerFactory); - - // wait 5 seconds and start with first run - timer.schedule(task, 5000l, configuration.getScannInterval()); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private PluginBackend backend; - - /** Field description */ - private BackendConfiguration configuration; - - /** Field description */ - private PluginScannerFactory scannerFactory; - - /** Field description */ - private Timer timer; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/CacheManagerProvider.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/CacheManagerProvider.java deleted file mode 100644 index 855782d525..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/CacheManagerProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.plugin.security; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; -import com.google.inject.Provider; -import com.google.inject.Singleton; - -import org.apache.shiro.cache.CacheManager; -import org.apache.shiro.cache.ehcache.EhCacheManager; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -public class CacheManagerProvider implements Provider -{ - - /** - * Constructs ... - * - * - * @param cacheManager - */ - @Inject - public CacheManagerProvider(net.sf.ehcache.CacheManager cacheManager) - { - this.cacheManager = cacheManager; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - public CacheManager get() - { - EhCacheManager eh = new EhCacheManager(); - - eh.setCacheManager(cacheManager); - - return eh; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private net.sf.ehcache.CacheManager cacheManager; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/DefaultAdminRealm.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/DefaultAdminRealm.java deleted file mode 100644 index 2d8e517236..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/DefaultAdminRealm.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * 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.plugin.security; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; - -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.AuthenticationInfo; -import org.apache.shiro.authc.AuthenticationToken; -import org.apache.shiro.authc.UnknownAccountException; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.authc.credential.CredentialsMatcher; -import org.apache.shiro.authz.AuthorizationInfo; -import org.apache.shiro.authz.SimpleAuthorizationInfo; -import org.apache.shiro.cache.CacheManager; -import org.apache.shiro.realm.AuthorizingRealm; -import org.apache.shiro.subject.PrincipalCollection; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.AdminAccountConfiguration; -import sonia.scm.plugin.BackendConfiguration; -import sonia.scm.plugin.Roles; - -/** - * - * @author Sebastian Sdorra - */ -public class DefaultAdminRealm extends AuthorizingRealm -{ - - /** Field description */ - public static final String NAME = "scm.backend"; - - /** - * the logger for ScmBackendRealm - */ - private static final Logger logger = - LoggerFactory.getLogger(DefaultAdminRealm.class); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param configuration - * @param credentialsMatcher - * @param cacheManager - */ - @Inject - public DefaultAdminRealm(BackendConfiguration configuration, - CredentialsMatcher credentialsMatcher, CacheManager cacheManager) - { - super(cacheManager, credentialsMatcher); - this.configuration = configuration; - setAuthenticationTokenClass(UsernamePasswordToken.class); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param token - * - * @return - * - * @throws AuthenticationException - */ - @Override - protected AuthenticationInfo doGetAuthenticationInfo( - AuthenticationToken token) - throws AuthenticationException - { - Preconditions.checkNotNull(token); - - UsernamePasswordToken upToken = (UsernamePasswordToken) token; - - String username = upToken.getUsername(); - - if (logger.isDebugEnabled()) - { - logger.debug("start authentication for user {}", username); - } - - AdminAccountConfiguration adminAccount = configuration.getAdminAccount(); - - if (!adminAccount.getUsername().equals(adminAccount.getUsername())) - { - throw new UnknownAccountException("unknown account ".concat(username)); - } - - return adminAccount; - } - - /** - * Method description - * - * - * @param principals - * - * @return - */ - @Override - protected AuthorizationInfo doGetAuthorizationInfo( - PrincipalCollection principals) - { - if (principals == null) - { - throw new AuthenticationException("principals should not be null"); - } - - return new SimpleAuthorizationInfo(ImmutableSet.of(Roles.ADMIN)); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private BackendConfiguration configuration; -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/SecurityModule.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/SecurityModule.java deleted file mode 100644 index eaedcab0fc..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/security/SecurityModule.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * 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.plugin.security; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.name.Named; -import com.google.inject.name.Names; - -import org.apache.shiro.authc.credential.CredentialsMatcher; -import org.apache.shiro.authc.credential.HashedCredentialsMatcher; -import org.apache.shiro.cache.CacheManager; -import org.apache.shiro.crypto.RandomNumberGenerator; -import org.apache.shiro.crypto.SecureRandomNumberGenerator; -import org.apache.shiro.crypto.hash.SimpleHash; -import org.apache.shiro.guice.web.ShiroWebModule; -import org.apache.shiro.util.ByteSource; - -import sonia.scm.plugin.Roles; - -//~--- JDK imports ------------------------------------------------------------ - -import javax.servlet.ServletContext; - -import javax.swing.JOptionPane; - -/** - * - * @author Sebastian Sdorra - */ -public class SecurityModule extends ShiroWebModule -{ - - /** Field description */ - private static final String ATTRIBUTE_FAILURE = "shiroLoginFailure"; - - /** Field description */ - private static final String HASH_ALGORITHM = "SHA-256"; - - /** Field description */ - private static final int HASH_ITERATIONS = 1024; - - /** Field description */ - private static final String PAGE_LOGIN = "/page/login.html"; - - /** Field description */ - private static final String PAGE_SUCCESS = "/admin/index.html"; - - /** Field description */ - private static final String PAGE_UNAUTHORIZED = "/error/unauthorized.html"; - - /** Field description */ - private static final String PARAM_PASSWORD = "password"; - - /** Field description */ - private static final String PARAM_REMEMBERME = "rememberme"; - - /** Field description */ - private static final String PARAM_USERNAME = "username"; - - /** Field description */ - private static final String PATTERN_ADMIN = "/admin/**"; - - /** Field description */ - private static final Named NAMED_USERNAMEPARAM = - Names.named("shiro.usernameParam"); - - /** Field description */ - private static final Named NAMED_UNAUTHORIZEDURL = - Names.named("shiro.unauthorizedUrl"); - - /** Field description */ - private static final Named NAMED_SUCCESSURL = Names.named("shiro.successUrl"); - - /** Field description */ - private static final Named NAMED_REMEMBERMEPARAM = - Names.named("shiro.rememberMeParam"); - - /** Field description */ - private static final Named NAMED_PASSWORDPARAM = - Names.named("shiro.passwordParam"); - - /** Field description */ - private static final Named NAMED_LOGINURL = Names.named("shiro.loginUrl"); - - /** Field description */ - private static final Named NAMED_FAILUREKEYATTRIBUTE = - Names.named("shiro.failureKeyAttribute"); - - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - * - * @param servletContext - */ - public SecurityModule(ServletContext servletContext) - { - super(servletContext); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param args - */ - public static void main(String[] args) - { - String value = JOptionPane.showInputDialog("Password"); - RandomNumberGenerator rng = new SecureRandomNumberGenerator(); - ByteSource salt = rng.nextBytes(); - SimpleHash hash = new SimpleHash(HASH_ALGORITHM, value, salt, - HASH_ITERATIONS); - - System.out.append("Salt: ").println(salt.toBase64()); - System.out.append("Hash: ").println(hash.toBase64()); - } - - /** - * Method description - * - */ - @Override - @SuppressWarnings("unchecked") - protected void configureShiroWeb() - { - bindConstants(); - bindCredentialsMatcher(); - - // bind cache manager - bind(CacheManager.class).toProvider(CacheManagerProvider.class); - - // bind realm - bindRealm().to(DefaultAdminRealm.class); - - // add filters - addFilterChain(PAGE_LOGIN, AUTHC); - addFilterChain(PATTERN_ADMIN, AUTHC, config(ROLES, Roles.ADMIN)); - } - - /** - * Method description - * - */ - private void bindConstants() - { - bindConstant().annotatedWith(NAMED_LOGINURL).to(PAGE_LOGIN); - bindConstant().annotatedWith(NAMED_USERNAMEPARAM).to(PARAM_USERNAME); - bindConstant().annotatedWith(NAMED_PASSWORDPARAM).to(PARAM_PASSWORD); - bindConstant().annotatedWith(NAMED_REMEMBERMEPARAM).to(PARAM_REMEMBERME); - bindConstant().annotatedWith(NAMED_SUCCESSURL).to(PAGE_SUCCESS); - bindConstant().annotatedWith(NAMED_UNAUTHORIZEDURL).to(PAGE_UNAUTHORIZED); - bindConstant().annotatedWith(NAMED_FAILUREKEYATTRIBUTE).to( - ATTRIBUTE_FAILURE); - } - - /** - * Method description - * - */ - private void bindCredentialsMatcher() - { - HashedCredentialsMatcher matcher = - new HashedCredentialsMatcher(HASH_ALGORITHM); - - matcher.setHashIterations(HASH_ITERATIONS); - matcher.setStoredCredentialsHexEncoded(false); - bind(CredentialsMatcher.class).toInstance(matcher); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/AbstractUrlBuilder.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/AbstractUrlBuilder.java deleted file mode 100644 index e15e2a980a..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/AbstractUrlBuilder.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * 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.plugin.url; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import sonia.scm.plugin.PluginInformation; -import sonia.scm.util.HttpUtil; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.net.MalformedURLException; -import java.net.URL; - -import java.text.MessageFormat; - -/** - * - * @author Sebastian Sdorra - */ -public abstract class AbstractUrlBuilder implements UrlBuilder -{ - - /** the logger for AbstractUrlBuilder */ - private static final Logger logger = - LoggerFactory.getLogger(AbstractUrlBuilder.class); - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - protected abstract String getServername(); - - /** - * Method description - * - * - * @return - */ - protected abstract String getUrlPattern(); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param latest - * @param plugin - * @param other - * - * @return - */ - @Override - public String createCompareUrl(PluginInformation latest, - PluginInformation plugin, PluginInformation other) - { - return createCompareUrl(latest.getUrl(), plugin.getVersion(), - other.getVersion()); - } - - /** - * Method description - * - * - * @param urlString - * @param version - * @param otherVersion - * - * @return - */ - public String createCompareUrl(String urlString, String version, - String otherVersion) - { - String result = null; - - try - { - URL url = new URL(urlString); - String path = url.getPath(); - - if (Util.isNotEmpty(path)) - { - path = HttpUtil.getUriWithoutStartSeperator(path); - - String[] parts = path.split(HttpUtil.SEPARATOR_PATH); - - if (parts.length >= 2) - { - result = MessageFormat.format(getUrlPattern(), parts[0], parts[1], - version, otherVersion); - } - } - } - catch (MalformedURLException ex) - { - logger.error("could not parse url", ex); - } - - return result; - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param url - * - * @return - */ - @Override - public boolean isCompareable(String url) - { - return url.contains(getServername()); - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/BitbucketUrlBuilder.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/BitbucketUrlBuilder.java deleted file mode 100644 index 3b2132230e..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/BitbucketUrlBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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.plugin.url; - -/** - * - * @author Sebastian Sdorra - */ -public class BitbucketUrlBuilder extends AbstractUrlBuilder -{ - - /** Field description */ - public static final String SERVERNAME = "bitbucket.org"; - - /** Field description */ - public static final String URL_PATTERN = - "https://bitbucket.org/{0}/{1}/compare/{2}..{3}"; - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - protected String getServername() - { - return SERVERNAME; - } - - /** - * Method description - * - * - * @return - */ - @Override - protected String getUrlPattern() - { - return URL_PATTERN; - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/GithubUrlBuilder.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/GithubUrlBuilder.java deleted file mode 100644 index 2a77263e22..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/GithubUrlBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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.plugin.url; - -/** - * - * @author Sebastian Sdorra - */ -public class GithubUrlBuilder extends AbstractUrlBuilder -{ - - /** Field description */ - public static final String SERVERNAME = "github.com"; - - /** Field description */ - public static final String URL_PATTERN = - "https://github.com/{0}/{1}/compare/{3}...{2}"; - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - protected String getServername() - { - return SERVERNAME; - } - - /** - * Method description - * - * - * @return - */ - @Override - protected String getUrlPattern() - { - return URL_PATTERN; - } -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilder.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilder.java deleted file mode 100644 index 1109625915..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.plugin.url; - -//~--- non-JDK imports -------------------------------------------------------- - -import sonia.scm.plugin.PluginInformation; - -/** - * - * @author Sebastian Sdorra - */ -public interface UrlBuilder -{ - - /** - * Method description - * - * - * @param latest - * @param plugin - * @param other - * - * @return - */ - public String createCompareUrl(PluginInformation latest, - PluginInformation plugin, PluginInformation other); - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param url - * - * @return - */ - public boolean isCompareable(String url); -} diff --git a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilderFactory.java b/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilderFactory.java deleted file mode 100644 index 1f2efa960c..0000000000 --- a/scm-plugin-backend/src/main/java/sonia/scm/plugin/url/UrlBuilderFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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.plugin.url; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import sonia.scm.plugin.PluginInformation; -import sonia.scm.util.Util; - -//~--- JDK imports ------------------------------------------------------------ - -import java.util.Set; - -/** - * - * @author Sebastian Sdorra - */ -@Singleton -public class UrlBuilderFactory -{ - - /** - * Constructs ... - * - * - * @param urlBuilderSet - */ - @Inject - public UrlBuilderFactory(Set urlBuilderSet) - { - this.urlBuilderSet = urlBuilderSet; - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param pluginUrl - * - * @return - */ - public UrlBuilder createCompareUrlBuilder(String pluginUrl) - { - UrlBuilder builder = null; - - if (Util.isNotEmpty(pluginUrl) && Util.isNotEmpty(urlBuilderSet)) - { - for (UrlBuilder cup : urlBuilderSet) - { - if (cup.isCompareable(pluginUrl)) - { - builder = cup; - - break; - } - } - } - - return builder; - } - - /** - * Method description - * - * - * @param plugin - * - * @return - */ - public UrlBuilder createCompareUrlBuilder(PluginInformation plugin) - { - return createCompareUrlBuilder(plugin.getUrl()); - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Set urlBuilderSet; -} diff --git a/scm-plugin-backend/src/main/resources/config/ehcache.xml b/scm-plugin-backend/src/main/resources/config/ehcache.xml deleted file mode 100644 index f49ba87106..0000000000 --- a/scm-plugin-backend/src/main/resources/config/ehcache.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/scm-plugin-backend/src/main/resources/logback.xml b/scm-plugin-backend/src/main/resources/logback.xml deleted file mode 100644 index aba83a8d17..0000000000 --- a/scm-plugin-backend/src/main/resources/logback.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/META-INF/context.xml b/scm-plugin-backend/src/main/webapp/META-INF/context.xml deleted file mode 100644 index 0495b7cd31..0000000000 --- a/scm-plugin-backend/src/main/webapp/META-INF/context.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/admin/index.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/admin/index.html deleted file mode 100644 index 939b3a4dc2..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/admin/index.html +++ /dev/null @@ -1,23 +0,0 @@ -<#include "../template/header.html"> - -

Admin (${subject.name})

- -

Actions

- - - - -<#include "../template/footer.html"> \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/error/unauthorized.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/error/unauthorized.html deleted file mode 100644 index 7f989ea5b1..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/error/unauthorized.html +++ /dev/null @@ -1,5 +0,0 @@ -<#include "../template/header.html"> - -

Unauthorized

- -<#include "../template/footer.html"> \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/detail.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/detail.html deleted file mode 100644 index 74f63b494b..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/detail.html +++ /dev/null @@ -1,136 +0,0 @@ -<#include "../template/header.html"> - -

${latest.description}

- -

Plugin Informations

- - - - - - - - - - - - - - - - - - - - - - - <#if latest.url??> - - - - - - <#if latest.wiki??> - - - - - -
Name${latest.name}
Category - <#if latest.category??> - ${latest.category} - <#else> - Miscellaneous - -
GroupId${latest.groupId}
ArtifactId${latest.artifactId}
Author${latest.author}
URL - - ${latest.url} - -
Wiki - - ${latest.wiki} - -
- -

 

- -<#if latest.screenshots??> - - - - -

 

- - - -

Plugin Versions

- -
-<#if versions?has_content> - <#list versions as versionWrapper> - <#assign version=versionWrapper.plugin> -

${version.version}

-
-

${version.description}

- <#if version.condition??> -

Conditions

-
    - <#if version.condition.minVersion??> -
  • Minimum Version: ${version.condition.minVersion}
  • - - <#if version.condition.os??> -
  • - Operatingsystems: - <#list version.condition.os as os> - ${os}<#if os_has_next>, - -
  • - - <#if version.condition.arch??> -
  • Architecture: ${version.condition.arch}
  • - -
- - <#if versionWrapper.compareUrl??> - - compare - - -
- -<#else> - Plugin not yet released - -
- -

 

- -Overview - - - -<#include "../template/footer.html"> \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/index.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/index.html deleted file mode 100644 index 50ba3625de..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/index.html +++ /dev/null @@ -1,28 +0,0 @@ -<#include "../template/header.html"> - -
-<#list categories as category> -
-

${category.name}

-
- <#list category.plugins as plugin> -

${plugin.name}

-
- ${plugin.description}
- more -
- -
-
- -
- - - -<#include "../template/footer.html"> \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/login.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/login.html deleted file mode 100644 index a5842ab7cf..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/page/login.html +++ /dev/null @@ -1,28 +0,0 @@ -<#include "../template/header.html"> - -
- - - - - - - - - - -
- - - -
- - - -
- - - -
- -<#include "../template/footer.html"> \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/footer.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/footer.html deleted file mode 100644 index d511f70a38..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/footer.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - -
-
-
-

© Sebastian Sdorra

-
-
-
- - - - - - - diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/header.html b/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/header.html deleted file mode 100644 index a1817abde0..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/ftl/template/header.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - SCM-Manager Plugin-Backend - - - - - - - - - - - - - - - <#if configuration.trackingCode??> - - - - -
-
-
- - -
-
-
-
-
-
-
-
-

${title}

-
- <#if error??> -
${error}
- -
- - diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/sun-web.xml b/scm-plugin-backend/src/main/webapp/WEB-INF/sun-web.xml deleted file mode 100644 index 77cc951e5d..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/sun-web.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - /scm-plugin-backend - - - - Keep a copy of the generated servlet class' java code. - - - diff --git a/scm-plugin-backend/src/main/webapp/WEB-INF/web.xml b/scm-plugin-backend/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 74529d06ae..0000000000 --- a/scm-plugin-backend/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - sonia.scm.plugin.BackendContextListener - - - - guiceFilter - com.google.inject.servlet.GuiceFilter - - - - guiceFilter - /* - - - - redirect.html - - - - 30 - - - - Restrict XHTML Documents - - XHTML - *.ftl - - - none - - - - diff --git a/scm-plugin-backend/src/main/webapp/template/css/custom.css b/scm-plugin-backend/src/main/webapp/template/css/custom.css deleted file mode 100644 index 2c8e6404de..0000000000 --- a/scm-plugin-backend/src/main/webapp/template/css/custom.css +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 - * - */ -h3.ui-accordion-header { - padding-bottom: 0 !important; -} \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/2cl.png b/scm-plugin-backend/src/main/webapp/template/css/images/2cl.png deleted file mode 100644 index def0bcd666..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/2cl.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/2cr.png b/scm-plugin-backend/src/main/webapp/template/css/images/2cr.png deleted file mode 100644 index 2aed4f91ea..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/2cr.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/arrow-down.png b/scm-plugin-backend/src/main/webapp/template/css/images/arrow-down.png deleted file mode 100644 index 9a96cb9eba..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/arrow-down.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/arrow-right.png b/scm-plugin-backend/src/main/webapp/template/css/images/arrow-right.png deleted file mode 100644 index bfab22784e..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/arrow-right.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/bg-texture.png b/scm-plugin-backend/src/main/webapp/template/css/images/bg-texture.png deleted file mode 100644 index f2c44bc3fd..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/bg-texture.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/gradient-overlay.png b/scm-plugin-backend/src/main/webapp/template/css/images/gradient-overlay.png deleted file mode 100644 index 317487f263..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/gradient-overlay.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/load.gif b/scm-plugin-backend/src/main/webapp/template/css/images/load.gif deleted file mode 100644 index d84f653789..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/load.gif and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-32x32.png b/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-32x32.png deleted file mode 100644 index da730a0dc6..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-32x32.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-icon.png b/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-icon.png deleted file mode 100644 index 4a0e38ccd1..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/portfolio-icon.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/css/images/rss-icon.png b/scm-plugin-backend/src/main/webapp/template/css/images/rss-icon.png deleted file mode 100644 index ba8105d700..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/css/images/rss-icon.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/blank.gif b/scm-plugin-backend/src/main/webapp/template/fancybox/blank.gif deleted file mode 100755 index 35d42e808f..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/blank.gif and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_close.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_close.png deleted file mode 100755 index 07035307ad..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_close.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_loading.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_loading.png deleted file mode 100755 index 2503017960..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_loading.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_left.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_left.png deleted file mode 100755 index ebaa6a4fd3..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_left.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_right.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_right.png deleted file mode 100755 index 873294e969..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_nav_right.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_e.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_e.png deleted file mode 100755 index 2eda089364..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_e.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_n.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_n.png deleted file mode 100755 index 69aa10e233..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_n.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_ne.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_ne.png deleted file mode 100755 index 79f6980a3b..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_ne.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_nw.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_nw.png deleted file mode 100755 index 7182cd938a..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_nw.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_s.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_s.png deleted file mode 100755 index d8858bfb78..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_s.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_se.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_se.png deleted file mode 100755 index 541e3ffd3e..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_se.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_sw.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_sw.png deleted file mode 100755 index b451689fa7..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_sw.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_w.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_w.png deleted file mode 100755 index 8a4e4a887f..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_shadow_w.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_left.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_left.png deleted file mode 100755 index 6049223d1e..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_left.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_main.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_main.png deleted file mode 100755 index 8044271f29..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_main.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_over.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_over.png deleted file mode 100755 index d9f458f4bb..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_over.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_right.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_right.png deleted file mode 100755 index e36d9db2a7..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancy_title_right.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-x.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-x.png deleted file mode 100755 index c2130f8698..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-x.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-y.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-y.png deleted file mode 100755 index 7ef399b990..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox-y.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox.png b/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox.png deleted file mode 100755 index 65e14f68fd..0000000000 Binary files a/scm-plugin-backend/src/main/webapp/template/fancybox/fancybox.png and /dev/null differ diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.easing-1.3.pack.js b/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.easing-1.3.pack.js deleted file mode 100755 index 9028179e7b..0000000000 --- a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.easing-1.3.pack.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ - * - * Uses the built in easing capabilities added In jQuery 1.1 - * to offer multiple easing options - * - * TERMS OF USE - jQuery Easing - * - * Open source under the BSD License. - * - * Copyright © 2008 George McGinley Smith - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 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. - * - * Neither the name of the author nor the names of 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 - * COPYRIGHT OWNER 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. - * -*/ - -// t: current time, b: begInnIng value, c: change In value, d: duration -eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t')[0], { prop: 0 }), - - isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest, - - /* - * Private methods - */ - - _abort = function() { - loading.hide(); - - imgPreloader.onerror = imgPreloader.onload = null; - - if (ajaxLoader) { - ajaxLoader.abort(); - } - - tmp.empty(); - }, - - _error = function() { - if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) { - loading.hide(); - busy = false; - return; - } - - selectedOpts.titleShow = false; - - selectedOpts.width = 'auto'; - selectedOpts.height = 'auto'; - - tmp.html( '

The requested content cannot be loaded.
Please try again later.

' ); - - _process_inline(); - }, - - _start = function() { - var obj = selectedArray[ selectedIndex ], - href, - type, - title, - str, - emb, - ret; - - _abort(); - - selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox'))); - - ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts); - - if (ret === false) { - busy = false; - return; - } else if (typeof ret == 'object') { - selectedOpts = $.extend(selectedOpts, ret); - } - - title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || ''; - - if (obj.nodeName && !selectedOpts.orig) { - selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); - } - - if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) { - title = selectedOpts.orig.attr('alt'); - } - - href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null; - - if ((/^(?:javascript)/i).test(href) || href == '#') { - href = null; - } - - if (selectedOpts.type) { - type = selectedOpts.type; - - if (!href) { - href = selectedOpts.content; - } - - } else if (selectedOpts.content) { - type = 'html'; - - } else if (href) { - if (href.match(imgRegExp)) { - type = 'image'; - - } else if (href.match(swfRegExp)) { - type = 'swf'; - - } else if ($(obj).hasClass("iframe")) { - type = 'iframe'; - - } else if (href.indexOf("#") === 0) { - type = 'inline'; - - } else { - type = 'ajax'; - } - } - - if (!type) { - _error(); - return; - } - - if (type == 'inline') { - obj = href.substr(href.indexOf("#")); - type = $(obj).length > 0 ? 'inline' : 'ajax'; - } - - selectedOpts.type = type; - selectedOpts.href = href; - selectedOpts.title = title; - - if (selectedOpts.autoDimensions) { - if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') { - selectedOpts.width = 'auto'; - selectedOpts.height = 'auto'; - } else { - selectedOpts.autoDimensions = false; - } - } - - if (selectedOpts.modal) { - selectedOpts.overlayShow = true; - selectedOpts.hideOnOverlayClick = false; - selectedOpts.hideOnContentClick = false; - selectedOpts.enableEscapeButton = false; - selectedOpts.showCloseButton = false; - } - - selectedOpts.padding = parseInt(selectedOpts.padding, 10); - selectedOpts.margin = parseInt(selectedOpts.margin, 10); - - tmp.css('padding', (selectedOpts.padding + selectedOpts.margin)); - - $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { - $(this).replaceWith(content.children()); - }); - - switch (type) { - case 'html' : - tmp.html( selectedOpts.content ); - _process_inline(); - break; - - case 'inline' : - if ( $(obj).parent().is('#fancybox-content') === true) { - busy = false; - return; - } - - $('
') - .hide() - .insertBefore( $(obj) ) - .bind('fancybox-cleanup', function() { - $(this).replaceWith(content.children()); - }).bind('fancybox-cancel', function() { - $(this).replaceWith(tmp.children()); - }); - - $(obj).appendTo(tmp); - - _process_inline(); - break; - - case 'image': - busy = false; - - $.fancybox.showActivity(); - - imgPreloader = new Image(); - - imgPreloader.onerror = function() { - _error(); - }; - - imgPreloader.onload = function() { - busy = true; - - imgPreloader.onerror = imgPreloader.onload = null; - - _process_image(); - }; - - imgPreloader.src = href; - break; - - case 'swf': - selectedOpts.scrolling = 'no'; - - str = ''; - emb = ''; - - $.each(selectedOpts.swf, function(name, val) { - str += ''; - emb += ' ' + name + '="' + val + '"'; - }); - - str += ''; - - tmp.html(str); - - _process_inline(); - break; - - case 'ajax': - busy = false; - - $.fancybox.showActivity(); - - selectedOpts.ajax.win = selectedOpts.ajax.success; - - ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, { - url : href, - data : selectedOpts.ajax.data || {}, - error : function(XMLHttpRequest, textStatus, errorThrown) { - if ( XMLHttpRequest.status > 0 ) { - _error(); - } - }, - success : function(data, textStatus, XMLHttpRequest) { - var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; - if (o.status == 200) { - if ( typeof selectedOpts.ajax.win == 'function' ) { - ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); - - if (ret === false) { - loading.hide(); - return; - } else if (typeof ret == 'string' || typeof ret == 'object') { - data = ret; - } - } - - tmp.html( data ); - _process_inline(); - } - } - })); - - break; - - case 'iframe': - _show(); - break; - } - }, - - _process_inline = function() { - var - w = selectedOpts.width, - h = selectedOpts.height; - - if (w.toString().indexOf('%') > -1) { - w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px'; - - } else { - w = w == 'auto' ? 'auto' : w + 'px'; - } - - if (h.toString().indexOf('%') > -1) { - h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px'; - - } else { - h = h == 'auto' ? 'auto' : h + 'px'; - } - - tmp.wrapInner('
'); - - selectedOpts.width = tmp.width(); - selectedOpts.height = tmp.height(); - - _show(); - }, - - _process_image = function() { - selectedOpts.width = imgPreloader.width; - selectedOpts.height = imgPreloader.height; - - $("").attr({ - 'id' : 'fancybox-img', - 'src' : imgPreloader.src, - 'alt' : selectedOpts.title - }).appendTo( tmp ); - - _show(); - }, - - _show = function() { - var pos, equal; - - loading.hide(); - - if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { - $.event.trigger('fancybox-cancel'); - - busy = false; - return; - } - - busy = true; - - $(content.add( overlay )).unbind(); - - $(window).unbind("resize.fb scroll.fb"); - $(document).unbind('keydown.fb'); - - if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') { - wrap.css('height', wrap.height()); - } - - currentArray = selectedArray; - currentIndex = selectedIndex; - currentOpts = selectedOpts; - - if (currentOpts.overlayShow) { - overlay.css({ - 'background-color' : currentOpts.overlayColor, - 'opacity' : currentOpts.overlayOpacity, - 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto', - 'height' : $(document).height() - }); - - if (!overlay.is(':visible')) { - if (isIE6) { - $('select:not(#fancybox-tmp select)').filter(function() { - return this.style.visibility !== 'hidden'; - }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() { - this.style.visibility = 'inherit'; - }); - } - - overlay.show(); - } - } else { - overlay.hide(); - } - - final_pos = _get_zoom_to(); - - _process_title(); - - if (wrap.is(":visible")) { - $( close.add( nav_left ).add( nav_right ) ).hide(); - - pos = wrap.position(), - - start_pos = { - top : pos.top, - left : pos.left, - width : wrap.width(), - height : wrap.height() - }; - - equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); - - content.fadeTo(currentOpts.changeFade, 0.3, function() { - var finish_resizing = function() { - content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish); - }; - - $.event.trigger('fancybox-change'); - - content - .empty() - .removeAttr('filter') - .css({ - 'border-width' : currentOpts.padding, - 'width' : final_pos.width - currentOpts.padding * 2, - 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 - }); - - if (equal) { - finish_resizing(); - - } else { - fx.prop = 0; - - $(fx).animate({prop: 1}, { - duration : currentOpts.changeSpeed, - easing : currentOpts.easingChange, - step : _draw, - complete : finish_resizing - }); - } - }); - - return; - } - - wrap.removeAttr("style"); - - content.css('border-width', currentOpts.padding); - - if (currentOpts.transitionIn == 'elastic') { - start_pos = _get_zoom_from(); - - content.html( tmp.contents() ); - - wrap.show(); - - if (currentOpts.opacity) { - final_pos.opacity = 0; - } - - fx.prop = 0; - - $(fx).animate({prop: 1}, { - duration : currentOpts.speedIn, - easing : currentOpts.easingIn, - step : _draw, - complete : _finish - }); - - return; - } - - if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { - title.show(); - } - - content - .css({ - 'width' : final_pos.width - currentOpts.padding * 2, - 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 - }) - .html( tmp.contents() ); - - wrap - .css(final_pos) - .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); - }, - - _format_title = function(title) { - if (title && title.length) { - if (currentOpts.titlePosition == 'float') { - return '
' + title + '
'; - } - - return '
' + title + '
'; - } - - return false; - }, - - _process_title = function() { - titleStr = currentOpts.title || ''; - titleHeight = 0; - - title - .empty() - .removeAttr('style') - .removeClass(); - - if (currentOpts.titleShow === false) { - title.hide(); - return; - } - - titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr); - - if (!titleStr || titleStr === '') { - title.hide(); - return; - } - - title - .addClass('fancybox-title-' + currentOpts.titlePosition) - .html( titleStr ) - .appendTo( 'body' ) - .show(); - - switch (currentOpts.titlePosition) { - case 'inside': - title - .css({ - 'width' : final_pos.width - (currentOpts.padding * 2), - 'marginLeft' : currentOpts.padding, - 'marginRight' : currentOpts.padding - }); - - titleHeight = title.outerHeight(true); - - title.appendTo( outer ); - - final_pos.height += titleHeight; - break; - - case 'over': - title - .css({ - 'marginLeft' : currentOpts.padding, - 'width' : final_pos.width - (currentOpts.padding * 2), - 'bottom' : currentOpts.padding - }) - .appendTo( outer ); - break; - - case 'float': - title - .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1) - .appendTo( wrap ); - break; - - default: - title - .css({ - 'width' : final_pos.width - (currentOpts.padding * 2), - 'paddingLeft' : currentOpts.padding, - 'paddingRight' : currentOpts.padding - }) - .appendTo( wrap ); - break; - } - - title.hide(); - }, - - _set_navigation = function() { - if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) { - $(document).bind('keydown.fb', function(e) { - if (e.keyCode == 27 && currentOpts.enableEscapeButton) { - e.preventDefault(); - $.fancybox.close(); - - } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') { - e.preventDefault(); - $.fancybox[ e.keyCode == 37 ? 'prev' : 'next'](); - } - }); - } - - if (!currentOpts.showNavArrows) { - nav_left.hide(); - nav_right.hide(); - return; - } - - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { - nav_left.show(); - } - - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { - nav_right.show(); - } - }, - - _finish = function () { - if (!$.support.opacity) { - content.get(0).style.removeAttribute('filter'); - wrap.get(0).style.removeAttribute('filter'); - } - - if (selectedOpts.autoDimensions) { - content.css('height', 'auto'); - } - - wrap.css('height', 'auto'); - - if (titleStr && titleStr.length) { - title.show(); - } - - if (currentOpts.showCloseButton) { - close.show(); - } - - _set_navigation(); - - if (currentOpts.hideOnContentClick) { - content.bind('click', $.fancybox.close); - } - - if (currentOpts.hideOnOverlayClick) { - overlay.bind('click', $.fancybox.close); - } - - $(window).bind("resize.fb", $.fancybox.resize); - - if (currentOpts.centerOnScroll) { - $(window).bind("scroll.fb", $.fancybox.center); - } - - if (currentOpts.type == 'iframe') { - $('').appendTo(content); - } - - wrap.show(); - - busy = false; - - $.fancybox.center(); - - currentOpts.onComplete(currentArray, currentIndex, currentOpts); - - _preload_images(); - }, - - _preload_images = function() { - var href, - objNext; - - if ((currentArray.length -1) > currentIndex) { - href = currentArray[ currentIndex + 1 ].href; - - if (typeof href !== 'undefined' && href.match(imgRegExp)) { - objNext = new Image(); - objNext.src = href; - } - } - - if (currentIndex > 0) { - href = currentArray[ currentIndex - 1 ].href; - - if (typeof href !== 'undefined' && href.match(imgRegExp)) { - objNext = new Image(); - objNext.src = href; - } - } - }, - - _draw = function(pos) { - var dim = { - width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10), - height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10), - - top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10), - left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10) - }; - - if (typeof final_pos.opacity !== 'undefined') { - dim.opacity = pos < 0.5 ? 0.5 : pos; - } - - wrap.css(dim); - - content.css({ - 'width' : dim.width - currentOpts.padding * 2, - 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2 - }); - }, - - _get_viewport = function() { - return [ - $(window).width() - (currentOpts.margin * 2), - $(window).height() - (currentOpts.margin * 2), - $(document).scrollLeft() + currentOpts.margin, - $(document).scrollTop() + currentOpts.margin - ]; - }, - - _get_zoom_to = function () { - var view = _get_viewport(), - to = {}, - resize = currentOpts.autoScale, - double_padding = currentOpts.padding * 2, - ratio; - - if (currentOpts.width.toString().indexOf('%') > -1) { - to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10); - } else { - to.width = currentOpts.width + double_padding; - } - - if (currentOpts.height.toString().indexOf('%') > -1) { - to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10); - } else { - to.height = currentOpts.height + double_padding; - } - - if (resize && (to.width > view[0] || to.height > view[1])) { - if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { - ratio = (currentOpts.width ) / (currentOpts.height ); - - if ((to.width ) > view[0]) { - to.width = view[0]; - to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10); - } - - if ((to.height) > view[1]) { - to.height = view[1]; - to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10); - } - - } else { - to.width = Math.min(to.width, view[0]); - to.height = Math.min(to.height, view[1]); - } - } - - to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10); - to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10); - - return to; - }, - - _get_obj_pos = function(obj) { - var pos = obj.offset(); - - pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0; - pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0; - - pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0; - pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0; - - pos.width = obj.width(); - pos.height = obj.height(); - - return pos; - }, - - _get_zoom_from = function() { - var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, - from = {}, - pos, - view; - - if (orig && orig.length) { - pos = _get_obj_pos(orig); - - from = { - width : pos.width + (currentOpts.padding * 2), - height : pos.height + (currentOpts.padding * 2), - top : pos.top - currentOpts.padding - 20, - left : pos.left - currentOpts.padding - 20 - }; - - } else { - view = _get_viewport(); - - from = { - width : currentOpts.padding * 2, - height : currentOpts.padding * 2, - top : parseInt(view[3] + view[1] * 0.5, 10), - left : parseInt(view[2] + view[0] * 0.5, 10) - }; - } - - return from; - }, - - _animate_loading = function() { - if (!loading.is(':visible')){ - clearInterval(loadingTimer); - return; - } - - $('div', loading).css('top', (loadingFrame * -40) + 'px'); - - loadingFrame = (loadingFrame + 1) % 12; - }; - - /* - * Public methods - */ - - $.fn.fancybox = function(options) { - if (!$(this).length) { - return this; - } - - $(this) - .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))) - .unbind('click.fb') - .bind('click.fb', function(e) { - e.preventDefault(); - - if (busy) { - return; - } - - busy = true; - - $(this).blur(); - - selectedArray = []; - selectedIndex = 0; - - var rel = $(this).attr('rel') || ''; - - if (!rel || rel == '' || rel === 'nofollow') { - selectedArray.push(this); - - } else { - selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); - selectedIndex = selectedArray.index( this ); - } - - _start(); - - return; - }); - - return this; - }; - - $.fancybox = function(obj) { - var opts; - - if (busy) { - return; - } - - busy = true; - opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; - - selectedArray = []; - selectedIndex = parseInt(opts.index, 10) || 0; - - if ($.isArray(obj)) { - for (var i = 0, j = obj.length; i < j; i++) { - if (typeof obj[i] == 'object') { - $(obj[i]).data('fancybox', $.extend({}, opts, obj[i])); - } else { - obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts)); - } - } - - selectedArray = jQuery.merge(selectedArray, obj); - - } else { - if (typeof obj == 'object') { - $(obj).data('fancybox', $.extend({}, opts, obj)); - } else { - obj = $({}).data('fancybox', $.extend({content : obj}, opts)); - } - - selectedArray.push(obj); - } - - if (selectedIndex > selectedArray.length || selectedIndex < 0) { - selectedIndex = 0; - } - - _start(); - }; - - $.fancybox.showActivity = function() { - clearInterval(loadingTimer); - - loading.show(); - loadingTimer = setInterval(_animate_loading, 66); - }; - - $.fancybox.hideActivity = function() { - loading.hide(); - }; - - $.fancybox.next = function() { - return $.fancybox.pos( currentIndex + 1); - }; - - $.fancybox.prev = function() { - return $.fancybox.pos( currentIndex - 1); - }; - - $.fancybox.pos = function(pos) { - if (busy) { - return; - } - - pos = parseInt(pos); - - selectedArray = currentArray; - - if (pos > -1 && pos < currentArray.length) { - selectedIndex = pos; - _start(); - - } else if (currentOpts.cyclic && currentArray.length > 1) { - selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1; - _start(); - } - - return; - }; - - $.fancybox.cancel = function() { - if (busy) { - return; - } - - busy = true; - - $.event.trigger('fancybox-cancel'); - - _abort(); - - selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); - - busy = false; - }; - - // Note: within an iframe use - parent.$.fancybox.close(); - $.fancybox.close = function() { - if (busy || wrap.is(':hidden')) { - return; - } - - busy = true; - - if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { - busy = false; - return; - } - - _abort(); - - $(close.add( nav_left ).add( nav_right )).hide(); - - $(content.add( overlay )).unbind(); - - $(window).unbind("resize.fb scroll.fb"); - $(document).unbind('keydown.fb'); - - content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank'); - - if (currentOpts.titlePosition !== 'inside') { - title.empty(); - } - - wrap.stop(); - - function _cleanup() { - overlay.fadeOut('fast'); - - title.empty().hide(); - wrap.hide(); - - $.event.trigger('fancybox-cleanup'); - - content.empty(); - - currentOpts.onClosed(currentArray, currentIndex, currentOpts); - - currentArray = selectedOpts = []; - currentIndex = selectedIndex = 0; - currentOpts = selectedOpts = {}; - - busy = false; - } - - if (currentOpts.transitionOut == 'elastic') { - start_pos = _get_zoom_from(); - - var pos = wrap.position(); - - final_pos = { - top : pos.top , - left : pos.left, - width : wrap.width(), - height : wrap.height() - }; - - if (currentOpts.opacity) { - final_pos.opacity = 1; - } - - title.empty().hide(); - - fx.prop = 1; - - $(fx).animate({ prop: 0 }, { - duration : currentOpts.speedOut, - easing : currentOpts.easingOut, - step : _draw, - complete : _cleanup - }); - - } else { - wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup); - } - }; - - $.fancybox.resize = function() { - if (overlay.is(':visible')) { - overlay.css('height', $(document).height()); - } - - $.fancybox.center(true); - }; - - $.fancybox.center = function() { - var view, align; - - if (busy) { - return; - } - - align = arguments[0] === true ? 1 : 0; - view = _get_viewport(); - - if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) { - return; - } - - wrap - .stop() - .animate({ - 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)), - 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding)) - }, typeof arguments[0] == 'number' ? arguments[0] : 200); - }; - - $.fancybox.init = function() { - if ($("#fancybox-wrap").length) { - return; - } - - $('body').append( - tmp = $('
'), - loading = $('
'), - overlay = $('
'), - wrap = $('
') - ); - - outer = $('
') - .append('
') - .appendTo( wrap ); - - outer.append( - content = $('
'), - close = $(''), - title = $('
'), - - nav_left = $(''), - nav_right = $('') - ); - - close.click($.fancybox.close); - loading.click($.fancybox.cancel); - - nav_left.click(function(e) { - e.preventDefault(); - $.fancybox.prev(); - }); - - nav_right.click(function(e) { - e.preventDefault(); - $.fancybox.next(); - }); - - if ($.fn.mousewheel) { - wrap.bind('mousewheel.fb', function(e, delta) { - if (busy) { - e.preventDefault(); - - } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) { - e.preventDefault(); - $.fancybox[ delta > 0 ? 'prev' : 'next'](); - } - }); - } - - if (!$.support.opacity) { - wrap.addClass('fancybox-ie'); - } - - if (isIE6) { - loading.addClass('fancybox-ie6'); - wrap.addClass('fancybox-ie6'); - - $('').prependTo(outer); - } - }; - - $.fn.fancybox.defaults = { - padding : 10, - margin : 40, - opacity : false, - modal : false, - cyclic : false, - scrolling : 'auto', // 'auto', 'yes' or 'no' - - width : 560, - height : 340, - - autoScale : true, - autoDimensions : true, - centerOnScroll : false, - - ajax : {}, - swf : { wmode: 'transparent' }, - - hideOnOverlayClick : true, - hideOnContentClick : false, - - overlayShow : true, - overlayOpacity : 0.7, - overlayColor : '#777', - - titleShow : true, - titlePosition : 'float', // 'float', 'outside', 'inside' or 'over' - titleFormat : null, - titleFromAlt : false, - - transitionIn : 'fade', // 'elastic', 'fade' or 'none' - transitionOut : 'fade', // 'elastic', 'fade' or 'none' - - speedIn : 300, - speedOut : 300, - - changeSpeed : 300, - changeFade : 'fast', - - easingIn : 'swing', - easingOut : 'swing', - - showCloseButton : true, - showNavArrows : true, - enableEscapeButton : true, - enableKeyboardNav : true, - - onStart : function(){}, - onCancel : function(){}, - onComplete : function(){}, - onCleanup : function(){}, - onClosed : function(){}, - onError : function(){} - }; - - $(document).ready(function() { - $.fancybox.init(); - }); - -})(jQuery); \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.fancybox-1.3.4.pack.js b/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.fancybox-1.3.4.pack.js deleted file mode 100755 index 1373ed0838..0000000000 --- a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.fancybox-1.3.4.pack.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * FancyBox - jQuery Plugin - * Simple and fancy lightbox alternative - * - * Examples and documentation at: http://fancybox.net - * - * Copyright (c) 2008 - 2010 Janis Skarnelis - * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. - * - * Version: 1.3.4 (11/11/2010) - * Requires: jQuery v1.3+ - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - */ - -;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("
")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('

The requested content cannot be loaded.
Please try again later.

'); -F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)|| -c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick= -false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('
').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel", -function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='';P="";b.each(e.swf,function(x,H){C+='';P+=" "+x+'="'+H+'"'});C+='";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win== -"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('
');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor, -opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length? -d.titlePosition=="float"?'
'+s+'
':'
'+s+"
":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding}); -y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height== -i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents()); -f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode== -37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto"); -s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('').appendTo(j); -f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c); -j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type== -"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"), -10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)}; -b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k= -0,C=a.length;ko.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+ -1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h= -true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1; -b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5- -d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('
'),t=b('
'),u=b('
'),f=b('
'));D=b('
').append('
').appendTo(f); -D.append(j=b('
'),E=b(''),n=b('
'),z=b(''),A=b(''));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()}); -b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('').prependTo(D)}}}; -b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing", -easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery); \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.mousewheel-3.0.4.pack.js b/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.mousewheel-3.0.4.pack.js deleted file mode 100755 index cb66588e29..0000000000 --- a/scm-plugin-backend/src/main/webapp/template/fancybox/jquery.mousewheel-3.0.4.pack.js +++ /dev/null @@ -1,14 +0,0 @@ -/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) -* Licensed under the MIT License (LICENSE.txt). -* -* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. -* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. -* Thanks to: Seamus Leahy for adding deltaX and deltaY -* -* Version: 3.0.4 -* -* Requires: 1.2.2+ -*/ - -(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a= -f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery); \ No newline at end of file diff --git a/scm-plugin-backend/src/main/webapp/template/js/html5.js b/scm-plugin-backend/src/main/webapp/template/js/html5.js deleted file mode 100644 index 3c2389a6d5..0000000000 --- a/scm-plugin-backend/src/main/webapp/template/js/html5.js +++ /dev/null @@ -1,5 +0,0 @@ -// html5shiv MIT @rem remysharp.com/html5-enabling-script -// iepp v1.5.1 MIT @jon_neal iecss.com/print-protector -/*@cc_on(function(p,e){var q=e.createElement("div");q.innerHTML="i";q.childNodes.length!==1&&function(){function r(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var c=s[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;r(a,b)}}function t(a,b){for(var c=new RegExp("\\b("+m+")\\b(?!.*[;}])","gi"),d=function(k){return".iepp_"+k},h=-1;++h\\s*$","i");i.innerHTML=a.outerHTML.replace(/\r|\n/g," ").replace(c,a.currentStyle.display=="block"?"":"");c=i.childNodes[0];c.className+=" iepp_"+ -d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[0])}t(e.styleSheets,"all")});p.attachEvent("onafterprint",function(){for(var a=-1,b;++a").text( options.errorTitle ) - ).append( - $("

").text( options.errorMsg ) - ); - } - - function renderFeeds(xml){ - var ul = $('