Example #1
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;
     }
   }
 }
  @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);
    }
  }
  @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;
  }
  @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;
  }
Example #5
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);
    }
  }
  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();
    }
  }
Example #7
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);
    }
  }
  /**
   * 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;
  }
  static ValueExpression restore(Object value, Class type, FacesContext context) {
    if (value == null) return null;

    String expr = (String) value;

    Application app = context.getApplication();
    ExpressionFactory factory = app.getExpressionFactory();

    return factory.createValueExpression(context.getELContext(), expr, type);
  }
Example #10
0
 /*
  * (non-Javadoc)
  *
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Application)
  */
 public Object visit(Application a) {
   /* visit function */
   a.setFunction((Expression) a.getFunction().visit(this));
   /* visit all bodies of alternative */
   List it = a.getArgs();
   for (int i = 0; i < it.size(); i++) {
     Expression e = (Expression) it.get(i);
     it.set(i, e.visit(this));
   }
   return a;
 }
 /**
  * Methode permettant de mettre l'application dans un état particulier pour se prémunir d'éventuel
  * problème de concurrence au niveau métier
  */
 @Override
 @Transactional
 public void setStatus(Application application, Status status) throws ServiceException {
   try {
     Application _application = applicationDAO.findOne(application.getId());
     _application.setStatus(status);
     application.setStatus(status);
     applicationDAO.saveAndFlush(_application);
   } catch (PersistenceException e) {
     throw new ServiceException(e.getLocalizedMessage(), e);
   }
 }
Example #12
0
 /**
  * This method produces an Expression from an arbitrary Abstraction object which is applied to a
  * list of Variables referencing captured bindings.
  *
  * @param a an Abstraction object to partially apply
  * @param captured
  * @return
  */
 private Expression applyLifted(String s, Set captured) {
   if (captured.isEmpty()) return new Variable(s);
   Application app = new Application();
   app.setFunction(new Variable(s));
   /* bind captured variables */
   Iterator it = captured.iterator();
   while (it.hasNext()) {
     LocalBinding lb = (LocalBinding) it.next();
     app.addArgument(new Variable(lb.getName()));
   }
   return app;
 }
  static ValueExpression restoreWithType(Object value, FacesContext context) {
    if (value == null) return null;

    Object[] state = (Object[]) value;

    String expr = (String) state[0];
    Class type = (Class) state[1];

    Application app = context.getApplication();
    ExpressionFactory factory = app.getExpressionFactory();

    return factory.createValueExpression(context.getELContext(), expr, type);
  }
