예제 #1
0
 protected List<String> getAllLocalPackageIdsFromName(String pkgName) {
   List<String> foundIds = new ArrayList<String>();
   for (Package pkg : getPkgList()) {
     if (pkg.getName().equals(pkgName)) {
       foundIds.add(pkg.getId());
     }
   }
   return foundIds;
 }
예제 #2
0
 public void pkgList(List<? extends Package> packagesList) {
   CommandInfo cmdInfo = cset.newCommandInfo(CommandInfo.CMD_LIST);
   try {
     if (packagesList.isEmpty()) {
       log.info("None");
     } else {
       NuxeoConnectClient.getPackageManager().sort(packagesList);
       StringBuilder sb = new StringBuilder();
       for (Package pkg : packagesList) {
         newPackageInfo(cmdInfo, pkg);
         String packageDescription = PackageState.getByValue(pkg.getState()).getLabel();
         packageDescription = String.format("%6s %11s\t", pkg.getType(), packageDescription);
         if (pkg.getState() == PackageState.REMOTE.getValue()
             && pkg.getType() != PackageType.STUDIO
             && pkg.getVisibility() != PackageVisibility.PUBLIC
             && !LogicalInstanceIdentifier.isRegistered()) {
           packageDescription += "Registration required for ";
         }
         packageDescription += String.format("%s (id: %s)\n", pkg.getName(), pkg.getId());
         sb.append(packageDescription);
       }
       log.info(sb.toString());
     }
   } catch (Exception e) {
     log.error(e);
     cmdInfo.exitCode = 1;
   }
 }
예제 #3
0
 protected String getBestIdForNameInList(String pkgName, List<? extends Package> pkgList) {
   String foundId = null;
   SortedMap<Version, String> foundPkgs = new TreeMap<Version, String>();
   SortedMap<Version, String> matchingPkgs = new TreeMap<Version, String>();
   for (Package pkg : pkgList) {
     if (pkg.getName().equals(pkgName)) {
       foundPkgs.put(pkg.getVersion(), pkg.getId());
       if (Arrays.asList(pkg.getTargetPlatforms()).contains(targetPlatform)) {
         matchingPkgs.put(pkg.getVersion(), pkg.getId());
       }
     }
   }
   if (matchingPkgs.size() != 0) {
     foundId = matchingPkgs.get(matchingPkgs.lastKey());
   } else if (foundPkgs.size() != 0) {
     foundId = foundPkgs.get(foundPkgs.lastKey());
   }
   return foundId;
 }