mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
package refactoring
This commit is contained in:
@@ -47,15 +47,15 @@ import java.io.File;
|
|||||||
public class BaseDirectory
|
public class BaseDirectory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
static final String DIRECTORY_PROPERTY = "scm-backend.home";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final String DIRECTORY_DEFAULT = ".scm-backend";
|
private static final String DIRECTORY_DEFAULT = ".scm-backend";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final String DIRECTORY_ENVIRONMENT = "SCMBACKEND_HOME";
|
private static final String DIRECTORY_ENVIRONMENT = "SCMBACKEND_HOME";
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
static final String DIRECTORY_PROPERTY = "scm-backend.home";
|
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static BaseDirectory instance;
|
private static BaseDirectory instance;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import java.util.Comparator;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class PluginInformationNameComparator
|
public class PluginInformationNameComparator
|
||||||
implements Comparator<PluginInformation>
|
implements Comparator<PluginInformation>
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import java.util.Comparator;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class PluginInformationVersionComparator
|
public class PluginInformationVersionComparator
|
||||||
implements Comparator<PluginInformation>
|
implements Comparator<PluginInformation>
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@@ -74,7 +74,7 @@ public class PluginInformationVersionComparator
|
|||||||
if (Util.isNotEmpty(v1) && Util.isNotEmpty(v2))
|
if (Util.isNotEmpty(v1) && Util.isNotEmpty(v2))
|
||||||
{
|
{
|
||||||
if (PluginVersion.createVersion(v1).isNewer(
|
if (PluginVersion.createVersion(v1).isNewer(
|
||||||
PluginVersion.createVersion(v2)))
|
PluginVersion.createVersion(v2)))
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class PluginUtil
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<PluginInformation> filterSameVersions(
|
public static List<PluginInformation> filterSameVersions(
|
||||||
List<PluginInformation> plugins)
|
List<PluginInformation> plugins)
|
||||||
{
|
{
|
||||||
List<PluginInformation> filteredPlugins =
|
List<PluginInformation> filteredPlugins =
|
||||||
new ArrayList<PluginInformation>();
|
new ArrayList<PluginInformation>();
|
||||||
@@ -87,7 +87,7 @@ public class PluginUtil
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<PluginInformation> filterSnapshots(
|
public static List<PluginInformation> filterSnapshots(
|
||||||
List<PluginInformation> allVersions)
|
List<PluginInformation> allVersions)
|
||||||
{
|
{
|
||||||
List<PluginInformation> filtered = new ArrayList<PluginInformation>();
|
List<PluginInformation> filtered = new ArrayList<PluginInformation>();
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ public class PluginUtil
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<PluginInformation> getFilteredPluginVersions(
|
public static List<PluginInformation> getFilteredPluginVersions(
|
||||||
PluginBackend backend, String groupId, String artifactId)
|
PluginBackend backend, String groupId, String artifactId)
|
||||||
{
|
{
|
||||||
List<PluginInformation> pluginVersions =
|
List<PluginInformation> pluginVersions =
|
||||||
PluginUtil.getPluginVersions(backend, groupId, artifactId);
|
PluginUtil.getPluginVersions(backend, groupId, artifactId);
|
||||||
@@ -145,7 +145,7 @@ public class PluginUtil
|
|||||||
if (Util.isNotEmpty(pluginVersions))
|
if (Util.isNotEmpty(pluginVersions))
|
||||||
{
|
{
|
||||||
Collections.sort(pluginVersions,
|
Collections.sort(pluginVersions,
|
||||||
PluginInformationNameComparator.INSTANCE);
|
PluginInformationNameComparator.INSTANCE);
|
||||||
pluginVersions = PluginUtil.filterSameVersions(pluginVersions);
|
pluginVersions = PluginUtil.filterSameVersions(pluginVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class PluginUtil
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static PluginInformation getLatestPluginVersion(PluginBackend backend,
|
public static PluginInformation getLatestPluginVersion(PluginBackend backend,
|
||||||
String groupId, String artifactId)
|
String groupId, String artifactId)
|
||||||
{
|
{
|
||||||
return getFilteredPluginVersions(backend, groupId, artifactId).get(0);
|
return getFilteredPluginVersions(backend, groupId, artifactId).get(0);
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ public class PluginUtil
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<PluginInformation> getPluginVersions(
|
public static List<PluginInformation> getPluginVersions(
|
||||||
PluginBackend backend, final String groupId, final String artifactId)
|
PluginBackend backend, final String groupId, final String artifactId)
|
||||||
{
|
{
|
||||||
List<PluginInformation> pluginVersions =
|
List<PluginInformation> pluginVersions =
|
||||||
backend.getPlugins(new PluginFilter()
|
backend.getPlugins(new PluginFilter()
|
||||||
@@ -189,7 +189,7 @@ public class PluginUtil
|
|||||||
public boolean accept(PluginInformation plugin)
|
public boolean accept(PluginInformation plugin)
|
||||||
{
|
{
|
||||||
return groupId.equals(plugin.getGroupId())
|
return groupId.equals(plugin.getGroupId())
|
||||||
&& artifactId.equals(plugin.getArtifactId());
|
&& artifactId.equals(plugin.getArtifactId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ package sonia.scm.plugin;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import sonia.scm.web.filter.HttpFilter;
|
import sonia.scm.web.filter.HttpFilter;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -52,9 +53,12 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class RedirectFilter extends HttpFilter
|
public class RedirectFilter extends HttpFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
private static final String STARTPAGE = "/page/index.html";
|
private static final String STARTPAGE = "/page/index.html";
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
* http://bitbucket.org/sdorra/scm-manager
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin;
|
package sonia.scm.plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,5 +37,7 @@ package sonia.scm.plugin;
|
|||||||
*/
|
*/
|
||||||
public class Roles
|
public class Roles
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
public static final String ADMIN = "admin";
|
public static final String ADMIN = "admin";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ import com.google.inject.servlet.ServletModule;
|
|||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
|
|
||||||
import sonia.scm.ConfigurationException;
|
import sonia.scm.ConfigurationException;
|
||||||
import sonia.scm.plugin.rest.PluginResource;
|
import sonia.scm.plugin.rest.api.PluginResource;
|
||||||
import sonia.scm.plugin.rest.url.BitbucketUrlBuilder;
|
|
||||||
import sonia.scm.plugin.rest.url.GithubUrlBuilder;
|
|
||||||
import sonia.scm.plugin.rest.url.UrlBuilder;
|
|
||||||
import sonia.scm.plugin.rest.url.UrlBuilderFactory;
|
|
||||||
import sonia.scm.plugin.scanner.DefaultPluginScannerFactory;
|
import sonia.scm.plugin.scanner.DefaultPluginScannerFactory;
|
||||||
import sonia.scm.plugin.scanner.PluginScannerFactory;
|
import sonia.scm.plugin.scanner.PluginScannerFactory;
|
||||||
import sonia.scm.plugin.scanner.PluginScannerScheduler;
|
import sonia.scm.plugin.scanner.PluginScannerScheduler;
|
||||||
import sonia.scm.plugin.scanner.TimerPluginScannerScheduler;
|
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.ProxyConfigurationProvider;
|
||||||
import sonia.scm.web.proxy.ProxyServlet;
|
import sonia.scm.web.proxy.ProxyServlet;
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class FreemarkerTemplateProvider implements ViewProcessor<String>
|
|||||||
{
|
{
|
||||||
configuration = new Configuration();
|
configuration = new Configuration();
|
||||||
configuration.setServletContextForTemplateLoading(servletContext,
|
configuration.setServletContextForTemplateLoading(servletContext,
|
||||||
DIRECTORY_TEMPLATES);
|
DIRECTORY_TEMPLATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
@@ -124,7 +124,7 @@ public class FreemarkerTemplateProvider implements ViewProcessor<String>
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(String resolvedPath, Viewable viewable, OutputStream out)
|
public void writeTo(String resolvedPath, Viewable viewable, OutputStream out)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import java.util.Comparator;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class PluginInformationComparator
|
public class PluginInformationComparator
|
||||||
implements Comparator<PluginInformation>
|
implements Comparator<PluginInformation>
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class ViewableResource
|
|||||||
* @param configuration
|
* @param configuration
|
||||||
*/
|
*/
|
||||||
public ViewableResource(ServletContext context,
|
public ViewableResource(ServletContext context,
|
||||||
BackendConfiguration configuration)
|
BackendConfiguration configuration)
|
||||||
{
|
{
|
||||||
this.contextPath = context.getContextPath();
|
this.contextPath = context.getContextPath();
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|||||||
@@ -29,13 +29,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.admin;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import sonia.scm.plugin.BackendConfiguration;
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
|
import sonia.scm.plugin.rest.ViewableResource;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.api;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class DefaultPluginFilter implements PluginFilter
|
|||||||
* @param snapshot
|
* @param snapshot
|
||||||
*/
|
*/
|
||||||
public DefaultPluginFilter(String version, String os, String arch,
|
public DefaultPluginFilter(String version, String os, String arch,
|
||||||
boolean snapshot)
|
boolean snapshot)
|
||||||
{
|
{
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.os = os;
|
this.os = os;
|
||||||
@@ -84,9 +84,10 @@ public class DefaultPluginFilter implements PluginFilter
|
|||||||
{
|
{
|
||||||
PluginCondition condition = plugin.getCondition();
|
PluginCondition condition = plugin.getCondition();
|
||||||
|
|
||||||
return (snapshot ||!plugin.getVersion().toUpperCase().contains(
|
return (snapshot
|
||||||
VERSION_SNAPSHOT)) && ((condition != null) && condition.isSupported(
|
||!plugin.getVersion().toUpperCase().contains(
|
||||||
version, os, arch) || (condition == null));
|
VERSION_SNAPSHOT)) && ((condition != null)
|
||||||
|
&& condition.isSupported(version, os, arch) || (condition == null));
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.api;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -51,6 +51,7 @@ import sonia.scm.plugin.PluginBackendListener;
|
|||||||
import sonia.scm.plugin.PluginCenter;
|
import sonia.scm.plugin.PluginCenter;
|
||||||
import sonia.scm.plugin.PluginInformation;
|
import sonia.scm.plugin.PluginInformation;
|
||||||
import sonia.scm.plugin.PluginVersion;
|
import sonia.scm.plugin.PluginVersion;
|
||||||
|
import sonia.scm.plugin.rest.PluginInformationComparator;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -97,8 +98,7 @@ public class PluginResource implements PluginBackendListener
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public PluginResource(PluginBackend backend,
|
public PluginResource(PluginBackend backend,
|
||||||
BackendConfiguration configuration,
|
BackendConfiguration configuration, CacheManager cacheManager)
|
||||||
CacheManager cacheManager)
|
|
||||||
{
|
{
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
@@ -143,15 +143,14 @@ public class PluginResource implements PluginBackendListener
|
|||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_XML)
|
@Produces(MediaType.APPLICATION_XML)
|
||||||
public Response getPlugins(@PathParam("version") String version,
|
public Response getPlugins(@PathParam("version") String version,
|
||||||
@QueryParam("os") String os,
|
@QueryParam("os") String os, @QueryParam("arch") String arch,
|
||||||
@QueryParam("arch") String arch,
|
@DefaultValue("false")
|
||||||
@DefaultValue("false")
|
|
||||||
@QueryParam("snapshot") boolean snapshot)
|
@QueryParam("snapshot") boolean snapshot)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("load plugins for version {}, include snapshots: {}",
|
logger.debug("load plugins for version {}, include snapshots: {}",
|
||||||
version, Boolean.toString(snapshot));
|
version, Boolean.toString(snapshot));
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginCenter pc = null;
|
PluginCenter pc = null;
|
||||||
@@ -201,7 +200,7 @@ public class PluginResource implements PluginBackendListener
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String createCacheKey(String version, String os, String arch,
|
private String createCacheKey(String version, String os, String arch,
|
||||||
boolean snapshot)
|
boolean snapshot)
|
||||||
{
|
{
|
||||||
StringBuilder key = new StringBuilder(version);
|
StringBuilder key = new StringBuilder(version);
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ public class PluginResource implements PluginBackendListener
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Set<PluginInformation> getNewestPlugins(
|
private Set<PluginInformation> getNewestPlugins(
|
||||||
List<PluginInformation> plugins)
|
List<PluginInformation> plugins)
|
||||||
{
|
{
|
||||||
Collections.sort(plugins, PluginInformationComparator.INSTANCE);
|
Collections.sort(plugins, PluginInformationComparator.INSTANCE);
|
||||||
|
|
||||||
@@ -278,10 +277,10 @@ public class PluginResource implements PluginBackendListener
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isSamePlugin(PluginInformation plugin,
|
private boolean isSamePlugin(PluginInformation plugin,
|
||||||
PluginInformation otherPlugin)
|
PluginInformation otherPlugin)
|
||||||
{
|
{
|
||||||
return plugin.getGroupId().equals(otherPlugin.getGroupId())
|
return plugin.getGroupId().equals(otherPlugin.getGroupId())
|
||||||
&& plugin.getArtifactId().equals(otherPlugin.getArtifactId());
|
&& plugin.getArtifactId().equals(otherPlugin.getArtifactId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
@@ -29,13 +29,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.error;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import sonia.scm.plugin.BackendConfiguration;
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
|
import sonia.scm.plugin.rest.ViewableResource;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.page;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -48,8 +48,9 @@ import sonia.scm.plugin.PluginBackend;
|
|||||||
import sonia.scm.plugin.PluginInformation;
|
import sonia.scm.plugin.PluginInformation;
|
||||||
import sonia.scm.plugin.PluginInformationVersionComparator;
|
import sonia.scm.plugin.PluginInformationVersionComparator;
|
||||||
import sonia.scm.plugin.PluginUtil;
|
import sonia.scm.plugin.PluginUtil;
|
||||||
import sonia.scm.plugin.rest.url.UrlBuilder;
|
import sonia.scm.plugin.rest.CachedViewableResource;
|
||||||
import sonia.scm.plugin.rest.url.UrlBuilderFactory;
|
import sonia.scm.plugin.url.UrlBuilder;
|
||||||
|
import sonia.scm.plugin.url.UrlBuilderFactory;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -103,8 +104,8 @@ public class DetailResource extends CachedViewableResource
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public DetailResource(ServletContext context, PluginBackend backend,
|
public DetailResource(ServletContext context, PluginBackend backend,
|
||||||
BackendConfiguration configuration,
|
BackendConfiguration configuration, UrlBuilderFactory urlFactory,
|
||||||
UrlBuilderFactory urlFactory, CacheManager cacheManager)
|
CacheManager cacheManager)
|
||||||
{
|
{
|
||||||
super(context, backend, configuration, cacheManager, CACHE);
|
super(context, backend, configuration, cacheManager, CACHE);
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
@@ -125,8 +126,7 @@ public class DetailResource extends CachedViewableResource
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
public Viewable getPluginDetails(@PathParam("groupId") String groupId,
|
public Viewable getPluginDetails(@PathParam("groupId") String groupId,
|
||||||
@PathParam("artifactId") String artifactId,
|
@PathParam("artifactId") String artifactId, @DefaultValue("false")
|
||||||
@DefaultValue("false")
|
|
||||||
@QueryParam("snapshot") boolean snapshot)
|
@QueryParam("snapshot") boolean snapshot)
|
||||||
{
|
{
|
||||||
String cacheKey = createCacheKey(groupId, artifactId, snapshot);
|
String cacheKey = createCacheKey(groupId, artifactId, snapshot);
|
||||||
@@ -160,7 +160,7 @@ public class DetailResource extends CachedViewableResource
|
|||||||
|
|
||||||
vars.put("latest", PluginUtil.prepareForView(latest));
|
vars.put("latest", PluginUtil.prepareForView(latest));
|
||||||
vars.put("versions", detailList);
|
vars.put("versions", detailList);
|
||||||
viewable = new Viewable("/detail", vars);
|
viewable = new Viewable("/page/detail", vars);
|
||||||
putToCache(cacheKey, viewable);
|
putToCache(cacheKey, viewable);
|
||||||
}
|
}
|
||||||
else if (logger.isDebugEnabled())
|
else if (logger.isDebugEnabled())
|
||||||
@@ -184,10 +184,10 @@ public class DetailResource extends CachedViewableResource
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String createCacheKey(String groupId, String artifactId,
|
private String createCacheKey(String groupId, String artifactId,
|
||||||
boolean snapshot)
|
boolean snapshot)
|
||||||
{
|
{
|
||||||
return new StringBuilder(Util.nonNull(groupId)).append(
|
return new StringBuilder(Util.nonNull(groupId)).append(
|
||||||
Util.nonNull(artifactId)).append(Boolean.toString(snapshot)).toString();
|
Util.nonNull(artifactId)).append(Boolean.toString(snapshot)).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -200,12 +200,12 @@ public class DetailResource extends CachedViewableResource
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<PluginDetailWrapper> createDetailList(PluginInformation latest,
|
private List<PluginDetailWrapper> createDetailList(PluginInformation latest,
|
||||||
List<PluginInformation> pluginVersions)
|
List<PluginInformation> pluginVersions)
|
||||||
{
|
{
|
||||||
List<PluginDetailWrapper> detailList = new ArrayList<PluginDetailWrapper>();
|
List<PluginDetailWrapper> detailList = new ArrayList<PluginDetailWrapper>();
|
||||||
|
|
||||||
Collections.sort(pluginVersions,
|
Collections.sort(pluginVersions,
|
||||||
PluginInformationVersionComparator.INSTANCE);
|
PluginInformationVersionComparator.INSTANCE);
|
||||||
|
|
||||||
Iterator<PluginInformation> pluginIterator = pluginVersions.iterator();
|
Iterator<PluginInformation> pluginIterator = pluginVersions.iterator();
|
||||||
UrlBuilder urlBuilder = urlFactory.createCompareUrlBuilder(latest);
|
UrlBuilder urlBuilder = urlFactory.createCompareUrlBuilder(latest);
|
||||||
@@ -29,13 +29,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.page;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import sonia.scm.plugin.BackendConfiguration;
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
|
import sonia.scm.plugin.rest.ViewableResource;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ public class LoginResource extends ViewableResource
|
|||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final String PAGE_LOGIN = "/login";
|
private static final String PAGE_LOGIN = "/page/login";
|
||||||
|
|
||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.page;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -43,6 +43,8 @@ import sonia.scm.plugin.CategoryNameComaparator;
|
|||||||
import sonia.scm.plugin.PluginBackend;
|
import sonia.scm.plugin.PluginBackend;
|
||||||
import sonia.scm.plugin.PluginInformation;
|
import sonia.scm.plugin.PluginInformation;
|
||||||
import sonia.scm.plugin.PluginUtil;
|
import sonia.scm.plugin.PluginUtil;
|
||||||
|
import sonia.scm.plugin.rest.PluginInformationComparator;
|
||||||
|
import sonia.scm.plugin.rest.ViewableResource;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -106,7 +108,7 @@ public class OverviewResource extends ViewableResource
|
|||||||
|
|
||||||
vars.put("categories", categories);
|
vars.put("categories", categories);
|
||||||
|
|
||||||
return new Viewable("/index", vars);
|
return new Viewable("/page/index", vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.page;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest;
|
package sonia.scm.plugin.rest.page;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ import com.google.inject.Inject;
|
|||||||
|
|
||||||
import org.imgscalr.Scalr;
|
import org.imgscalr.Scalr;
|
||||||
|
|
||||||
|
import sonia.scm.plugin.BaseDirectory;
|
||||||
import sonia.scm.plugin.PluginBackend;
|
import sonia.scm.plugin.PluginBackend;
|
||||||
import sonia.scm.plugin.PluginInformation;
|
import sonia.scm.plugin.PluginInformation;
|
||||||
import sonia.scm.plugin.PluginUtil;
|
import sonia.scm.plugin.PluginUtil;
|
||||||
@@ -66,7 +67,6 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import sonia.scm.plugin.BaseDirectory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -125,11 +125,9 @@ public class ScreenshotResource
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces("image/jpeg")
|
@Produces("image/jpeg")
|
||||||
public Response getScreenshot(
|
public Response getScreenshot(@PathParam("groupId") String groupId,
|
||||||
@PathParam("groupId") String groupId,
|
|
||||||
@PathParam("artifactId") String artifactId,
|
@PathParam("artifactId") String artifactId,
|
||||||
@PathParam("number") int number,
|
@PathParam("number") int number, @PathParam("size") String size)
|
||||||
@PathParam("size") String size)
|
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
PluginInformation plugin = PluginUtil.getLatestPluginVersion(backend,
|
PluginInformation plugin = PluginUtil.getLatestPluginVersion(backend,
|
||||||
@@ -57,7 +57,7 @@ public class PluginScannerRunnable implements Runnable
|
|||||||
* @param directory
|
* @param directory
|
||||||
*/
|
*/
|
||||||
public PluginScannerRunnable(PluginBackend backend,
|
public PluginScannerRunnable(PluginBackend backend,
|
||||||
PluginScanner pluginScanner, File directory)
|
PluginScanner pluginScanner, File directory)
|
||||||
{
|
{
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
this.pluginScanner = pluginScanner;
|
this.pluginScanner = pluginScanner;
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ public class PluginScannerTimerTask extends TimerTask
|
|||||||
* @param scannerFactory
|
* @param scannerFactory
|
||||||
*/
|
*/
|
||||||
public PluginScannerTimerTask(PluginBackend backend,
|
public PluginScannerTimerTask(PluginBackend backend,
|
||||||
BackendConfiguration configuration,
|
BackendConfiguration configuration, PluginScannerFactory scannerFactory)
|
||||||
PluginScannerFactory scannerFactory)
|
|
||||||
{
|
{
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
@@ -103,7 +102,7 @@ public class PluginScannerTimerTask extends TimerTask
|
|||||||
if (configuration.isMultithreaded())
|
if (configuration.isMultithreaded())
|
||||||
{
|
{
|
||||||
new Thread(new PluginScannerRunnable(backend, scanner,
|
new Thread(new PluginScannerRunnable(backend, scanner,
|
||||||
directory)).start();
|
directory)).start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ public class TimerPluginScannerScheduler implements PluginScannerScheduler
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public TimerPluginScannerScheduler(PluginBackend backend,
|
public TimerPluginScannerScheduler(PluginBackend backend,
|
||||||
BackendConfiguration configuration,
|
BackendConfiguration configuration, PluginScannerFactory scannerFactory)
|
||||||
PluginScannerFactory scannerFactory)
|
|
||||||
{
|
{
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
@@ -105,7 +104,7 @@ public class TimerPluginScannerScheduler implements PluginScannerScheduler
|
|||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
logger.info("start scanner task with an interval of {}",
|
logger.info("start scanner task with an interval of {}",
|
||||||
Util.convertTime(configuration.getScannInterval()));
|
Util.convertTime(configuration.getScannInterval()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginScannerTimerTask task = new PluginScannerTimerTask(backend,
|
PluginScannerTimerTask task = new PluginScannerTimerTask(backend,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest.url;
|
package sonia.scm.plugin.url;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -92,11 +92,10 @@ public abstract class AbstractUrlBuilder implements UrlBuilder
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String createCompareUrl(PluginInformation latest,
|
public String createCompareUrl(PluginInformation latest,
|
||||||
PluginInformation plugin,
|
PluginInformation plugin, PluginInformation other)
|
||||||
PluginInformation other)
|
|
||||||
{
|
{
|
||||||
return createCompareUrl(latest.getUrl(), plugin.getVersion(),
|
return createCompareUrl(latest.getUrl(), plugin.getVersion(),
|
||||||
other.getVersion());
|
other.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +109,7 @@ public abstract class AbstractUrlBuilder implements UrlBuilder
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String createCompareUrl(String urlString, String version,
|
public String createCompareUrl(String urlString, String version,
|
||||||
String otherVersion)
|
String otherVersion)
|
||||||
{
|
{
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ public abstract class AbstractUrlBuilder implements UrlBuilder
|
|||||||
if (parts.length >= 2)
|
if (parts.length >= 2)
|
||||||
{
|
{
|
||||||
result = MessageFormat.format(getUrlPattern(), parts[0], parts[1],
|
result = MessageFormat.format(getUrlPattern(), parts[0], parts[1],
|
||||||
version, otherVersion);
|
version, otherVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest.url;
|
package sonia.scm.plugin.url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest.url;
|
package sonia.scm.plugin.url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest.url;
|
package sonia.scm.plugin.url;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -55,8 +55,7 @@ public interface UrlBuilder
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String createCompareUrl(PluginInformation latest,
|
public String createCompareUrl(PluginInformation latest,
|
||||||
PluginInformation plugin,
|
PluginInformation plugin, PluginInformation other);
|
||||||
PluginInformation other);
|
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.plugin.rest.url;
|
package sonia.scm.plugin.url;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<#include "template/header.html">
|
<#include "../template/header.html">
|
||||||
|
|
||||||
<p>${latest.description}</p>
|
<p>${latest.description}</p>
|
||||||
|
|
||||||
@@ -133,4 +133,4 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<#include "template/footer.html">
|
<#include "../template/footer.html">
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<#include "template/header.html">
|
<#include "../template/header.html">
|
||||||
|
|
||||||
<div id="categories">
|
<div id="categories">
|
||||||
<#list categories as category>
|
<#list categories as category>
|
||||||
@@ -25,4 +25,4 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<#include "template/footer.html">
|
<#include "../template/footer.html">
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<#include "template/header.html">
|
<#include "../template/header.html">
|
||||||
|
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<#include "template/footer.html">
|
<#include "../template/footer.html">
|
||||||
@@ -35,6 +35,7 @@ package sonia.scm.plugin.rest.url;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.plugin.url.BitbucketUrlBuilder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ package sonia.scm.plugin.rest.url;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.plugin.url.GithubUrlBuilder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|||||||
Reference in New Issue
Block a user