Some fixes for the ongoing refactoring/removal of the old dispatcher code.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2077 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a4a94953c4
commit
6c79fc15a9
|
|
@ -22,9 +22,7 @@ import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.cms.dispatcher.CMSPage;
|
import com.arsdigita.cms.dispatcher.CMSPage;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleCache;
|
import com.arsdigita.cms.dispatcher.SimpleCache;
|
||||||
import com.arsdigita.cms.ui.CMSApplicationPage;
|
import com.arsdigita.cms.ui.CMSApplicationPage;
|
||||||
import com.arsdigita.cms.ui.CMSItemSearchPage;
|
|
||||||
import com.arsdigita.cms.ui.CMSSearchResultRedirector;
|
import com.arsdigita.cms.ui.CMSSearchResultRedirector;
|
||||||
// Old version (dispatcher based) of CMSItemSearchPage
|
|
||||||
import com.arsdigita.cms.ui.ItemSearchPage;
|
import com.arsdigita.cms.ui.ItemSearchPage;
|
||||||
import com.arsdigita.cms.ui.contentcenter.MainPage;
|
import com.arsdigita.cms.ui.contentcenter.MainPage;
|
||||||
import com.arsdigita.developersupport.DeveloperSupport;
|
import com.arsdigita.developersupport.DeveloperSupport;
|
||||||
|
|
@ -37,21 +35,21 @@ import com.arsdigita.templating.PresentationManager;
|
||||||
import com.arsdigita.templating.Templating;
|
import com.arsdigita.templating.Templating;
|
||||||
import com.arsdigita.ui.login.LoginHelper;
|
import com.arsdigita.ui.login.LoginHelper;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.web.*;
|
import com.arsdigita.web.Application;
|
||||||
|
import com.arsdigita.web.ApplicationFileResolver;
|
||||||
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
|
import com.arsdigita.web.LoginSignal;
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletConfig;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,27 +95,27 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
s_log.info("starting doInit method");
|
s_log.info("starting doInit method");
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED STUFF for servlet internally process pages, maybe required
|
// DEPRECATED STUFF for servlet internally process pages, maybe required
|
||||||
// for JSP extension.
|
// for JSP extension.
|
||||||
// m_trailingSlashList = new ArrayList();
|
// m_trailingSlashList = new ArrayList();
|
||||||
// requireTrailingSlash("");
|
// requireTrailingSlash("");
|
||||||
|
|
||||||
// NEW STUFF here used to process the pages in this servlet
|
// NEW STUFF here used to process the pages in this servlet
|
||||||
// Addresses previously noted in WEB-INF/resources/content-center-map.xml
|
// Addresses previously noted in WEB-INF/resources/content-center-map.xml
|
||||||
// Obviously not required.
|
// Obviously not required.
|
||||||
addPage("/", new MainPage()); // index page at address ~/cc
|
addPage("/", new MainPage()); // index page at address ~/cc
|
||||||
addPage("/index", new MainPage());
|
addPage("/index", new MainPage());
|
||||||
// addPage("/item-search", new CMSItemSearchPage());
|
// addPage("/item-search", new CMSItemSearchPage());
|
||||||
// Old style
|
// Old style
|
||||||
addPage("/item-search", new ItemSearchPage());
|
addPage("/item-search", new ItemSearchPage());
|
||||||
addPage("/searchredirect", new CMSSearchResultRedirector());
|
addPage("/searchredirect", new CMSSearchResultRedirector());
|
||||||
|
|
||||||
|
|
||||||
// STUFF to use for JSP extension, i.e. jsp's to try for URLs which are not
|
// STUFF to use for JSP extension, i.e. jsp's to try for URLs which are not
|
||||||
// handled by the this servlet directly.
|
// handled by the this servlet directly.
|
||||||
/** Set Template base path for JSP's */
|
/** Set Template base path for JSP's */
|
||||||
// ToDo: Make it configurable by an appropriate config registry entry!
|
// ToDo: Make it configurable by an appropriate config registry entry!
|
||||||
// m_templatePath = CMS.getConfig().getTemplateRoot();
|
// m_templatePath = CMS.getConfig().getTemplateRoot();
|
||||||
m_templatePath = "/templates/ccm-cms/content-center";
|
m_templatePath = "/templates/ccm-cms/content-center";
|
||||||
Assert.exists(m_templatePath, String.class);
|
Assert.exists(m_templatePath, String.class);
|
||||||
Assert.isTrue(m_templatePath.startsWith("/"),
|
Assert.isTrue(m_templatePath.startsWith("/"),
|
||||||
|
|
@ -136,16 +134,16 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
* (HttpServletRequest, HttpServletResponse, Application)
|
* (HttpServletRequest, HttpServletResponse, Application)
|
||||||
*/
|
*/
|
||||||
protected void doService(HttpServletRequest sreq,
|
protected void doService(HttpServletRequest sreq,
|
||||||
HttpServletResponse sresp,
|
HttpServletResponse sresp,
|
||||||
Application app)
|
Application app)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.info("starting doService method");
|
s_log.info("starting doService method");
|
||||||
}
|
}
|
||||||
DeveloperSupport.startStage("ContentCenterServlet.doService");
|
DeveloperSupport.startStage("ContentCenterServlet.doService");
|
||||||
|
|
||||||
// ContentCenter workspace = (ContentCenter) app;
|
// ContentCenter workspace = (ContentCenter) app;
|
||||||
|
|
||||||
/* Check user and privilegies */
|
/* Check user and privilegies */
|
||||||
if (Web.getContext().getUser() == null) { // user not logged in
|
if (Web.getContext().getUser() == null) { // user not logged in
|
||||||
|
|
@ -186,10 +184,10 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
// probably want to redirect.
|
// probably want to redirect.
|
||||||
// Probably DEPRECATED with new access method or only relevant for jsp
|
// Probably DEPRECATED with new access method or only relevant for jsp
|
||||||
// extension
|
// extension
|
||||||
// if (m_trailingSlashList.contains(url) && !originalUrl.endsWith("/")) {
|
// if (m_trailingSlashList.contains(url) && !originalUrl.endsWith("/")) {
|
||||||
// DispatcherHelper.sendRedirect(sresp, originalUrl + "/");
|
// DispatcherHelper.sendRedirect(sresp, originalUrl + "/");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
final Page page = (Page) m_pages.get(pathInfo);
|
final Page page = (Page) m_pages.get(pathInfo);
|
||||||
|
|
@ -206,7 +204,7 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
cmsPage.dispatch(sreq, sresp, ctx);
|
cmsPage.dispatch(sreq, sresp, ctx);
|
||||||
} else {
|
} else {
|
||||||
final CMSApplicationPage cmsAppPage = (CMSApplicationPage) page;
|
final CMSApplicationPage cmsAppPage = (CMSApplicationPage) page;
|
||||||
cmsAppPage.init(sreq,sresp,app);
|
cmsAppPage.init(sreq, sresp, app);
|
||||||
// Serve the page.
|
// Serve the page.
|
||||||
final Document doc = cmsAppPage.buildDocument(sreq, sresp);
|
final Document doc = cmsAppPage.buildDocument(sreq, sresp);
|
||||||
|
|
||||||
|
|
@ -232,8 +230,7 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
rd.forward(sreq, sresp);
|
rd.forward(sreq, sresp);
|
||||||
} else {
|
} else {
|
||||||
// String requestUri = sreq.getRequestURI();
|
// String requestUri = sreq.getRequestURI();
|
||||||
sresp.sendError(404, sreq.getRequestURI() +
|
sresp.sendError(404, sreq.getRequestURI() + " not found on this server.");
|
||||||
" not found on this server.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -274,8 +271,8 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
Iterator itr = s_pageURLs.keySet().iterator();
|
Iterator itr = s_pageURLs.keySet().iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
String classname2 = (String) itr.next();
|
String classname2 = (String) itr.next();
|
||||||
s_log.debug("key: " + classname + " value: "
|
s_log.debug("key: " + classname + " value: "
|
||||||
+ (String) s_pageURLs.get(classname2));
|
+ (String) s_pageURLs.get(classname2));
|
||||||
}
|
}
|
||||||
String url = (String) s_pageURLs.get(classname);
|
String url = (String) s_pageURLs.get(classname);
|
||||||
return url;
|
return url;
|
||||||
|
|
@ -302,7 +299,7 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
* @param actx The request context
|
* @param actx The request context
|
||||||
**/
|
**/
|
||||||
protected void checkUserAccess(final HttpServletRequest request,
|
protected void checkUserAccess(final HttpServletRequest request,
|
||||||
final HttpServletResponse response //,
|
final HttpServletResponse response //,
|
||||||
/// final RequestContext actx
|
/// final RequestContext actx
|
||||||
)
|
)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
|
|
@ -320,8 +317,8 @@ public class ContentCenterServlet extends BaseApplicationServlet {
|
||||||
* trying to redirect, wrap that exception in a ServletException
|
* trying to redirect, wrap that exception in a ServletException
|
||||||
**/
|
**/
|
||||||
protected void redirectToLoginPage(HttpServletRequest req,
|
protected void redirectToLoginPage(HttpServletRequest req,
|
||||||
HttpServletResponse resp)
|
HttpServletResponse resp)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
String url = Util.getSecurityHelper()
|
String url = Util.getSecurityHelper()
|
||||||
.getLoginURL(req)
|
.getLoginURL(req)
|
||||||
+ "?" + LoginHelper.RETURN_URL_PARAM_NAME
|
+ "?" + LoginHelper.RETURN_URL_PARAM_NAME
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ import org.apache.log4j.Logger;
|
||||||
* - Refactor content item UI bebop ApplicationPage or PageFactory instead of
|
* - Refactor content item UI bebop ApplicationPage or PageFactory instead of
|
||||||
* legacy infected sitenode / package dispatchers.
|
* legacy infected sitenode / package dispatchers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content Section's Application Servlet according CCM core web application
|
* Content Section's Application Servlet according CCM core web application
|
||||||
* structure {@see com.arsdigita.web.Application} implements the content
|
* structure {@see com.arsdigita.web.Application} implements the content
|
||||||
|
|
@ -101,15 +100,13 @@ import org.apache.log4j.Logger;
|
||||||
* @author Sören Bernstein <sbernstein@quasiweb.de>
|
* @author Sören Bernstein <sbernstein@quasiweb.de>
|
||||||
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
|
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ContentSectionServlet extends BaseApplicationServlet {
|
public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
/** Creates a s_logging category with name = full name of class */
|
/** Creates a s_logging category with name = full name of class */
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(ContentSectionServlet.class);
|
Logger.getLogger(ContentSectionServlet.class);
|
||||||
|
|
||||||
/** Stringarray of file name patterns for index files. */
|
/** Stringarray of file name patterns for index files. */
|
||||||
private static final String[] WELCOME_FILES = new String[] {
|
private static final String[] WELCOME_FILES = new String[]{
|
||||||
"index.jsp", "index.html"
|
"index.jsp", "index.html"
|
||||||
};
|
};
|
||||||
/** The context (in url) for previewing items */
|
/** The context (in url) for previewing items */
|
||||||
|
|
@ -124,23 +121,17 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
public static final String XML_SUFFIX = ".xml";
|
public static final String XML_SUFFIX = ".xml";
|
||||||
public static final String XML_MODE = "xmlMode";
|
public static final String XML_MODE = "xmlMode";
|
||||||
public static final String MEDIA_TYPE = "templateContext";
|
public static final String MEDIA_TYPE = "templateContext";
|
||||||
|
|
||||||
private static final String CACHE_KEY_DELIMITER = "%";
|
private static final String CACHE_KEY_DELIMITER = "%";
|
||||||
|
|
||||||
|
|
||||||
private ContentItemDispatcher m_disp = new ContentItemDispatcher();
|
private ContentItemDispatcher m_disp = new ContentItemDispatcher();
|
||||||
|
|
||||||
public static Map s_itemResolverCache = Collections
|
public static Map s_itemResolverCache = Collections
|
||||||
.synchronizedMap(new HashMap());
|
.synchronizedMap(new HashMap());
|
||||||
/** cache the content items */
|
/** cache the content items */
|
||||||
private static Map s_itemURLCacheMap = null;
|
private static Map s_itemURLCacheMap = null;
|
||||||
private static boolean s_cacheItems = true;
|
private static boolean s_cacheItems = true;
|
||||||
|
|
||||||
// NEW STUFF here used to process the pages in this servlet
|
// NEW STUFF here used to process the pages in this servlet
|
||||||
/** URL (pathinfo) -> Page object mapping. Based on it (and the http
|
/** URL (pathinfo) -> Page object mapping. Based on it (and the http
|
||||||
* request url) the doService method selects a page to display */
|
* request url) the doService method selects a page to display */
|
||||||
private final Map m_pages = new HashMap();
|
private final Map m_pages = new HashMap();
|
||||||
|
|
||||||
/** Path to directory containg ccm-cms template (jsp) files */
|
/** Path to directory containg ccm-cms template (jsp) files */
|
||||||
private String m_templatePath;
|
private String m_templatePath;
|
||||||
// Probably compatibility stuff, based on dispatcher
|
// Probably compatibility stuff, based on dispatcher
|
||||||
|
|
@ -153,7 +144,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* If not specified system wide defaults are used.
|
* If not specified system wide defaults are used.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException {
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
super.init(config);
|
super.init(config);
|
||||||
|
|
||||||
|
|
@ -168,27 +159,26 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
Assert.exists(m_templatePath, String.class);
|
Assert.exists(m_templatePath, String.class);
|
||||||
Assert.isTrue(m_templatePath.startsWith("/"),
|
Assert.isTrue(m_templatePath.startsWith("/"),
|
||||||
"template-path must start with '/'");
|
"template-path must start with '/'");
|
||||||
Assert.isTrue(!m_templatePath.endsWith("/"),
|
Assert.isTrue(!m_templatePath.endsWith("/"),
|
||||||
"template-path must not end with '/'");
|
"template-path must not end with '/'");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// optional init-param named file-resolver from ~/WEB-INF/web.xml
|
// optional init-param named file-resolver from ~/WEB-INF/web.xml
|
||||||
String resolverName = config.getInitParameter("file-resolver");
|
String resolverName = config.getInitParameter("file-resolver");
|
||||||
if (resolverName == null) {
|
if (resolverName == null) {
|
||||||
m_resolver = Web.getConfig().getApplicationFileResolver();
|
m_resolver = Web.getConfig().getApplicationFileResolver();
|
||||||
} else {
|
} else {
|
||||||
m_resolver = (ApplicationFileResolver)Classes.newInstance(resolverName);
|
m_resolver = (ApplicationFileResolver) Classes.newInstance(resolverName);
|
||||||
}
|
}
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Template path is " + m_templatePath +
|
s_log.debug("Template path is " + m_templatePath + " with resolver " + m_resolver.getClass().getName());
|
||||||
" with resolver " + m_resolver.getClass().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEW STUFF here used to process the pages in this servlet
|
// NEW STUFF here used to process the pages in this servlet
|
||||||
// addPage("/admin", new MainPage()); // index page at address ~/cs
|
// addPage("/admin", new MainPage()); // index page at address ~/cs
|
||||||
// addPage("/admin/index.jsp", new MainPage());
|
// addPage("/admin/index.jsp", new MainPage());
|
||||||
// addPage("/admin/item.jsp", new MainPage());
|
// addPage("/admin/item.jsp", new MainPage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,13 +190,13 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* {@see com.arsdigita.web.BaseApplicationServlet#doService
|
* {@see com.arsdigita.web.BaseApplicationServlet#doService
|
||||||
* (HttpServletRequest, HttpServletResponse, Application)}
|
* (HttpServletRequest, HttpServletResponse, Application)}
|
||||||
*/
|
*/
|
||||||
protected void doService( HttpServletRequest sreq,
|
protected void doService(HttpServletRequest sreq,
|
||||||
HttpServletResponse sresp,
|
HttpServletResponse sresp,
|
||||||
Application app)
|
Application app)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
ContentSection section = (ContentSection) app;
|
ContentSection section = (ContentSection) app;
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////
|
||||||
// Prepare OLD style dispatcher based page service
|
// Prepare OLD style dispatcher based page service
|
||||||
// ////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -217,19 +207,20 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* SiteNodeRequestContext removed, resolves currently to
|
* SiteNodeRequestContext removed, resolves currently to
|
||||||
* KernelRequestContext which will be removed as well.
|
* KernelRequestContext which will be removed as well.
|
||||||
*/
|
*/
|
||||||
RequestContext ctx = DispatcherHelper.getRequestContext();
|
RequestContext ctx = DispatcherHelper.getRequestContext();
|
||||||
String url = ctx.getRemainingURLPart(); // here KernelRequestContext now
|
String url = ctx.getRemainingURLPart(); // here KernelRequestContext now
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("Resolving item URL " + url);
|
s_log.info("Resolving item URL " + url);
|
||||||
}
|
}
|
||||||
final ItemResolver itemResolver = getItemResolver(section);
|
final ItemResolver itemResolver = getItemResolver(section);
|
||||||
final ContentItem item = getItem(section, url, itemResolver);
|
|
||||||
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////
|
||||||
// Prepare NEW style servlet based bebpo page service
|
// Prepare NEW style servlet based bebpo page service
|
||||||
// ////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////
|
||||||
String pathInfo = sreq.getPathInfo();
|
String pathInfo = sreq.getPathInfo();
|
||||||
|
|
||||||
|
final ContentItem item = getItem(section, pathInfo, itemResolver);
|
||||||
|
|
||||||
Assert.exists(pathInfo, "String pathInfo");
|
Assert.exists(pathInfo, "String pathInfo");
|
||||||
if (pathInfo.length() > 1 && pathInfo.endsWith("/")) {
|
if (pathInfo.length() > 1 && pathInfo.endsWith("/")) {
|
||||||
/* NOTE: ServletAPI specifies, pathInfo may be empty or will
|
/* NOTE: ServletAPI specifies, pathInfo may be empty or will
|
||||||
|
|
@ -254,12 +245,12 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
if (page instanceof CMSPage) {
|
if (page instanceof CMSPage) {
|
||||||
// backwards compatibility fix until migration completed
|
// backwards compatibility fix until migration completed
|
||||||
final CMSPage cmsPage = (CMSPage) page;
|
final CMSPage cmsPage = (CMSPage) page;
|
||||||
// final RequestContext ctx = DispatcherHelper.getRequestContext();
|
// final RequestContext ctx = DispatcherHelper.getRequestContext();
|
||||||
cmsPage.init();
|
cmsPage.init();
|
||||||
cmsPage.dispatch(sreq, sresp, ctx);
|
cmsPage.dispatch(sreq, sresp, ctx);
|
||||||
} else {
|
} else {
|
||||||
final CMSApplicationPage cmsAppPage = (CMSApplicationPage) page;
|
final CMSApplicationPage cmsAppPage = (CMSApplicationPage) page;
|
||||||
cmsAppPage.init(sreq,sresp,app);
|
cmsAppPage.init(sreq, sresp, app);
|
||||||
// Serve the page.
|
// Serve the page.
|
||||||
final Document doc = cmsAppPage.buildDocument(sreq, sresp);
|
final Document doc = cmsAppPage.buildDocument(sreq, sresp);
|
||||||
|
|
||||||
|
|
@ -267,9 +258,9 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
pm.servePage(doc, sreq, sresp);
|
pm.servePage(doc, sreq, sresp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SECONDLY try if we have to serve an item (old style dispatcher based */
|
/* SECONDLY try if we have to serve an item (old style dispatcher based */
|
||||||
} else if (item != null) {
|
} else if (item != null) {
|
||||||
|
|
||||||
/* We have to serve an item here */
|
/* We have to serve an item here */
|
||||||
String param = sreq.getParameter("transID");
|
String param = sreq.getParameter("transID");
|
||||||
|
|
||||||
|
|
@ -281,6 +272,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
public void beforeCommit(TransactionContext txn) {
|
public void beforeCommit(TransactionContext txn) {
|
||||||
Assert.fail("uncommittable transaction");
|
Assert.fail("uncommittable transaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Kernel.getContext().getTransaction().setCommitRequested(false);
|
Kernel.getContext().getTransaction().setCommitRequested(false);
|
||||||
|
|
@ -290,8 +282,8 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
serveItem(sreq, sresp, section, item);
|
serveItem(sreq, sresp, section, item);
|
||||||
|
|
||||||
/* OTHERWISE delegate to a JSP in file system */
|
/* OTHERWISE delegate to a JSP in file system */
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* We have to deal with a content-section, folder or an other bit*/
|
/* We have to deal with a content-section, folder or an other bit*/
|
||||||
|
|
@ -310,16 +302,15 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
s_log.debug("Got dispatcher " + rd);
|
s_log.debug("Got dispatcher " + rd);
|
||||||
}
|
}
|
||||||
sreq = DispatcherHelper.restoreOriginalRequest(sreq);
|
sreq = DispatcherHelper.restoreOriginalRequest(sreq);
|
||||||
rd.forward(sreq,sresp);
|
rd.forward(sreq, sresp);
|
||||||
} else {
|
} else {
|
||||||
// sresp.sendError(404, packageURL + " not found on this server.");
|
// sresp.sendError(404, packageURL + " not found on this server.");
|
||||||
String requestUri = sreq.getRequestURI(); // same as ctx.getRemainingURLPart()
|
String requestUri = sreq.getRequestURI(); // same as ctx.getRemainingURLPart()
|
||||||
sresp.sendError(404, requestUri + " not found on this server.");
|
sresp.sendError(404, requestUri + " not found on this server.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // END doService
|
} // END doService
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sreq
|
* @param sreq
|
||||||
|
|
@ -333,7 +324,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
HttpServletResponse sresp,
|
HttpServletResponse sresp,
|
||||||
ContentSection section,
|
ContentSection section,
|
||||||
ContentItem item)
|
ContentItem item)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
//this is a content item, so use ContentItemDispatcher
|
//this is a content item, so use ContentItemDispatcher
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("serving content item");
|
s_log.info("serving content item");
|
||||||
|
|
@ -350,14 +341,14 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
//set the template context
|
//set the template context
|
||||||
TemplateResolver templateResolver =
|
TemplateResolver templateResolver =
|
||||||
m_disp.getTemplateResolver(section);
|
m_disp.getTemplateResolver(section);
|
||||||
String templateURL = url;
|
String templateURL = url;
|
||||||
if (!templateURL.startsWith("/")) {
|
if (!templateURL.startsWith("/")) {
|
||||||
templateURL = "/" + templateURL;
|
templateURL = "/" + templateURL;
|
||||||
}
|
}
|
||||||
if (templateURL.startsWith(PREVIEW)) {
|
if (templateURL.startsWith(PREVIEW)) {
|
||||||
templateURL = templateURL.substring(PREVIEW.length());
|
templateURL = templateURL.substring(PREVIEW.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
String sTemplateContext = itemResolver.getTemplateFromURL(templateURL);
|
String sTemplateContext = itemResolver.getTemplateFromURL(templateURL);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
|
|
@ -373,8 +364,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
Date endDate = cycle.getEndDate();
|
Date endDate = cycle.getEndDate();
|
||||||
|
|
||||||
if (endDate != null) {
|
if (endDate != null) {
|
||||||
int maxAge = (int) ((endDate.getTime() -
|
int maxAge = (int) ((endDate.getTime() - System.currentTimeMillis()) / 1000l);
|
||||||
System.currentTimeMillis()) / 1000l);
|
|
||||||
if (maxAge < expires) {
|
if (maxAge < expires) {
|
||||||
expires = maxAge;
|
expires = maxAge;
|
||||||
}
|
}
|
||||||
|
|
@ -386,8 +376,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
// this page to be publically cached
|
// this page to be publically cached
|
||||||
if (s_cacheItems && item.isLiveVersion()) {
|
if (s_cacheItems && item.isLiveVersion()) {
|
||||||
SecurityManager sm = new SecurityManager(section);
|
SecurityManager sm = new SecurityManager(section);
|
||||||
if (sm.canAccess
|
if (sm.canAccess((User) null, SecurityManager.PUBLIC_PAGES, item)) {
|
||||||
((User) null, SecurityManager.PUBLIC_PAGES, item)) {
|
|
||||||
DispatcherHelper.cacheForWorld(sresp, expires);
|
DispatcherHelper.cacheForWorld(sresp, expires);
|
||||||
} else {
|
} else {
|
||||||
DispatcherHelper.cacheForUser(sresp, expires);
|
DispatcherHelper.cacheForUser(sresp, expires);
|
||||||
|
|
@ -397,7 +386,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
//use ContentItemDispatcher
|
//use ContentItemDispatcher
|
||||||
m_disp.dispatch(sreq,sresp,ctx);
|
m_disp.dispatch(sreq, sresp, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -418,7 +407,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
m_pages.put(pathInfo, page);
|
m_pages.put(pathInfo, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the content section from the request attributes.
|
* Fetches the content section from the request attributes.
|
||||||
*
|
*
|
||||||
|
|
@ -441,7 +430,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
String path = section.getPath();
|
String path = section.getPath();
|
||||||
ItemResolver ir = (ItemResolver) s_itemResolverCache.get(path);
|
ItemResolver ir = (ItemResolver) s_itemResolverCache.get(path);
|
||||||
|
|
||||||
if ( ir == null ) {
|
if (ir == null) {
|
||||||
ir = section.getItemResolver();
|
ir = section.getItemResolver();
|
||||||
s_itemResolverCache.put(path, ir);
|
s_itemResolverCache.put(path, ir);
|
||||||
}
|
}
|
||||||
|
|
@ -467,7 +456,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
//first sanitize the url
|
//first sanitize the url
|
||||||
if (url.endsWith(XML_SUFFIX)) {
|
if (url.endsWith(XML_SUFFIX)) {
|
||||||
request.setAttribute(XML_MODE, Boolean.TRUE);
|
request.setAttribute(XML_MODE, Boolean.TRUE);
|
||||||
s_log.debug ("StraightXML Requested");
|
s_log.debug("StraightXML Requested");
|
||||||
url = "/" + url.substring(0, url.length() - XML_SUFFIX.length());
|
url = "/" + url.substring(0, url.length() - XML_SUFFIX.length());
|
||||||
} else {
|
} else {
|
||||||
request.setAttribute(XML_MODE, Boolean.FALSE);
|
request.setAttribute(XML_MODE, Boolean.FALSE);
|
||||||
|
|
@ -502,8 +491,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
item = itemResolver.getItem(section, url, CMSDispatcher.PREVIEW);
|
item = itemResolver.getItem(section, url, CMSDispatcher.PREVIEW);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
hasPermission = sm.canAccess
|
hasPermission = sm.canAccess(request, SecurityManager.PREVIEW_PAGES, item);
|
||||||
(request, SecurityManager.PREVIEW_PAGES, item);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
|
|
@ -513,21 +501,18 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
//check if this item is in the cache
|
//check if this item is in the cache
|
||||||
//we only cache live items
|
//we only cache live items
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Trying to get content item for URL " + url +
|
s_log.debug("Trying to get content item for URL " + url + " from cache");
|
||||||
" from cache");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the negotiated locale
|
// Get the negotiated locale
|
||||||
String lang = GlobalizationHelper.getNegotiatedLocale().getLanguage();
|
String lang = GlobalizationHelper.getNegotiatedLocale().getLanguage();
|
||||||
|
|
||||||
item = itemURLCacheGet(section, url, lang);
|
item = itemURLCacheGet(section, url, lang);
|
||||||
item = null;
|
item = null;
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug
|
s_log.debug("Did not find content item in cache, so trying " + "to retrieve and cache...");
|
||||||
("Did not find content item in cache, so trying " +
|
|
||||||
"to retrieve and cache...");
|
|
||||||
}
|
}
|
||||||
//item not cached, so retreive it and cache it
|
//item not cached, so retreive it and cache it
|
||||||
item = itemResolver.getItem(section, url, ContentItem.LIVE);
|
item = itemResolver.getItem(section, url, ContentItem.LIVE);
|
||||||
|
|
@ -537,8 +522,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_log.isDebugEnabled() && item != null) {
|
if (s_log.isDebugEnabled() && item != null) {
|
||||||
s_log.debug
|
s_log.debug("Sanity check: item.getPath() is " + item.getPath());
|
||||||
("Sanity check: item.getPath() is " + item.getPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
@ -551,7 +535,6 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
item);
|
item);
|
||||||
|
|
||||||
if (hasPermission) {
|
if (hasPermission) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -577,8 +560,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPermission &&
|
if (!hasPermission && !LocalRequestPassword.validLocalRequest(request)) {
|
||||||
!LocalRequestPassword.validLocalRequest(request)) {
|
|
||||||
|
|
||||||
// first, check if the user is logged-in
|
// first, check if the user is logged-in
|
||||||
// if he isn't, give him a chance to do so...
|
// if he isn't, give him a chance to do so...
|
||||||
|
|
@ -600,12 +582,11 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// synchronize access to the item-url cache
|
// synchronize access to the item-url cache
|
||||||
|
private static synchronized void itemURLCachePut(ContentSection section,
|
||||||
private static synchronized void itemURLCachePut(ContentSection section,
|
|
||||||
String sURL,
|
String sURL,
|
||||||
String lang,
|
String lang,
|
||||||
BigDecimal itemID) {
|
BigDecimal itemID) {
|
||||||
|
|
||||||
getItemURLCache(section).put(sURL + CACHE_KEY_DELIMITER + lang, itemID);
|
getItemURLCache(section).put(sURL + CACHE_KEY_DELIMITER + lang, itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -615,7 +596,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* @param sURL the URL at which the content item s published
|
* @param sURL the URL at which the content item s published
|
||||||
* @param item the content item at the URL
|
* @param item the content item at the URL
|
||||||
*/
|
*/
|
||||||
public static synchronized void itemURLCachePut(ContentSection section,
|
public static synchronized void itemURLCachePut(ContentSection section,
|
||||||
String sURL,
|
String sURL,
|
||||||
String lang,
|
String lang,
|
||||||
ContentItem item) {
|
ContentItem item) {
|
||||||
|
|
@ -634,7 +615,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* @param section the content section in which to remove the key
|
* @param section the content section in which to remove the key
|
||||||
* @param sURL the cache entry key to remove
|
* @param sURL the cache entry key to remove
|
||||||
*/
|
*/
|
||||||
public static synchronized void itemURLCacheRemove(ContentSection section,
|
public static synchronized void itemURLCacheRemove(ContentSection section,
|
||||||
String sURL,
|
String sURL,
|
||||||
String lang) {
|
String lang) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
|
|
@ -649,7 +630,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
* @param sURL the URL for the item to fetch
|
* @param sURL the URL for the item to fetch
|
||||||
* @return the ContentItem in the cache, or null
|
* @return the ContentItem in the cache, or null
|
||||||
*/
|
*/
|
||||||
public static ContentItem itemURLCacheGet(ContentSection section,
|
public static ContentItem itemURLCacheGet(ContentSection section,
|
||||||
final String sURL,
|
final String sURL,
|
||||||
final String lang) {
|
final String lang) {
|
||||||
final BigDecimal itemID = (BigDecimal) getItemURLCache(section)
|
final BigDecimal itemID = (BigDecimal) getItemURLCache(section)
|
||||||
|
|
@ -659,8 +640,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return (ContentItem) DomainObjectFactory.newInstance
|
return (ContentItem) DomainObjectFactory.newInstance(new OID(ContentItem.BASE_DATA_OBJECT_TYPE, itemID));
|
||||||
(new OID(ContentItem.BASE_DATA_OBJECT_TYPE, itemID));
|
|
||||||
} catch (DataObjectNotFoundException donfe) {
|
} catch (DataObjectNotFoundException donfe) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -683,9 +663,9 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
String idStr = section.getID().toString();
|
String idStr = section.getID().toString();
|
||||||
String path = section.getPath();
|
String path = section.getPath();
|
||||||
CacheTable itemURLCache =
|
CacheTable itemURLCache =
|
||||||
new CacheTable("ContentSectionServletItemURLCache" + idStr);
|
new CacheTable("ContentSectionServletItemURLCache" + idStr);
|
||||||
s_itemURLCacheMap.put(path, itemURLCache);
|
s_itemURLCacheMap.put(path, itemURLCache);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -695,15 +675,15 @@ public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
public static boolean checkAdminAccess(HttpServletRequest request,
|
public static boolean checkAdminAccess(HttpServletRequest request,
|
||||||
ContentSection section) {
|
ContentSection section) {
|
||||||
|
|
||||||
User user ;
|
User user;
|
||||||
KernelContext kernelContext = Kernel.getContext();
|
KernelContext kernelContext = Kernel.getContext();
|
||||||
if ( kernelContext.getParty() instanceof User ) {
|
if (kernelContext.getParty() instanceof User) {
|
||||||
user = (User) kernelContext.getParty();
|
user = (User) kernelContext.getParty();
|
||||||
} else {
|
} else {
|
||||||
// Should not happen, at this stage the user has to be logged in.
|
// Should not happen, at this stage the user has to be logged in.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityManager sm = new SecurityManager(section);
|
SecurityManager sm = new SecurityManager(section);
|
||||||
|
|
||||||
return sm.canAccess(user, SecurityManager.ADMIN_PAGES);
|
return sm.canAccess(user, SecurityManager.ADMIN_PAGES);
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ public class CMSItemSearchPage extends CMSApplicationPage {
|
||||||
addGlobalStateParam(new IntegerParameter("lastTab"));
|
addGlobalStateParam(new IntegerParameter("lastTab"));
|
||||||
addGlobalStateParam(new BooleanParameter("disableCreatePane"));
|
addGlobalStateParam(new BooleanParameter("disableCreatePane"));
|
||||||
addGlobalStateParam(new BooleanParameter("editAfterCreate"));
|
addGlobalStateParam(new BooleanParameter("editAfterCreate"));
|
||||||
|
addGlobalStateParam(new StringParameter("queryField"));
|
||||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||||
addGlobalStateParam(m_sectionId);
|
addGlobalStateParam(m_sectionId);
|
||||||
|
|
||||||
|
|
@ -136,6 +137,10 @@ public class CMSItemSearchPage extends CMSApplicationPage {
|
||||||
m_create.setEditAfterCreate((Boolean) state.getValue(new BooleanParameter("editAfterCreate")));
|
m_create.setEditAfterCreate((Boolean) state.getValue(new BooleanParameter("editAfterCreate")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.getValue(new StringParameter("queryField")) != null) {
|
||||||
|
m_flatBrowse.addQueryField((String) state.getValue(new StringParameter("queryField")));
|
||||||
|
}
|
||||||
|
|
||||||
// if (m_lastTab != m_tabbedPane.getSelectedIndex(state)) {
|
// if (m_lastTab != m_tabbedPane.getSelectedIndex(state)) {
|
||||||
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
||||||
// return;
|
// return;
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ class ItemSearchCreateItemPane extends CMSContainer
|
||||||
*/
|
*/
|
||||||
public ItemSearchCreateItemPane(final ItemSearchPage parent) {
|
public ItemSearchCreateItemPane(final ItemSearchPage parent) {
|
||||||
super();
|
super();
|
||||||
|
m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID));
|
||||||
m_folderSel = new FolderSelectionModel(m_model);
|
m_folderSel = new FolderSelectionModel(m_model);
|
||||||
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
||||||
init();
|
init();
|
||||||
|
|
@ -126,6 +127,7 @@ class ItemSearchCreateItemPane extends CMSContainer
|
||||||
*/
|
*/
|
||||||
public ItemSearchCreateItemPane(final CMSItemSearchPage parent) {
|
public ItemSearchCreateItemPane(final CMSItemSearchPage parent) {
|
||||||
super();
|
super();
|
||||||
|
m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID));
|
||||||
m_folderSel = new FolderSelectionModel(m_model);
|
m_folderSel = new FolderSelectionModel(m_model);
|
||||||
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
||||||
init();
|
init();
|
||||||
|
|
@ -145,7 +147,7 @@ class ItemSearchCreateItemPane extends CMSContainer
|
||||||
|
|
||||||
// m_newItem = new SectionNewItemForm("newItem");
|
// m_newItem = new SectionNewItemForm("newItem");
|
||||||
|
|
||||||
m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID));
|
//m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID));
|
||||||
// m_folderSel = new FolderSelectionModel(m_model);
|
// m_folderSel = new FolderSelectionModel(m_model);
|
||||||
|
|
||||||
this.setIdAttr("folder-new-item");
|
this.setIdAttr("folder-new-item");
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -54,6 +56,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
private final Table resultsTable;
|
private final Table resultsTable;
|
||||||
private final Paginator paginator;
|
private final Paginator paginator;
|
||||||
private final StringParameter queryParam;
|
private final StringParameter queryParam;
|
||||||
|
private final List<String> queryFields = new ArrayList<String>();
|
||||||
private final Submit submit;
|
private final Submit submit;
|
||||||
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance();
|
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance();
|
||||||
|
|
||||||
|
|
@ -61,14 +64,14 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
setIdAttr("itemSearchFlatBrowse");
|
setIdAttr("itemSearchFlatBrowse");
|
||||||
|
|
||||||
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
queryParam = new StringParameter(QUERY_PARAM);
|
queryParam = new StringParameter(QUERY_PARAM);
|
||||||
|
|
||||||
final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL);
|
final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||||
boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter")));
|
boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter")));
|
||||||
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
||||||
boxPanel.add(filter);
|
boxPanel.add(filter);
|
||||||
submit = new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit"));
|
submit = new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit"));
|
||||||
boxPanel.add(submit);
|
boxPanel.add(submit);
|
||||||
|
|
@ -79,8 +82,8 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
CMS_CONFIG.getItemSearchFlatBrowsePanePageSize());
|
CMS_CONFIG.getItemSearchFlatBrowsePanePageSize());
|
||||||
mainPanel.add(paginator);
|
mainPanel.add(paginator);
|
||||||
|
|
||||||
mainPanel.add(resultsTable);
|
mainPanel.add(resultsTable);
|
||||||
|
|
||||||
add(mainPanel);
|
add(mainPanel);
|
||||||
|
|
||||||
addInitListener(this);
|
addInitListener(this);
|
||||||
|
|
@ -101,7 +104,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
if ((query == null) || query.isEmpty()) {
|
if ((query == null) || query.isEmpty()) {
|
||||||
data.setParameter(QUERY_PARAM,
|
data.setParameter(QUERY_PARAM,
|
||||||
new ParameterData(queryParam, state.getValue(new StringParameter(ItemSearchPopup.QUERY))));
|
new ParameterData(queryParam, state.getValue(new StringParameter(ItemSearchPopup.QUERY))));
|
||||||
state.setValue(queryParam, data.getParameter(QUERY_PARAM).getValue());
|
state.setValue(queryParam, data.getParameter(QUERY_PARAM).getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,6 +116,10 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
state.setValue(new StringParameter(ItemSearchPopup.QUERY), data.get(QUERY_PARAM));
|
state.setValue(new StringParameter(ItemSearchPopup.QUERY), data.get(QUERY_PARAM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addQueryField(final String queryField) {
|
||||||
|
queryFields.add(queryField);
|
||||||
|
}
|
||||||
|
|
||||||
private class ResultsTable extends Table {
|
private class ResultsTable extends Table {
|
||||||
|
|
||||||
private static final String TABLE_COL_TITLE = "title";
|
private static final String TABLE_COL_TITLE = "title";
|
||||||
|
|
@ -181,15 +188,26 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
final ContentType type = new ContentType(typeId);
|
final ContentType type = new ContentType(typeId);
|
||||||
collection.set(state, session.retrieve(type.getClassName()));
|
collection.set(state, session.retrieve(type.getClassName()));
|
||||||
}
|
}
|
||||||
((DataCollection)collection.get(state)).addFilter("version = 'draft'");
|
((DataCollection) collection.get(state)).addFilter("version = 'draft'");
|
||||||
((DataCollection)collection.get(state)).addFilter("section is not null");
|
((DataCollection) collection.get(state)).addFilter("section is not null");
|
||||||
|
|
||||||
final String query = (String) state.getValue(queryParam);
|
final String query = (String) state.getValue(queryParam);
|
||||||
if ((query != null) && !query.isEmpty()) {
|
if ((query != null) && !query.isEmpty()) {
|
||||||
((DataCollection) collection.get(state)).addFilter(String.format(
|
final StringBuffer buffer = new StringBuffer(String.format(
|
||||||
"((lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%')))",
|
"((lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%'))",
|
||||||
ContentItem.NAME, query,
|
ContentItem.NAME, query,
|
||||||
ContentPage.TITLE, query));
|
ContentPage.TITLE, query));
|
||||||
|
for (String field : queryFields) {
|
||||||
|
buffer.append(String.format(" or (lower(%s) like lower('%%%s%%'))", field, query));
|
||||||
|
}
|
||||||
|
buffer.append(')');
|
||||||
|
|
||||||
|
((DataCollection) collection.get(state)).addFilter(buffer.toString());
|
||||||
|
|
||||||
|
// ((DataCollection) collection.get(state)).addFilter(String.format(
|
||||||
|
// "((lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%')))",
|
||||||
|
// ContentItem.NAME, query,
|
||||||
|
// ContentPage.TITLE, query));
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataCollection) collection.get(state)).addOrder("title asc, name asc");
|
((DataCollection) collection.get(state)).addOrder("title asc, name asc");
|
||||||
|
|
@ -306,9 +324,11 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Submit getSubmit() {
|
protected Submit getSubmit() {
|
||||||
return submit;
|
return submit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
addGlobalStateParam(new IntegerParameter("lastTab"));
|
addGlobalStateParam(new IntegerParameter("lastTab"));
|
||||||
addGlobalStateParam(new BooleanParameter("disableCreatePane"));
|
addGlobalStateParam(new BooleanParameter("disableCreatePane"));
|
||||||
addGlobalStateParam(new BooleanParameter("editAfterCreate"));
|
addGlobalStateParam(new BooleanParameter("editAfterCreate"));
|
||||||
|
addGlobalStateParam(new StringParameter("queryField"));
|
||||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||||
addGlobalStateParam(m_sectionId);
|
addGlobalStateParam(m_sectionId);
|
||||||
|
|
||||||
|
|
@ -135,6 +136,10 @@ public class ItemSearchPage extends CMSPage {
|
||||||
if (state.getValue(new BooleanParameter("editAfterCreate")) != null) {
|
if (state.getValue(new BooleanParameter("editAfterCreate")) != null) {
|
||||||
m_create.setEditAfterCreate((Boolean) state.getValue(new BooleanParameter("editAfterCreate")));
|
m_create.setEditAfterCreate((Boolean) state.getValue(new BooleanParameter("editAfterCreate")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.getValue(new StringParameter("queryField")) != null) {
|
||||||
|
m_flatBrowse.addQueryField((String) state.getValue(new StringParameter("queryField")));
|
||||||
|
}
|
||||||
|
|
||||||
// if (m_lastTab != m_tabbedPane.getSelectedIndex(state)) {
|
// if (m_lastTab != m_tabbedPane.getSelectedIndex(state)) {
|
||||||
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
private String m_searchName;
|
private String m_searchName;
|
||||||
private String m_clearName;
|
private String m_clearName;
|
||||||
private Folder m_defaultCreationFolder;
|
private Folder m_defaultCreationFolder;
|
||||||
|
private String m_queryField;
|
||||||
private ParameterModel m_model;
|
private ParameterModel m_model;
|
||||||
private ParameterModel m_searchModel;
|
private ParameterModel m_searchModel;
|
||||||
private boolean disableCreatePane = false;
|
private boolean disableCreatePane = false;
|
||||||
|
|
@ -283,6 +284,10 @@ public class ItemSearchWidget extends FormSection
|
||||||
if (m_defaultCreationFolder != null) {
|
if (m_defaultCreationFolder != null) {
|
||||||
params.setParameter("defaultCreationFolder", m_defaultCreationFolder.getOID().toString());
|
params.setParameter("defaultCreationFolder", m_defaultCreationFolder.getOID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_queryField != null) {
|
||||||
|
params.setParameter("queryField", m_queryField);
|
||||||
|
}
|
||||||
|
|
||||||
String searchURL = ContentCenterServlet.getURLStubForClass(
|
String searchURL = ContentCenterServlet.getURLStubForClass(
|
||||||
ItemSearchPage.class.getName());
|
ItemSearchPage.class.getName());
|
||||||
|
|
@ -507,6 +512,10 @@ public class ItemSearchWidget extends FormSection
|
||||||
m_defaultCreationFolder = folder;
|
m_defaultCreationFolder = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setQueryField(final String queryField) {
|
||||||
|
m_queryField = queryField;
|
||||||
|
}
|
||||||
|
|
||||||
public void publishCreatedItem(final FormData data, final ContentItem item) {
|
public void publishCreatedItem(final FormData data, final ContentItem item) {
|
||||||
final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
|
final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
|
||||||
final Boolean publish = Boolean.valueOf(publishStr);
|
final Boolean publish = Boolean.valueOf(publishStr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue