Package com.tll.server

Examples of com.tll.server.AppContext


      @Override
      public AppContext get() {
        final String stage = config.getString(ConfigKeys.STAGE.getKey(), AppContext.DEFAULT_STAGE);
        final String environment = config.getString(ConfigKeys.ENVIRONMENT.getKey(), AppContext.DEFAULT_ENVIRONMENT);
        final String dfltUserEmail = config.getString(ConfigKeys.NOSECURITY_USER_EMAIL.getKey());
        return new AppContext(stage, environment, dfltUserEmail, aas);
      }
    }).in(Scopes.SINGLETON);
  }
View Full Code Here


      if(session == null) {
        session = hsr.getSession(true);
        if(session == null) throw new ServletException("Unable to obtain a servlet session");
        log.info("Servlet session created: " + session.getId());
        final ServletContext sc = session.getServletContext();
        final AppContext appContext = (AppContext) sc.getAttribute(AppContext.KEY);
        if(appContext == null) {
          throw new ServletException("Unable to obtain the app context");
        }
        final PersistContext pc = (PersistContext) sc.getAttribute(PersistContext.KEY);
        if(pc == null) {
          throw new ServletException("Unable to obtain the persist context");
        }
        final IUserService userService = pc.getEntityServiceFactory().instance(IUserService.class);
        final User user = (User) userService.loadUserByUsername(appContext.getDfltUserEmail());
        log.debug("Creating mock admin context from default user email specified in config..");
        final AdminContext ac = new AdminContext();
        ac.setUser(user);
        session.setAttribute(AdminContext.KEY, ac);
        log.info("Server-side admin context created and stored in the servlet context");
View Full Code Here

  @Override
  public AdminContextPayload getAdminContext() {
    final RequestContext rc = getRequestContext();
    final PersistContext mec = (PersistContext) rc.getServletContext().getAttribute(PersistContext.KEY);
    final AppContext ac = (AppContext) rc.getServletContext().getAttribute(AppContext.KEY);

    final Status status = new Status();

    final com.tll.server.AdminContext sac =
      (com.tll.server.AdminContext) rc.getSession().getAttribute(
          com.tll.server.AdminContext.KEY);
    if(sac == null) {
      // presume not logged in yet
      status.addMsg("Admin Context not found.", MsgLevel.INFO, MsgAttr.STATUS.flag);
      return new AdminContextPayload(status, ac.isDebug(), ac.getEnvironment(), null, null);
    }

    final Marshaler entityMarshaller = mec.getMarshaler();
    assert entityMarshaller != null : "No marshaler present";

    final Model user = entityMarshaller.marshalEntity(sac.getUser(), new MarshalOptions(true, 1, null));
    // NOTE: we want a distinct copy of the account here so we separately
    // marshall the account as opposed to grabbing the nested account from the
    // just marshaled user
    final Model account = entityMarshaller.marshalEntity(sac.getUser().getAccount(), MarshalOptions.NON_RELATIONAL);

    status.addMsg("Admin Context retrieved.", MsgLevel.INFO, MsgAttr.STATUS.flag);
    return new AdminContextPayload(status, ac.isDebug(), ac.getEnvironment(), user, account);
  }
View Full Code Here

  @Override
  public ModelPayload add(AddAccountRequest request) {
    final ModelPayload p = new ModelPayload();
    final Status s = p.getStatus();

    final AppContext ac = (AppContext) getServletContext().getAttribute(AppContext.KEY);
    assert ac != null;
    final com.tll.service.entity.account.AddAccountService svc = ac.getAddAccountService();
    final PersistContext pc = (PersistContext) getServletContext().getAttribute(PersistContext.KEY);
    assert svc != null && pc != null;
    final Marshaler mlr = pc.getMarshaler();

    Class<? extends Account> accountClass;
View Full Code Here

TOP

Related Classes of com.tll.server.AppContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.