Пример #1
0
  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;
  }
Пример #2
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;
  }