mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
added proxy servlet for news fetching
This commit is contained in:
@@ -57,6 +57,12 @@
|
||||
<version>0.9.29</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>rome</groupId>
|
||||
<artifactId>rome</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-core</artifactId>
|
||||
|
||||
@@ -41,6 +41,8 @@ import sonia.scm.xml.XmlIntervalAdapter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
@@ -81,6 +83,17 @@ public class BackendConfiguration
|
||||
return excludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public URL getNewsUrl()
|
||||
{
|
||||
return newsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -149,6 +162,17 @@ public class BackendConfiguration
|
||||
this.multithreaded = multithreaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param newsUrl
|
||||
*/
|
||||
public void setNewsUrl(URL newsUrl)
|
||||
{
|
||||
this.newsUrl = newsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -186,6 +210,10 @@ public class BackendConfiguration
|
||||
/** Field description */
|
||||
private boolean multithreaded = true;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name= "news-url")
|
||||
private URL newsUrl;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "repository")
|
||||
@XmlElementWrapper(name = "repositories")
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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.ProxyURLProvider;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class NewsProxyURLProvider implements ProxyURLProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param configuration
|
||||
*/
|
||||
@Inject
|
||||
public NewsProxyURLProvider(BackendConfiguration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public URL getProxyURL()
|
||||
{
|
||||
return configuration.getNewsUrl();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private BackendConfiguration configuration;
|
||||
}
|
||||
@@ -44,6 +44,8 @@ import sonia.scm.plugin.scanner.PluginScannerFactory;
|
||||
import sonia.scm.plugin.scanner.PluginScannerScheduler;
|
||||
import sonia.scm.plugin.scanner.TimerPluginScannerScheduler;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.web.proxy.ProxyServet;
|
||||
import sonia.scm.web.proxy.ProxyURLProvider;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -117,6 +119,10 @@ public class ScmBackendModule extends ServletModule
|
||||
bind(PluginScannerFactory.class).to(DefaultPluginScannerFactory.class);
|
||||
bind(PluginScannerScheduler.class).to(TimerPluginScannerScheduler.class);
|
||||
|
||||
// news proxy
|
||||
bind(ProxyURLProvider.class).to(NewsProxyURLProvider.class);
|
||||
serve("/news*").with(ProxyServet.class);
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
|
||||
params.put(PackagesResourceConfig.PROPERTY_PACKAGES,
|
||||
|
||||
Reference in New Issue
Block a user