move scm-plugin-backend to its own repository at https://bitbucket.org/sdorra/scm-plugin-backend

This commit is contained in:
Sebastian Sdorra
2014-10-10 19:50:48 +02:00
parent b465e4b18b
commit 9aa0ce46f5
104 changed files with 0 additions and 9578 deletions

View File

@@ -72,7 +72,6 @@
<module>scm-dao-xml</module>
<module>scm-webapp</module>
<module>scm-server</module>
<module>scm-plugin-backend</module>
<module>scm-clients</module>
</modules>

View File

@@ -1,162 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>scm</artifactId>
<groupId>sonia.scm</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm</groupId>
<artifactId>scm-plugin-backend</artifactId>
<packaging>war</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- fix javadoc -->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<dependency>
<groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache.version}</version>
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<!-- security -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-guice</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>${shiro.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
<configuration>
<header>http://download.scm-manager.org/licenses/mvn-license.txt</header>
<includes>
<include>src/**</include>
<include>**/test/**</include>
</includes>
<excludes>
<exclude>target/**</exclude>
<exclude>.hg/**</exclude>
<exclude>**/html5.js</exclude>
<exclude>**/*.html</exclude>
<exclude>**/fancybox/**</exclude>
</excludes>
<strictCheck>true</strictCheck>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<stopPort>8004</stopPort>
<stopKey>STOP</stopKey>
<webApp>
<contextPath>/scm-plugin-backend</contextPath>
</webApp>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
<finalName>scm-plugin-backend</finalName>
</build>
<properties>
<ehcache.version>2.6.6</ehcache.version>
</properties>
</project>

View File

@@ -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<PluginBackendListener> 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<PluginInformation> plugins)
{
for (PluginBackendListener listener : listenerSet)
{
listener.addedNewPlugins(plugins);
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Set<PluginBackendListener> listenerSet =
new HashSet<PluginBackendListener>();
}

View File

@@ -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;
}

View File

@@ -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<File> getDirectories()
{
return directories;
}
/**
* Method description
*
*
* @return
*/
public Set<String> getExcludes()
{
return excludes;
}
/**
* Method description
*
*
* @return
*/
public ProxyConfiguration getNewsConfiguration()
{
return newsConfiguration;
}
/**
* Method description
*
*
* @return
*/
public Set<PluginRepository> 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<File> directories;
/** Field description */
@XmlElement(name = "exclude")
@XmlElementWrapper(name = "excludes")
private Set<String> 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<PluginRepository> repositories;
/** Field description */
@XmlElement(name = "scann-interval")
@XmlJavaTypeAdapter(XmlIntervalAdapter.class)
private Long scannInterval;
/** Field description */
@XmlElement(name = "tracking-code")
private String trackingCode;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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<PluginInformation>(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<PluginInformation> getPlugins()
{
if (plugins == null)
{
plugins = new TreeSet<PluginInformation>();
}
return plugins;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param plugins
*/
public void setPlugins(SortedSet<PluginInformation> plugins)
{
this.plugins = plugins;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String name;
/** Field description */
private SortedSet<PluginInformation> plugins;
}

View File

@@ -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<Category>
{
/** 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());
}
}

View File

@@ -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<PluginInformation> 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<File> 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<String> getExcludes()
{
return configuration.getExcludes();
}
/**
* Method description
*
*
* @return
*/
@Override
public List<PluginInformation> getPlugins()
{
return pluginStore.getPlugins();
}
/**
* Method description
*
*
* @param predicate
*
* @return
*/
@Override
public List<PluginInformation> getPlugins(Predicate<PluginInformation> predicate)
{
List<PluginInformation> filteredPlugins =
new ArrayList<PluginInformation>();
for (PluginInformation plugin : pluginStore)
{
if (predicate.apply(plugin))
{
filteredPlugins.add(plugin);
}
}
return filteredPlugins;
}
/**
* Method description
*
*
* @return
*/
@Override
public Set<File> 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<File> scannedFiles = new HashSet<File>();
/** Field description */
private JAXBContext storeContext;
/** Field description */
private File storeFile;
}

View File

@@ -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;
}

View File

@@ -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<PluginBackendListener> listeners);
/**
* Method description
*
*
*
* @param plugins
*/
public void addPlugins(PluginInformation... plugins);
/**
* Method description
*
*
* @param plugins
*/
public void addPlugins(Collection<PluginInformation> plugins);
/**
* Method description
*
*
* @param scannedFiles
*/
public void addScannedFiles(Collection<File> 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<String> getExcludes();
/**
* Method description
*
*
* @return
*/
public List<PluginInformation> getPlugins();
/**
* Method description
*
* @param predicate
*
* @return
*/
public List<PluginInformation> getPlugins(
Predicate<PluginInformation> predicate);
/**
* Method description
*
*
* @return
*/
public Set<File> getScannedFiles();
}

View File

@@ -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<PluginInformation> plugins);
}

