Example #1
0
 /**
  * Extract the set of version(s) of the given application represented as an untagged version name
  *
  * @param untaggedName the application name as an untagged version : an application name without
  *     version identifier
  * @param target the target where we want to get all the versions
  * @return all the version(s) of the given application
  */
 private final List<String> getAllversions(String untaggedName, String target) {
   List<Application> allApplications = null;
   if (target != null) {
     allApplications = domain.getApplicationsInTarget(target);
   } else {
     allApplications = domain.getApplications().getApplications();
   }
   return VersioningUtils.getVersions(untaggedName, allApplications);
 }
  private String getApplicationName(String path) {
    Habitat habitat = Globals.getDefaultHabitat();

    Domain domain = habitat.getInhabitantByType(Domain.class).get();

    List<Application> applicationList = domain.getApplications().getApplications();

    // looks like path always ends with "/" .. but just to be sure..
    for (Application app : applicationList) {
      if (path.startsWith(app.getContextRoot() + "/") || path.equals(app.getContextRoot()))
        return app.getName();
    }

    return null;
  }
Example #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;
  }