@SuppressWarnings("unchecked")
  private Collection<KnowledgePackage> downloadFromGuvnor(String packageId, String version) throws IOException, ClassNotFoundException{
    UrlResource res=(UrlResource)ResourceFactory.newUrlResource(new URL(basePath+packageId+"/"+version));
    if (enableBasicAuthentication){
      res.setBasicAuthentication("enabled");
      res.setUsername(username);
      res.setPassword(password);
    }
    List<KnowledgePackage> result=new ArrayList<KnowledgePackage>();
    try{
      Object binaryPkg=DroolsStreamUtils.streamIn(res.getInputStream());
      if (binaryPkg instanceof Collection<?>) {
          result.addAll((Collection<KnowledgePackage>)binaryPkg);
      }else if (binaryPkg instanceof KnowledgePackage) {
          result.add((KnowledgePackage)binaryPkg);
      }else if (binaryPkg instanceof org.drools.rule.Package) {
          result.add(new KnowledgePackageImp((org.drools.rule.Package)binaryPkg));
      }else if (binaryPkg instanceof org.drools.rule.Package[]) {
          for (org.drools.rule.Package pkg:(org.drools.rule.Package[])binaryPkg) {
              result.add(new KnowledgePackageImp(pkg));
          }
      }
    }catch(IOException e){
      if (failoverToEmptyRulePackage)
        result.add(new KnowledgePackageImp(new Package("EMPTY")));// EMPTY PACKAGE - no rules will fire
      else
        throw e;
    }
    return result;
  }