Пример #1
0
  /**
   * Process the expression matching operation of the given application name.
   *
   * @param name the application name containing the version expression
   * @param target the target we are looking for the verisons
   * @return a List of all expression matched versions, return empty list if no version is
   *     registered on this target or if getUntaggedName throws an exception
   */
  public final List<String> getMatchedVersions(String name, String target)
      throws VersioningSyntaxException, VersioningException {

    String untagged = VersioningUtils.getUntaggedName(name);
    List<String> allVersions = getAllversions(untagged, target);

    if (allVersions.size() == 0) {
      // if versionned
      if (!name.equals(untagged)) {
        throw new VersioningException(
            VersioningUtils.LOCALSTRINGS.getLocalString(
                "versioning.deployment.application.noversion",
                "Application {0} has no version registered",
                untagged));
      }
      return Collections.EMPTY_LIST;
    }

    return VersioningUtils.matchExpression(allVersions, name);
  }
Пример #2
0
  /**
   * Search for the enabled version of the given application.
   *
   * @param name the application name
   * @param target an option supply from admin command, it's retained for compatibility with other
   *     releases
   * @return the enabled version of the application, if exists
   * @throws VersioningSyntaxException if getUntaggedName throws an exception
   */
  public final String getEnabledVersion(String name, String target)
      throws VersioningSyntaxException {

    String untaggedName = VersioningUtils.getUntaggedName(name);
    List<String> allVersions = getAllversions(untaggedName, target);

    if (allVersions != null) {
      Iterator it = allVersions.iterator();

      while (it.hasNext()) {
        String app = (String) it.next();

        // if a version of the app is enabled
        if (domain.isAppEnabledInTarget(app, target)) {
          return app;
        }
      }
    }
    // no enabled version found
    return null;
  }
Пример #3
0
  /**
   * Get the version directory-deployed from the given directory
   *
   * @param directory
   * @return the name of the version currently using the directory, else null
   * @throws VersioningSyntaxException *
   */
  public String getVersionFromSameDir(File dir) throws VersioningSyntaxException {

    try {
      Iterator it = domain.getApplications().getApplications().iterator();
      Application app = null;

      // check if directory deployment exist
      while (it.hasNext()) {
        app = (Application) it.next();
        /*
         * A lifecycle module appears as an application but has a null location.
         */
        if (dir.toURI().toString().equals(app.getLocation())) {
          if (!VersioningUtils.getUntaggedName(app.getName()).equals(app.getName())) {
            return app.getName();
          }
        }
      }
    } catch (VersioningSyntaxException ex) {
      // return null if an exception is thrown
    }
    return null;
  }