CCM NG/ccm-cms: Several optimisations
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4729 8810af33-2d31-482b-a856-94f89814c4df
parent
e8960f8812
commit
4248d0073b
|
|
@ -54,6 +54,7 @@ import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
|
|
||||||
import org.hibernate.envers.NotAudited;
|
import org.hibernate.envers.NotAudited;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
||||||
|
|
@ -69,42 +70,95 @@ import static org.librecms.CmsConstants.*;
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.findById",
|
name = "ContentItem.findById",
|
||||||
query = "SELECT DISTINCT i "
|
query
|
||||||
|
= "SELECT DISTINCT i "
|
||||||
+ "FROM ContentItem i "
|
+ "FROM ContentItem i "
|
||||||
+ "JOIN i.permissions p "
|
+ "JOIN i.permissions p "
|
||||||
+ "WHERE i.objectId = :objectId "
|
+ "WHERE i.objectId = :objectId "
|
||||||
+ "AND ((p.grantee IN :roles "
|
+ "AND ("
|
||||||
+ "AND p.grantedPrivilege = (CASE WHEN i.version = 'DRAFT' THEN 'preview_items' ELSE 'view_published_items' END)) "
|
+ " ("
|
||||||
+ "OR true = :isSystemUser OR true = :isAdmin)")
|
+ " p.grantee IN :roles "
|
||||||
|
+ " AND p.grantedPrivilege = "
|
||||||
|
+ " (CASE WHEN i.version = 'DRAFT' "
|
||||||
|
+ " THEN '" + ItemPrivileges.PREVIEW + "' "
|
||||||
|
+ " ELSE '" + ItemPrivileges.VIEW_PUBLISHED + "' "
|
||||||
|
+ " END"
|
||||||
|
+ " )"
|
||||||
|
+ " ) "
|
||||||
|
+ " OR true = :isSystemUser OR true = :isAdmin"
|
||||||
|
+ " )")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.findByType",
|
name = "ContentItem.findByType",
|
||||||
query = "SELECT i FROM ContentItem i WHERE TYPE(i) = :type")
|
query
|
||||||
|
= "SELECT DISTINCT i "
|
||||||
|
+ "FROM ContentItem i "
|
||||||
|
+ "JOIN i.permissions p "
|
||||||
|
+ "WHERE TYPE(i) = :type "
|
||||||
|
+ "AND ("
|
||||||
|
+ " ("
|
||||||
|
+ " p.grantee IN :roles "
|
||||||
|
+ " AND p.grantedPrivilege = "
|
||||||
|
+ " (CASE WHEN i.version = 'DRAFT' "
|
||||||
|
+ " THEN '" + ItemPrivileges.PREVIEW + "' "
|
||||||
|
+ " ELSE '" + ItemPrivileges.VIEW_PUBLISHED + "' "
|
||||||
|
+ " END"
|
||||||
|
+ " )"
|
||||||
|
+ " ) "
|
||||||
|
+ " OR true = :isSystemUser OR true = :isAdmin"
|
||||||
|
+ " )")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.findByFolder",
|
name = "ContentItem.findByFolder",
|
||||||
query = "SELECT i FROM ContentItem i "
|
query
|
||||||
|
= "SELECT DISTINCT i "
|
||||||
|
+ "FROM ContentItem i "
|
||||||
+ "JOIN i.categories c "
|
+ "JOIN i.categories c "
|
||||||
|
+ "JOIN i.permissions p "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||||
+ "'")
|
+ "AND ("
|
||||||
|
+ " ("
|
||||||
|
+ " p.grantee IN :roles "
|
||||||
|
+ " AND p.grantedPrivilege = "
|
||||||
|
+ " (CASE WHEN i.version = 'DRAFT' "
|
||||||
|
+ " THEN '" + ItemPrivileges.PREVIEW + "' "
|
||||||
|
+ " ELSE '" + ItemPrivileges.VIEW_PUBLISHED + "' "
|
||||||
|
+ " END"
|
||||||
|
+ " )"
|
||||||
|
+ " )"
|
||||||
|
+ " OR true = :isSystemUser OR true = :isAdmin"
|
||||||
|
+ " )")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.countItemsInFolder",
|
name = "ContentItem.countItemsInFolder",
|
||||||
query = "SELECT count(i) FROM ContentItem i "
|
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||||
+ "JOIN i.categories c "
|
+ "JOIN i.categories c "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'")
|
||||||
+ "'")
|
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.findByNameInFolder",
|
name = "ContentItem.findByNameInFolder",
|
||||||
query = "SELECT i FROM ContentItem i "
|
query
|
||||||
|
= "SELECT DISTINCT i "
|
||||||
|
+ "FROM ContentItem i "
|
||||||
+ "JOIN i.categories c "
|
+ "JOIN i.categories c "
|
||||||
|
+ "JOIN i.permissions p "
|
||||||
+ "WHERE c.category = :folder "
|
+ "WHERE c.category = :folder "
|
||||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||||
+ "' "
|
+ "AND i.displayName = :name "
|
||||||
+ "AND i.displayName = :name")
|
+ "AND ("
|
||||||
|
+ " ("
|
||||||
|
+ " p.grantee IN :roles "
|
||||||
|
+ " AND p.grantedPrivilege = "
|
||||||
|
+ " (CASE WHEN i.version = 'DRAFT' "
|
||||||
|
+ " THEN '" + ItemPrivileges.PREVIEW + "' "
|
||||||
|
+ " ELSE '" + ItemPrivileges.VIEW_PUBLISHED + "' "
|
||||||
|
+ " END"
|
||||||
|
+ " )"
|
||||||
|
+ " )"
|
||||||
|
+ " OR true = :isSystemUser OR true = :isAdmin"
|
||||||
|
+ " )")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentItem.countByNameInFolder",
|
name = "ContentItem.countByNameInFolder",
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,22 @@
|
||||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
|
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
|
||||||
|
|
||||||
<jsp:directive.page import="com.arsdigita.bebop.Page"/>
|
|
||||||
<jsp:directive.page import="com.arsdigita.cms.ui.ContentItemPage"/>
|
<jsp:directive.page import="com.arsdigita.cms.ui.ContentItemPage"/>
|
||||||
<jsp:directive.page import="org.librecms.ContentSectionServlet"/>
|
<jsp:directive.page import="org.librecms.contentsection.ContentSection"/>
|
||||||
<jsp:directive.page import="org.librecms.ContentSection"/>
|
<jsp:directive.page import="org.librecms.contentsection.ContentSectionServlet"/>
|
||||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||||
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
||||||
<jsp:directive.page import="org.apache.logging.log4j.Logger"/>
|
|
||||||
<jsp:directive.page import="org.apache.logging.log4j.LogManager"/>
|
|
||||||
<jsp:directive.page import="java.util.Date"/>
|
<jsp:directive.page import="java.util.Date"/>
|
||||||
|
<jsp:directive.page import="org.libreccm.cdi.utils.CdiUtil"/>
|
||||||
|
<jsp:directive.page import="org.libreccm.security.Shiro"/>
|
||||||
|
|
||||||
<jsp:declaration>
|
<jsp:declaration>
|
||||||
private static final Logger s_log =
|
|
||||||
LogManager.getLogger("content-section.www.admin.item.jsp");
|
|
||||||
private ContentItemPage itemPage = null;
|
private ContentItemPage itemPage = null;
|
||||||
private Date timestamp = new Date(0);
|
private Date timestamp = new Date(0);
|
||||||
</jsp:declaration>
|
</jsp:declaration>
|
||||||
|
|
||||||
<jsp:scriptlet>
|
<jsp:scriptlet>
|
||||||
s_log.debug("entered item.jsp's service method");
|
|
||||||
// Restore the wrapped request
|
// Restore the wrapped request
|
||||||
HttpServletRequest myRequest = DispatcherHelper.getRequest();
|
HttpServletRequest myRequest = DispatcherHelper.getRequest();
|
||||||
DispatcherHelper.cacheDisable(response);
|
DispatcherHelper.cacheDisable(response);
|
||||||
|
|
@ -31,37 +26,25 @@
|
||||||
|
|
||||||
ContentSection section = ContentSectionServlet.getContentSection(myRequest);
|
ContentSection section = ContentSectionServlet.getContentSection(myRequest);
|
||||||
|
|
||||||
|
//if (Web.getWebContext().getUser() == null) {
|
||||||
if (Web.getWebContext().getUser() == null) {
|
if (!CdiUtil.createCdiUtil().findBean(Shiro.class).getSubject().isAuthenticated()) {
|
||||||
throw new LoginSignal(myRequest);
|
throw new LoginSignal(myRequest);
|
||||||
} else if (! ContentSectionServlet.checkAdminAccess(myRequest, section)) {
|
} else if (! ContentSectionServlet.checkAdminAccess(myRequest, section)) {
|
||||||
throw new com.arsdigita.cms.dispatcher.AccessDeniedException();
|
throw new com.arsdigita.dispatcher.AccessDeniedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// page needs to be refreshed when content types or authoring kits
|
// page needs to be refreshed when content types or authoring kits
|
||||||
// in the section change
|
// in the section change
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (Utilities.getLastSectionRefresh(section).after(timestamp)) {
|
if (Utilities.getLastSectionRefresh(section).after(timestamp)) {
|
||||||
s_log.debug("refreshing itemPage");
|
|
||||||
s_log.debug("Creating new ContentItemPage instance...");
|
|
||||||
itemPage = new ContentItemPage();
|
itemPage = new ContentItemPage();
|
||||||
s_log.debug("Calling init on new instance...");
|
|
||||||
itemPage.init();
|
itemPage.init();
|
||||||
s_log.debug("Creating time stamp...");
|
|
||||||
timestamp = new Date();
|
timestamp = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s_log.debug("Starting dispatch process...");
|
|
||||||
RequestContext context = DispatcherHelper.getRequestContext(myRequest);
|
RequestContext context = DispatcherHelper.getRequestContext(myRequest);
|
||||||
if(itemPage == null) {
|
|
||||||
s_log.warn("WARNING: itemPage is NULL");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s_log.info("ALL OK: itemPage is not null");
|
|
||||||
}
|
|
||||||
itemPage.dispatch(myRequest, response, context);
|
itemPage.dispatch(myRequest, response, context);
|
||||||
s_log.debug("exited item.jsp's service method");
|
|
||||||
</jsp:scriptlet>
|
</jsp:scriptlet>
|
||||||
</jsp:root>
|
</jsp:root>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue