public static Module parse(final URI descriptor, final Handler defaultHandler)
      throws IOException, ParseException, IllegalArgumentException {
    if (descriptor == null)
      throw new IllegalArgumentException("The module descriptor URI cannot be null.");

    // Instantiate module and load document
    final Module module = new Module(descriptor, defaultHandler);
    final Document document;
    try {
      document = builderFactory.newDocumentBuilder().parse(new File(descriptor));
    } catch (SAXException e) {
      throw new ParseException("Cannot parse XML document, see inner exception for details.", e);
    } catch (ParserConfigurationException e) {
      throw new ParseException(
          "XML parser configuration invalid, see inner exception for details.", e);
    }

    // Verify root element
    final String moduleType = extract(document, "/module/@type", "Cannot extract module type");
    if (!"JAVA_MODULE".equals(moduleType))
      throw new ParseException("Module \"" + module.getName() + "\" is not a Java module.");

    try {
      module.processComponents(document);
    } catch (ParseException e) {
      throw new ParseException("Cannot parse module \"" + module.getName() + "\".", e);
    }

    return module;
  }
  private static boolean packageResources(
      @NotNull AndroidFacet facet, @NotNull CompileContext context) {
    final Module module = facet.getModule();

    try {
      context.processMessage(
          new ProgressMessage(
              AndroidJpsBundle.message(
                  "android.jps.progress.packaging.resources", module.getName())));

      final File manifestFile = AndroidJpsUtil.getManifestFileForCompilationPath(facet);
      if (manifestFile == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.manifest.not.found", module.getName())));
        return false;
      }
      final ArrayList<String> assetsDirPaths = new ArrayList<String>();
      collectAssetDirs(facet, assetsDirPaths);

      final File outputDir =
          AndroidJpsUtil.getOutputDirectoryForPackagedFiles(context.getProjectPaths(), module);
      if (outputDir == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.output.dir.not.specified", module.getName())));
        return false;
      }

      final Pair<AndroidSdk, IAndroidTarget> pair =
          AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
      if (pair == null) {
        return false;
      }
      final IAndroidTarget target = pair.getSecond();

      final String outputFilePath = getPackagedResourcesFile(module, outputDir).getPath();
      final String[] resourceDirPaths =
          AndroidJpsUtil.collectResourceDirsForCompilation(facet, true, context);

      return doPackageResources(
          context,
          manifestFile,
          target,
          resourceDirPaths,
          ArrayUtil.toStringArray(assetsDirPaths),
          outputFilePath,
          AndroidJpsUtil.isReleaseBuild(context));
    } catch (IOException e) {
      AndroidJpsUtil.reportExceptionError(context, null, e, BUILDER_NAME);
      return false;
    }
  }
  private static boolean runPngCaching(
      @NotNull CompileContext context,
      @NotNull Module module,
      @NotNull AndroidFileSetStorage storage,
      @Nullable AndroidFileSetState state)
      throws IOException {
    final AndroidFileSetState savedState = storage.getState(module.getName());
    if (context.isMake() && savedState != null && savedState.equalsTo(state)) {
      return true;
    }

    final AndroidFacet facet = AndroidJpsUtil.getFacet(module);
    if (facet == null) {
      return true;
    }

    context.processMessage(
        new CompilerMessage(
            BUILDER_NAME,
            BuildMessage.Kind.INFO,
            AndroidJpsBundle.message("android.jps.progress.res.caching", module.getName())));

    final File resourceDir = AndroidJpsUtil.getResourceDirForCompilationPath(facet);
    if (resourceDir == null) {
      return true;
    }

    final Pair<AndroidSdk, IAndroidTarget> pair =
        AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
    if (pair == null) {
      return false;
    }

    final File resCacheDir = AndroidJpsUtil.getResourcesCacheDir(context, module);

    if (!resCacheDir.exists()) {
      if (!resCacheDir.mkdirs()) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                "Cannot create directory " + resCacheDir.getPath()));
        return false;
      }
    }

    final IAndroidTarget target = pair.second;

    final Map<AndroidCompilerMessageKind, List<String>> messages =
        AndroidApt.crunch(
            target, Collections.singletonList(resourceDir.getPath()), resCacheDir.getPath());

    AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME);

    final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty();
    storage.update(module.getName(), success ? state : null);
    return success;
  }
  public List<ContainerUnit> listContainers(String applicationName, boolean withModules)
      throws ServiceException {
    List<ContainerUnit> containers = new ArrayList<>();
    try {
      Application application =
          findByNameAndUser(authentificationUtils.getAuthentificatedUser(), applicationName);
      if (application != null) {
        try {
          // Serveurs
          List<Server> servers = application.getServers();
          // Ajout des containers de type server
          for (Server server : servers) {
            DockerContainer dockerContainer = new DockerContainer();
            dockerContainer.setName(server.getName());
            dockerContainer = DockerContainer.findOne(dockerContainer, application.getManagerIp());
            server = containerMapper.mapDockerContainerToServer(dockerContainer, server);
            ContainerUnit containerUnit =
                new ContainerUnit(server.getName(), server.getContainerID(), "server");
            containers.add(containerUnit);
          }
          if (withModules) {
            // Ajout des containers de type module
            List<Module> modules = application.getModules();
            for (Module module : modules) {
              // on evite de remonter les modules de type toolkit
              // (git, maven...)
              if (module.isTool()) {
                continue;
              }
              DockerContainer dockerContainer = new DockerContainer();
              dockerContainer.setName(module.getName());
              dockerContainer =
                  DockerContainer.findOne(dockerContainer, application.getManagerIp());
              module = containerMapper.mapDockerContainerToModule(dockerContainer, module);
              ContainerUnit containerUnit =
                  new ContainerUnit(module.getName(), module.getContainerID(), "module");
              containers.add(containerUnit);
            }
          }
        } catch (Exception ex) {
          // Si une application sort en erreur, il ne faut pas
          // arrêter la suite des traitements
          logger.error(application.toString(), ex);
        }
      }

    } catch (Exception e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return containers;
  }
 private static Map<String, String> buildClassToSourceMap(
     ModuleChunk chunk,
     CompileContext context,
     Set<String> toCompilePaths,
     String moduleOutputPath)
     throws IOException {
   final Map<String, String> class2Src = new HashMap<String, String>();
   for (Module module : chunk.getModules()) {
     final String moduleName = module.getName().toLowerCase(Locale.US);
     final SourceToOutputMapping srcToOut =
         context.getDataManager().getSourceToOutputMap(moduleName, context.isCompilingTests());
     for (String src : srcToOut.getKeys()) {
       if (!toCompilePaths.contains(src) && isGroovyFile(src)) {
         final Collection<String> outs = srcToOut.getState(src);
         if (outs != null) {
           for (String out : outs) {
             if (out.endsWith(".class") && out.startsWith(moduleOutputPath)) {
               final String className =
                   out.substring(moduleOutputPath.length(), out.length() - ".class".length())
                       .replace('/', '.');
               class2Src.put(className, src);
             }
           }
         }
       }
     }
   }
   return class2Src;
 }
  private ProjectWrapper(
      final GantBinding binding,
      final String prjDir,
      final String setupScript,
      final Map<String, String> pathVariables,
      final boolean loadHistory) {
    affectedFiles = new HashSet<String>();

    myProject = new GantBasedProject(binding == null ? new GantBinding() : binding);
    myProjectBuilder = myProject.getBuilder();

    final File prjFile = new File(prjDir);
    final boolean dirBased = !(prjFile.isFile() && prjDir.endsWith(".ipr"));

    myRoot = dirBased ? getCanonicalPath(prjDir) : getCanonicalPath(prjFile.getParent());

    final String loadPath = dirBased ? getAbsolutePath(myIDEADir) : prjDir;

    IdeaProjectLoader.loadFromPath(
        myProject,
        loadPath,
        pathVariables != null ? pathVariables : Collections.<String, String>emptyMap(),
        setupScript);

    myProjectSnapshot =
        myHomeDir
            + File.separator
            + myJPSDir
            + File.separator
            + myRoot.replace(File.separatorChar, myFileSeparatorReplacement);

    try {
      dependencyMapping = new Mappings(getMapDir());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    backendCallback = dependencyMapping.getCallback();

    for (Module m : myProject.getModules().values()) {
      myModules.put(m.getName(), new ModuleWrapper(m));
    }

    for (Library l : myProject.getLibraries().values()) {
      myLibraries.put(l.getName(), new LibraryWrapper(l));
    }

    myHistory = loadHistory ? loadSnapshot(affectedFiles) : null;

    if (loadHistory) {
      dependencyMapping = myHistory.dependencyMapping;
    }
  }
  private static boolean checkUpToDate(
      @NotNull Module module,
      @NotNull Map<Module, AndroidFileSetState> module2state,
      @NotNull AndroidFileSetStorage storage)
      throws IOException {
    final AndroidFileSetState moduleState = module2state.get(module);
    final AndroidFileSetState savedState = storage.getState(module.getName());
    if (savedState == null || !savedState.equalsTo(moduleState)) {
      return false;
    }

    for (AndroidFacet libFacet : AndroidJpsUtil.getAllAndroidDependencies(module, true)) {
      final Module libModule = libFacet.getModule();
      final AndroidFileSetState currentLibState = module2state.get(libModule);
      final AndroidFileSetState savedLibState = storage.getState(libModule.getName());

      if (savedLibState == null || !savedLibState.equalsTo(currentLibState)) {
        return false;
      }
    }
    return true;
  }
    public ModuleWrapper(final Module m) {
      m.forceInit();
      myModule = m;
      myDependsOn = null;
      myTestDependsOn = null;
      myName = m.getName();
      myExcludes = new HashSet<String>(m.getExcludes());
      mySource = new Properties(m.getSourceRoots(), m.getOutputPath(), myExcludes);
      myTest = new Properties(m.getTestRoots(), m.getTestOutputPath(), myExcludes);

      myLibraries = new HashSet<LibraryWrapper>();

      for (Library lib : m.getLibraries().values()) {
        myLibraries.add(new LibraryWrapper(lib));
      }
    }
  public void makeModules(final Collection<Module> initial, final Flags flags) {
    if (myHistory == null && !flags.tests()) {
      clean();
    }

    new Logger(flags) {
      @Override
      public void log(final PrintStream stream) {
        stream.println("Request to make modules:");
        logMany(stream, initial);
        stream.println("End of request");
      }
    }.log();

    final ClasspathKind kind = ClasspathKind.compile(flags.tests());

    final Set<Module> modules = new HashSet<Module>();
    final Set<String> marked = new HashSet<String>();
    final Map<String, Boolean> visited = new HashMap<String, Boolean>();
    final Set<String> frontier = new HashSet<String>();

    final Map<String, Set<String>> reversedDependencies = new HashMap<String, Set<String>>();
    final DotPrinter printer = new DotPrinter(flags.logStream());

    printer.header();

    for (Module m : myProject.getModules().values()) {
      final String mName = m.getName();

      printer.node(mName);

      for (ClasspathItem cpi : m.getClasspath(kind)) {
        if (cpi instanceof Module) {
          final String name = ((Module) cpi).getName();

          printer.edge(name, mName);

          Set<String> sm = reversedDependencies.get(name);

          if (sm == null) {
            sm = new HashSet<String>();
            reversedDependencies.put(name, sm);
          }

          sm.add(mName);
        }
      }
    }

    printer.footer();

    // Building "upper" subgraph

    printer.header();

    new Object() {
      public void run(final Collection<Module> initial) {
        if (initial == null) return;

        for (Module module : initial) {

          final String mName = module.getName();

          if (marked.contains(mName)) continue;

          printer.node(mName);

          final List<Module> dep = new ArrayList<Module>();

          for (ClasspathItem cpi : module.getClasspath(kind)) {
            if (cpi instanceof Module && !marked.contains(((Module) cpi).getName())) {
              printer.edge(((Module) cpi).getName(), mName);
              dep.add((Module) cpi);
            }
          }

          if (dep.size() == 0) {
            frontier.add(mName);
          }

          marked.add(mName);

          run(dep);
        }
      }
    }.run(initial);

    printer.footer();

    // Traversing "upper" subgraph and collecting outdated modules and their descendants
    new Object() {
      public void run(final Collection<String> initial, final boolean force) {
        if (initial == null) return;

        for (String moduleName : initial) {
          if (!marked.contains(moduleName)) continue;

          final Boolean property = visited.get(moduleName);

          if (property == null || !property && force) {
            final boolean outdated = getModule(moduleName).isOutdated(flags.tests(), myHistory);

            if (force || outdated) {
              visited.put(moduleName, true);
              modules.add(myProject.getModules().get(moduleName));

              run(reversedDependencies.get(moduleName), true);
            } else {
              if (property == null) {
                visited.put(moduleName, false);
              }
              run(reversedDependencies.get(moduleName), false);
            }
          }
        }
      }
    }.run(frontier, flags.force());

    new Logger(flags) {
      @Override
      public void log(PrintStream stream) {
        stream.println("Propagated modules:");
        logMany(stream, modules);
        stream.println("End of propagated");
      }
    }.log();

    if (modules.size() == 0 && !flags.force()) {
      System.out.println("All requested modules are up-to-date.");
      return;
    }

    final BusyBeaver beaver = new BusyBeaver(myProjectBuilder);

    myProjectBuilder.buildStart();

    if (flags.tests()) {
      beaver.build(
          modules,
          new Flags() {
            public boolean tests() {
              return false;
            }

            public boolean incremental() {
              return flags.incremental();
            }

            public boolean force() {
              return flags.force();
            }

            public PrintStream logStream() {
              return flags.logStream();
            }
          });
    }

    beaver.build(modules, flags);

    myProjectBuilder.buildStop();

    for (Module mod : modules) {
      getModule(mod.getName()).updateOutputStatus();
    }
  }
    public BuildStatus build(final Collection<Module> modules, final Flags flags) {
      boolean incremental = flags.incremental();
      final List<ModuleChunk> chunks = myProjectBuilder.getChunks(flags.tests()).getChunkList();

      for (final ModuleChunk c : chunks) {
        final Set<Module> chunkModules = c.getElements();

        if (!DefaultGroovyMethods.intersect(modules, chunkModules).isEmpty()) {
          final Set<String> removedSources = new HashSet<String>();

          if (incremental) {
            final Set<String> chunkSources = new HashSet<String>();
            final Set<String> outdatedSources = new HashSet<String>();

            for (Module m : chunkModules) {
              final ModuleWrapper mw = getModule(m.getName());

              outdatedSources.addAll(mw.getOutdatedFiles(flags.tests()));
              chunkSources.addAll(mw.getSources(flags.tests()));
              removedSources.addAll(mw.getRemovedFiles(flags.tests()));
            }

            final BuildStatus result =
                iterativeCompile(c, chunkSources, outdatedSources, removedSources, flags);

            incremental = result == BuildStatus.INCREMENTAL;

            if (result == BuildStatus.FAILURE) {
              return result;
            }
          } else {
            new Logger(flags) {
              @Override
              public void log(PrintStream stream) {
                stream.println("Compiling chunk " + c.getName() + " non-incrementally.");
              }
            }.log();

            for (Module m : chunkModules) {
              final ModuleWrapper mw = getModule(m.getName());
              removedSources.addAll(flags.tests() ? mw.getRemovedTests() : mw.getRemovedSources());
            }

            final Set<Module> toClean = new HashSet<Module>();

            for (Module m : chunkModules) {
              if (!cleared.contains(m)) {
                toClean.add(m);
              }
            }

            if (!toClean.isEmpty() && !flags.tests()) {
              builder.clearChunk(new ModuleChunk(toClean), null, ProjectWrapper.this);
              cleared.addAll(toClean);
            }

            final Mappings delta = dependencyMapping.createDelta();
            final Callbacks.Backend deltaCallback = delta.getCallback();

            try {
              builder.buildChunk(c, flags.tests(), null, deltaCallback, ProjectWrapper.this);
            } catch (Exception e) {
              e.printStackTrace();
              return BuildStatus.FAILURE;
            }

            final Set<String> allFiles = new HashSet<String>();

            for (Module m : c.getElements()) {
              final ModuleWrapper module = getModule(m.getName());
              affectedFiles.removeAll(module.getSources(flags.tests()));
              allFiles.addAll(module.getSources(flags.tests()));
            }

            final Collection<File> files = new HashSet<File>();

            for (String f : allFiles) {
              files.add(new File(f));
            }

            dependencyMapping.integrate(delta, files, removedSources);

            for (Module m : chunkModules) {
              Reporter.reportBuildSuccess(m, flags.tests());
            }
          }
        }
      }

      return BuildStatus.INCREMENTAL;
    }
 @NotNull
 private static File getPackagedResourcesFile(@NotNull Module module, @NotNull File outputDir) {
   return new File(outputDir.getPath(), module.getName() + ".apk.res");
 }
  private static boolean doPackagingForModule(
      @NotNull CompileContext context,
      @NotNull Module module,
      @NotNull AndroidFileSetStorage apkFileSetStorage,
      @NotNull AndroidApkBuilderConfigStateStorage apkBuilderConfigStateStorage,
      boolean release)
      throws IOException {
    final AndroidFacet facet = AndroidJpsUtil.getFacet(module);
    if (facet == null || facet.isLibrary()) {
      return true;
    }

    final String[] sourceRoots =
        AndroidJpsUtil.toPaths(AndroidJpsUtil.getSourceRootsForModuleAndDependencies(module));
    final ProjectPaths paths = context.getProjectPaths();

    final File outputDir = AndroidJpsUtil.getOutputDirectoryForPackagedFiles(paths, module);
    if (outputDir == null) {
      context.processMessage(
          new CompilerMessage(
              BUILDER_NAME,
              BuildMessage.Kind.ERROR,
              AndroidJpsBundle.message(
                  "android.jps.errors.output.dir.not.specified", module.getName())));
      return false;
    }

    final Pair<AndroidSdk, IAndroidTarget> pair =
        AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
    if (pair == null) {
      return false;
    }

    final Set<String> externalJarsSet = AndroidJpsUtil.getExternalLibraries(paths, module);
    final File resPackage = getPackagedResourcesFile(module, outputDir);

    final File classesDexFile = new File(outputDir.getPath(), AndroidCommonUtils.CLASSES_FILE_NAME);

    final String sdkPath = pair.getFirst().getSdkPath();
    final String outputPath = AndroidJpsUtil.getApkPath(facet, outputDir);
    if (outputPath == null) {
      context.processMessage(
          new CompilerMessage(
              BUILDER_NAME,
              BuildMessage.Kind.ERROR,
              "Cannot compute output path for file " + AndroidJpsUtil.getApkName(module)));
      return false;
    }
    final String customKeyStorePath =
        FileUtil.toSystemDependentName(facet.getCustomDebugKeyStorePath());
    final String[] nativeLibDirs = collectNativeLibsFolders(facet);

    final String resPackagePath =
        release ? resPackage.getPath() + RELEASE_SUFFIX : resPackage.getPath();
    final String outputApkPath = release ? outputPath + UNSIGNED_SUFFIX : outputPath;
    final String classesDexFilePath = classesDexFile.getPath();
    final String[] externalJars = ArrayUtil.toStringArray(externalJarsSet);

    final AndroidFileSetState currentFileSetState =
        buildCurrentApkBuilderState(
            context.getProject(),
            resPackagePath,
            classesDexFilePath,
            nativeLibDirs,
            sourceRoots,
            externalJars,
            release);

    final AndroidApkBuilderConfigState currentApkBuilderConfigState =
        new AndroidApkBuilderConfigState(outputApkPath, customKeyStorePath);

    final AndroidFileSetState savedApkFileSetState = apkFileSetStorage.getState(module.getName());
    final AndroidApkBuilderConfigState savedApkBuilderConfigState =
        apkBuilderConfigStateStorage.getState(module.getName());

    if (context.isMake()
        && currentFileSetState.equalsTo(savedApkFileSetState)
        && currentApkBuilderConfigState.equalsTo(savedApkBuilderConfigState)) {
      return true;
    }
    context.processMessage(
        new ProgressMessage(
            AndroidJpsBundle.message(
                "android.jps.progress.packaging", AndroidJpsUtil.getApkName(module))));

    final Map<AndroidCompilerMessageKind, List<String>> messages =
        AndroidApkBuilder.execute(
            resPackagePath,
            classesDexFilePath,
            sourceRoots,
            externalJars,
            nativeLibDirs,
            outputApkPath,
            release,
            sdkPath,
            customKeyStorePath,
            new MyExcludedSourcesFilter(context.getProject()));

    AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME);
    final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty();

    apkFileSetStorage.update(module.getName(), success ? currentFileSetState : null);
    apkBuilderConfigStateStorage.update(
        module.getName(), success ? currentApkBuilderConfigState : null);
    return success;
  }
  private static boolean doResourcePackaging(
      @NotNull CompileContext context,
      @NotNull Collection<Module> modules,
      @NotNull Map<Module, AndroidFileSetState> resourcesStates,
      @NotNull Map<Module, AndroidFileSetState> assetsStates)
      throws IOException {
    boolean success = true;

    final File dataStorageRoot = context.getDataManager().getDataStorageRoot();
    final boolean releaseBuild = AndroidJpsUtil.isReleaseBuild(context);
    AndroidFileSetStorage resourcesStorage = null;
    AndroidFileSetStorage assetsStorage = null;

    try {
      final String resourcesStorageName =
          releaseBuild ? "resources_packaging_release" : "resources_packaging_dev";
      resourcesStorage = new AndroidFileSetStorage(dataStorageRoot, resourcesStorageName);

      final String assetsStorageName =
          releaseBuild ? "assets_packaging_release" : "assets_packaging_dev";
      assetsStorage = new AndroidFileSetStorage(dataStorageRoot, assetsStorageName);

      final Set<Module> modulesToUpdateState = new HashSet<Module>();

      for (Module module : modules) {
        final AndroidFacet facet = AndroidJpsUtil.getFacet(module);
        if (facet == null) {
          continue;
        }

        boolean updateState = true;

        if (!facet.isLibrary()
            && !(context.isMake()
                && checkUpToDate(module, resourcesStates, resourcesStorage)
                && checkUpToDate(module, assetsStates, assetsStorage))) {

          updateState = packageResources(facet, context);

          if (!updateState) {
            success = false;
          }
        }
        if (updateState) {
          modulesToUpdateState.add(module);
        }
      }

      for (Module module : modules) {
        final boolean updateState = modulesToUpdateState.contains(module);
        resourcesStorage.update(module.getName(), updateState ? resourcesStates.get(module) : null);
        assetsStorage.update(module.getName(), updateState ? assetsStates.get(module) : null);
      }
    } finally {
      if (resourcesStorage != null) {
        resourcesStorage.close();
      }

      if (assetsStorage != null) {
        assetsStorage.close();
      }
    }
    return success;
  }
  /**
   * Remove an application
   *
   * @param application
   * @param user
   * @return
   * @throws ServiceException
   */
  @Override
  @Transactional
  public Application remove(Application application, User user)
      throws ServiceException, CheckException {

    try {
      logger.info("Starting removing application " + application.getName());

      // Delete all modules
      List<Module> listModules = application.getModules();
      for (Module module : listModules) {
        try {
          moduleService.remove(application, user, module, false, application.getStatus());
        } catch (ServiceException | CheckException e) {
          application.setStatus(Status.FAIL);
          logger.error(
              "ApplicationService Error : failed to remove module "
                  + module.getName()
                  + " for application "
                  + application.getName()
                  + " : "
                  + e);
          e.printStackTrace();
        }
      }

      // Delete all alias
      List<String> aliases = new ArrayList<>();
      aliases.addAll(application.getAliases());
      for (String alias : aliases) {
        removeAlias(application, alias);
      }

      // Delete all servers
      List<Server> listServers = application.getServers();
      for (Server server : listServers) {
        serverService.remove(server.getName());
        if (listServers.indexOf(server) == listServers.size() - 1) {
          hipacheRedisUtils.removeRedisAppKey(application);
          applicationDAO.delete(server.getApplication());
          portUtils.releaseProxyPorts(application);
        }
      }

      logger.info("ApplicationService : Application successfully removed ");

    } catch (PersistenceException e) {
      setStatus(application, Status.FAIL);
      logger.error(
          "ApplicationService Error : failed to remove " + application.getName() + " : " + e);

      throw new ServiceException(e.getLocalizedMessage(), e);
    } catch (ServiceException e) {
      setStatus(application, Status.FAIL);
      logger.error(
          "ApplicationService Error : failed to remove application "
              + application.getName()
              + " : "
              + e);
    }
    return application;
  }
Exemple #15
0
  public static void main(String[] args) {

    Module sw = new Module("Software Workshop", "Jon Rowe");

    System.out.println(sw);

    System.out.println(sw.getName());
    System.out.println(sw.getLecturer());

    System.out.println("changing lecturer");
    sw.setLecturer("Martin Escardo");

    System.out.println(sw);

    Student alf = new Student("Alfred Smith", 12345);
    Student bob = new Student("Bob Mascheranas", 24680);

    System.out.println(alf);
    System.out.println(alf.getName());
    System.out.println(alf.getId());

    System.out.println("changing id");
    alf.setId(54321);
    System.out.println(alf);

    alf.setModule(0, sw);
    alf.setModule(1, new Module("Foundations", "Dan Ghica"));
    alf.setModule(2, new Module("Intro to AI", "Volker Sorge"));

    bob.setModule(0, sw);
    bob.setModule(1, new Module("Foundations", "Dan Ghica"));
    bob.setModule(2, new Module("Intro to AI", "Volker Sorge"));

    TutorGroup TG = new TutorGroup("Nick Hawes");

    System.out.println("Does sw = sw?");
    System.out.println(sw.equals(sw));

    System.out.println("Is alf on sw?");
    System.out.println(alf.onModule(sw));

    System.out.println("Check: TutorGroup toString()");
    System.out.println(TG);

    System.out.println("Check: TutorGroup getStudents()");
    System.out.println(TG.getStudents());

    System.out.println("Check: TutorGroup addStudent()");
    TG.addStudent(bob);
    System.out.println(TG.getStudents());

    System.out.println("Check: TutorGroup setTutor()");
    TG.setTutor("Achim Jung");
    System.out.println(TG);

    System.out.println("Check: TutorGroup getTutor()");
    System.out.println(TG.getTutor());

    // System.out.println(alf.getModule(1));

    for (int i = 0; i < 3; i++) {
      System.out.println(alf.getModule(i));
    }
  }