ItemSearch Widget funktionierte aufgrund der Änderungen in den Revision 2046 bis 2053 nicht mehr. Problem ist jetzt behoben.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2059 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-01-31 12:49:23 +00:00
parent a6fda4180b
commit 5a86ae68e6
2 changed files with 63 additions and 74 deletions

View File

@ -27,7 +27,6 @@ import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Application domain class for the CMS module user entry page (content-center) * Application domain class for the CMS module user entry page (content-center)
* *
@ -38,11 +37,9 @@ public class ContentCenter extends Application {
/** A logger instance, primarily to assist debugging . */ /** A logger instance, primarily to assist debugging . */
private static final Logger s_log = Logger.getLogger(ContentSection.class); private static final Logger s_log = Logger.getLogger(ContentSection.class);
// pdl stuff (constants) // pdl stuff (constants)
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.ContentCenter"; "com.arsdigita.cms.ContentCenter";
// general constants // general constants
public static final String PACKAGE_KEY = "content-center"; public static final String PACKAGE_KEY = "content-center";
public static final String INSTANCE_NAME = "Content Center"; public static final String INSTANCE_NAME = "Content Center";
@ -66,7 +63,7 @@ public class ContentCenter extends Application {
* @param id The <code>id</code> for the retrieved * @param id The <code>id</code> for the retrieved
* <code>DataObject</code>. * <code>DataObject</code>.
*/ */
public ContentCenter(BigDecimal key) throws DataObjectNotFoundException { public ContentCenter(BigDecimal key) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, key)); this(new OID(BASE_DATA_OBJECT_TYPE, key));
} }
@ -95,15 +92,13 @@ public class ContentCenter extends Application {
Application parent) { Application parent) {
ContentCenter app = ContentCenter app =
(ContentCenter) Application.createApplication (ContentCenter) Application.createApplication(BASE_DATA_OBJECT_TYPE, urlName, title, parent);
(BASE_DATA_OBJECT_TYPE, urlName, title, parent);
app.save(); app.save();
return app; return app;
} }
/** /**
* Fetch the URL of the CMS ContentCenter. * Fetch the URL of the CMS ContentCenter.
* *
@ -115,20 +110,20 @@ public class ContentCenter extends Application {
*/ */
public static String getURL() { public static String getURL() {
// quick 'nd dirty! // quick 'nd dirty!
return "/"+PACKAGE_KEY; return "/" + PACKAGE_KEY + "/";
// Doesn't work as expected // Doesn't work as expected
// see c.ad.ui.login.UserInfo for a working (hopefully) example. // see c.ad.ui.login.UserInfo for a working (hopefully) example.
// ApplicationCollection apps = Application // ApplicationCollection apps = Application
// .retrieveAllApplications(BASE_DATA_OBJECT_TYPE); // .retrieveAllApplications(BASE_DATA_OBJECT_TYPE);
// if (apps.next()) { // if (apps.next()) {
// // Note: Currently only one Content Center application is allowed! // // Note: Currently only one Content Center application is allowed!
// s_log.error("Instance of ContentCenter found!"); // s_log.error("Instance of ContentCenter found!");
// return apps.getPrimaryURL(); // return apps.getPrimaryURL();
// } else { // } else {
// s_log.error("No instance of ContentCenter could be found!"); // s_log.error("No instance of ContentCenter could be found!");
// return null; // return null;
// } // }
} }
/** /**

View File

@ -16,12 +16,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.cms; package com.arsdigita.cms;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.dispatcher.CMSPage;
import com.arsdigita.cms.dispatcher.SimpleCache; import com.arsdigita.cms.dispatcher.SimpleCache;
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;
import com.arsdigita.dispatcher.AccessDeniedException; import com.arsdigita.dispatcher.AccessDeniedException;
@ -60,38 +60,28 @@ public class ContentCenterServlet extends BaseApplicationServlet {
/** Logger instance for debugging */ /** Logger instance for debugging */
private static Logger s_log = Logger private static Logger s_log = Logger
.getLogger(ContentCenterServlet.class.getName()); .getLogger(ContentCenterServlet.class.getName());
// DEPRECATED STUFF follows. Should be no longer used, deleted in future! // DEPRECATED STUFF follows. Should be no longer used, deleted in future!
/** The path of the file that maps resources. */ /** The path of the file that maps resources. */
public final static String DEFAULT_MAP_FILE = public final static String DEFAULT_MAP_FILE =
"/WEB-INF/resources/content-center-old-map.xml"; "/WEB-INF/resources/content-center-old-map.xml";
/** Mapping between a relative URL and the class name of a ResourceHandler.*/ /** Mapping between a relative URL and the class name of a ResourceHandler.*/
// private static HashMap s_pageClasses = ContentCenterSetup.getURLToClassMap(); // private static HashMap s_pageClasses = ContentCenterSetup.getURLToClassMap();
private static HashMap s_pageURLs = ContentCenterSetup.getClassToURLMap(); private static HashMap s_pageURLs = ContentCenterSetup.getClassToURLMap();
/** Instantiated ResourceHandlers cache. This allows for lazy loading. */ /** Instantiated ResourceHandlers cache. This allows for lazy loading. */
private static SimpleCache s_pages = new SimpleCache(); private static SimpleCache s_pages = new SimpleCache();
private ArrayList m_trailingSlashList = new ArrayList(); private ArrayList m_trailingSlashList = new ArrayList();
// 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 to selects a page to display */ * request url) the doService method to selects a page to display */
private final Map m_pages = new HashMap(); private final Map m_pages = new HashMap();
// 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.
/** Path to directory containg ccm-cms template files */ /** Path to directory containg ccm-cms template files */
private String m_templatePath; private String m_templatePath;
/** Resolvers to find templates (JSP) and other stuff stored in file system.*/ /** Resolvers to find templates (JSP) and other stuff stored in file system.*/
private ApplicationFileResolver m_resolver; private ApplicationFileResolver m_resolver;
/** /**
* Use parent's class initialization extension point to perform additional * Use parent's class initialization extension point to perform additional
* initialisation tasks. * initialisation tasks.
@ -110,9 +100,10 @@ public class ContentCenterServlet extends BaseApplicationServlet {
// 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 ~/ds addPage("/", new MainPage()); // index page at address ~/ds
// addPage("/index/", new MainPage()); // addPage("/index/", new MainPage());
// addPage("/ItemSearchPage/", new CCItemSearchPage()); //addPage("/ItemSearchPage/", new ItemSearchPage());
// addPage("/SearchResultRedirector/", new CCSearchResultRedirector()); addPage("/item-search", new ItemSearchPage());
// addPage("/SearchResultRedirector/", new CCSearchResultRedirector());
// 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
@ -123,14 +114,13 @@ public class ContentCenterServlet extends BaseApplicationServlet {
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("/"),
"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 '/'");
/** Set TemplateResolver class */ /** Set TemplateResolver class */
m_resolver = Web.getConfig().getApplicationFileResolver(); m_resolver = Web.getConfig().getApplicationFileResolver();
} }
/** /**
* Implements the (abstract) doService method of BaseApplicationServlet to * Implements the (abstract) doService method of BaseApplicationServlet to
* create the ContentCenter page. * create the ContentCenter page.
@ -138,10 +128,10 @@ public class ContentCenterServlet 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 {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.info("starting doService method"); s_log.info("starting doService method");
@ -170,13 +160,13 @@ public class ContentCenterServlet extends BaseApplicationServlet {
sections.close(); sections.close();
if (!hasAccess) { // user has no access privilege if (!hasAccess) { // user has no access privilege
throw new AccessDeniedException( throw new AccessDeniedException(
"User is not entitled to access any content section"); "User is not entitled to access any content section");
// throw new LoginSignal(sreq); // send to login page // throw new LoginSignal(sreq); // send to login page
} }
RequestContext ctx = DispatcherHelper.getRequestContext(); RequestContext ctx = DispatcherHelper.getRequestContext();
String url = ctx.getRemainingURLPart(); // here SiteNodeRequestContext String url = ctx.getRemainingURLPart(); // here SiteNodeRequestContext
String originalUrl = ctx.getOriginalURL(); String originalUrl = ctx.getOriginalURL();
@ -191,30 +181,38 @@ public class ContentCenterServlet extends BaseApplicationServlet {
* trailing '/' if a "virtual" page, i.e. not a real jsp, but * trailing '/' if a "virtual" page, i.e. not a real jsp, but
* result of a servlet mapping. But Application requires url * result of a servlet mapping. But Application requires url
* NOT to end with a trailing '/' for legacy free applications. */ * NOT to end with a trailing '/' for legacy free applications. */
pathInfo = pathInfo.substring(0, pathInfo.length()-1); pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
} }
// An empty remaining URL or a URL which doesn't end in trailing slash: // An empty remaining URL or a URL which doesn't end in trailing slash:
// 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);
if ( page != null ) { if (page != null) {
// Check user access. // Check user access.
checkUserAccess(sreq, sresp); checkUserAccess(sreq, sresp);
// Serve the page. //Lock the page
final Document doc = page.buildDocument(sreq, sresp);
PresentationManager pm = Templating.getPresentationManager(); if (page instanceof CMSPage) {
pm.servePage(doc, sreq, sresp); final CMSPage cmsPage = (CMSPage) page;
// page.init(); cmsPage.init();
// page.dispatch(sreq, sresp, ctx); cmsPage.dispatch(sreq, sresp, ctx);
} else {
page.lock();
// Serve the page.
final Document doc = page.buildDocument(sreq, sresp);
PresentationManager pm = Templating.getPresentationManager();
pm.servePage(doc, sreq, sresp);
}
} else { } else {
// Fall back on the JSP application dispatcher. // Fall back on the JSP application dispatcher.
@ -223,7 +221,7 @@ public class ContentCenterServlet extends BaseApplicationServlet {
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("NO page registered to serve the requst url."); s_log.info("NO page registered to serve the requst url.");
} }
RequestDispatcher rd = m_resolver.resolve(m_templatePath, RequestDispatcher rd = m_resolver.resolve(m_templatePath,
sreq, sresp, app); sreq, sresp, app);
if (rd != null) { if (rd != null) {
@ -231,21 +229,20 @@ public class ContentCenterServlet 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, requestUri + " not found on this server."); sresp.sendError(404, requestUri + " not found on this server.");
} }
} }
DeveloperSupport.endStage("ContentCenterServlet.doService"); DeveloperSupport.endStage("ContentCenterServlet.doService");
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.info("doService method completed"); s_log.info("doService method completed");
} }
} // END doService() } // END doService()
/** /**
* Adds one pair of Url - Page to the internal hash map, used as a cache. * Adds one pair of Url - Page to the internal hash map, used as a cache.
* *
@ -264,7 +261,6 @@ public class ContentCenterServlet extends BaseApplicationServlet {
m_pages.put(pathInfo, page); m_pages.put(pathInfo, page);
} }
/** /**
* Service Method returns the URL stub for the class name, * Service Method returns the URL stub for the class name,
* can return null if not mapped * can return null if not mapped
@ -274,11 +270,10 @@ public class ContentCenterServlet extends BaseApplicationServlet {
s_log.debug("Getting URL Stub for : " + classname); s_log.debug("Getting URL Stub for : " + classname);
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;
} }
@ -293,7 +288,6 @@ public class ContentCenterServlet extends BaseApplicationServlet {
s_pages.remove(url); s_pages.remove(url);
} }
/** /**
* Verify that the user is logged in and is able to view the * Verify that the user is logged in and is able to view the
* page. Subclasses can override this method if they need to, but * page. Subclasses can override this method if they need to, but
@ -305,10 +299,10 @@ public class ContentCenterServlet extends BaseApplicationServlet {
**/ **/
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 {
if (!Web.getUserContext().isLoggedIn()) { if (!Web.getUserContext().isLoggedIn()) {
throw new LoginSignal(request); throw new LoginSignal(request);
@ -324,11 +318,11 @@ public class ContentCenterServlet extends BaseApplicationServlet {
**/ **/
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
+"="+UserContext.encodeReturnURL(req); + "=" + UserContext.encodeReturnURL(req);
try { try {
LoginHelper.sendRedirect(req, resp, url); LoginHelper.sendRedirect(req, resp, url);
} catch (IOException e) { } catch (IOException e) {