@Test
  @InSequence(2)
  public void adminCreateApplicationTest() {
    driver.get(contextRoot.toExternalForm());
    loginPage.waitForPage();
    loginPage.login(ADMIN_USERNAME, PASSWORD);
    if (passwordChangePage.isPagePresent()) {
      passwordChangePage.changePassword(PASSWORD);
    }
    navigation.goToApplications();
    pushAppsPage.waitForPage();

    navigation.goToApplications();
    // initially there shouldn't exist any push applications
    while (!pushAppsPage.getApplicationList().isEmpty()) {
      Application application = pushAppsPage.getApplicationList().get(0);
      application.remove();
      modal.waitForDialog();
      modal.confirmName(application.getName());
      modal.remove();
    }

    pushAppsPage.pressCreateButton();
    pushAppEditPage.registerNewPushApp(ADMIN_APPLICATION, "");

    header.logout();
  }
Esempio n. 2
0
 public void testLoadTestData() throws Exception {
   makeRequest("GET", "loadTestData");
   controller.handle(request);
   Application app = (Application) request.getSession().getAttribute("Application");
   assertEquals(6, app.getPatronGateway().countActive());
   assertEquals(10, app.getMediaGateway().copyCount());
 }
  @BeforeTest
  public void setup() throws Exception {
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    orgMgr.createSubOrganization(SUB_REALM.substring(1), Collections.EMPTY_MAP);
    delegatedUser = IdRepoUtils.createUser(SUB_REALM, DELEGATED_USER);
    delegatedUser1 = IdRepoUtils.createUser(SUB_REALM, DELEGATED_USER1);

    orgMgr = new OrganizationConfigManager(adminToken, SUB_REALM);
    orgMgr.createSubOrganization(SUB_SUB_REALM, Collections.EMPTY_MAP);

    createReferral();

    Application appl =
        ApplicationManager.newApplication(
            SUB_REALM,
            APPLICATION_NAME,
            ApplicationTypeManager.getAppplicationType(
                PrivilegeManager.superAdminSubject,
                ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
    // Test disabled, unable to make model change.
    // Set<String> resources = new HashSet<String>();
    // resources.add(DELEGATED_RESOURCE);
    // appl.setResources(resources);
    appl.setEntitlementCombiner(DenyOverride.class);
    ApplicationManager.saveApplication(SubjectUtils.createSuperAdminSubject(), SUB_REALM, appl);
  }
Esempio n. 4
0
 /** Remove this sessions's user node. */
 public void logout() {
   if (userHandle != null) {
     try {
       // Invoke User.onLogout() iff this is a transactor request with a request
       // evaluator already associated (i.e., if this is called from an app/script).
       // Otherwise, we assume being called from the scheduler thread, which takes
       // care of calling User.onLogout().
       RequestEvaluator reval = app.getCurrentRequestEvaluator();
       if (reval != null) {
         Node userNode = userHandle.getNode(app.nmgr.safe);
         if (userNode != null)
           reval.invokeDirectFunction(userNode, "onLogout", new Object[] {sessionId});
       }
     } catch (Exception x) {
       // errors should already be logged by request evaluator, but you never know
       app.logError("Error in onLogout", x);
     } finally {
       // do log out
       userHandle = null;
       uid = null;
       lastModified = System.currentTimeMillis();
       modifiedInRequest = true;
     }
   }
 }
Esempio n. 5
0
 public static void runOnEventThread(Runnable r) {
   if (Application.isEventDispatchThread()) {
     r.run();
   } else {
     Application.getApplication().invokeLater(r);
   }
 }
  @Override
  @Transactional
  public void addNewAlias(Application application, String alias)
      throws ServiceException, CheckException {

    logger.info("ALIAS VALUE IN addNewAlias : " + alias);

    if (checkAliasIfExists(alias)) {
      throw new CheckException(
          "This alias is already used by another application on this CloudUnit instance");
    }

    alias = alias.toLowerCase();
    if (alias.startsWith("https://") || alias.startsWith("http://") || alias.startsWith("ftp://")) {
      alias = alias.substring(alias.lastIndexOf("//") + 2, alias.length());
    }

    if (!StringUtils.isAlphanumeric(alias)) {
      throw new CheckException(
          "This alias must be alphanumeric. Please remove all other characters");
    }

    try {
      Server server = application.getServers().get(0);
      application.getAliases().add(alias);
      hipacheRedisUtils.writeNewAlias(alias, application, server.getServerAction().getServerPort());
      applicationDAO.save(application);

    } catch (DataAccessException e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
  }
  @Test
  public void testChain() {

    Application app = new Application(new ApplicationTemplate()).name("ins").description("desc");
    Assert.assertEquals("ins", app.getName());
    Assert.assertEquals("desc", app.getDescription());
  }
  @Override
  @Transactional
  public Application stop(Application application) throws ServiceException {

    try {
      List<Server> servers = application.getServers();
      for (Server server : servers) {
        server = serverService.stopServer(server);
      }
      List<Module> modules = application.getModules();
      for (Module module : modules) {
        try {
          module = moduleService.stopModule(module);
        } catch (ServiceException e) {
          logger.error(
              "ApplicationService Error : failed to stop " + application.getName() + " : " + e);
        }
      }
      logger.info("ApplicationService : Application successfully stopped ");
    } catch (PersistenceException e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }

    return application;
  }
  private boolean tryToReloadApplication() {
    try {
      final Application app = ApplicationManager.getApplication();

      if (app.isDisposed()) return false;
      final HashSet<Pair<VirtualFile, StateStorage>> causes =
          new HashSet<Pair<VirtualFile, StateStorage>>(myChangedApplicationFiles);
      if (causes.isEmpty()) return true;

      final boolean[] reloadOk = {false};
      final LinkedHashSet<String> components = new LinkedHashSet<String>();

      ApplicationManager.getApplication()
          .runWriteAction(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    reloadOk[0] =
                        ((ApplicationImpl) app).getStateStore().reload(causes, components);
                  } catch (StateStorageException e) {
                    Messages.showWarningDialog(
                        ProjectBundle.message("project.reload.failed", e.getMessage()),
                        ProjectBundle.message("project.reload.failed.title"));
                  } catch (IOException e) {
                    Messages.showWarningDialog(
                        ProjectBundle.message("project.reload.failed", e.getMessage()),
                        ProjectBundle.message("project.reload.failed.title"));
                  }
                }
              });

      if (!reloadOk[0] && !components.isEmpty()) {
        String message = "Application components were changed externally and cannot be reloaded:\n";
        for (String component : components) {
          message += component + "\n";
        }

        final boolean canRestart = ApplicationManager.getApplication().isRestartCapable();
        message += "Would you like to " + (canRestart ? "restart " : "shutdown ");
        message += ApplicationNamesInfo.getInstance().getProductName() + "?";

        if (Messages.showYesNoDialog(
                message, "Application Configuration Reload", Messages.getQuestionIcon())
            == Messages.YES) {
          for (Pair<VirtualFile, StateStorage> cause : causes) {
            StateStorage stateStorage = cause.getSecond();
            if (stateStorage instanceof XmlElementStorage) {
              ((XmlElementStorage) stateStorage).disableSaving();
            }
          }
          ApplicationManagerEx.getApplicationEx().restart(true);
        }
      }

      return reloadOk[0];
    } finally {
      myChangedApplicationFiles.clear();
    }
  }
