/** * Checks whether the given Deployable can actually be deployed and whether a deployable has a * web context path that already exist in another previously deployed Deployable. * * @param newDeployable deployable * @return true, if the deployable can be deployed */ protected boolean canBeDeployed(Deployable newDeployable) { final Set<String> newDeployableContextSet = getWebContextsSet(newDeployable); for (Deployable deployedDeployable : this.deployedDeployables) { for (String webContext : getWebContexts(deployedDeployable)) { if (newDeployableContextSet.contains(webContext)) { return false; } } } return true; }
/** * Create a set of all web contexts for a Deployable. * * @param deployable Deployable * @return a set of all web contexts contained in this deployable. */ private static Set<String> getWebContextsSet(Deployable deployable) { final Set<String> webContextSet = new HashSet<String>(); for (String webContext : getWebContexts(deployable)) { webContextSet.add(webContext); } return webContextSet; }