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