Esempio n. 10
0
  @Override
  public void afterShow() {
    final boolean autostart =
        Boolean.parseBoolean(application.getParameters().getNamed().get("autostart"));
    if (autostart) {
      javafx.application.Platform.runLater(
          () -> {
            final Alert dialog = new Alert(AlertType.INFORMATION);
            dialog.initOwner(application.getPrimaryStage());
            dialog.setHeaderText("Autostart in 10 seconds. Close this dialog to cancel");
            dialog.show();
            final Task<Void> sleeper =
                new Task<Void>() {

                  @Override
                  protected Void call() throws Exception {
                    try {
                      Thread.sleep(10000);
                    } catch (final Exception e) {
                      logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                    return null;
                  }
                };
            sleeper.setOnSucceeded(
                event -> {
                  if (dialog.isShowing()) {
                    dialog.close();
                    startButton.fire();
                  }
                });
            new Thread(sleeper, "autostartThread").start();
          });
    }
  }
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (JOkCancelPanel.OK.equals(cmd)) {
     // update evaluator
     evaluator.name = tfName.getText();
     evaluator.type = (byte) cbType.getSelectedIndex();
     evaluator.ignoreDiagonals = cbDiagonals.isSelected();
     evaluator.investments = (byte) cbInvestment.getSelectedIndex();
     evaluator.orgFile = orgFile;
     setVisible(false);
   } else if (JOkCancelPanel.CANCEL.equals(cmd)) {
     // don't update evaluator
     setVisible(false);
   } else if (CMD_CHOOSE_FILE.equals(cmd)) {
     // get a file dialog
     JFrame f = new JFrame();
     JFileChooser jfc = Application.getFileChooser();
     int res = jfc.showOpenDialog(f);
     Application.setWorkingDirectory(jfc.getCurrentDirectory());
     if (res == JFileChooser.CANCEL_OPTION) {
       return;
     }
     orgFile = jfc.getSelectedFile();
     lOrgFileName.setText("File: " + orgFile.getName());
   }
 }
  // This method returns all of the vulnerabilities and tab numbers
  public Object tableMap(int orgId, int appId, TableSortBean bean) throws IOException {

    if (appId != -1) {
      Application application = applicationService.loadApplication(appId);
      if (application == null || !application.isActive()) {
        log.warn(ResourceNotFoundException.getLogMessage("Application", appId));
        throw new ResourceNotFoundException();
      }
      // we update vulns and application information but not scan
      vulnerabilityFilterService.updateVulnerabilities(application);
    }
    if (orgId != -1) {
      Organization organization = organizationService.loadById(orgId);
      if (organization == null || !organization.isActive()) {
        log.warn(ResourceNotFoundException.getLogMessage("Team", orgId));
        throw new ResourceNotFoundException();
      }
      // we update vulns and team information but not scan
      vulnerabilityFilterService.updateVulnerabilities(
          organization, organization.getActiveAppIds());
    }

    if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, appId)) {
      return RestResponse.failure("You are not authorized to view this information.");
    }

    return RestResponse.success("Bulk Operation successfully ended.");
  }
