.entity("Package [" + packageName + "] does not exist").build());
}
try {
ModuleItem p = compileModuleIfNeeded(packageName);
byte[] result = p.getCompiledBinaryBytes();
ModuleAssembler moduleAssembler = ModuleAssemblerManager.getModuleAssembler(p.getFormat(), p, null);
String fileName = packageName + "." + moduleAssembler.getBinaryExtension();
return Response.ok(result).header("Content-Disposition", "attachment; filename=" + fileName).
header("Last-Modified", createDateFormat().format(this.convertToGmt(p.getLastModified()).getTime())).build();
} catch (RuntimeException e) {
//catch RulesRepositoryException and other exceptions. For example when the package does not exists.
throw new WebApplicationException(e);