diff --git a/nexus-core-plugins/nexus-buup-plugin/pom.xml b/nexus-core-plugins/nexus-buup-plugin/pom.xml index 99e061ad39..e4c9074969 100644 --- a/nexus-core-plugins/nexus-buup-plugin/pom.xml +++ b/nexus-core-plugins/nexus-buup-plugin/pom.xml @@ -6,7 +6,7 @@ org.sonatype.nexus.plugins nexus-core-plugins - 1.4.1-SNAPSHOT + 1.4.2-SNAPSHOT nexus-buup-plugin diff --git a/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/BundleDownloadTask.java b/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/BundleDownloadTask.java new file mode 100644 index 0000000000..ac6c32a0a8 --- /dev/null +++ b/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/BundleDownloadTask.java @@ -0,0 +1,55 @@ +package org.sonatype.nexus.buup; + +import java.io.File; + +import org.codehaus.plexus.component.annotations.Component; +import org.sonatype.nexus.scheduling.AbstractNexusTask; +import org.sonatype.scheduling.SchedulerTask; + +@Component( role = SchedulerTask.class, hint = "BundleDownloadTask", instantiationStrategy = "per-lookup" ) +public class BundleDownloadTask + extends AbstractNexusTask +{ + private boolean successful; + + private File targetDirectory; + + public boolean isSuccessful() + { + return successful; + } + + public File getTargetDirectory() + { + return targetDirectory; + } + + public void setTargetDirectory( File targetDirectory ) + { + this.targetDirectory = targetDirectory; + } + + @Override + protected Object doRun() + throws Exception + { + // downloads bundle from somewhere (from where?) + // checks it's checksum (similar is applied as to maven artifacts) + // unzip it to targetDirectory + + return null; + } + + @Override + protected String getAction() + { + return "BUUP"; + } + + @Override + protected String getMessage() + { + return "Downloading bundle for OneClickUpgrade"; + } + +} diff --git a/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/DefaultNexusBuupPlugin.java b/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/DefaultNexusBuupPlugin.java index 66c389fea6..42ee14e91c 100644 --- a/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/DefaultNexusBuupPlugin.java +++ b/nexus-core-plugins/nexus-buup-plugin/src/main/java/org/sonatype/nexus/buup/DefaultNexusBuupPlugin.java @@ -10,6 +10,7 @@ import org.sonatype.nexus.buup.invoke.NexusBuupInvocationException; import org.sonatype.nexus.buup.invoke.NexusBuupInvocationRequest; import org.sonatype.nexus.buup.invoke.NexusBuupInvoker; +import org.sonatype.nexus.scheduling.NexusScheduler; @Component( role = NexusBuupPlugin.class ) public class DefaultNexusBuupPlugin @@ -18,6 +19,9 @@ public class DefaultNexusBuupPlugin @Requirement private NexusBuupInvoker invoker; + @Requirement + private NexusScheduler nexusScheduler; + @Requirement private FSPermissionChecker permissionChecker; @@ -33,6 +37,8 @@ public class DefaultNexusBuupPlugin @Configuration( value = "${nexus-work}/upgrade-bundle" ) private File upgradeBundleDir; + private BundleDownloadTask downloadTask; + public void initiateBundleDownload() throws IOException { @@ -47,13 +53,22 @@ public void initiateBundleDownload() } // start download thread + downloadTask = nexusScheduler.createTaskInstance( BundleDownloadTask.class ); + downloadTask.setTargetDirectory( upgradeBundleDir ); + nexusScheduler.submit( "Bundle Download", downloadTask ); } public boolean isUpgradeProcessReady() { - // check download thread is done, and check for exploded bundle dir content - // TODO Auto-generated method stub - return true; + if ( downloadTask != null && downloadTask.isSuccessful() ) + { + // check for unziped files + return true; + } + else + { + return false; + } } public boolean initiateUpgradeProcess()