Esempio n. 13
0
 public void testKbdInputBuffer() throws Exception {
   Application app = new Application(null, null, null);
   app.setKbd("3 45 67");
   assertEquals(app.readNextFromKbd(), 3);
   assertEquals(app.readNextFromKbd(), 45);
   assertEquals(app.readNextFromKbd(), 67);
   try {
     app.readNextFromKbd();
     fail("Should have thrown an exception now: no more data.");
   } catch (TTK91NoKbdData err) {
   }
   app.setKbd("-3 ;: 6;:\n\r\n7");
   assertEquals(app.readNextFromKbd(), -3);
   assertEquals(app.readNextFromKbd(), 6);
   assertEquals(app.readNextFromKbd(), 7);
   try {
     app.readNextFromKbd();
     fail("Should have thrown an exception now: no more data.");
   } catch (TTK91NoKbdData err) {
   }
   try {
     app.setKbd("-3 5 a");
     fail("Should have thrown an exception now: invalid input.");
   } catch (IllegalArgumentException err) {
   }
 }
Esempio n. 14
0
  public ComponentDescriptor analyze(ASTType astType) {
    Application applicationAnnotation = astType.getAnnotation(Application.class);

    PackageClass inputType = astType.getPackageClass();
    PackageClass applicationClassName;

    if (StringUtils.isBlank(applicationAnnotation.name())) {
      applicationClassName = inputType.append("Application");
    } else {
      applicationClassName = inputType.replaceName(applicationAnnotation.name());
    }

    ComponentDescriptor applicationDescriptor =
        new ComponentDescriptor(android.app.Application.class.getName(), applicationClassName);

    // analyze delegate
    AnalysisContext analysisContext =
        analysisContextFactory.buildAnalysisContext(buildVariableBuilderMap());

    // application generation profile
    setupApplicationProfile(applicationDescriptor, astType, analysisContext);

    // add manifest elements
    setupManifest(
        applicationAnnotation,
        applicationDescriptor.getPackageClass().getFullyQualifiedName(),
        applicationAnnotation.label());

    return applicationDescriptor;
  }