Example #14
0
 /** @see jaskell.compiler.JaskellVisitor#visit(Application) */
 public Object visit(Application a) {
   try {
     /* get type of function */
     Expression fun = a.getFunction();
     /* get type deduced from arguments */
     LinkedList l = new LinkedList();
     Iterator it = a.getArgs().iterator();
     while (it.hasNext()) {
       Expression e = (Expression) it.next();
       l.add((Type) e.visit(this));
     }
     Type vt = TypeFactory.freshBinding();
     Type ft = Types.fun(l, vt);
     log.finer("TypeChecker => In application " + a + ", type is " + ft);
     /* apply substitution on both types */
     ft = subst.substitute(ft);
     /* try to unify function type and constructed types */
     Type t = (Type) fun.visit(this);
     log.finer("In application, function " + fun + " :: " + t);
     t = subst.substitute(t);
     log.finer("In application, trying to unify function type " + t + " with body " + ft);
     /*
      * TODO : problem with unification of constrained types
      */
     TypeApplication uni = (TypeApplication) tu.unify(t, ft, typeVariablesMap);
     /* sets type of functional expression - this allows
      * polymorphic functions to receive several types
      * in the same code */
     // fun.setType(uni);
     /* apply arguments type to compute return type */
     log.finer("Done unify application :" + uni);
     it = PrimitiveType.functionIterator(uni);
     Iterator it2 = l.iterator();
     TypeApplication ut = uni;
     while (it2.hasNext()) {
       /* type of argument */
       Type at = (Type) it2.next();
       ut = (TypeApplication) it.next();
       /* try unification */
       tu.unify(((TypeApplication) ut.getDomain()).getRange(), at, new HashMap(typeVariablesMap));
     }
     ft = subst.substitute(ft);
     fun.setType(ft);
     log.finer("Setting type of functional element [" + fun + "] to :" + ft);
     a.setType(ut.getRange());
     return ut.getRange();
   } catch (TypeError te) {
     if (te.getLineCol() == null) te.setLineCol(a.getTag("source"));
     throw te;
   }
 }
  @Override
  @Transactional
  public Application deploy(File file, Application application)
      throws ServiceException, CheckException {

    int code = -1;
    Map<String, String> configShell = new HashMap<>();

    try {
      // get app with all its components

      for (Server server : application.getServers()) {

        // loading server ssh informations

        String rootPassword = server.getApplication().getUser().getPassword();
        configShell.put("port", server.getSshPort());
        configShell.put("dockerManagerAddress", application.getManagerIp());
        configShell.put("password", rootPassword);
        String destFile = "/cloudunit/tmp/";

        // send the file on container

        shellUtils.sendFile(
            file, rootPassword, server.getSshPort(), application.getManagerIp(), destFile);

        // call deployment script

        code =
            shellUtils.executeShell(
                "bash /cloudunit/scripts/deploy.sh "
                    + file.getName()
                    + " "
                    + application.getUser().getLogin(),
                configShell);
      }

      // if all is ok, create a new deployment tag and set app to starting

      if (code == 0) {
        deploymentService.create(application, Type.WAR);
      } else {
        throw new CheckException("No way to deploy application " + file + ", " + application);
      }

    } catch (Exception e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }

    return application;
  }
  public void reloadProjectImpl(@NotNull final Project p, final boolean clearCopyToRestore) {
    if (clearCopyToRestore) {
      mySavedCopies.clear();
      mySavedTimestamps.clear();
    }

    final Project[] project = {p};

    ProjectReloadState.getInstance(project[0]).onBeforeAutomaticProjectReload();
    final Application application = ApplicationManager.getApplication();

    application.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            LOG.debug("Reloading project.");
            ProjectImpl projectImpl = (ProjectImpl) project[0];
            if (projectImpl.isDisposed()) return;
            IProjectStore projectStore = projectImpl.getStateStore();
            final String location = projectImpl.getPresentableUrl();

            final List<IFile> original;
            try {
              final IComponentStore.SaveSession saveSession = projectStore.startSave();
              original = saveSession.getAllStorageFiles(true);
              saveSession.finishSave();
            } catch (IOException e) {
              LOG.error(e);
              return;
            }

            if (project[0].isDisposed() || ProjectUtil.closeAndDispose(project[0])) {
              application.runWriteAction(
                  new Runnable() {
                    @Override
                    public void run() {
                      for (final IFile originalFile : original) {
                        restoreCopy(
                            LocalFileSystem.getInstance().refreshAndFindFileByIoFile(originalFile));
                      }
                    }
                  });

              project[0] = null; // Let it go.

              ProjectUtil.openProject(location, null, true);
            }
          }
        },
        ModalityState.NON_MODAL);
  }
  @Override
  @Transactional
  public void updateAliases(Application application) throws ServiceException {
    try {
      Server server = application.getServers().get(0);
      List<String> aliases = applicationDAO.findAllAliases(application.getName());
      for (String alias : aliases) {
        hipacheRedisUtils.updateAlias(alias, application, server.getServerAction().getServerPort());
      }

    } catch (DataAccessException e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
  }
Example #18
0
  private AccountManager() {
    this.application = Application.getInstance();
    accountItems = new HashMap<String, AccountItem>();
    enabledAccounts = new HashSet<String>();
    savedStatuses = new ArrayList<SavedStatus>();
    authorizationErrorProvider =
        new BaseAccountNotificationProvider<AccountAuthorizationError>(
            R.drawable.ic_stat_auth_failed);
    passwordRequestProvider =
        new BaseAccountNotificationProvider<PasswordRequest>(R.drawable.ic_stat_request);

    TypedArray accountAvatars =
        application.getResources().obtainTypedArray(R.array.account_avatars);
    colors = accountAvatars.length();
    accountAvatars.recycle();

    TypedArray types = application.getResources().obtainTypedArray(R.array.account_types);
    accountTypes = new ArrayList<AccountType>();
    for (int index = 0; index < types.length(); index++) {
      int id = types.getResourceId(index, 0);
      TypedArray values = application.getResources().obtainTypedArray(id);
      AccountProtocol protocol = AccountProtocol.valueOf(values.getString(0));
      if (Application.SDK_INT < 8 && protocol == AccountProtocol.wlm) {
        values.recycle();
        continue;
      }
      ArrayList<String> servers = new ArrayList<String>();
      servers.add(values.getString(9));
      for (int i = 10; i < values.length(); i++) servers.add(values.getString(i));
      accountTypes.add(
          new AccountType(
              id,
              protocol,
              values.getString(1),
              values.getString(2),
              values.getString(3),
              values.getDrawable(4),
              values.getBoolean(5, false),
              values.getString(6),
              values.getInt(7, 5222),
              values.getBoolean(8, false),
              servers));
      values.recycle();
    }
    types.recycle();
    away = false;
    xa = false;
  }
  private static String getMessage(FacesContext context, String messageId, String defaultMessage) {
    Application app = context.getApplication();

    String bundleName = app.getMessageBundle();

    if (bundleName == null) return defaultMessage;

    ResourceBundle bundle = app.getResourceBundle(context, bundleName);

    if (bundle == null) return defaultMessage;

    String msg = bundle.getString(messageId);

    if (msg != null) return msg;
    else return defaultMessage;
  }
Example #20
0
 public static Result route(Application app, FakeRequest fakeRequest, byte[] body, long timeout) {
   return wrapScalaResult(
       Scala.orNull(
           play.api.test.Helpers.jRoute(
               app.getWrappedApplication(), fakeRequest.getWrappedRequest(), body)),
       timeout);
 }
Example #21
0
  @Override
  public void reloadFeed() {
    if (ConnectionChecker.isNetworkAvailable(getBaseContext())) {
      //			ThumbnailCache.getInstance().clearCache();
      //			setContentView(R.layout.articles_list);

      //			rubricsList = (LinearLayout) findViewById(R.id.articles_list);
      //			emptyMessage = (TextView) findViewById(R.id.empty);

      //			generateRubricsList();

      refreshImages();

      //			final ScrollView scrollView = (ScrollView)findViewById(R.id.article_scroll_view);
      //			scrollView.post(new Runnable() {
      //
      //				@Override
      //				public void run() {
      //					scrollView.scrollTo(0, currentPosition);
      //				}
      //			});

      Application.showProgressBar();

      articleFeed.reloadRss();
    }
  }
Example #22
0
 /** Gets the user Node from this Application's NodeManager. */
 public INode getUserNode() {
   if (userHandle != null) {
     return userHandle.getNode(app.getWrappedNodeManager());
   } else {
     return null;
   }
 }
Example #23
0
  /**
   * The ejb element specifies the URI of a ejb-jar, relative to the top level of the application
   * package.
   *
   * @param descriptor the Application deployment descriptor
   * @return <code>Result</code> the results for this assertion
   */
  public Result check(Application descriptor) {

    Result result = getInitializedResult();

    if (descriptor.getBundleDescriptors(EjbBundleDescriptor.class).size() > 0) {
      boolean oneFailed = false;
      for (Iterator itr = descriptor.getBundleDescriptors(EjbBundleDescriptor.class).iterator();
          itr.hasNext(); ) {
        EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();

        // not sure what we can do to test this string?
        if (ejbd.getModuleDescriptor().getArchiveUri().endsWith(".jar")) {
          result.passed(
              smh.getLocalString(
                  getClass().getName() + ".passed",
                  "[ {0} ] specifies the URI [ {1} ] of an ejb-jar, relative to the top level of the application package [ {2} ].",
                  new Object[] {
                    ejbd.getName(), ejbd.getModuleDescriptor().getArchiveUri(), descriptor.getName()
                  }));
        } else {
          if (!oneFailed) {
            oneFailed = true;
          }
          result.addErrorDetails(
              smh.getLocalString(
                  getClass().getName() + ".failed",
                  "Error: [ {0} ] does not specify the URI [ {1} ] of an ejb-jar, relative to the top level of the application package [ {2} ], or does not end with \".jar\"",
                  new Object[] {
                    ejbd.getName(), ejbd.getModuleDescriptor().getArchiveUri(), descriptor.getName()
                  }));
        }
      }
      if (oneFailed) {
        result.setStatus(Result.FAILED);
      } else {
        result.setStatus(Result.PASSED);
      }
    } else {
      result.notApplicable(
          smh.getLocalString(
              getClass().getName() + ".notApplicable",
              "There are no ejb components in application [ {0} ]",
              new Object[] {descriptor.getName()}));
    }

    return result;
  }
  /**
   * Methode qui teste la validité d'une application
   *
   * @param applicationName
   * @param serverName
   * @throws ServiceException
   * @throws CheckException
   */
  public void isValid(String applicationName, String serverName)
      throws ServiceException, CheckException {
    logger.info("--CALL APP IS VALID--");
    Application application = new Application();
    logger.info("applicationName = " + applicationName + ", serverName = " + serverName);

    User user = authentificationUtils.getAuthentificatedUser();
    if (user == null) {
      throw new CheckException("User is not authentificated");
    }

    application.setName(applicationName);
    application.setUser(user);
    application.setModules(new ArrayList<>());

    this.checkCreate(application, serverName);
  }
 /**
  * Method useful for Logs and Monitoring Management
  *
  * @return
  * @throws ServiceException
  */
 @Override
 public List<Application> findAll() throws ServiceException {
   try {
     logger.debug("start findAll");
     List<Application> listApplications = applicationDAO.findAll();
     for (Application application : listApplications) {
       application.setServers(serverService.findByApp(application));
       application.setModules(
           moduleService.findByAppAndUser(application.getUser(), application.getName()));
     }
     logger.debug("ApplicationService : All Applications found ");
     return listApplications;
   } catch (PersistenceException e) {
     logger.error("Error ApplicationService : error findAll Method : " + e);
     throw new ServiceException(e.getLocalizedMessage(), e);
   }
 }
 @Override
 @Transactional
 public Application saveGitPush(Application application, String login)
     throws ServiceException, CheckException {
   logger.info("parameters - application : " + application.toString());
   deploymentService.create(application, Type.GITPUSH);
   return application;
 }
 @Override
 public List<String> getListAliases(Application application) throws ServiceException {
   try {
     return applicationDAO.findAllAliases(application.getName());
   } catch (DataAccessException e) {
     throw new ServiceException(e.getLocalizedMessage(), e);
   }
 }
Example #28
0
 /**
  * Try logging in this session given the userName and password.
  *
  * @param userName the user name
  * @param password the password
  * @return true if session was logged in.
  */
 public boolean login(String userName, String password) {
   if (app.loginSession(userName, password, this)) {
     lastModified = System.currentTimeMillis();
     modifiedInRequest = true;
     return true;
   }
   return false;
 }
Example #29
0
 @SuppressWarnings("unchecked")
 public static Result route(Application app, RequestBuilder requestBuilder, long timeout) {
   final scala.Option<scala.concurrent.Future<play.api.mvc.Result>> opt =
       play.api.test.Helpers.jRoute(
           app.getWrappedApplication(),
           requestBuilder.build()._underlyingRequest(),
           requestBuilder.body());
   return wrapScalaResult(Scala.orNull(opt), timeout);
 }
Example #30
0
 @Before
 static void setConnectedUser() {
   if (Security.isConnected()) {
     User user = User.find("byUsername", Security.connected()).first();
     if (!user.isAdmin) {
       flash.error(Messages.get("UserIsNotAuthorized"));
       Application.index();
     }
   }
 }