use of org.activityinfo.server.database.hibernate.entity.Domain in project activityinfo by bedatadriven.
the class BrandingConfigResource method getPage.
@GET
@Produces(MediaType.TEXT_HTML)
@Path("{host}")
public Viewable getPage(@InjectParam EntityManager em, @PathParam("host") String host) {
Domain domain = em.find(Domain.class, host);
if (domain == null) {
domain = new Domain();
domain.setHost(host);
}
Map<String, Object> model = Maps.newHashMap();
model.put("customDomain", domain);
return new Viewable("/page/BrandingConfig.ftl", model);
}
use of org.activityinfo.server.database.hibernate.entity.Domain in project activityinfo by bedatadriven.
the class BrandingConfigResource method updateConfig.
@POST
@Path("{host}")
public Response updateConfig(@InjectParam EntityManager em, @Context UriInfo uri, @PathParam("host") String host, @FormParam("title") String updatedTitle, @FormParam("scaffolding") String updatedScaffolding, @FormParam("homePageBody") String updatedHomePageBody) {
em.getTransaction().begin();
Domain domain = em.find(Domain.class, host);
if (domain == null) {
domain = new Domain();
domain.setHost(host);
}
domain.setTitle(updatedTitle);
domain.setScaffolding(updatedScaffolding);
domain.setHomePageBody(updatedHomePageBody);
em.persist(domain);
em.getTransaction().commit();
return Response.seeOther(uri.getRequestUri()).build();
}
use of org.activityinfo.server.database.hibernate.entity.Domain in project activityinfo by bedatadriven.
the class DomainProvider method get.
@Override
public Domain get() {
String host = getBrandHostName();
Domain result = entityManager.get().find(Domain.class, host);
if (result == null) {
result = new Domain();
result.setTitle("ActivityInfo");
result.setSignUpAllowed(true);
} else {
entityManager.get().detach(result);
}
result.setHost(getExternalHostName());
result.setPort(request.get().getServerPort());
return result;
}
use of org.activityinfo.server.database.hibernate.entity.Domain in project activityinfo by bedatadriven.
the class TemplateModule method provideConfiguration.
@Provides
@Singleton
public Configuration provideConfiguration(Provider<Domain> domainProvider) throws TemplateModelException {
Configuration config = new Configuration();
config.setClassForTemplateLoading(TemplateModule.class, "/template");
config.setDefaultEncoding("UTF-8");
config.setSharedVariable("domain", new InjectedTemplateModel<Domain>(domainProvider));
return config;
}
Aggregations