Verschiedene kleinere Formatierungen / Kommentierungen.

git-svn-id: https://svn.libreccm.org/ccm/trunk@662 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2010-12-26 00:37:19 +00:00
parent 932060e3d2
commit fbc7372b64
10 changed files with 151 additions and 80 deletions

View File

@ -18,8 +18,6 @@
*/
package com.arsdigita.cms.dispatcher;
import org.apache.log4j.Logger;
import com.arsdigita.categorization.Category;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem;
@ -39,10 +37,28 @@ import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import com.arsdigita.web.Web;
import org.apache.log4j.Logger;
/**
* Implementation of {@link com.arsdigita.kernel.URLFinder} for content types,
* necessary for ccm dispatcher to find a concrete content item for an url
* provided by a client request.
*
* Specifically it is a helper class for {@link com.arsdigita.web.OIDRedirectServlet}
* to map an OID to an URL.
*
*/
public class ItemURLFinder implements URLFinder {
private static final Logger s_log = Logger.getLogger(ItemURLFinder.class);
/**
*
* @param oid
* @param context publication status ['live'|'draft']
* @return
* @throws NoValidURLException
*/
public String find(OID oid, String context) throws NoValidURLException {
if (s_log.isDebugEnabled()) {
s_log.debug("Locating " + oid + " in " + context);
@ -78,6 +94,12 @@ public class ItemURLFinder implements URLFinder {
return find(item, context);
}
/**
*
* @param oid
* @return
* @throws NoValidURLException
*/
public String find(OID oid) throws NoValidURLException {
if (s_log.isDebugEnabled()) {
s_log.debug("Locating " + oid);
@ -98,14 +120,18 @@ public class ItemURLFinder implements URLFinder {
s_log.debug("Item version is " + item.getVersion());
}
// Revert to the behavior before change# 41315. Clients relied on the behavior that
// links with no context defaulted to the live version (if one existed). Changing
// that behavior broke a lot of links in static content that couldn't easily be updated.
// This change restores the old behavior. We don't get a regression of bz 116226
// (which bz 41315 was intended to fix) because the CMS search.xsl has been updated to
// append "&context=draft" to the search results. The CMS DHTML editor has also been
// updated to append generated links with "&context=live". If at some point in the future
// all unqualified links have been removed, then this fix could be removed as well.
// Revert to the behavior before change #41315.
// Clients relied on the behavior that links with no context
// defaulted to the live version (if one existed). Changing
// that behavior broke a lot of links in static content that couldn't
// easily be updated.
// This change restores the old behavior. We don't get a regression of
// bz 116226 (which bz 41315 was intended to fix) because the CMS
// search.xsl has been updated to append "&context=draft" to the search
// results. The CMS DHTML editor has also been updated to append
// generated links with "&context=live". If at some point in the future
// all unqualified links have been removed, then this fix could be
// removed as well.
if (item.isLive() && !item.isLiveVersion()) {
item = item.getLiveVersion();
if (s_log.isDebugEnabled()) {
@ -116,8 +142,16 @@ public class ItemURLFinder implements URLFinder {
return find(item, item.getVersion());
}
private String find(ContentItem item,
String context) throws NoValidURLException {
/**
*
* @param item
* @param context publication status ['live'|'draft']
* @return
* @throws NoValidURLException
*/
private String find(ContentItem item, String context)
throws NoValidURLException {
ContentSection section = item.getContentSection();
ItemResolver resolver = section.getItemResolver();
@ -127,7 +161,7 @@ public class ItemURLFinder implements URLFinder {
// always send to the admin screen (that's for results of the admin
// search)
if (!ContentItem.DRAFT.equals(context)) {
if (!ContentItem.DRAFT.equals(context)) { // LIVE context
ACSObject parent = item.getParent();
ContentBundle bundle = null;
if (parent instanceof ContentBundle) {
@ -137,6 +171,10 @@ public class ItemURLFinder implements URLFinder {
DataAssociationCursor categories =
((DataAssociation) DomainServiceInterfaceExposer.
get(bundle, Category.CATEGORIES)).cursor();
// XXX pb (2010.12.15) ToDO
// solution is currently not subsite aware!
// provides an index url even if the category tree is not part
// of subsite (which results in a resource not found exception)
categories.addEqualsFilter("link." + Category.IS_INDEX, Boolean.TRUE);
if (categories.next()) {
Category indexCat = (Category) DomainObjectFactory.
@ -144,7 +182,8 @@ public class ItemURLFinder implements URLFinder {
categories.close();
try {
if (s_log.isDebugEnabled()) {
s_log.debug(item + " is a Category index item. Resolving URL for " + indexCat);
s_log.debug(item + " is a Category index item. " +
"Resolving URL for " + indexCat);
}
return URLService.locate(indexCat.getOID(), context);
} catch (URLFinderNotFoundException ufnfe) {
@ -165,12 +204,14 @@ public class ItemURLFinder implements URLFinder {
} else { // DRAFT context
// public users get 404 when item gets unpublished
// if com.arsdigita.cms.unpublished_not_found=true
if (ContentSection.getConfig().isUnpublishedNotFound() && !Web.getUserContext().isLoggedIn()) {
if (ContentSection.getConfig().isUnpublishedNotFound()
&& !Web.getUserContext().isLoggedIn()) {
throw new NoValidURLException("user must be logged-in to get draft");
} else {
// force the switch to draft version at this point
// otherwise resolver below breaks with:
// java.lang.IllegalStateException: Generating draft url: item must be draft version
// java.lang.IllegalStateException: Generating draft url:
// item must be draft version
if (!item.isDraftVersion()) {
item = item.getDraftVersion();
s_log.debug("switching to draft version");

View File

@ -21,13 +21,16 @@ package com.arsdigita.bebop.parameters;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.util.Assert;
import com.arsdigita.globalization.Globalization;
import com.arsdigita.util.Assert;
import com.arsdigita.util.Lockable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**

View File

@ -31,7 +31,6 @@ import javax.servlet.http.HttpUtils;
import java.net.URLEncoder;
/**
*
* A URLFinder that can be registered for most object types. The
* GenericURLFinder is constructed with a specified URL pattern such
* as <code>one-ticket?ticket_id=:id</code>. For a given OID, the
@ -102,12 +101,10 @@ import java.net.URLEncoder;
* <code>PackageInstance</code>.
*
* @author Oumi Mehrotra
*
* @version $Id: GenericURLFinder.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class GenericURLFinder implements URLFinder {
public static final String versionId = "$Id: GenericURLFinder.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
private String m_base;
private Map m_params;

View File

@ -35,12 +35,9 @@ import org.apache.log4j.Logger;
* Initializes the Kernel and bootstraps the rest of the system.
*
* @version $Revision: #39 $ $Date: 2004/08/16 $
* @version $Id: Initializer.java 1169 2006-06-14 13:08:25Z fabrice $
*/
public class Initializer extends BaseInitializer {
public static final String versionId =
"$Id: Initializer.java 1169 2006-06-14 13:08:25Z fabrice $" +
"$Author: fabrice $" +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(Initializer.class);

View File

@ -37,11 +37,10 @@ import com.arsdigita.persistence.OID;
* should write a new URLFinder that uses application-specific logic.
*
* @author Oumi Mehrotra
**/
* @version $Id: URLFinder.java 287 2005-02-22 00:29:02Z sskracic $
*/
public interface URLFinder {
public static final String versionId = "$Id: URLFinder.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
/**
* Returns a URL path to a page that displays the object identified by
* the given OID. The URL path is relative to the server root.

View File

@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
/**
* Supports generically locating a domain object on the site.
*
* The URLService can produce the path (relative to the root URL) to a page
* that displays the domain object identified by a given OID.
* <P>
@ -82,11 +83,12 @@ public class URLService {
* @throws NoValidURLException when the
* URLFinder registered for the given <i>oid</i>'s object type is unable
* to produce a valid non-null URL.
**/
*/
public static String locate(OID oid)
throws URLFinderNotFoundException, NoValidURLException {
return locate(oid,null);
}
/**
* Returns a URL path to a page that displays the object identified by
* the given <i>oid</i>. The URL path is relative to the server root.
@ -100,10 +102,10 @@ public class URLService {
* @throws NoValidURLException when the
* URLFinder registered for the given <i>oid</i>'s object type is unable
* to produce a valid non-null URL.
**/
*/
public static String locate(OID oid, String context)
throws URLFinderNotFoundException, NoValidURLException
{
throws URLFinderNotFoundException, NoValidURLException{
URLFinder f = getFinder(oid.getObjectType());
if (f==null) {
throw new URLFinderNotFoundException("There is no URLFinder " +
@ -112,6 +114,7 @@ public class URLService {
oid.getObjectType().getQualifiedName());
}
// Determine the URL using the objects URLFinder
String url = (context == null) ? f.find(oid) : f.find(oid,context);
if (url == null) {
@ -149,7 +152,7 @@ public class URLService {
*
* @return the previous finder that was
* registered with this service for this object type.
**/
*/
public synchronized static URLFinder registerFinder(ObjectType objectType,
URLFinder finder) {
return (URLFinder) s_finders.put(objectType, finder);

View File

@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletRequest;
import com.arsdigita.persistence.OID;
import com.arsdigita.bebop.parameters.ParameterModel;
/*
/**
* A {@link com.arsdigita.bebop.parameters.ParameterModel} for an
* {@link com.arsdigita.persistence.OID}
*
@ -31,6 +31,7 @@ import com.arsdigita.bebop.parameters.ParameterModel;
* @since Iteration 1
*/
public class OIDParameter extends ParameterModel {
public OIDParameter(String name) {
super(name);
}

View File

@ -18,22 +18,39 @@
*/
package com.arsdigita.web;
import com.arsdigita.kernel.URLService;
import com.arsdigita.kernel.NoValidURLException;
import com.arsdigita.kernel.URLFinderNotFoundException;
import com.arsdigita.persistence.OID;
import com.arsdigita.toolbox.ui.OIDParameter;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.arsdigita.kernel.URLService;
import com.arsdigita.kernel.NoValidURLException;
import com.arsdigita.kernel.URLFinderNotFoundException;
import com.arsdigita.persistence.OID;
import com.arsdigita.toolbox.ui.OIDParameter;
import java.util.Map;
import org.apache.log4j.Logger;
/**
* Servlet to redirect an OID based request to a complete url in an application's
* url tree and is one of the basic servlets required by any ccm-core application
* instance to work correctly.
*
* It has to be declared in an application web.xml, typically:
* <servlet>
* <servlet-name>oid-redirect</servlet-name>
* <servlet-class>com.arsdigita.web.OIDRedirectServlet</servlet-class>
* </servlet>
* ....
* ....
* <servlet-mapping>
* <servlet-name>oid-redirect</servlet-name>
* <url-pattern>/redirect/*</url-pattern>
* </servlet-mapping>
*
*/
public class OIDRedirectServlet extends BaseServlet {
private static final Logger s_log =
@ -48,6 +65,8 @@ public class OIDRedirectServlet extends BaseServlet {
OID oid = null;
try {
// extract parameter named OID_PARAM (="oid") from sreq object
// searches for something like oid=Article-id-167013
oid = (OID) param.transformValue(sreq);
} catch (Exception e) {
// invalid OID value, return 400 Bad Request
@ -65,6 +84,7 @@ public class OIDRedirectServlet extends BaseServlet {
sresp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
if (s_log.isDebugEnabled()) {
s_log.debug("Tried to read non encoded OID, result: " + oid);
}
@ -82,6 +102,7 @@ public class OIDRedirectServlet extends BaseServlet {
String context = sreq.getParameter("context");
String url = URLService.locate(oid, context);
/* Addition by JensP: */
Map<?, ?> parameters = sreq.getParameterMap();
StringBuilder urlParams = new StringBuilder();
for (Map.Entry<?, ?> entry : parameters.entrySet()) {
@ -98,20 +119,21 @@ public class OIDRedirectServlet extends BaseServlet {
}
}
}
url = url.concat(urlParams.toString());
/* JensP END */
if (s_log.isDebugEnabled()) {
s_log.debug("Redirecting oid " + oid + " to " + url);
}
throw new RedirectSignal(url, false);
} catch (URLFinderNotFoundException ex) {
if (s_log.isDebugEnabled()) {
s_log.debug("No URL finder for oid " + oid);
}
sresp.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
} catch (NoValidURLException ex) {
if (s_log.isDebugEnabled()) {
s_log.debug("No URL for oid " + oid);

View File

@ -4,19 +4,20 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - basic web.xml for ccm-core and basic functions. If
additional modules provide specific web.xml snippets they must be integrated before CCM is ready to work. Alternatively a
complete web.xml file from an installation bundle may be used. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-->
<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
basic web.xml for ccm-core and basic functions. If
additional modules provide specific web.xml snippets they must be
integrated before CCM is ready to work. Alternatively a
complete web.xml file from an installation bundle may be used.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<display-name>CCM</display-name>
<description>Content and Collaboration Management</description>
<!--
path and filename of the log4j user accessible config file WEB-INF/conf/log4j.properties is the built-in default value
path and filename of the log4j user accessible config file
WEB-INF/conf/log4j.properties is the built-in default value
-->
<context-param>
<param-name>log4j-conf-file</param-name>
@ -24,20 +25,18 @@
</context-param>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Context Listener required and used to
initialize the runtime environment before any other task is performed or any servlet initialized. - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Context Listener required and used to initialize the runtime environment
before any other task is performed or any servlet initialized.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<listener>
<listener-class>com.arsdigita.web.CCMApplicationContextListener</listener-class>
</listener>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BASE SERVLET DECLARATIONS SECTION basically
requirred by ccm-core - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BASE SERVLET DECLARATIONS SECTION
basically requirred by ANY ccm-core application to work correctly!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<servlet>
<servlet-name>reg</servlet-name>
<servlet-class>com.arsdigita.web.ContextRegistrationServlet</servlet-class>
@ -95,10 +94,11 @@
</servlet>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ADDITIONAL SERVLET DECLARATIONS SECTION
basically requirred by ccm-cms - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ADDITIONAL SERVLET DECLARATIONS SECTION
basically requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet>
<servlet-name>content-section</servlet-name>
<servlet-class>com.arsdigita.cms.ContentSectionServlet</servlet-class>
@ -140,8 +140,10 @@
</servlet>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BASE SERVLET MAPPINGS SECTION basically
requirred by ccm-core - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BASE SERVLET MAPPINGS SECTION basically
requirred by ccm-core
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet-mapping>
@ -185,8 +187,10 @@
</servlet-mapping>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ADDITIONAL SERVLET MAPPINGS SECTION basically
requirred by ccm-cms - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ADDITIONAL SERVLET MAPPINGS SECTION basically
requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet-mapping>
@ -220,8 +224,9 @@
</servlet-mapping>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR PAGES - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ERROR PAGES
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<error-page>
@ -260,8 +265,9 @@
</error-page>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TAG LIBS - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TAG LIBS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<jsp-config>

View File

@ -22,14 +22,16 @@ import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.TemplateManager;
import javax.servlet.http.HttpServletRequest;
import com.arsdigita.cms.dispatcher.DefaultTemplateResolver;
import com.arsdigita.util.ResourceManager;
import java.io.File;
import com.arsdigita.london.subsite.Site;
import com.arsdigita.london.subsite.Subsite;
import java.io.File;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;