/** * 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); }
/** * 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); }
/** * 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; }
/** * 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; }