Esempio n. 15
0
 @Test
 public void testBuildTaskURL() throws Exception {
   Application application =
       new Application(null, null, null, null, null, null, null, null, null, null, null);
   TaskOptions task = application.buildTaskUrl(RunJobFilter.class);
   Assert.assertEquals("/filters/runJob/", task.getUrl());
 }
Esempio n. 16
0
 @RequestMapping(
     value = "/jobs/{jobId}/finalList",
     method = {RequestMethod.GET})
 public String visitFinalListPage(
     @PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null || !user.getRole().equals("manager")) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     Job j = JobsDao.instance.getById(jobId);
     if (!j.getStatus().equals(RecruitmentStatus.SENT_INVITATIONS)) {
       return "redirect:/jobs";
     }
     List<Application> validApplications = new ArrayList<Application>();
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       if (a.getStatus().equals(ApplicationStatus.ACCEPTED_INVITATION)) {
         validApplications.add(a);
       }
     }
     model.addAttribute("applications", validApplications);
     model.addAttribute("job", j);
     return "finalList";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Esempio n. 17
0
 @RequestMapping(value = "/jobs/{jobId}/delete")
 public String deleteJob(@PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     // Archive applications as well
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     if (request.getParameter("selectedCandidate") != null) {
       for (Application a : applications) {
         a.setStatus(ApplicationStatus.ARCHIVED);
         ApplicationsDao.instance.update(a);
       }
     }
     JobsDao.instance.delete(ORSKEY, user.getShortKey(), jobId);
     return "redirect:/jobs";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
 private Application getApplication(String applicationName) throws MalformedURLException {
   Application application =
       new Application(applicationName, "BBC n-screen application", "*****@*****.**");
   application.setOAuthCallback(new URL("http://example.com/callback"));
   application.setWebsite(new URL("http://bbc.co.uk"));
   return application;
 }
Esempio n. 19
0
 @RequestMapping(
     value = "/jobs/{jobId}/shortlist",
     method = {RequestMethod.GET})
 public String visitShortlistPage(
     @PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null || !user.getRole().equals("manager")) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     Job j = JobsDao.instance.getById(jobId);
     if (j.getStatus().equals(RecruitmentStatus.CREATED)) {
       return "redirect:/jobs";
     }
     List<DetailedApplication> list = new ArrayList<DetailedApplication>();
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       DetailedApplication da = new DetailedApplication(a);
       da.setReviews(
           (ArrayList<Review>)
               ReviewsDao.instance.getByApplication(ORSKEY, user.getShortKey(), a.get_appId()));
       list.add(da);
     }
     model.addAttribute("applications", list);
     model.addAttribute("job", j);
     return "shortlist";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Esempio n. 20
