Search in sources :

Example 1 with Domain

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);
}
Also used : Viewable(com.sun.jersey.api.view.Viewable) Domain(org.activityinfo.server.database.hibernate.entity.Domain)

Example 2 with Domain

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();
}
Also used : Domain(org.activityinfo.server.database.hibernate.entity.Domain)

Example 3 with Domain

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;
}
Also used : Domain(org.activityinfo.server.database.hibernate.entity.Domain)

Example 4 with Domain

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;
}
Also used : Configuration(freemarker.template.Configuration) Domain(org.activityinfo.server.database.hibernate.entity.Domain) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Domain (org.activityinfo.server.database.hibernate.entity.Domain)4 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Viewable (com.sun.jersey.api.view.Viewable)1 Configuration (freemarker.template.Configuration)1