2014-07-13 09:47:14 +02: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
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package sonia.scm.plugin;
|
|
|
|
|
|
|
|
|
|
//~--- non-JDK imports --------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Function;
|
2019-01-10 12:09:07 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2014-07-13 09:47:14 +02:00
|
|
|
|
|
|
|
|
//~--- JDK imports ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
2014-07-13 13:47:35 +02:00
|
|
|
import java.util.Set;
|
2014-07-13 09:47:14 +02:00
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* The ExplodedSmp object represents an extracted SCM-Manager plugin. The object
|
|
|
|
|
* contains the path to the plugin directory and loads the plugin descriptor.
|
|
|
|
|
* The ExplodedSmp can be created with the {@link #create(java.nio.file.Path)}
|
|
|
|
|
* method.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
|
|
|
|
* @author Sebastian Sdorra
|
|
|
|
|
*/
|
2020-01-31 12:27:02 +01:00
|
|
|
public final class ExplodedSmp
|
2014-07-13 09:47:14 +02:00
|
|
|
{
|
|
|
|
|
|
2019-01-10 12:09:07 +01:00
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ExplodedSmp.class);
|
|
|
|
|
|
2014-07-13 09:47:14 +02:00
|
|
|
/**
|
|
|
|
|
* Constructs ...
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param path
|
2014-07-13 13:47:35 +02:00
|
|
|
* @param plugin
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
2019-08-20 08:05:41 +02:00
|
|
|
ExplodedSmp(Path path, InstalledPluginDescriptor plugin)
|
2014-07-13 09:47:14 +02:00
|
|
|
{
|
2019-01-10 12:09:07 +01:00
|
|
|
logger.trace("create exploded scm for plugin {} and dependencies {}", plugin.getInformation().getName(), plugin.getDependencies());
|
2014-07-13 09:47:14 +02:00
|
|
|
this.path = path;
|
2014-07-13 13:47:35 +02:00
|
|
|
this.plugin = plugin;
|
2014-07-13 09:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~--- methods --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* Creates a new ExplodedSmp object.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
|
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @param directory directory containing an extracted SCM-Manager plugin.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @return ExplodedSmp object
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @throws PluginException if the path does not contain an plugin descriptor
|
|
|
|
|
* or the plugin descriptor could not be parsed
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
2014-10-10 21:26:47 +02:00
|
|
|
public static ExplodedSmp create(Path directory)
|
2014-07-13 09:47:14 +02:00
|
|
|
{
|
2014-07-13 13:47:35 +02:00
|
|
|
Path desc = directory.resolve(PluginConstants.FILE_DESCRIPTOR);
|
2014-07-13 09:47:14 +02:00
|
|
|
|
2014-07-13 13:47:35 +02:00
|
|
|
return new ExplodedSmp(directory, Plugins.parsePluginDescriptor(desc));
|
2014-07-13 09:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~--- get methods ----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* Returns the path to the plugin directory.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
|
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @return to plugin directory
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
|
|
|
|
public Path getPath()
|
|
|
|
|
{
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* Returns parsed plugin descriptor.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
|
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @return plugin descriptor
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
2019-08-20 08:05:41 +02:00
|
|
|
public InstalledPluginDescriptor getPlugin()
|
2014-07-13 09:47:14 +02:00
|
|
|
{
|
2014-07-13 13:47:35 +02:00
|
|
|
return plugin;
|
2014-07-13 09:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~--- inner classes --------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* Transforms {@link Path} to {@link ExplodedSmp}.
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
|
|
|
|
public static class PathTransformer implements Function<Path, ExplodedSmp>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-10 21:26:47 +02:00
|
|
|
* Transforms {@link Path} to {@link ExplodedSmp}. The path must contain an
|
|
|
|
|
* extracted SCM-Manager plugin.
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
|
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @param directory directory containing exploded plugin
|
2014-07-13 09:47:14 +02:00
|
|
|
*
|
2014-10-10 21:26:47 +02:00
|
|
|
* @return exploded smp object
|
|
|
|
|
*
|
|
|
|
|
* @throws PluginException if the path does not contain an extracted
|
|
|
|
|
* SCM-Manager plugin.
|
2014-07-13 09:47:14 +02:00
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ExplodedSmp apply(Path directory)
|
|
|
|
|
{
|
2014-10-10 21:26:47 +02:00
|
|
|
return ExplodedSmp.create(directory);
|
2014-07-13 09:47:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//~--- fields ---------------------------------------------------------------
|
|
|
|
|
|
2014-10-10 21:26:47 +02:00
|
|
|
/** directory */
|
2014-07-13 09:47:14 +02:00
|
|
|
private final Path path;
|
|
|
|
|
|
2014-10-10 21:26:47 +02:00
|
|
|
/** plugin object */
|
2019-08-20 08:05:41 +02:00
|
|
|
private final InstalledPluginDescriptor plugin;
|
2014-07-13 09:47:14 +02:00
|
|
|
}
|