added api to install plugin packages

This commit is contained in:
Sebastian Sdorra
2012-09-29 21:44:39 +02:00
parent 5c43ece689
commit a5ca1a55d2
6 changed files with 159 additions and 29 deletions

View File

@@ -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;

View File

@@ -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
*