0
  public void render(FacesContext context) throws FacesException {
    if (context.getResponseComplete()) return;

    Application app = context.getApplication();
    ViewHandler view = app.getViewHandler();

    beforePhase(context, PhaseId.RENDER_RESPONSE);

    try {
      if (log.isLoggable(Level.FINER)) log.finer(context.getViewRoot() + " before render view");

      view.renderView(context, context.getViewRoot());
    } catch (java.io.IOException e) {
      if (sendError(context, "renderView", e)) return;

      throw new FacesException(e);
    } catch (RuntimeException e) {
      if (sendError(context, "renderView", e)) return;

      throw e;
    } finally {
      afterPhase(context, PhaseId.RENDER_RESPONSE);

      logMessages(context);
    }
  }
  @Override
  public void runWhenProjectIsInitialized(@NotNull final Runnable action) {
    final Application application = ApplicationManager.getApplication();
    if (application == null) return;

    //noinspection SynchronizeOnThis
    synchronized (this) {
      // in tests which simulate project opening, post-startup activities could have been run
      // already.
      // Then we should act as if the project was initialized
      boolean initialized =
          myProject.isInitialized()
              || application.isUnitTestMode() && myPostStartupActivitiesPassed;
      if (!initialized) {
        registerPostStartupActivity(action);
        return;
      }
    }

    Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            if (!myProject.isDisposed()) {
              action.run();
            }
          }
        };
    if (application.isDispatchThread() && ModalityState.current() == ModalityState.NON_MODAL) {
      runnable.run();
    } else {
      application.invokeLater(runnable, ModalityState.NON_MODAL);
    }
  }
  @Override
  @Transactional
  public Application start(Application application) throws ServiceException {
    try {
      User user = authentificationUtils.getAuthentificatedUser();
      logger.debug("start : Methods parameters : " + application);

      List<Module> modules = application.getModules();
      for (Module module : modules) {
        try {
          module = moduleService.startModule(module);
        } catch (ServiceException e) {
          logger.error("failed to start " + application.toString(), e);
        }
      }
      List<Server> servers = application.getServers();
      for (Server server : servers) {
        logger.info("old server ip : " + server.getContainerIP());
        server = serverService.startServer(server);
      }

      if (application.getAliases() != null && !application.getAliases().isEmpty()) {
        updateAliases(application);
      }
      logger.info("ApplicationService : Application successfully started ");
    } catch (PersistenceException e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return application;
  }
Esempio n. 23
0
  public ApplicationPanel(final Application application) {
    super("applicationPanel");

    WebMarkupContainer webMarkupContainer = new WebMarkupContainer("appWrapper");
    webMarkupContainer.setOutputMarkupId(true);
    webMarkupContainer.add(
        new AjaxEventBehavior("onclick") {

          @Override
          protected void onEvent(AjaxRequestTarget ajaxRequestTarget) {
            PageParameters parameters = new PageParameters();
            parameters.add(APPLICATION_NAME, application.getApplicationName());
            parameters.add(GROUP_ID, application.getArtifact().getGroupId());
            parameters.add(ARTIFACT_ID, application.getArtifact().getArtifactId());
            parameters.add(PACKAGING, application.getArtifact().getPackaging());

            setResponsePage(RepoPage.class, parameters);
          }
        });

    webMarkupContainer.add(new Image("applicationImage", application.getImageUrl()));
    webMarkupContainer.add(new Label("applicationName", application.getApplicationName()));
    webMarkupContainer.add(new Label("applicationDescription", application.getDescription()));

    add(webMarkupContainer);
  }
  // add watcher for config reloads.
  private void readConfig() {
    ApplicationConfig[] configuredApplications =
        MoskitoControlConfiguration.getConfiguration().getApplications();
    for (ApplicationConfig ac : configuredApplications) {
      Application app = new Application(ac.getName());
      for (ComponentConfig cc : ac.getComponents()) {
        Component comp = new Component(app);
        comp.setCategory(cc.getCategory());
        comp.setName(cc.getName());
        app.addComponent(comp);
      }

      if (ac.getCharts() != null && ac.getCharts().length > 0) {
        for (ChartConfig cc : ac.getCharts()) {
          Chart chart = new Chart(app, cc.getName());

          ChartLineConfig[] lines = cc.getLines();
          for (ChartLineConfig line : lines) {
            chart.addLine(line.getComponent(), line.getAccumulator(), line.getCaption());
          }

          app.addChart(chart);
        }
      }
      addApplication(app);
    }
  }
Esempio n. 25
0
  private void restoreView(FacesContext context) throws FacesException {
    Application app = context.getApplication();

    if (app instanceof ApplicationImpl) ((ApplicationImpl) app).initRequest();

    ViewHandler view = app.getViewHandler();

    view.initView(context);

    UIViewRoot viewRoot = context.getViewRoot();

    if (viewRoot != null) {
      ExternalContext extContext = context.getExternalContext();

      viewRoot.setLocale(extContext.getRequestLocale());

      doSetBindings(context.getELContext(), viewRoot);

      return;
    }

    String viewId = calculateViewId(context);

    String renderKitId = view.calculateRenderKitId(context);

    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);

    RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId);

    ResponseStateManager stateManager = renderKit.getResponseStateManager();

    if (stateManager.isPostback(context)) {
      viewRoot = view.restoreView(context, viewId);

      if (viewRoot != null) {
        doSetBindings(context.getELContext(), viewRoot);
      } else {
        // XXX: backward compat issues with ViewHandler and StateManager

        // throw new ViewExpiredException(L.l("{0} is an expired view", viewId));

        context.renderResponse();

        viewRoot = view.createView(context, viewId);

        context.setViewRoot(viewRoot);
      }

      context.setViewRoot(viewRoot);
    } else {
      context.renderResponse();

      viewRoot = view.createView(context, viewId);

      context.setViewRoot(viewRoot);
    }
  }
