2010-10-31 19:22:53 +01:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*
|
2010-10-12 09:16:40 +02:00
|
|
|
*/
|
|
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
package sonia.scm.plugin;
|
2010-10-12 09:16:40 +02:00
|
|
|
|
|
|
|
|
//~--- non-JDK imports --------------------------------------------------------
|
|
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
import com.google.inject.Inject;
|
2010-12-16 07:46:02 +01:00
|
|
|
import com.google.inject.Provider;
|
2010-12-13 18:59:00 +01:00
|
|
|
import com.google.inject.Singleton;
|
|
|
|
|
|
2010-10-16 11:03:54 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
import sonia.scm.ConfigurationException;
|
2010-12-13 21:02:39 +01:00
|
|
|
import sonia.scm.SCMContext;
|
2010-12-13 18:59:00 +01:00
|
|
|
import sonia.scm.cache.CacheManager;
|
|
|
|
|
import sonia.scm.cache.SimpleCache;
|
|
|
|
|
import sonia.scm.config.ScmConfiguration;
|
2010-12-16 07:46:02 +01:00
|
|
|
import sonia.scm.security.SecurityContext;
|
2010-12-18 13:37:34 +01:00
|
|
|
import sonia.scm.util.AssertUtil;
|
2010-12-16 07:46:02 +01:00
|
|
|
import sonia.scm.util.SecurityUtil;
|
2010-12-01 14:26:29 +01:00
|
|
|
|
2010-10-12 09:16:40 +02:00
|
|
|
//~--- JDK imports ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
import java.util.Collection;
|
2010-12-13 18:59:00 +01:00
|
|
|
import java.util.HashMap;
|
2010-12-17 19:02:32 +01:00
|
|
|
import java.util.HashSet;
|
2010-12-18 16:25:57 +01:00
|
|
|
import java.util.LinkedHashSet;
|
2010-12-13 18:59:00 +01:00
|
|
|
import java.util.Map;
|
2010-12-17 19:02:32 +01:00
|
|
|
import java.util.Set;
|
2010-10-12 09:16:40 +02:00
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
|
|
import javax.xml.bind.JAXBException;
|
|
|
|
|
import javax.xml.bind.Unmarshaller;
|
2010-10-12 09:16:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Sebastian Sdorra
|
|
|
|
|
*/
|
2010-12-13 18:59:00 +01:00
|
|
|
@Singleton
|
2010-12-01 14:26:29 +01:00
|
|
|
public class DefaultPluginManager implements PluginManager
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** Field description */
|
2010-12-13 18:59:00 +01:00
|
|
|
public static final String CACHE_NAME = "sonia.cache.plugins";
|
2010-12-01 14:26:29 +01:00
|
|
|
|
|
|
|
|
/** the logger for DefaultPluginManager */
|
2010-10-12 09:16:40 +02:00
|
|
|
private static final Logger logger =
|
2010-12-01 14:26:29 +01:00
|
|
|
LoggerFactory.getLogger(DefaultPluginManager.class);
|
2010-10-12 09:16:40 +02:00
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
/** Field description */
|
|
|
|
|
public static final PluginFilter FILTER_UPDATES =
|
|
|
|
|
new StatePluginFilter(PluginState.UPDATE_AVAILABLE);
|
|
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
//~--- constructors ---------------------------------------------------------
|
2010-10-12 09:16:40 +02:00
|
|
|
|
|
|
|
|
/**
|
2010-12-01 14:26:29 +01:00
|
|
|
* Constructs ...
|
2010-10-12 09:16:40 +02:00
|
|
|
*
|
2010-12-13 18:59:00 +01:00
|
|
|
*
|
|
|
|
|
*
|
2010-12-16 07:46:02 +01:00
|
|
|
*
|
|
|
|
|
* @param securityContextProvicer
|
2010-12-13 18:59:00 +01:00
|
|
|
* @param configuration
|
|
|
|
|
* @param pluginLoader
|
|
|
|
|
* @param cacheManager
|
2010-10-12 09:16:40 +02:00
|
|
|
*/
|
2010-12-13 18:59:00 +01:00
|
|
|
@Inject
|
2010-12-16 07:46:02 +01:00
|
|
|
public DefaultPluginManager(
|
|
|
|
|
Provider<SecurityContext> securityContextProvicer,
|
|
|
|
|
ScmConfiguration configuration, PluginLoader pluginLoader,
|
|
|
|
|
CacheManager cacheManager)
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
this.securityContextProvicer = securityContextProvicer;
|
2010-12-13 18:59:00 +01:00
|
|
|
this.configuration = configuration;
|
|
|
|
|
this.cache = cacheManager.getSimpleCache(String.class, PluginCenter.class,
|
|
|
|
|
CACHE_NAME);
|
2010-12-18 16:25:57 +01:00
|
|
|
installedPlugins = new HashMap<String, Plugin>();
|
2010-12-13 18:59:00 +01:00
|
|
|
|
|
|
|
|
for (Plugin plugin : pluginLoader.getInstalledPlugins())
|
|
|
|
|
{
|
|
|
|
|
PluginInformation info = plugin.getInformation();
|
|
|
|
|
|
2010-12-16 07:46:02 +01:00
|
|
|
if ((info != null) && info.isValid())
|
2010-12-13 18:59:00 +01:00
|
|
|
{
|
2010-12-18 16:25:57 +01:00
|
|
|
installedPlugins.put(info.getId(), plugin);
|
2010-12-13 18:59:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-12 09:16:40 +02:00
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
try
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
2010-12-13 18:59:00 +01:00
|
|
|
unmarshaller =
|
|
|
|
|
JAXBContext.newInstance(PluginCenter.class).createUnmarshaller();
|
2010-12-01 14:26:29 +01:00
|
|
|
}
|
2010-12-13 18:59:00 +01:00
|
|
|
catch (JAXBException ex)
|
2010-12-01 14:26:29 +01:00
|
|
|
{
|
2010-12-13 18:59:00 +01:00
|
|
|
throw new ConfigurationException(ex);
|
2010-10-12 09:16:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
//~--- methods --------------------------------------------------------------
|
|
|
|
|
|
2010-12-18 14:18:14 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void clearCache()
|
|
|
|
|
{
|
|
|
|
|
cache.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 09:16:40 +02:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2010-12-13 18:59:00 +01:00
|
|
|
* @param id
|
2010-10-12 09:16:40 +02:00
|
|
|
*/
|
2010-12-01 14:26:29 +01:00
|
|
|
@Override
|
2010-12-13 18:59:00 +01:00
|
|
|
public void install(String id)
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-13 21:02:39 +01:00
|
|
|
if (pluginHandler == null)
|
|
|
|
|
{
|
|
|
|
|
getPluginCenter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginHandler.install(id);
|
2010-12-13 18:59:00 +01:00
|
|
|
}
|
2010-12-01 14:26:29 +01:00
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void uninstall(String id)
|
|
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-18 16:25:57 +01:00
|
|
|
Plugin plugin = installedPlugins.get(id);
|
|
|
|
|
|
|
|
|
|
if (plugin == null)
|
|
|
|
|
{
|
2010-12-18 18:21:21 +01:00
|
|
|
throw new PluginNotInstalledException(id.concat(" is not install"));
|
2010-12-18 16:25:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pluginHandler == null)
|
|
|
|
|
{
|
|
|
|
|
pluginHandler = new AetherPluginHandler(SCMContext.getContext());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginHandler.uninstall(plugin.getPath());
|
2010-10-12 09:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void update(String id)
|
|
|
|
|
{
|
|
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-18 18:21:21 +01:00
|
|
|
String[] idParts = id.split(":");
|
|
|
|
|
String groupId = idParts[0];
|
|
|
|
|
String artefactId = idParts[1];
|
|
|
|
|
PluginInformation installed = null;
|
|
|
|
|
|
|
|
|
|
for (PluginInformation info : getInstalled())
|
|
|
|
|
{
|
|
|
|
|
if (groupId.equals(info.getGroupId())
|
|
|
|
|
&& artefactId.equals(info.getArtifactId()))
|
|
|
|
|
{
|
|
|
|
|
installed = info;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (installed == null)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder msg = new StringBuilder(groupId);
|
|
|
|
|
|
|
|
|
|
msg.append(":").append(groupId).append(" is not install");
|
|
|
|
|
|
|
|
|
|
throw new PluginNotInstalledException(msg.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pluginHandler == null)
|
|
|
|
|
{
|
|
|
|
|
getPluginCenter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginHandler.uninstall(installed.getId());
|
|
|
|
|
pluginHandler.install(id);
|
2010-12-18 13:37:34 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-12 09:16:40 +02:00
|
|
|
//~--- get methods ----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2010-12-13 18:59:00 +01:00
|
|
|
* @param id
|
|
|
|
|
*
|
2010-10-12 09:16:40 +02:00
|
|
|
* @return
|
|
|
|
|
*/
|
2010-12-01 14:26:29 +01:00
|
|
|
@Override
|
2010-12-13 18:59:00 +01:00
|
|
|
public PluginInformation get(String id)
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-13 21:02:39 +01:00
|
|
|
PluginInformation result = null;
|
|
|
|
|
|
|
|
|
|
for (PluginInformation info : getPluginCenter().getPlugins())
|
|
|
|
|
{
|
|
|
|
|
if (id.equals(info.getId()))
|
|
|
|
|
{
|
|
|
|
|
result = info;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2010-10-12 09:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param filter
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Set<PluginInformation> get(PluginFilter filter)
|
|
|
|
|
{
|
|
|
|
|
AssertUtil.assertIsNotNull(filter);
|
|
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
|
|
|
|
Set<PluginInformation> infoSet = new HashSet<PluginInformation>();
|
|
|
|
|
|
2010-12-18 16:25:57 +01:00
|
|
|
filter(infoSet, getInstalled(), filter);
|
2010-12-18 13:37:34 +01:00
|
|
|
filter(infoSet, getPluginCenter().getPlugins(), filter);
|
|
|
|
|
|
|
|
|
|
return infoSet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Collection<PluginInformation> getAll()
|
|
|
|
|
{
|
|
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-18 16:25:57 +01:00
|
|
|
Set<PluginInformation> infoSet = getInstalled();
|
2010-12-18 13:37:34 +01:00
|
|
|
|
|
|
|
|
infoSet.addAll(getPluginCenter().getPlugins());
|
|
|
|
|
|
|
|
|
|
return infoSet;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 14:26:29 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2010-12-13 18:59:00 +01:00
|
|
|
* @return
|
2010-12-01 14:26:29 +01:00
|
|
|
*/
|
2010-12-13 18:59:00 +01:00
|
|
|
@Override
|
|
|
|
|
public Collection<PluginInformation> getAvailable()
|
2010-12-01 14:26:29 +01:00
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-17 19:02:32 +01:00
|
|
|
Set<PluginInformation> availablePlugins = new HashSet<PluginInformation>();
|
|
|
|
|
Set<PluginInformation> centerPlugins = getPluginCenter().getPlugins();
|
|
|
|
|
|
|
|
|
|
for (PluginInformation info : centerPlugins)
|
|
|
|
|
{
|
|
|
|
|
if (!installedPlugins.containsKey(info.getId()))
|
|
|
|
|
{
|
|
|
|
|
availablePlugins.add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return availablePlugins;
|
2010-12-01 14:26:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
2010-12-18 16:25:57 +01:00
|
|
|
public Set<PluginInformation> getAvailableUpdates()
|
2010-12-18 13:37:34 +01:00
|
|
|
{
|
|
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
|
|
|
|
return get(FILTER_UPDATES);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 09:16:40 +02:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2010-12-13 18:59:00 +01:00
|
|
|
* @return
|
2010-10-12 09:16:40 +02:00
|
|
|
*/
|
2010-12-13 18:59:00 +01:00
|
|
|
@Override
|
2010-12-18 16:25:57 +01:00
|
|
|
public Set<PluginInformation> getInstalled()
|
2010-10-12 09:16:40 +02:00
|
|
|
{
|
2010-12-16 07:46:02 +01:00
|
|
|
SecurityUtil.assertIsAdmin(securityContextProvicer);
|
|
|
|
|
|
2010-12-18 16:25:57 +01:00
|
|
|
Set<PluginInformation> infoSet = new LinkedHashSet<PluginInformation>();
|
|
|
|
|
|
|
|
|
|
for (Plugin plugin : installedPlugins.values())
|
|
|
|
|
{
|
|
|
|
|
infoSet.add(plugin.getInformation());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return infoSet;
|
2010-12-13 18:59:00 +01:00
|
|
|
}
|
2010-12-01 14:26:29 +01:00
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
//~--- methods --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param target
|
|
|
|
|
* @param source
|
|
|
|
|
* @param filter
|
|
|
|
|
*/
|
|
|
|
|
private void filter(Set<PluginInformation> target,
|
|
|
|
|
Collection<PluginInformation> source, PluginFilter filter)
|
|
|
|
|
{
|
|
|
|
|
for (PluginInformation info : source)
|
|
|
|
|
{
|
|
|
|
|
if (filter.accept(info))
|
|
|
|
|
{
|
|
|
|
|
target.add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param available
|
|
|
|
|
*/
|
|
|
|
|
private void preparePlugin(PluginInformation available)
|
|
|
|
|
{
|
|
|
|
|
PluginState state = PluginState.AVAILABLE;
|
|
|
|
|
|
2010-12-18 16:25:57 +01:00
|
|
|
for (PluginInformation installed : getInstalled())
|
2010-12-18 13:37:34 +01:00
|
|
|
{
|
|
|
|
|
if (isSamePlugin(available, installed))
|
|
|
|
|
{
|
|
|
|
|
if (installed.getVersion().equals(available.getVersion()))
|
|
|
|
|
{
|
2010-12-18 18:21:21 +01:00
|
|
|
state = PluginState.INSTALLED;
|
2010-12-18 13:37:34 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-18 18:21:21 +01:00
|
|
|
state = PluginState.UPDATE_AVAILABLE;
|
2010-12-18 13:37:34 +01:00
|
|
|
}
|
2010-12-18 18:21:21 +01:00
|
|
|
|
|
|
|
|
break;
|
2010-12-18 13:37:34 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
available.setState(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param pc
|
|
|
|
|
*/
|
|
|
|
|
private void preparePlugins(PluginCenter pc)
|
|
|
|
|
{
|
|
|
|
|
Set<PluginInformation> infoSet = pc.getPlugins();
|
|
|
|
|
|
|
|
|
|
if (infoSet != null)
|
|
|
|
|
{
|
|
|
|
|
for (PluginInformation available : infoSet)
|
|
|
|
|
{
|
|
|
|
|
preparePlugin(available);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~--- get methods ----------------------------------------------------------
|
|
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private PluginCenter getPluginCenter()
|
|
|
|
|
{
|
|
|
|
|
PluginCenter center = cache.get(PluginCenter.class.getName());
|
2010-10-12 09:16:40 +02:00
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
if (center == null)
|
|
|
|
|
{
|
2010-12-13 21:02:39 +01:00
|
|
|
synchronized (DefaultPluginManager.class)
|
2010-12-13 18:59:00 +01:00
|
|
|
{
|
2010-12-13 21:02:39 +01:00
|
|
|
if (logger.isInfoEnabled())
|
|
|
|
|
{
|
|
|
|
|
logger.info("fetch plugin informations from {}",
|
|
|
|
|
configuration.getPluginUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
center = (PluginCenter) unmarshaller.unmarshal(
|
|
|
|
|
new URL(configuration.getPluginUrl()));
|
2010-12-18 13:37:34 +01:00
|
|
|
preparePlugins(center);
|
2010-12-13 21:02:39 +01:00
|
|
|
cache.put(PluginCenter.class.getName(), center);
|
|
|
|
|
|
|
|
|
|
if (pluginHandler == null)
|
|
|
|
|
{
|
|
|
|
|
pluginHandler = new AetherPluginHandler(SCMContext.getContext());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginHandler.setPluginRepositories(center.getRepositories());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new PluginLoadException(ex);
|
|
|
|
|
}
|
2010-12-13 18:59:00 +01:00
|
|
|
}
|
2010-10-12 09:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
return center;
|
|
|
|
|
}
|
2010-12-01 14:26:29 +01:00
|
|
|
|
2010-12-18 13:37:34 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param p1
|
|
|
|
|
* @param p2
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean isSamePlugin(PluginInformation p1, PluginInformation p2)
|
|
|
|
|
{
|
|
|
|
|
return p1.getGroupId().equals(p2.getGroupId())
|
|
|
|
|
&& p1.getArtifactId().equals(p2.getArtifactId());
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 09:16:40 +02:00
|
|
|
//~--- fields ---------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/** Field description */
|
2010-12-13 18:59:00 +01:00
|
|
|
private SimpleCache<String, PluginCenter> cache;
|
|
|
|
|
|
|
|
|
|
/** Field description */
|
|
|
|
|
private ScmConfiguration configuration;
|
|
|
|
|
|
|
|
|
|
/** Field description */
|
2010-12-18 16:25:57 +01:00
|
|
|
private Map<String, Plugin> installedPlugins;
|
2010-12-13 18:59:00 +01:00
|
|
|
|
2010-12-13 21:02:39 +01:00
|
|
|
/** Field description */
|
|
|
|
|
private AetherPluginHandler pluginHandler;
|
|
|
|
|
|
2010-12-16 07:46:02 +01:00
|
|
|
/** Field description */
|
|
|
|
|
private Provider<SecurityContext> securityContextProvicer;
|
|
|
|
|
|
2010-12-13 18:59:00 +01:00
|
|
|
/** Field description */
|
|
|
|
|
private Unmarshaller unmarshaller;
|
2010-10-12 09:16:40 +02:00
|
|
|
}
|