use of org.activityinfo.server.login.model.HostPageModel in project activityinfo by bedatadriven.
the class HostController method getHostPage.
@GET
@Produces(MediaType.TEXT_HTML)
public Response getHostPage(@Context UriInfo uri, @Context HttpServletRequest req, @QueryParam("redirect") boolean redirect, @QueryParam("ui") String ui, @QueryParam("locale") String locale, @QueryParam("logging") String logging, @QueryParam("gwt.codesvr") String codeServer) throws Exception {
if (!authProvider.isAuthenticated()) {
// Otherwise, go to the default ActivityInfo root page
return Response.temporaryRedirect(uri.getAbsolutePathBuilder().replacePath("/login").build()).build();
}
if (redirect) {
return Response.seeOther(uri.getAbsolutePathBuilder().replacePath(ENDPOINT).build()).build();
}
String appUri = uri.getAbsolutePathBuilder().replaceQuery("").build().toString();
HostPageModel model = new HostPageModel(appUri);
User authenticatedUser = entityManager.get().find(User.class, authProvider.get().getUserId());
model.setFeatureFlags(authenticatedUser.getFeatures());
model.setNewUI("3".equals(ui) || "3dev".equals(ui));
if ("3dev".equals(ui)) {
model.setBootstrapScript("/App/App.nocache.js");
} else if ("dev".equals(ui)) {
// Running in development mode
// Use the default bootstrap script
model.setBootstrapScript("/ActivityInfo/ActivityInfo.nocache.js");
} else if ("true".equalsIgnoreCase(logging)) {
// Load a special logging version of the Application
model.setBootstrapScript("/ActivityInfoLogging/ActivityInfoLogging.nocache.js");
} else {
// locale or the one explicitly provided
if (Strings.isNullOrEmpty(locale)) {
locale = authProvider.get().getUserLocale();
}
String module;
if (model.isNewUI()) {
module = "App";
} else {
module = "ActivityInfo";
}
model.setBootstrapScript(String.format("/%s/%s.js", module, locale));
model.setAppCacheManifest(String.format("/%s/%s.appcache", module, locale));
}
return Response.ok(model.asViewable()).type(MediaType.TEXT_HTML).cacheControl(CacheControl.valueOf("no-cache")).build();
}
use of org.activityinfo.server.login.model.HostPageModel in project activityinfo by bedatadriven.
the class HostViewTest method templateProcesses.
@Test
public void templateProcesses() {
User user = new User();
user.setName("Alex");
user.setEmail("akbertram@gmail.com");
user.setLocale("fr");
Authentication auth = new Authentication(user);
auth.setId("XYZ12345");
auth.setUser(user);
HostPageModel pageModel = new HostPageModel("http://www.activityinfo.org");
pageModel.setBootstrapScript("/ActivityInfo/en.js");
assertProcessable(pageModel);
}
Aggregations