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 org.hibernate.envers.NotAudited;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
|
|
@ -69,42 +70,95 @@ import static org.librecms.CmsConstants.*;
|
|||
@NamedQueries({
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findById",
|
||||
query = "SELECT DISTINCT i "
|
||||
+ "FROM ContentItem i "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE i.objectId = :objectId "
|
||||
+ "AND ((p.grantee IN :roles "
|
||||
+ "AND p.grantedPrivilege = (CASE WHEN i.version = 'DRAFT' THEN 'preview_items' ELSE 'view_published_items' END)) "
|
||||
+ "OR true = :isSystemUser OR true = :isAdmin)")
|
||||
query
|
||||
= "SELECT DISTINCT i "
|
||||
+ "FROM ContentItem i "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE i.objectId = :objectId "
|
||||
+ "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(
|
||||
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(
|
||||
name = "ContentItem.findByFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
query
|
||||
= "SELECT DISTINCT i "
|
||||
+ "FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE c.category = :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(
|
||||
name = "ContentItem.countItemsInFolder",
|
||||
query = "SELECT count(i) FROM ContentItem i "
|
||||
query = "SELECT COUNT(i) FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "'")
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "ContentItem.findByNameInFolder",
|
||||
query = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER
|
||||
+ "' "
|
||||
+ "AND i.displayName = :name")
|
||||
query
|
||||
= "SELECT DISTINCT i "
|
||||
+ "FROM ContentItem i "
|
||||
+ "JOIN i.categories c "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||
+ "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(
|
||||
name = "ContentItem.countByNameInFolder",
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
|
||||
|
||||
<jsp:directive.page import="com.arsdigita.cms.ui.ContentSectionPage"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSection"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSectionServlet"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
||||
<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:directive.page import="com.arsdigita.cms.ui.ContentSectionPage"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSection"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSectionServlet"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
||||
<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 ContentSectionPage sectionPage = new ContentSectionPage();
|
||||
</jsp:declaration>
|
||||
</jsp:declaration>
|
||||
|
||||
<jsp:scriptlet>
|
||||
<jsp:scriptlet>
|
||||
// Restore the wrapped request
|
||||
HttpServletRequest myRequest = DispatcherHelper.getRequest();
|
||||
DispatcherHelper.cacheDisable(response);
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
RequestContext context = DispatcherHelper.getRequestContext(myRequest);
|
||||
sectionPage.init();
|
||||
sectionPage.dispatch(myRequest, response, context);
|
||||
</jsp:scriptlet>
|
||||
</jsp:scriptlet>
|
||||
</jsp:root>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,22 @@
|
|||
<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="org.librecms.ContentSectionServlet"/>
|
||||
<jsp:directive.page import="org.librecms.ContentSection"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||
<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="com.arsdigita.cms.ui.ContentItemPage"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSection"/>
|
||||
<jsp:directive.page import="org.librecms.contentsection.ContentSectionServlet"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
||||
<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>
|
||||
private static final Logger s_log =
|
||||
LogManager.getLogger("content-section.www.admin.item.jsp");
|
||||
<jsp:declaration>
|
||||
private ContentItemPage itemPage = null;
|
||||
private Date timestamp = new Date(0);
|
||||
</jsp:declaration>
|
||||
</jsp:declaration>
|
||||
|
||||
<jsp:scriptlet>
|
||||
s_log.debug("entered item.jsp's service method");
|
||||
<jsp:scriptlet>
|
||||
// Restore the wrapped request
|
||||
HttpServletRequest myRequest = DispatcherHelper.getRequest();
|
||||
DispatcherHelper.cacheDisable(response);
|
||||
|
|
@ -31,38 +26,26 @@
|
|||
|
||||
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);
|
||||
} 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
|
||||
// in the section change
|
||||
synchronized(this) {
|
||||
if (Utilities.getLastSectionRefresh(section).after(timestamp)) {
|
||||
s_log.debug("refreshing itemPage");
|
||||
s_log.debug("Creating new ContentItemPage instance...");
|
||||
itemPage = new ContentItemPage();
|
||||
s_log.debug("Calling init on new instance...");
|
||||
itemPage.init();
|
||||
s_log.debug("Creating time stamp...");
|
||||
timestamp = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
s_log.debug("Starting dispatch process...");
|
||||
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);
|
||||
s_log.debug("exited item.jsp's service method");
|
||||
</jsp:scriptlet>
|
||||
</jsp:scriptlet>
|
||||
</jsp:root>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue