@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);
}