CCM NG: Next part of the sites/pages/themes complex
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5040 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: e7dfec180d
pull/2/head
parent
8ace3ddfed
commit
6a7f85f4de
|
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package org.librecms.pagemodel;
|
|
||||||
|
|
||||||
import com.arsdigita.templating.Templating;
|
|
||||||
import com.arsdigita.xml.Document;
|
|
||||||
import javax.script.ScriptEngine;
|
|
||||||
import javax.script.ScriptEngineManager;
|
|
||||||
import javax.script.ScriptException;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@WebServlet(urlPatterns = {"*.bebop"})
|
|
||||||
public class PageModel extends HttpServlet {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1056528247823275004L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(final HttpServletRequest request,
|
|
||||||
final HttpServletResponse response)
|
|
||||||
throws ServletException {
|
|
||||||
|
|
||||||
final BasePage page = new BasePage();
|
|
||||||
final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
|
||||||
final ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(
|
|
||||||
"JavaScript");
|
|
||||||
scriptEngine.put("page", page);
|
|
||||||
|
|
||||||
try {
|
|
||||||
scriptEngine.eval(
|
|
||||||
"load(\'nashorn:mozilla_compat.js\');\n"
|
|
||||||
+ "importClass(org.librecms.pagemodel.BasePage);\n"
|
|
||||||
+ "var BasePage = Java.type('org.librecms.pagemodel.BasePage');\n"
|
|
||||||
// + "var page = new BasePage;\n"
|
|
||||||
// + "print(page.getClass().getName());\n"
|
|
||||||
+ "page.setPageAttribute(\'name\', \'page-model-demo\');\n"
|
|
||||||
+ "page.setPageAttribute(\'application\', \'content\');\n"
|
|
||||||
+ "label = new com.arsdigita.bebop.Label(\'Test\');\n"
|
|
||||||
+ "page.add(label);\n");
|
|
||||||
} catch (ScriptException ex) {
|
|
||||||
throw new ServletException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// final BasePage page = (BasePage) scriptEngine.get("page");
|
|
||||||
page.lock();
|
|
||||||
|
|
||||||
final Document document = page.buildDocument(request, response);
|
|
||||||
Templating.getPresentationManager().servePage(document,
|
|
||||||
request,
|
|
||||||
response);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 LibreCCM Foundation.
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
|
@ -16,18 +16,31 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
* MA 02110-1301 USA
|
* MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.librecms.pagemodel;
|
package org.librecms.pages;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Page;
|
import org.libreccm.pagemodel.AbstractPageBuilder;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public class BasePage extends Page {
|
@RequestScoped
|
||||||
|
public class CmsPageBuilder extends AbstractPageBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> buildPage(final Map<String, Object> parameters) {
|
||||||
|
|
||||||
|
final Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
public void setPageAttribute(final String name, final String value) {
|
|
||||||
super.setAttribute(name, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -62,8 +62,27 @@ import static org.librecms.CmsConstants.*;
|
||||||
name = "Pages.availableForDefaultSite",
|
name = "Pages.availableForDefaultSite",
|
||||||
query = "SELECT (CASE WHEN COUNT(p) > 0 THEN true ELSE false END) "
|
query = "SELECT (CASE WHEN COUNT(p) > 0 THEN true ELSE false END) "
|
||||||
+ "FROM Pages p JOIN p.site s "
|
+ "FROM Pages p JOIN p.site s "
|
||||||
+ "WHERE s.defaultSite = true"),
|
+ "WHERE s.defaultSite = true")
|
||||||
|
,
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Pages.findPageModelForIndexPage",
|
||||||
|
query = "SELECT DISTINCT m "
|
||||||
|
+ "FROM PageModel m "
|
||||||
|
+ "JOIN m.categories c "
|
||||||
|
+ "WHERE c.category = :category "
|
||||||
|
+ "AND c.type = '"
|
||||||
|
+ PagesConstants.CATEGORIZATION_TYPE_PAGE_MODEL_INDEX + "' "
|
||||||
|
+ "AND m.version = :version")
|
||||||
|
,
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Pages.findPageModelForItemPage",
|
||||||
|
query = "SELECT DISTINCT m "
|
||||||
|
+ "FROM PageModel m "
|
||||||
|
+ "JOIN m.categories c "
|
||||||
|
+ "WHERE c.category = :category "
|
||||||
|
+ "AND c.type = '"
|
||||||
|
+ PagesConstants.CATEGORIZATION_TYPE_PAGE_MODEL_ITEM + "' "
|
||||||
|
+ "AND m.version = :version")
|
||||||
})
|
})
|
||||||
public class Pages extends CcmApplication implements Serializable {
|
public class Pages extends CcmApplication implements Serializable {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.pages;
|
package org.librecms.pages;
|
||||||
|
|
||||||
import com.arsdigita.ui.admin.AdminUiConstants;
|
import org.libreccm.categorization.Category;
|
||||||
|
|
||||||
import org.libreccm.core.AbstractEntityRepository;
|
import org.libreccm.core.AbstractEntityRepository;
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
|
import org.libreccm.pagemodel.PageModelVersion;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
import org.libreccm.sites.SiteRepository;
|
import org.libreccm.sites.SiteRepository;
|
||||||
import org.librecms.CmsConstants;
|
import org.libreccm.pagemodel.PageModel;
|
||||||
import org.librecms.contentsection.privileges.AdminPrivileges;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
@ -56,7 +55,7 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Optional.of(query.getSingleResult());
|
return Optional.of(query.getSingleResult());
|
||||||
} catch(NoResultException ex) {
|
} catch (NoResultException ex) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -70,6 +69,40 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public Optional<PageModel> findPageModelForIndexPage(
|
||||||
|
final Category category,
|
||||||
|
final PageModelVersion version) {
|
||||||
|
|
||||||
|
final TypedQuery<PageModel> query = getEntityManager()
|
||||||
|
.createNamedQuery("Pages.findPageModelForIndexPage", PageModel.class);
|
||||||
|
query.setParameter("category", category);
|
||||||
|
query.setParameter("version", version.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Optional.of(query.getSingleResult());
|
||||||
|
} catch(NoResultException ex) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public Optional<PageModel> findPageModelForItemPage(
|
||||||
|
final Category category,
|
||||||
|
final PageModelVersion version) {
|
||||||
|
|
||||||
|
final TypedQuery<PageModel> query = getEntityManager()
|
||||||
|
.createNamedQuery("Pages.findPageModelForItemPage", PageModel.class);
|
||||||
|
query.setParameter("category", category);
|
||||||
|
query.setParameter("version", version.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Optional.of(query.getSingleResult());
|
||||||
|
} catch(NoResultException ex) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Pages> getEntityClass() {
|
public Class<Pages> getEntityClass() {
|
||||||
return Pages.class;
|
return Pages.class;
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,22 @@ package org.librecms.pages;
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
import org.libreccm.categorization.CategoryManager;
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.categorization.CategoryRepository;
|
import org.libreccm.categorization.CategoryRepository;
|
||||||
|
import org.libreccm.pagemodel.PageModel;
|
||||||
import org.libreccm.pagemodel.PageModelManager;
|
import org.libreccm.pagemodel.PageModelManager;
|
||||||
|
import org.libreccm.pagemodel.PageModelVersion;
|
||||||
|
import org.libreccm.sites.Site;
|
||||||
|
import org.libreccm.sites.SiteRepository;
|
||||||
|
import org.libreccm.theming.ThemeInfo;
|
||||||
|
import org.libreccm.theming.ThemeVersion;
|
||||||
|
import org.libreccm.theming.Themes;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import javax.ws.rs.DefaultValue;
|
import javax.ws.rs.DefaultValue;
|
||||||
import javax.ws.rs.NotFoundException;
|
import javax.ws.rs.NotFoundException;
|
||||||
|
|
@ -32,7 +44,9 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -49,26 +63,57 @@ public class PagesRouter {
|
||||||
@Inject
|
@Inject
|
||||||
private CategoryRepository categoryRepo;
|
private CategoryRepository categoryRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CmsPageBuilder pageBuilder;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PagesRepository pagesRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PageModelManager pageModelManager;
|
private PageModelManager pageModelManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PagesRepository siteRepo;
|
private SiteRepository siteRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Themes themes;
|
||||||
|
|
||||||
@Path("/index.{lang}.html")
|
@Path("/index.{lang}.html")
|
||||||
@Produces("text/html")
|
@Produces("text/html")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String getCategoryIndexPage(
|
public String getCategoryIndexPage(
|
||||||
@Context final UriInfo uriInfo,
|
@Context
|
||||||
@PathParam("page") final String page,
|
final UriInfo uriInfo,
|
||||||
@PathParam("lang") final String language,
|
@PathParam("page")
|
||||||
@QueryParam("theme") @DefaultValue("--DEFAULT--") final String theme) {
|
final String page,
|
||||||
|
@PathParam("lang")
|
||||||
|
final String language,
|
||||||
|
@QueryParam("theme")
|
||||||
|
@DefaultValue("--DEFAULT--")
|
||||||
|
final String theme,
|
||||||
|
@QueryParam("theme-version")
|
||||||
|
@DefaultValue("LIVE")
|
||||||
|
final String themeVersion,
|
||||||
|
@QueryParam("pagemodel-version")
|
||||||
|
@DefaultValue("LIVE")
|
||||||
|
final String pageModelVersion) {
|
||||||
|
|
||||||
final String domain = uriInfo.getBaseUri().getHost();
|
final String domain = uriInfo.getBaseUri().getHost();
|
||||||
|
|
||||||
final Pages pages = siteRepo
|
final Site site;
|
||||||
|
if (siteRepo.hasSiteForDomain(domain)) {
|
||||||
|
site = siteRepo.findByDomain(domain).get();
|
||||||
|
} else {
|
||||||
|
site = siteRepo
|
||||||
|
.findDefaultSite()
|
||||||
|
.orElseThrow(() -> new NotFoundException(
|
||||||
|
"No matching Site and no default Site."));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Pages pages = pagesRepo
|
||||||
.findPagesForSite(domain)
|
.findPagesForSite(domain)
|
||||||
.orElseThrow(() -> new NotFoundException(String
|
.orElseThrow(() -> new NotFoundException(String
|
||||||
.format("No Pages for domain \"%s\" available.",
|
.format("No Pages for domain \"%s\" available.",
|
||||||
|
|
@ -81,13 +126,64 @@ public class PagesRouter {
|
||||||
page,
|
page,
|
||||||
domain)));
|
domain)));
|
||||||
|
|
||||||
|
final Optional<PageModel> pageModel = pagesRepo
|
||||||
|
.findPageModelForIndexPage(category,
|
||||||
|
PageModelVersion
|
||||||
|
.valueOf(pageModelVersion));
|
||||||
|
|
||||||
|
final Map<String, Object> parameters = new HashMap<>();
|
||||||
|
parameters.put("currentCategory", category);
|
||||||
|
|
||||||
|
final Map<String, Object> buildResult;
|
||||||
|
if (pageModel.isPresent()) {
|
||||||
|
buildResult = pageBuilder.buildPage(pageModel.get(), parameters);
|
||||||
|
} else {
|
||||||
|
buildResult = pageBuilder.buildPage(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
final ThemeInfo themeInfo;
|
||||||
|
if ("--DEFAULT--".equals(theme)) {
|
||||||
|
themeInfo = themes
|
||||||
|
.getTheme(site.getDefaultTheme(),
|
||||||
|
ThemeVersion.valueOf(themeVersion))
|
||||||
|
.orElseThrow(() -> new WebApplicationException(
|
||||||
|
String.format("The configured default theme \"%s\" for "
|
||||||
|
+ "site \"%s\" is not available.",
|
||||||
|
site.getDomainOfSite(),
|
||||||
|
site.getDefaultTheme()),
|
||||||
|
Response.Status.INTERNAL_SERVER_ERROR));
|
||||||
|
} else {
|
||||||
|
themeInfo = themes.getTheme(theme,
|
||||||
|
ThemeVersion.valueOf(themeVersion))
|
||||||
|
.orElseThrow(() -> new WebApplicationException(
|
||||||
|
String.format("The theme \"%s\" is not available.",
|
||||||
|
theme),
|
||||||
|
Response.Status.BAD_REQUEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
return themes.process(buildResult, themeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Path("/index.{lang}.tree")
|
||||||
|
@Produces("text/html")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String getCategoryIndexPageTree(
|
||||||
|
@Context
|
||||||
|
final UriInfo uriInfo,
|
||||||
|
@PathParam("page")
|
||||||
|
final String page,
|
||||||
|
@PathParam("lang")
|
||||||
|
final String language,
|
||||||
|
@QueryParam("theme")
|
||||||
|
@DefaultValue("--DEFAULT--")
|
||||||
|
final String theme,
|
||||||
|
@QueryParam("theme-version")
|
||||||
|
@DefaultValue("LIVE")
|
||||||
|
final String themeVersion,
|
||||||
|
@QueryParam("pagemodel-version")
|
||||||
|
@DefaultValue("LIVE")
|
||||||
|
final String pageModelVersion) {
|
||||||
|
|
||||||
// ToDo Get PageModelBuilder
|
|
||||||
// ToDo Build page
|
|
||||||
// ToDo Get Theme Processor
|
|
||||||
// ToDo Pass page to theme processor
|
|
||||||
// ToDo Return result of ThemeProcessor
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,11 @@ package org.libreccm.pagemodel;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for page builders. A page builder is invoked to build a page a
|
* Interface for page builders. A page builder is invoked to build a page a
|
||||||
* specific type. An implementation must be a CDI bean which is annotated with
|
* specific type. An implementation should be a CDI bean which is annotated with
|
||||||
* the qualifier {@link PageModelType}. The recommended scope is
|
* the qualifier {@link PageModelType}.
|
||||||
* {@link RequestScoped}.
|
|
||||||
*
|
*
|
||||||
* An implementation should add all default components which have to be present
|
* An implementation should add all default components which have to be present
|
||||||
* in page. The {@link PageModel} should only specify
|
* in page. The {@link PageModel} should only specify
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
||||||
throw new IllegalArgumentException("PageModel can't be null.");
|
throw new IllegalArgumentException("PageModel can't be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return pageModel.getPageModelId() == 0;
|
return pageModel.getObjectId() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,11 @@ import javax.persistence.Table;
|
||||||
query = "SELECT s FROM Site s WHERE s.domainOfSite = :domain"
|
query = "SELECT s FROM Site s WHERE s.domainOfSite = :domain"
|
||||||
)
|
)
|
||||||
,
|
,
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Site.findDefaultSite",
|
||||||
|
query = "SELECT s FROM Site s WHERE s.defaultSite = true"
|
||||||
|
)
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Site.hasSiteForDomain",
|
name = "Site.hasSiteForDomain",
|
||||||
query = "SELECT (CASE WHEN COUNT(s) > 0 THEN true ELSE false END) "
|
query = "SELECT (CASE WHEN COUNT(s) > 0 THEN true ELSE false END) "
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
package org.libreccm.sites;
|
package org.libreccm.sites;
|
||||||
|
|
||||||
import org.libreccm.core.AbstractEntityRepository;
|
import org.libreccm.core.AbstractEntityRepository;
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
|
|
||||||
|
|
@ -51,6 +50,18 @@ public class SiteRepository extends AbstractEntityRepository<Long, Site> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public Optional<Site> findDefaultSite() {
|
||||||
|
final TypedQuery<Site> query = getEntityManager()
|
||||||
|
.createNamedQuery("Site.findDefaultSite", Site.class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Optional.of(query.getSingleResult());
|
||||||
|
} catch (NoResultException ex) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public boolean hasSiteForDomain(final String domain) {
|
public boolean hasSiteForDomain(final String domain) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue