mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
added api to install plugin packages
This commit is contained in:
@@ -44,8 +44,10 @@ import sonia.scm.util.IOUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@@ -66,6 +68,30 @@ public class ZipUnArchiver extends AbstractUnArchiver
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param inputStream
|
||||
* @param outputDirectory
|
||||
*
|
||||
* @throws IOException
|
||||
* @since 1.21
|
||||
*/
|
||||
public void extractArchive(InputStream inputStream, File outputDirectory)
|
||||
throws IOException
|
||||
{
|
||||
ZipInputStream input = new ZipInputStream(inputStream);
|
||||
|
||||
ZipEntry entry = input.getNextEntry();
|
||||
|
||||
while (entry != null)
|
||||
{
|
||||
extractEntry(outputDirectory, input, entry);
|
||||
entry = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -77,27 +103,20 @@ public class ZipUnArchiver extends AbstractUnArchiver
|
||||
*/
|
||||
@Override
|
||||
protected void extractArchive(File archive, File outputDirectory)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("extract zip \"{}\" to \"{}\"", archive.getPath(),
|
||||
outputDirectory.getAbsolutePath());
|
||||
outputDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
ZipInputStream input = null;
|
||||
InputStream input = null;
|
||||
|
||||
try
|
||||
{
|
||||
input = new ZipInputStream(new FileInputStream(archive));
|
||||
|
||||
ZipEntry entry = input.getNextEntry();
|
||||
|
||||
while (entry != null)
|
||||
{
|
||||
extractEntry(outputDirectory, input, entry);
|
||||
entry = input.getNextEntry();
|
||||
}
|
||||
input = new FileInputStream(archive);
|
||||
extractArchive(input, outputDirectory);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -135,8 +154,8 @@ public class ZipUnArchiver extends AbstractUnArchiver
|
||||
* @throws IOException
|
||||
*/
|
||||
private void extractEntry(File outputDirectory, ZipInputStream input,
|
||||
ZipEntry entry)
|
||||
throws IOException
|
||||
ZipEntry entry)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -177,7 +196,7 @@ public class ZipUnArchiver extends AbstractUnArchiver
|
||||
* @throws IOException
|
||||
*/
|
||||
private void extractFile(ZipInputStream input, File outputFile)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
FileOutputStream output = null;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -58,6 +61,17 @@ public interface PluginManager
|
||||
*/
|
||||
public void install(String id);
|
||||
|
||||
/**
|
||||
* Installs a plugin package from a inputstream.
|
||||
*
|
||||
*
|
||||
* @param packageStream package input stream
|
||||
*
|
||||
* @throws IOException
|
||||
* @since 1.21
|
||||
*/
|
||||
public void installPackage(InputStream packageStream) throws IOException;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user