Package org.ungoverned.osgi.service.bundlerepository

Examples of org.ungoverned.osgi.service.bundlerepository.BundleRecord


  }
  */

  private BundleRecord findBundleRecord(String name, String versionString)
  {
    BundleRecord record = null;

    if(name.startsWith("=")) {
      int id = -1;
      try {
        id = Integer.parseInt(name.substring(1));
        record = brs.getBundleRecord(id - 1);
        if(record != null) {
          System.out.println(id + " " + record.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION));
          return record;
        }
      } catch (Exception ignored) {
      }
    }
View Full Code Here


        }
      };
    }

    void installOrStartSync(OBRNode obrNode, boolean bStart) {
      BundleRecord br = obrNode.getBundleRecord();
      if(br == null) {
        return;
      }

      String updateURL =
        (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);

      // Check if bundle already is installed. If so,
      // ask user if it should be updated, installed again or
      // if the operation should be cancelled.
      Bundle b = getBundle(br);
View Full Code Here

     */
    synchronized void refreshList(final boolean bReload) {
      Thread t = new Thread() {
          public void run() {
            locationMap.clear();
            BundleRecord brOld = brSelected != null ? brSelected.getBundleRecord() : null;

            setRootText(STR_LOADING);

            rootNode = new TopNode(STR_TOPNAME);
            treeModel = new DefaultTreeModel(rootNode);

            BundleRepositoryService obr = getOBR();

            if(obr != null) {
              if(bReload) {
                obrErr = "";
                try {
                  assertRepoURLs(obr.getRepositoryURLs());
                  obr.setRepositoryURLs(obr.getRepositoryURLs());
                } catch (Exception e) {
                  obrErr =
                    "<b>" + e.getClass().getName() + "</b>"+
                    "<pre>\n" +
                    e.getMessage() +
                    "</pre>";
                }
              }
              int count = obr.getBundleRecordCount();

              // String (category) -> Set (BundleRecord)
              Map categories = new TreeMap(new Comparator() {
                  public int compare(Object o1, Object o2) {
                    return o1.toString().compareToIgnoreCase(o2.toString());
                  }
                });

              // move all bundle records into a sorted
              // category map of sets
              for(int i = 0; i < count; i++) {
                BundleRecord br = obr.getBundleRecord(i);

                String loc = (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);

                String category = "other";
                if(sortCategory == SORT_CATEGORY) {
                  category = Util.getAttribute(br,
                                               BundleRecord.BUNDLE_CATEGORY,
                                               "[no category]");
                } else if(sortCategory == SORT_VENDOR) {
                  category = Util.getAttribute(br,
                                               BundleRecord.BUNDLE_VENDOR,
                                               "[no vendor]");
                } else if(sortCategory == SORT_STATUS) {
                  if(isInstalled(br)) {
                    category = "Installed";
                  } else {
                    category = "Not installed";
                  }
                } else if(sortCategory == SORT_NONE) {
                  category = SORT_NAMES[SORT_NONE];
                } else {
                  int ix = loc.indexOf(":");
                  if(ix != -1) {
                    category = loc.substring(0, ix);
                    if(loc.startsWith("http://")) {
                      ix = loc.indexOf("/", 8);
                      if(ix != -1) {
                        category = loc.substring(0, ix);
                      }
                    } else {
                      ix = loc.indexOf("/", ix + 1);
                      if(ix != -1) {
                        category = loc.substring(0, ix);
                      } else {
                        ix = loc.indexOf("\\", ix + 1);
                        if(ix != -1) {
                          category = loc.substring(0, ix);
                        }
                      }
                    }
                  }
                }
                Set set = (Set)categories.get(category);
                if(set == null) {
                  set = new TreeSet(new BRComparator());
                  categories.put(category, set);
                }
                set.add(br);
              }


              int i = 0;
              DefaultMutableTreeNode selNode = null;

              for(Iterator it = categories.keySet().iterator(); it.hasNext();) {
                String category = (String)it.next();
                Set    set      = (Set)categories.get(category);

                final DefaultMutableTreeNode categoryNode =
                  new CategoryNode(category);

                for(Iterator it2 = set.iterator(); it2.hasNext();) {
                  BundleRecord br = (BundleRecord)it2.next();

                  DefaultMutableTreeNode brNode =  new OBRNode(br);
                  categoryNode.add(brNode);
                  i++;

                  String loc = (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);

                  locationMap.put(loc, brNode);
                  if(brOld != null && loc.equals(brOld.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION))) {
                    selNode = brNode;

View Full Code Here

   * Sort first by case-insensite name, tehn by version
   * </p>
   */
  class BRComparator implements Comparator {
    public int compare(Object o1, Object o2) {
      BundleRecord br1 = (BundleRecord)o1;
      BundleRecord br2 = (BundleRecord)o2;
      String s1 = Util.getBRName(br1).toLowerCase();
      String s2 = Util.getBRName(br2).toLowerCase();
      int n = 0;

      try {
        n = s1.compareTo(s2);
        if(n == 0) {
          s1 = (String)br1.getAttribute(BundleRecord.BUNDLE_VERSION);
          s2 = (String)br2.getAttribute(BundleRecord.BUNDLE_VERSION);
        }

        n = s1.compareTo(s2);
      } catch (Exception e) {
      }
View Full Code Here

TOP

Related Classes of org.ungoverned.osgi.service.bundlerepository.BundleRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.