View File

@@ -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<PluginInformation>
{
/**
* 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<PluginInformation> iterator()
{
return plugins.iterator();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<PluginInformation> getPlugins()
{
return plugins;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param plugins
*/
public void setPlugins(List<PluginInformation> plugins)
{
this.plugins = plugins;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElement(name = "plugin")
@XmlElementWrapper(name = "plugins")
private List<PluginInformation> plugins = new ArrayList<PluginInformation>();
}

View File

@@ -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<PluginInformation>
{
/** 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());
}
}

View File

@@ -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<PluginInformation>
{
/** 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;
}
}

View File

@@ -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<PluginInformation> filterSameVersions(
List<PluginInformation> plugins)
{
List<PluginInformation> filteredPlugins =
new ArrayList<PluginInformation>();
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<PluginInformation> filterSnapshots(
List<PluginInformation> allVersions)
{
List<PluginInformation> filtered = new ArrayList<PluginInformation>();
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<PluginInformation> getFilteredPluginVersions(
PluginBackend backend, String groupId, String artifactId)
{
List<PluginInformation> 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<PluginInformation> getPluginVersions(
PluginBackend backend, final String groupId, final String artifactId)
{
List<PluginInformation> pluginVersions =
backend.getPlugins(new Predicate<PluginInformation>()
{
@Override
public boolean apply(PluginInformation plugin)
{
return groupId.equals(plugin.getGroupId())
&& artifactId.equals(plugin.getArtifactId());
}
});
return pluginVersions;
}
}

View File

@@ -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);
}
}
}

View File

@@ -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() {}
}

View File

@@ -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<UrlBuilder> 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<String, String> params = new HashMap<String, String>();
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);
}
}

View File

@@ -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<PluginInformation> 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;
}

View File

@@ -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<String>
{
/** 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;
}

View File

@@ -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<PluginInformation>
{
/** 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;
}
}

View File

@@ -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;
}

View File

@@ -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<String, Object> createVarMap(String title)
{
Map<String, Object> vars = new HashMap<String, Object>();
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;
}

View File

@@ -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<String, Object> 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;
}

View File

@@ -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<PluginInformation>
{
/** 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;
}

View File

@@ -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<PluginInformation> 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<PluginInformation> 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<PluginInformation> getNewestPlugins(
List<PluginInformation> plugins)
{
Collections.sort(plugins, PluginInformationComparator.INSTANCE);
Set<PluginInformation> pluginSet = new HashSet<PluginInformation>();
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;
}

View File

@@ -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<String, Object> env = createVarMap("Unauthorized");
return new Viewable(PAGE_UNAUTHORIZED, env);
}
}

View File

@@ -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<PluginInformation> 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<PluginDetailWrapper> detailList = createDetailList(latest,
pluginVersions);
Map<String, Object> 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<PluginDetailWrapper> createDetailList(PluginInformation latest,
List<PluginInformation> pluginVersions)
{
List<PluginDetailWrapper> detailList = new ArrayList<PluginDetailWrapper>();
Collections.sort(pluginVersions,
PluginInformationVersionComparator.INSTANCE);
Iterator<PluginInformation> 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;
}

View File

@@ -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<String, Object> 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<String, Object> vars = createVarMap("Login");
return new Viewable(PAGE_LOGIN, vars);
}
}

View File

@@ -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<Category> categories = getPluginOverview();
Map<String, Object> vars = createVarMap("Plugin Overview");
vars.put("categories", categories);
return new Viewable("/page/index", vars);
}
/**
* Method description
*
*
* @param categories
* @param plugin
*/
private void append(Map<String, Category> 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<Category> getPluginOverview()
{
List<PluginInformation> allPlugins = backend.getPlugins();
Collections.sort(allPlugins, PluginInformationComparator.INSTANCE);
String pid = "";
Map<String, Category> categoryMap = new HashMap<String, Category>();
for (PluginInformation p : allPlugins)
{
String currentPid = p.getGroupId().concat(":").concat(p.getArtifactId());
if (!currentPid.equals(pid))
{
pid = currentPid;
append(categoryMap, p);
}
}
List<Category> categories = new ArrayList<Category>(categoryMap.values());
Collections.sort(categories, CategoryNameComaparator.INSTANCE);
return categories;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private PluginBackend backend;
}

View File

@@ -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;
}

View File

@@ -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<String> 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;
}

View File

@@ -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<String> 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<String> excludes;
}

