mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 05:25:44 +01:00
merge with branch 1.x
This commit is contained in:
@@ -40,20 +40,17 @@ import com.github.legman.Subscribe;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.ConfigurationException;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.cache.Cache;
|
||||
import sonia.scm.cache.CacheManager;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.config.ScmConfigurationChangedEvent;
|
||||
import sonia.scm.io.ZipUnArchiver;
|
||||
import sonia.scm.net.HttpClient;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.SystemUtil;
|
||||
@@ -78,12 +75,12 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import sonia.scm.net.ahc.AdvancedHttpClient;
|
||||
|
||||
/**
|
||||
* TODO replace aether stuff
|
||||
* TODO replace aether stuff.
|
||||
* TODO check AdvancedPluginConfiguration from 1.x
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@@ -117,17 +114,17 @@ public class DefaultPluginManager implements PluginManager
|
||||
* @param configuration
|
||||
* @param pluginLoader
|
||||
* @param cacheManager
|
||||
* @param clientProvider
|
||||
* @param httpClient
|
||||
*/
|
||||
@Inject
|
||||
public DefaultPluginManager(SCMContextProvider context,
|
||||
ScmConfiguration configuration, PluginLoader pluginLoader,
|
||||
CacheManager cacheManager, Provider<HttpClient> clientProvider)
|
||||
CacheManager cacheManager, AdvancedHttpClient httpClient)
|
||||
{
|
||||
this.context = context;
|
||||
this.configuration = configuration;
|
||||
this.cache = cacheManager.getCache(CACHE_NAME);
|
||||
this.clientProvider = clientProvider;
|
||||
this.httpClient = httpClient;
|
||||
installedPlugins = new HashMap<>();
|
||||
|
||||
for (PluginWrapper wrapper : pluginLoader.getInstalledPlugins())
|
||||
@@ -140,16 +137,6 @@ public class DefaultPluginManager implements PluginManager
|
||||
installedPlugins.put(info.getId(), plugin);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
unmarshaller =
|
||||
JAXBContext.newInstance(PluginCenter.class).createUnmarshaller();
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
throw new ConfigurationException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -624,21 +611,9 @@ public class DefaultPluginManager implements PluginManager
|
||||
*/
|
||||
if (REMOTE_PLUGINS_ENABLED && Util.isNotEmpty(pluginUrl))
|
||||
{
|
||||
InputStream input = null;
|
||||
|
||||
try
|
||||
{
|
||||
input = clientProvider.get().get(pluginUrl).getContent();
|
||||
|
||||
/*
|
||||
* TODO: add gzip support
|
||||
*
|
||||
* if (gzip)
|
||||
* {
|
||||
* input = new GZIPInputStream(input);
|
||||
* }
|
||||
*/
|
||||
center = (PluginCenter) unmarshaller.unmarshal(input);
|
||||
center = httpClient.get(pluginUrl).request().contentFromXml(PluginCenter.class);
|
||||
preparePlugins(center);
|
||||
cache.put(PluginCenter.class.getName(), center);
|
||||
|
||||
@@ -653,14 +628,10 @@ public class DefaultPluginManager implements PluginManager
|
||||
* pluginHandler.setPluginRepositories(center.getRepositories());
|
||||
*/
|
||||
}
|
||||
catch (IOException | JAXBException ex)
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.error("could not load plugins from plugin center", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (center == null)
|
||||
@@ -758,7 +729,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
private final Cache<String, PluginCenter> cache;
|
||||
|
||||
/** Field description */
|
||||
private final Provider<HttpClient> clientProvider;
|
||||
private final AdvancedHttpClient httpClient;
|
||||
|
||||
/** Field description */
|
||||
private final ScmConfiguration configuration;
|
||||
@@ -768,7 +739,4 @@ public class DefaultPluginManager implements PluginManager
|
||||
|
||||
/** Field description */
|
||||
private final Map<String, Plugin> installedPlugins;
|
||||
|
||||
/** Field description */
|
||||
private Unmarshaller unmarshaller;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user