Beispiel #1
0
  /**
   * Through the method <code>getAddonVersion</code> you can get a addon version instance passing
   * like parameter a version reference instance.
   *
   * @param addonVersionReference addon version reference data.
   * @return a addon version instance.
   * @throws VersionNotFoundException if we can't find a addon version with the given version
   *     reference parameters.
   */
  public final AbstractAddon getAddonVersion(final AddonVersionReference addonVersionReference)
      throws VersionNotFoundException {

    try {

      return getAddonDeveloper(addonVersionReference.getAddonDeveloperReference())
          .getAddonByVersion(addonVersionReference);

    } catch (DeveloperNotFoundException e) {

      throw new VersionNotFoundException(
          e,
          addonVersionReference.toString(),
          "addon version not found in the platform of the system context.");
    }
  }
  /*
     Created by matias, used in fragment to get loglevels
  */
  @Override
  public List<ClassHierarchyLevels> getClassesHierarchyAddons(AddonVersionReference addon)
      throws CantGetClasessHierarchyAddonsException {

    try {
      /** I get the class full patch from the plug in. */
      List<String> classes =
          ((LogManagerForDevelopers) this.LoggingLstAddons.get(addon)).getClassesFullPath();

      /**
       * I need to know the minimun number of packages on the plug in. If there are more than three,
       * then I will create only three levels *
       */
      int minPackages = 100, cantPackages = 0;
      for (String myClass : classes) {
        String[] packages = myClass.split(Pattern.quote("."));
        cantPackages = packages.length;
        if (minPackages > cantPackages) minPackages = cantPackages;
      }
      /** minPackages holds the minimun number of packages available on the plug in. */

      /**
       * I instantiate the class that will hold the levels of the packages. Level 1: root (which may
       * contain a lot of packages) Level 2: the last package Level 3: the class name.
       */
      List<ClassHierarchyLevels> returnedClasses = new ArrayList<>();

      for (String myClass : classes) {
        String[] packages = myClass.split(Pattern.quote("."));
        ClassHierarchyLevels classesAndPackages = new ClassHierarchyLevels();
        classesAndPackages.setLevel0(addon.toKey());
        classesAndPackages.setFullPath(myClass);
        if (packages.length == minPackages) {
          /** if this is the root, then I will add it to level2 and nothing else. */
          classesAndPackages.setLevel1(packages[packages.length - 1]);

        } else {
          /** si no es el root, I will add the other levels. */
          StringBuilder splitedPackages = new StringBuilder();
          for (int i = 0; i < packages.length - 1; i++) {
            splitedPackages.append(packages[i]);
            splitedPackages.append(".");
          }
          /** I remove the last dot of the package. */
          splitedPackages.substring(0, splitedPackages.length() - 1);

          classesAndPackages.setLevel1(splitedPackages.toString());
          classesAndPackages.setLevel2(packages[packages.length - 1]);
        }
        returnedClasses.add(classesAndPackages);
      }
      /** I return the object */
      return returnedClasses;
    } catch (Exception e) {
      throw new CantGetClasessHierarchyAddonsException(
          CantGetClasessHierarchyAddonsException.DEFAULT_MESSAGE,
          e,
          "Error to get from the plugin the list of classes with their full paths",
          "");
    }
  }