View File

@@ -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<File> scannedFiles = new HashSet<File>();
Set<PluginInformation> plugins = new HashSet<PluginInformation>();
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<File> scannedFiles,
Set<PluginInformation> 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<PluginInformation> 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;
}

View File

@@ -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();
}
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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);
}
}
}
}

View File

@@ -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;
}

View File

@@ -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<CacheManager>
{
/**
* 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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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<UrlBuilder> 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<UrlBuilder> urlBuilderSet;
}

View File

@@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!--
Document : ehcache.xml
Created on : October 14, 2010, 6:54 AM
Author : sdorra
Description:
Purpose of the document follows.
-->
<ehcache xmlns="http://ehcache.org/ehcache.xsd">
<!--
Sets the path to the directory where cache .data files are created.
If the path is a Java System Property it is replaced by
its value in the running VM.
The following properties are translated:
user.home - User's home directory
user.dir - User's current working directory
java.io.tmpdir - Default temp file path
-->
<diskStore path="java.io.tmpdir"/>
<!--
Default Cache configuration. These will applied to caches programmatically created through
the CacheManager.
The following attributes are required:
maxElementsInMemory - Sets the maximum number of objects that will be created in memory
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
element is never expired.
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
has reached the maxInMemory limit.
The following attributes are optional:
timeToIdleSeconds - Sets the time to idle for an element before it expires.
i.e. The maximum amount of time between accesses before an element expires
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that an Element can idle for infinity.
The default value is 0.
timeToLiveSeconds - Sets the time to live for an element before it expires.
i.e. The maximum time between creation time and when an element expires.
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that and Element can live for infinity.
The default value is 0.
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
The default value is false.
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
is 120 seconds.
-->
<defaultCache
maxElementsInMemory="20000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="1200"
timeToLiveSeconds="2400"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="2400"
/>
<cache
name="sonia.cache.plugin-backend"
maxElementsInMemory="20000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="1800"
timeToLiveSeconds="3600"
diskPersistent="false"
/>
<cache
name="sonia.cache.plugin-detail"
maxElementsInMemory="20000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="1800"
timeToLiveSeconds="3600"
diskPersistent="false"
/>
<!-- shiro -->
<!-- We want eternal="true" and no timeToIdle or timeToLive settings because Shiro manages session
expirations explicitly. If we set it to false and then set corresponding timeToIdle and timeToLive properties,
ehcache would evict sessions without Shiro's knowledge, which would cause many problems
(e.g. "My Shiro session timeout is 30 minutes - why isn't a session available after 2 minutes?"
Answer - ehcache expired it due to the timeToIdle property set to 120 seconds.)
diskPersistent=true since we want an enterprise session management feature - ability to use sessions after
even after a JVM restart. -->
<cache name="shiro-activeSessionCache"
maxElementsInMemory="10000"
overflowToDisk="true"
eternal="true"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="600"
/>
<cache name="org.apache.shiro.realm.text.PropertiesRealm-0-accounts"
maxElementsInMemory="1000"
eternal="true"
overflowToDisk="true"
/>
</ehcache>

View File

@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!--
Document : logback.xml
Created on : March 12, 2011, 11:34 AM
Author : sdorra
Description:
Purpose of the document follows.
-->
<configuration scan="true" scanPeriod="30 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are by default assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="sonia.scm" level="DEBUG" />
<logger name="sonia.scm.plugin.scanner.DefaultPluginScanner" level="INFO" />
<!-- trace logging -->
<logger name="org.apache.shiro" level="INFO" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<Context antiJARLocking="true" path="/scm-plugin-backend"/>

View File

@@ -1,23 +0,0 @@
<#include "../template/header.html">
<h2>Admin (${subject.name})</h2>
<h3>Actions</h3>
<ul id="actions">
<li>
<a rel="${contextPath}/admin/action/scann">Scann Directories</a>
</li>
</ul>
<script type="text/javascript">
$(document).ready(function(){
$('#actions a').click(function(){
var action = $(this).attr('rel');
$.post(action, function(text){
});
});
});
</script>
<#include "../template/footer.html">

View File

@@ -1,5 +0,0 @@
<#include "../template/header.html">
<h2>Unauthorized</h2>
<#include "../template/footer.html">

View File

@@ -1,136 +0,0 @@
<#include "../template/header.html">
<p>${latest.description}</p>
<h2>Plugin Informations</h2>
<table>
<tr>
<th>Name</th>
<td>${latest.name}</td>
</tr>
<tr>
<th>Category</th>
<td>
<#if latest.category??>
${latest.category}
<#else>
Miscellaneous
</#if>
</td>
</tr>
<tr>
<th>GroupId</th>
<td>${latest.groupId}</td>
</tr>
<tr>
<th>ArtifactId</th>
<td>${latest.artifactId}</td>
</tr>
<tr>
<th>Author</th>
<td>${latest.author}</td>
</tr>
<#if latest.url??>
<tr>
<th>URL</th>
<td>
<a href="${latest.url}" target="_blank">
${latest.url}
</a>
</td>
</tr>
</#if>
<#if latest.wiki??>
<tr>
<th>Wiki</th>
<td>
<a href="${latest.wiki}" target="_blank">
${latest.wiki}
</a>
</td>
</tr>
</#if>
</table>
<p>&nbsp;</p>
<#if latest.screenshots??>
<div class="screenshots">
<#list latest.screenshots as screenshot>
<a class="screenshot" href="${screenshot}">
<#if latest.screenshots?size == 1>
<#assign size="l">
<#elseif latest.screenshots?size == 2>
<#assign size="m">
<#else>
<#assign size="s">
</#if>
<img class="screenshot" src="${contextPath}/page/screenshot/${latest.groupId}/${latest.artifactId}/${screenshot_index}/${size}.jpg" alt="screenshot" />
</a>
</#list>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('a.screenshot').fancybox();
});
</script>
<p>&nbsp;</p>
</#if>
<h2>Plugin Versions</h2>
<div id="accordion">
<#if versions?has_content>
<#list versions as versionWrapper>
<#assign version=versionWrapper.plugin>
<h3><a href="#">${version.version}</a></h3>
<div>
<p>${version.description}</p>
<#if version.condition??>
<h4>Conditions</h4>
<ul>
<#if version.condition.minVersion??>
<li>Minimum Version: ${version.condition.minVersion}</li>
</#if>
<#if version.condition.os??>
<li>
Operatingsystems:
<#list version.condition.os as os>
${os}<#if os_has_next>, </#if>
</#list>
</li>
</#if>
<#if version.condition.arch??>
<li>Architecture: ${version.condition.arch}</li>
</#if>
</ul>
</#if>
<#if versionWrapper.compareUrl??>
<a href="${versionWrapper.compareUrl}" target="_blank" style="color: #1C94C4;">
compare
</a>
</#if>
</div>
</#list>
<#else>
Plugin not yet released
</#if>
</div>
<p>&nbsp;</p>
<a href="${contextPath}/page/index.html">Overview</a>
<script type="text/javascript">
jQuery(document).ready(function(){
$( "#accordion" ).accordion({
active: false
});
});
</script>
<#include "../template/footer.html">

View File

@@ -1,28 +0,0 @@
<#include "../template/header.html">
<div id="categories">
<#list categories as category>
<div style="padding-bottom: 20px">
<h2>${category.name}</h2>
<div class="plugins">
<#list category.plugins as plugin>
<h3><a href="#">${plugin.name}</a></h3>
<div>
${plugin.description}<br />
<a href="${contextPath}/page/detail/${plugin.groupId}/${plugin.artifactId}.html" style="color: #1C94C4;">more</a>
</div>
</#list>
</div>
</div>
</#list>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
$( "div.plugins" ).accordion({
active: false
});
});
</script>
<#include "../template/footer.html">

View File

@@ -1,28 +0,0 @@
<#include "../template/header.html">
<form method="POST" action="">
<table>
<tr>
<td>
<label for="username">Username</label>
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
<label for="password">Password</label>
</td>
<td>
<input type="password" name="password">
</td>
</tr>
</table>
<input type="submit" value="Login">
</form>
<#include "../template/footer.html">

View File

@@ -1,102 +0,0 @@
<!-- content end -->
</div>
</article>
</div>
<div class="primary" id="sidebar">
<ul class="xoxo">
<li id="linkcat-3" class="widget-container widget_links">
<h3 class="widget-title">Links</h3>
<ul class="xoxo blogroll">
<li>
<a href="//www.scm-manager.org/download/">Download</a>
</li>
<li>
<a href="https://bitbucket.org/sdorra/scm-manager/issues?status=new&amp;status=open" target="_blank">Issue Tracker</a>
</li>
<li>
<a href="http://groups.google.com/group/scmmanager" target="_blank">Mailing List</a>
</li>
<li>
<a href="https://bitbucket.org/sdorra/scm-manager/wiki" target="_blank">Wiki</a>
</li>
</ul>
</li>
<li class="widget-container widget_recent_entries">
<h3 class="widget-title">Latest News</h3>
<div id="news"></div>
<script type="text/javascript">
$(document).ready(function(){
$('#news').feeds('${contextPath}/news', {
loadingImage: '${contextPath}/template/css/images/load.gif',
maxItems: 3
});
});
</script>
</li>
<li class="widget-container widget_links">
<h3 class="widget-title">Social</h3>
<div style="position: relative; display: block;" id="social4i">
<div style="float:left;margin-right: 8px;" class="socialicons">
<div id="fb-root" style="float: left;"></div>
<fb:like href="http://www.scm-manager.org" send="false" layout="box_count" width="52" show_faces="true" font=""></fb:like>
<script type="text/javascript">// <![CDATA[
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.async=true; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&#038;appId=221636557882194";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// ]]></script>
</div>
<div style="float:left;margin-right: 8px;" class="socialicons">
<g:plusone size="tall" href="http://www.scm-manager.org"></g:plusone>
</div>
<div style="float:left;margin-right: 8px;" class="socialicons">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.scm-manager.org" data-count="vertical">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
<div style="clear: both;"></div>
</div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</li>
<li class="widget-container widget_links">
<h3 class="widget-title">Donate</h3>
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_s-xclick" name="cmd">
<input type="hidden" value="GLUQJWKA7EPDE" name="hosted_button_id">
<input type="image" border="0" alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif">
<img width="1" height="1" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" alt="">
</form>
</li>
<li class="widget-container widget_links">
<h3 class="widget-title">Build and test</h3>
<a href="https://scm-manager.ci.cloudbees.com/">
<img src="//web-static-cloudfront.s3.amazonaws.com/images/badges/BuiltOnDEV.png" alt="Cloudbees">
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<footer id="colophon">
<div class="col-width">
<div id="site-generator">
<p>&copy; Sebastian Sdorra</p>
</div>
</div>
</footer>
</div>
<script type='text/javascript' src='//www.scm-manager.org/wp-content/themes/portfolio-press/js/superfish.js?ver=3.9.1'></script>
<script type='text/javascript' src='//www.scm-manager.org/wp-content/themes/portfolio-press/js/theme.js?ver=3.9.1'></script>
</body>
</html>

View File

@@ -1,126 +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
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>SCM-Manager Plugin-Backend</title>
<link rel="stylesheet" type="text/css" media="all" href="//www.scm-manager.org/wp-content/themes/portfolio-press/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="all" href="${contextPath}/template/fancybox/jquery.fancybox-1.3.4.css" />
<link rel="stylesheet" type="text/css" media="all" href="${contextPath}/template/css/custom.css" />
<link rel="shortcut icon" href="//www.scm-manager.org/wp-content/uploads/2011/12/favicon_16x16px_transparent.png"/>
<link rel='stylesheet' id='portfoliopress_open_sans-css' href='//fonts.googleapis.com/css?family=Open+Sans:400italic,400,600' type='text/css' media='screen' />
<link rel='stylesheet' id='portfoliopress_rokkitt-css' href='//fonts.googleapis.com/css?family=Rokkitt:400,700' type='text/css' media='screen' />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script type="text/javascript" src="${contextPath}/template/js/jquery.feed.js"></script>
<script type="text/javascript" src="${contextPath}/template/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<!--[if lt IE 9]>
<script src="${contextPath}template/js/html5.js"></script>
<![endif]-->
<base href="${contextPath}" />
<#if configuration.trackingCode??>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '${configuration.trackingCode}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</#if>
</head>
<body class="home page page-id-8 page-template-default logged-in admin-bar layout-2cr">
<div id="wrapper">
<header id="branding">
<div class="col-width">
<hgroup id="logo">
<h1 id="site-title">
<a href="http://www.scm-manager.org/" title="SCM-Manager" rel="home">
<img src="http://www.scm-manager.org/wp-content/uploads/2012/10/scm-manager_logo_neg2-300x74.jpg" alt="SCM-Manager" />
</a>
</h1>
</hgroup>
<nav id="navigation">
<h3 class="menu-toggle">Menu</h3>
<div class="skip-link screen-reader-text"><a title="Skip to content" href="#content">Skip to content</a></div>
<div class="menu">
<ul class="sf-js-enabled">
<li class="menu-item menu-item-type-post_type menu-item-object-page">
<a href="//www.scm-manager.org/" title="Home">Home</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page">
<a href="//www.scm-manager.org/news/">News</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page">
<a href="//www.scm-manager.org/download/">Download</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item current_page_item current_page_parent">
<a href="//plugins.scm-manager.org/scm-plugin-backend/page/index.html">Plugins</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page">
<a href="//www.scm-manager.org/screenshots/">Screenshots</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page">
<a href="//www.scm-manager.org/videos/">Videos</a>
</li>
</ul>
</div>
</nav>
</div>
</header>
<div id="main">
<div class="col-width">
<div id="primary">
<div id="content">
<article class="page type-page status-publish hentry">
<header class="entry-header">
<h1 class="entry-title">${title}</h1>
</header>
<#if error??>
<div style="color: red">${error}</div>
</#if>
<div class="entry-content">
<!-- content begin -->

View File

@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/scm-plugin-backend</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>

View File

@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>sonia.scm.plugin.BackendContextListener</listener-class>
</listener>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>redirect.html</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<security-constraint>
<display-name>Restrict XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.ftl</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>none</role-name>
</auth-constraint>
</security-constraint>
</web-app>

View File

@@ -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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -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(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?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<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))
/*
*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License.
*
* Copyright © 2001 Robert Penner
* 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.
*
*/

View File

@@ -1,359 +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
*/
#fancybox-loading {
position: fixed;
top: 50%;
left: 50%;
width: 40px;
height: 40px;
margin-top: -20px;
margin-left: -20px;
cursor: pointer;
overflow: hidden;
z-index: 1104;
display: none;
}
#fancybox-loading div {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 480px;
background-image: url('fancybox.png');
}
#fancybox-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 1100;
display: none;
}
#fancybox-tmp {
padding: 0;
margin: 0;
border: 0;
overflow: auto;
display: none;
}
#fancybox-wrap {
position: absolute;
top: 0;
left: 0;
padding: 20px;
z-index: 1101;
outline: none;
display: none;
}
#fancybox-outer {
position: relative;
width: 100%;
height: 100%;
background: #fff;
}
#fancybox-content {
width: 0;
height: 0;
padding: 0;
outline: none;
position: relative;
overflow: hidden;
z-index: 1102;
border: 0px solid #fff;
}
#fancybox-hide-sel-frame {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 1101;
}
#fancybox-close {
position: absolute;
top: -15px;
right: -15px;
width: 30px;
height: 30px;
background: transparent url('fancybox.png') -40px 0px;
cursor: pointer;
z-index: 1103;
display: none;
}
#fancybox-error {
color: #444;
font: normal 12px/20px Arial;
padding: 14px;
margin: 0;
}
#fancybox-img {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
border: none;
outline: none;
line-height: 0;
vertical-align: top;
}
#fancybox-frame {
width: 100%;
height: 100%;
border: none;
display: block;
}
#fancybox-left, #fancybox-right {
position: absolute;
bottom: 0px;
height: 100%;
width: 35%;
cursor: pointer;
outline: none;
background: transparent url('blank.gif');
z-index: 1102;
display: none;
}
#fancybox-left {
left: 0px;
}
#fancybox-right {
right: 0px;
}
#fancybox-left-ico, #fancybox-right-ico {
position: absolute;
top: 50%;
left: -9999px;
width: 30px;
height: 30px;
margin-top: -15px;
cursor: pointer;
z-index: 1102;
display: block;
}
#fancybox-left-ico {
background-image: url('fancybox.png');
background-position: -40px -30px;
}
#fancybox-right-ico {
background-image: url('fancybox.png');
background-position: -40px -60px;
}
#fancybox-left:hover, #fancybox-right:hover {
visibility: visible; /* IE6 */
}
#fancybox-left:hover span {
left: 20px;
}
#fancybox-right:hover span {
left: auto;
right: 20px;
}
.fancybox-bg {
position: absolute;
padding: 0;
margin: 0;
border: 0;
width: 20px;
height: 20px;
z-index: 1001;
}
#fancybox-bg-n {
top: -20px;
left: 0;
width: 100%;
background-image: url('fancybox-x.png');
}
#fancybox-bg-ne {
top: -20px;
right: -20px;
background-image: url('fancybox.png');
background-position: -40px -162px;
}
#fancybox-bg-e {
top: 0;
right: -20px;
height: 100%;
background-image: url('fancybox-y.png');
background-position: -20px 0px;
}
#fancybox-bg-se {
bottom: -20px;
right: -20px;
background-image: url('fancybox.png');
background-position: -40px -182px;
}
#fancybox-bg-s {
bottom: -20px;
left: 0;
width: 100%;
background-image: url('fancybox-x.png');
background-position: 0px -20px;
}
#fancybox-bg-sw {
bottom: -20px;
left: -20px;
background-image: url('fancybox.png');
background-position: -40px -142px;
}
#fancybox-bg-w {
top: 0;
left: -20px;
height: 100%;
background-image: url('fancybox-y.png');
}
#fancybox-bg-nw {
top: -20px;
left: -20px;
background-image: url('fancybox.png');
background-position: -40px -122px;
}
#fancybox-title {
font-family: Helvetica;
font-size: 12px;
z-index: 1102;
}
.fancybox-title-inside {
padding-bottom: 10px;
text-align: center;
color: #333;
background: #fff;
position: relative;
}
.fancybox-title-outside {
padding-top: 10px;
color: #fff;
}
.fancybox-title-over {
position: absolute;
bottom: 0;
left: 0;
color: #FFF;
text-align: left;
}
#fancybox-title-over {
padding: 10px;
background-image: url('fancy_title_over.png');
display: block;
}
.fancybox-title-float {
position: absolute;
left: 0;
bottom: -20px;
height: 32px;
}
#fancybox-title-float-wrap {
border: none;
border-collapse: collapse;
width: auto;
}
#fancybox-title-float-wrap td {
border: none;
white-space: nowrap;
}
#fancybox-title-float-left {
padding: 0 0 0 15px;
background: url('fancybox.png') -40px -90px no-repeat;
}
#fancybox-title-float-main {
color: #FFF;
line-height: 29px;
font-weight: bold;
padding: 0 0 3px 0;
background: url('fancybox-x.png') 0px -40px;
}
#fancybox-title-float-right {
padding: 0 0 0 15px;
background: url('fancybox.png') -55px -90px no-repeat;
}
/* IE6 */
.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
height: expression(this.parentNode.clientHeight + "px");
}
#fancybox-loading.fancybox-ie6 {
position: absolute; margin-top: 0;
top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
}
#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); }
/* IE6, IE7, IE8 */
.fancybox-ie .fancybox-bg { background: transparent !important; }
.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }

View File

@@ -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("<div/>")[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('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
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('<div class="fancybox-inline-tmp" />').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("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";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('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');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"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":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('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').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;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.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&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){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('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));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('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').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);

View File

@@ -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);

Some files were not shown because too many files have changed in this diff Show More