Esempio n. 26
0
 public static RepeaterUtil get() {
   Application app = Application.get();
   RepeaterUtil util = app.getMetaData(REPEATER_UTIL_KEY);
   if (util != null) {
     return util;
   }
   util = new RepeaterUtil(app); // this registers too
   return util;
 }
Esempio n. 27
0
  /**
   * Creates a new Task using two strings, the Application name and Method name.
   *
   * @param a Application name.
   * @param m Method name
   * @return Task
   */
  public static Task Create(final String a, final String m) {
    Application application = new Application();
    application.setName(a);

    Method method = new Method();
    method.setName(m);

    return Create(application, method);
  }
Esempio n. 28
0
  @Test
  public void canUserEditApplicationTest() {
    // Initial setup
    User user = getUser();
    userService.add(user);
    Organization organization = createOrganization();
    Category category = createCategory(organization);
    organization.getCategories().add(category);
    Application application =
        createApplication(category, "Test Application", AppState.GROUP_PUBLISH);
    Group group = createGroup(organization);
    group.getOwnedApplications().add(application);

    entityManager.flush();

    createUserDomain(user, group.getId(), DomainType.GROUP, UserRole.ROLE_GROUP_ADMIN);
    entityManager.flush();

    assertTrue(userService.canUserEditApplication(user.getId(), application.getId()));

    // Reset
    userService.delete(user.getId());
    ReflectionTestUtils.setField(this, "user", null);
    entityManager.flush();

    // Test if org admin can edit application
    user = getUser();
    userService.add(user);
    entityManager.flush();
    createUserDomain(user, organization.getId(), DomainType.ORGANIZATION, UserRole.ROLE_ORG_ADMIN);
    entityManager.flush();
    assertTrue(userService.canUserEditApplication(user.getId(), application.getId()));

    // Reset
    userService.delete(user.getId());
    ReflectionTestUtils.setField(this, "user", null);
    entityManager.flush();

    // Test user is org user
    user = getUser();
    userService.add(user);
    entityManager.flush();
    createUserDomain(user, organization.getId(), DomainType.ORGANIZATION, UserRole.ROLE_ORG_USER);
    entityManager.flush();
    assertFalse(userService.canUserEditApplication(user.getId(), application.getId()));

    // Reset
    userService.delete(user.getId());
    ReflectionTestUtils.setField(this, "user", null);
    entityManager.flush();

    // Test user is not part of organization and not group admin
    user = getUser();
    userService.add(user);
    entityManager.flush();
    assertFalse(userService.canUserEditApplication(user.getId(), application.getId()));
  }
  /**
   * Lancer par signal de NoPublicController quand le processus sshd est démarré dans les containers
   * serveur et git
   */
  public Application updateEnv(Application application, User user) throws ServiceException {

    logger.info("--update Env of Server--");
    String command = null;
    Map<String, String> configShellModule = new HashMap<>();
    Map<String, String> configShellServer = new HashMap<>();

    Module moduleGit = moduleService.findGitModule(user.getLogin(), application);
    Server server = application.getServers().get(0);

    String rootPassword = application.getUser().getPassword();
    configShellModule.put("port", moduleGit.getSshPort());
    configShellModule.put("dockerManagerAddress", moduleGit.getApplication().getManagerIp());
    configShellModule.put("password", rootPassword);
    configShellModule.put("dockerManagerAddress", application.getManagerIp());
    logger.info("new server ip : " + server.getContainerIP());
    try {
      int counter = 0;
      while (!server.getStatus().equals(Status.START)
          || !moduleGit.getStatus().equals(Status.START)) {
        if (counter == 100) {
          break;
        }
        Thread.sleep(1000);
        logger.info(" wait git and server sshd processus start");
        logger.info(
            "SSHDSTATUS = server : " + server.getStatus() + " - module : " + moduleGit.getStatus());
        moduleGit = moduleService.findById(moduleGit.getId());
        server = serverService.findById(server.getId());
        counter++;
      }
      command = ". /cloudunit/scripts/update-env.sh " + server.getContainerIP();
      logger.info("command shell to execute [" + command + "]");

      shellUtils.executeShell(command, configShellModule);

      configShellServer.put("port", server.getSshPort());
      configShellServer.put("dockerManagerAddress", server.getApplication().getManagerIp());
      configShellServer.put("password", rootPassword);
      command = ". /cloudunit/scripts/rm-auth-keys.sh ";
      logger.info("command shell to execute [" + command + "]");

      shellUtils.executeShell(command, configShellServer);
      String cleanCommand = server.getServerAction().cleanCommand();
      if (cleanCommand != null) {
        shellUtils.executeShell(server.getServerAction().cleanCommand(), configShellServer);
      }
    } catch (Exception e) {
      moduleGit.setStatus(Status.FAIL);
      moduleGit = moduleService.saveInDB(moduleGit);
      server.setStatus(Status.FAIL);
      server = serverService.saveInDB(server);
      logger.error("Error :  Error during update Env var of GIT " + e);
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return application;
  }
  public boolean process() {
    boolean status = true;
    Application currentRecord = null;
    boolean inEntry = false;
    String textValue = "";

    try {
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      factory.setNamespaceAware(true);
      XmlPullParser xpp = factory.newPullParser();
      xpp.setInput(new StringReader(this.xmlData));
      int eventType = xpp.getEventType();

      while (eventType != XmlPullParser.END_DOCUMENT) {
        String tagName = xpp.getName();
        switch (eventType) {
          case XmlPullParser.START_TAG:
            // Log.d("ParseApplications", "Starting tag for " + tagName);
            if (tagName.equalsIgnoreCase("entry")) {
              inEntry = true;
              currentRecord = new Application();
            }
            break;

          case XmlPullParser.TEXT:
            textValue = xpp.getText();
            break;

          case XmlPullParser.END_TAG:
            // Log.d("ParseApplications", "Ending tag for " + tagName);
            if (inEntry) {
              if (tagName.equalsIgnoreCase("entry")) {
                applications.add(currentRecord);
                inEntry = false;
              } else if (tagName.equalsIgnoreCase("name")) {
                currentRecord.setName(textValue);
              } else if (tagName.equalsIgnoreCase("artist")) {
                currentRecord.setArtist(textValue);
              } else if (tagName.equalsIgnoreCase("releaseDate")) {
                currentRecord.setReleaseDate(textValue);
              }
            }
            break;

          default:
            // nothing else to do
        }
        eventType = xpp.next();
      }

    } catch (Exception e) {
      status = false;
      e.printStackTrace();
    }
    return true;
  }