updated build scripts to sbt 1.0
added service returning a tar archive with all the requested packages
This commit is contained in:
24
build.sbt
24
build.sbt
@@ -54,15 +54,17 @@ wildflyURL := "localhost:1234"
|
||||
|
||||
val deploy2Wildfly = TaskKey[Unit]("deploy2Wildfly", "Deploy to a wildfly server instance", KeyRanks.ATask)
|
||||
|
||||
deploy2Wildfly <<= (packagedArtifact in(Compile, Keys.`package`), wildflyURL, wildflyUsername, wildflyPassword) map
|
||||
|
||||
deploy2Wildfly := {
|
||||
val cmd = s"/opt/wildfly/bin/jboss-cli.sh " +
|
||||
s"--controller='${wildflyURL.value}' " +
|
||||
s"--connect --user='${wildflyUsername.value}' " +
|
||||
s"--password='${wildflyPassword.value}' " +
|
||||
s"--command=\'deploy ${(packagedArtifact in(Compile, Keys.`package`)).value._2} --force\'"
|
||||
println(cmd)
|
||||
sys.process.stringToProcess(cmd).! match
|
||||
{
|
||||
case ((art: Artifact, warFile: File), url: String, username: String, password: String) =>
|
||||
//val warFile = (artifactPath in Keys.`package` in Compile).value//(artifactPath in `package`).value.absolutePath //(packageBin in Compile).value //(artifactPath in (Compile, package)).value
|
||||
val cmd = s"/opt/wildfly/bin/jboss-cli.sh --controller='${url}' --connect --user='${username}' --password='${password}' --command=\'deploy ${warFile.absolutePath} --force\'"
|
||||
println(cmd)
|
||||
sys.process.stringToProcess(cmd).! match
|
||||
{
|
||||
case 0 => "OK"
|
||||
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||
}
|
||||
}
|
||||
case 0 => "OK"
|
||||
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
sbt.version=0.13.13
|
||||
sbt.version=1.0.1
|
||||
|
@@ -1 +1 @@
|
||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.0")
|
||||
|
@@ -9,7 +9,8 @@ import com.oggio88.jpacrepo.model.PkgName;
|
||||
import com.oggio88.jpacrepo.model.StringList;
|
||||
import com.oggio88.jpacrepo.pacbase.Parser;
|
||||
import com.oggio88.jpacrepo.persistence.QueryEngine;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.ejb.*;
|
||||
@@ -354,9 +355,54 @@ public class PacmanWebService
|
||||
}
|
||||
|
||||
@POST
|
||||
public Response foo()
|
||||
@Path("/downloadTar")
|
||||
@Produces("application/x-tar")
|
||||
public Response downloadTar(List<String> files)
|
||||
{
|
||||
TarArchiveouputStream tais = new TarArchiveOutputStream();
|
||||
for(String fname : files)
|
||||
{
|
||||
if(!ctx.getFile(fname).exists()) throw new NotFoundException(String.format("Package file '%s' does not exist", fname));
|
||||
}
|
||||
StreamingOutput stream = new StreamingOutput()
|
||||
{
|
||||
@Override
|
||||
public void write(OutputStream output) throws IOException, WebApplicationException
|
||||
{
|
||||
TarArchiveOutputStream taos = new TarArchiveOutputStream(output);
|
||||
try
|
||||
{
|
||||
for (String fname : files)
|
||||
{
|
||||
File file = ctx.getFile(fname);
|
||||
FileInputStream input = new FileInputStream(file);
|
||||
|
||||
TarArchiveEntry entry = new TarArchiveEntry(fname);
|
||||
entry.setSize(file.length());
|
||||
taos.putArchiveEntry(entry);
|
||||
byte[] bytes = new byte[1024];
|
||||
while (true)
|
||||
{
|
||||
int size = input.read(bytes);
|
||||
if (size < 0) break;
|
||||
else taos.write(bytes, 0, size);
|
||||
}
|
||||
taos.closeArchiveEntry();
|
||||
}
|
||||
taos.close();
|
||||
output.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
taos.close();
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
return Response.ok(stream).build();
|
||||
}
|
||||
|
||||
private Response manageQueryResult(List<PkgData> list)
|
||||
|
Reference in New Issue
Block a user