CCM NG: Several things, mostly importantly removal of all usages of legacy log4j 1.2 API. Dependency for artifact log4j-1.2-api has been removed.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4551 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-02-04 16:37:18 +00:00
parent 7b1d0fd625
commit 21b149905d
161 changed files with 2327 additions and 2291 deletions

View File

@ -55,6 +55,16 @@
</dependency> </dependency>
<!-- CCM Modules end --> <!-- CCM Modules end -->
<!-- Dependencies for log4j 2 including adapter for the log4j 1.2 API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -9,6 +9,20 @@
<Root level="warn"> <Root level="warn">
<AppenderRef ref="Console"/> <AppenderRef ref="Console"/>
</Root> </Root>
<Logger name="org.hibernate"
level="info">
</Logger>
<Logger name="org.hibernate.SQL"
level="debug">
</Logger>
<Logger name="org.hibernate.type"
level="trace">
</Logger>
<Logger name="org.hibernate.type.descriptor.sql"
level="trace">
</Logger>
<Logger name="com.arsdigita.ui.admin.AdminServlet" <Logger name="com.arsdigita.ui.admin.AdminServlet"
level="debug"> level="debug">
</Logger> </Logger>
@ -52,10 +66,10 @@
level="debug"> level="debug">
</Logger> </Logger>
<Logger name="org.librecms.contentsection.ContentSectionServlet" <Logger name="org.librecms.contentsection.ContentSectionServlet"
level="debug"> level="debug">
</Logger> </Logger>
<Logger name="com.arsdigita.web.DefaultApplicationFileResolver" <Logger name="com.arsdigita.web.DefaultApplicationFileResolver"
level="debug"> level="debug">
</Logger> </Logger>
</Loggers> </Loggers>
</Configuration> </Configuration>

View File

@ -28,13 +28,16 @@
<properties> <properties>
<!-- Properties for Hibernate --> <!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="validate"/> <property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.connection.autocommit" value="false" /> <property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.id.new_generator_mappings" value="true"/> <property name="hibernate.id.new_generator_mappings" value="true" />
<property name="wildfly.jpa.hibernate.search.module" <property name="wildfly.jpa.hibernate.search.module"
value="org.hibernate.search.orm:main"/> value="org.hibernate.search.orm:main" />
<!--<property name="hibernate.show_sql" value="true" />
<property name="format_sql" value="true" />
<property name="use_sql_comments" value="true" />-->
<!-- <!--
Properties for Hibernate Envers Properties for Hibernate Envers
We are using the ValidityAuditStrategy here because it is faster We are using the ValidityAuditStrategy here because it is faster

View File

@ -18,9 +18,6 @@
*/ */
package com.arsdigita.cms; package com.arsdigita.cms;
import org.apache.log4j.Logger;
/** /**
* <p> * <p>
* A central location for commonly used CMS services and their accessories.</p> * A central location for commonly used CMS services and their accessories.</p>
@ -31,14 +28,9 @@ import org.apache.log4j.Logger;
* *
* @author Daniel Berrange * @author Daniel Berrange
* @see com.arsdigita.kernel.Kernel * @see com.arsdigita.kernel.Kernel
* @version $Id$
*/ */
public abstract class CMS { public abstract class CMS {
/**
* Private Logger instance for debugging purpose.
*/
private static final Logger s_log = Logger.getLogger(CMS.class);
/** /**
* The CMS XML namespace. * The CMS XML namespace.

View File

@ -20,7 +20,8 @@ package com.arsdigita.cms;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
@ -43,11 +44,10 @@ import org.librecms.contentsection.ContentSection;
* @see com.arsdigita.cms.CMS * @see com.arsdigita.cms.CMS
* *
* @author Daniel Berrange * @author Daniel Berrange
* @version $Id$
*/ */
public final class CMSContext { public final class CMSContext {
private static final Logger s_log = Logger.getLogger(CMSContext.class); private static final Logger LOGGER = LogManager.getLogger(CMSContext.class);
private ContentSection m_section = null; private ContentSection m_section = null;
private ContentItem m_item = null; private ContentItem m_item = null;
@ -102,8 +102,8 @@ public final class CMSContext {
public final void setContentSection(final ContentSection section) { public final void setContentSection(final ContentSection section) {
m_section = section; m_section = section;
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Content section set to " + section); LOGGER.debug("Content section set to " + section);
} }
} }
@ -123,8 +123,8 @@ public final class CMSContext {
public final ContentItem getContentItem() { public final ContentItem getContentItem() {
// removing this which is necessarily true in ContentList // removing this which is necessarily true in ContentList
//Assert.exists(m_item, "item"); //Assert.exists(m_item, "item");
if (s_log.isDebugEnabled() && m_item == null) { if (LOGGER.isDebugEnabled() && m_item == null) {
s_log.debug("Content item is null"); LOGGER.debug("Content item is null");
} }
return m_item; return m_item;
} }
@ -136,8 +136,8 @@ public final class CMSContext {
public final void setContentItem(final ContentItem item) { public final void setContentItem(final ContentItem item) {
m_item = item; m_item = item;
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Content item set to " + item); LOGGER.debug("Content item set to " + item);
} }
} }
@ -166,8 +166,8 @@ public final class CMSContext {
public final void setSecurityManager(final SecurityManager security) { public final void setSecurityManager(final SecurityManager security) {
m_security = security; m_security = security;
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Security manager set to " + security); LOGGER.debug("Security manager set to " + security);
} }
} }
} }

View File

@ -28,6 +28,9 @@ import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.LoginSignal; import com.arsdigita.web.LoginSignal;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -37,7 +40,6 @@ 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.shiro.authz.AuthorizationException; import org.apache.shiro.authz.AuthorizationException;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
@ -119,7 +121,7 @@ import org.librecms.dispatcher.ItemResolver;
*/ */
public class CMSDispatcher implements Dispatcher, ChainedDispatcher { public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
private static Logger s_log = Logger.getLogger(CMSDispatcher.class); private static Logger LOGGER = LogManager.getLogger(CMSDispatcher.class);
public static final String CONTENT_SECTION public static final String CONTENT_SECTION
= "com.arsdigita.cms.dispatcher.section"; = "com.arsdigita.cms.dispatcher.section";
@ -170,8 +172,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
HttpServletResponse response, HttpServletResponse response,
RequestContext actx) RequestContext actx)
throws IOException, ServletException { throws IOException, ServletException {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Dispatching request for " + new URL(request) LOGGER.debug("Dispatching request for " + new URL(request)
.toDebugString()); .toDebugString());
} }
@ -182,10 +184,10 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
processedUrl = processedUrl.substring(webappURLContext.length()); processedUrl = processedUrl.substring(webappURLContext.length());
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Determined the path to the current site node; it " LOGGER.debug("Determined the path to the current site node; it "
+ "is '" + processedUrl + "' according to the " + "is '" + processedUrl + "' according to the "
+ "request context"); + "request context");
} }
// This is the path within the site node. // This is the path within the site node.
@ -200,9 +202,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
remainingUrl = "index"; remainingUrl = "index";
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Determined the path after the current site node; " LOGGER.debug("Determined the path after the current site node; "
+ "it is '" + remainingUrl + "'"); + "it is '" + remainingUrl + "'");
} }
// Fetch the current content section. // Fetch the current content section.
@ -214,8 +216,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
} }
request.setAttribute(CONTENT_SECTION, section); request.setAttribute(CONTENT_SECTION, section);
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Found content section '" + section + "'"); LOGGER.debug("Found content section '" + section + "'");
} }
// Check user access to this page and deny access if necessary. // Check user access to this page and deny access if necessary.
@ -224,12 +226,12 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
// Look for a site-node-specific asset (if any). // Look for a site-node-specific asset (if any).
// KG: This hack will be replaced by a ChainedDispatcher // KG: This hack will be replaced by a ChainedDispatcher
try { try {
s_log.debug("Looking for a site node asset"); LOGGER.debug("Looking for a site node asset");
String siteNodeAssetURL = getSiteNodeAsset(request, actx); String siteNodeAssetURL = getSiteNodeAsset(request, actx);
if (siteNodeAssetURL != null) { if (siteNodeAssetURL != null) {
s_log.debug("Site node asset found at '" + siteNodeAssetURL LOGGER.debug("Site node asset found at '" + siteNodeAssetURL
+ "'"); + "'");
DispatcherHelper.cacheDisable(response); DispatcherHelper.cacheDisable(response);
DispatcherHelper.setRequestContext(request, actx); DispatcherHelper.setRequestContext(request, actx);
@ -238,8 +240,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
return; return;
} }
s_log.debug("No site node asset found; proceeding with normal " LOGGER.debug("No site node asset found; proceeding with normal "
+ "dispatching"); + "dispatching");
} catch (RedirectException e) { } catch (RedirectException e) {
throw new ServletException(e); throw new ServletException(e);
} }
@ -247,26 +249,26 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
// Fetch the requested resource (if any). // Fetch the requested resource (if any).
ResourceHandler resource = getResource(section, remainingUrl); ResourceHandler resource = getResource(section, remainingUrl);
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Got a resource '" + resource + "'"); LOGGER.debug("Got a resource '" + resource + "'");
} }
if (resource != null) { if (resource != null) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Found resource '" + remainingUrl + "'; " LOGGER.debug("Found resource '" + remainingUrl + "'; "
+ "dispatching to it"); + "dispatching to it");
} }
s_log.info("resource dispatch for " + remainingUrl); LOGGER.info("resource dispatch for " + remainingUrl);
// Found resource, now serve it. // Found resource, now serve it.
// NB, ResouceHandler implementations should take care of caching options // NB, ResouceHandler implementations should take care of caching options
resource.dispatch(request, response, actx); resource.dispatch(request, response, actx);
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("No resource found at '" + remainingUrl + "'; " LOGGER.debug("No resource found at '" + remainingUrl + "'; "
+ "searching for a previewable content item at " + "searching for a previewable content item at "
+ "this path"); + "this path");
} }
// If the remaining URL starts with "preview/", then try and // If the remaining URL starts with "preview/", then try and
@ -301,16 +303,16 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
} }
if (item != null) { if (item != null) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Found item " + item + "; serving it"); LOGGER.debug("Found item " + item + "; serving it");
} }
DispatcherHelper.cacheDisable(response); DispatcherHelper.cacheDisable(response);
preview(request, response, actx); preview(request, response, actx);
} else { } else {
s_log.debug("No item to preview found; falling back to " LOGGER.debug("No item to preview found; falling back to "
+ "JSP dispatcher to look for some concrete " + "JSP dispatcher to look for some concrete "
+ "resource in the file system"); + "resource in the file system");
// If no resource was found, look for a JSP page. // If no resource was found, look for a JSP page.
JSPApplicationDispatcher jsp = JSPApplicationDispatcher JSPApplicationDispatcher jsp = JSPApplicationDispatcher
@ -338,8 +340,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
} }
if (url.equals(ADMIN_URL)) { if (url.equals(ADMIN_URL)) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Resolving admin URL '" + url + "'"); LOGGER.info("Resolving admin URL '" + url + "'");
} }
dispatch(request, response, actx); dispatch(request, response, actx);
@ -362,6 +364,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
* @param request The HTTP request * @param request The HTTP request
* @param response The HTTP response * @param response The HTTP response
* @param actx The request context * @param actx The request context
*
* @throws javax.servlet.ServletException * @throws javax.servlet.ServletException
* *
*/ */
@ -472,9 +475,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
*/ */
protected ResourceHandler getResource(ContentSection section, String url) protected ResourceHandler getResource(ContentSection section, String url)
throws ServletException { throws ServletException {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Searching for a resource for the URL fragment '" + url LOGGER.debug("Searching for a resource for the URL fragment '" + url
+ "' under " + section); + "' under " + section);
} }
final PageResolver pageResolver = CMSDispatcher.getPageResolver(section); final PageResolver pageResolver = CMSDispatcher.getPageResolver(section);
@ -556,14 +559,14 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
* @return The PageResolver associated with the content section * @return The PageResolver associated with the content section
*/ */
public static PageResolver getPageResolver(ContentSection section) { public static PageResolver getPageResolver(ContentSection section) {
s_log.debug("Getting the page resolver"); LOGGER.debug("Getting the page resolver");
final String name = section.getLabel(); final String name = section.getLabel();
PageResolver pr = (PageResolver) s_pageResolverCache.get(name); PageResolver pr = (PageResolver) s_pageResolverCache.get(name);
if (pr == null) { if (pr == null) {
s_log.debug("The page resolver was not cached; fetching a new " LOGGER.debug("The page resolver was not cached; fetching a new "
+ "one and placing it in the cache"); + "one and placing it in the cache");
final String pageResolverClassName = section.getPageResolverClass(); final String pageResolverClassName = section.getPageResolverClass();
final PageResolver pageResolver; final PageResolver pageResolver;

View File

@ -31,6 +31,9 @@ import com.arsdigita.web.Web;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -38,7 +41,6 @@ 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.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.Shiro; import org.libreccm.security.Shiro;
@ -68,11 +70,10 @@ import java.util.Optional;
* *
* @author Michael Pih (pihman@arsdigita.com) * @author Michael Pih (pihman@arsdigita.com)
* @author Uday Mathur (umathur@arsdigita.com) * @author Uday Mathur (umathur@arsdigita.com)
* @version $Id$
*/ */
public class CMSPage extends Page implements ResourceHandler { public class CMSPage extends Page implements ResourceHandler {
private static final Logger s_log = Logger.getLogger(CMSPage.class); private static final Logger LOGGER = LogManager.getLogger(CMSPage.class);
/** The global assets URL stub XML parameter name. */ /** The global assets URL stub XML parameter name. */
public final static String ASSETS = "ASSETS"; public final static String ASSETS = "ASSETS";
@ -157,10 +158,10 @@ public class CMSPage extends Page implements ResourceHandler {
*/ */
@Override @Override
public synchronized void init() { public synchronized void init() {
s_log.debug("Initializing the page"); LOGGER.debug("Initializing the page");
if (!isLocked()) { if (!isLocked()) {
s_log.debug("The page hasn't been locked; locking it now"); LOGGER.debug("The page hasn't been locked; locking it now");
lock(); lock();
} }

View File

@ -25,7 +25,6 @@ import com.arsdigita.util.Assert;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -34,10 +33,8 @@ 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.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionConfig;
/** /**
* This is the dispatcher for content-sections. It maintains a * This is the dispatcher for content-sections. It maintains a
@ -56,13 +53,6 @@ public class ContentItemDispatcher implements Dispatcher {
/** */ /** */
protected ItemXML m_itemXML; protected ItemXML m_itemXML;
/**
* Private Logger instance for debugging purpose.
*/
private static final Logger s_log = Logger.getLogger(
ContentItemDispatcher.class.getName());
/** /**
* */ * */
public ContentItemDispatcher() { public ContentItemDispatcher() {

View File

@ -21,29 +21,36 @@ package com.arsdigita.cms.dispatcher;
import com.arsdigita.dispatcher.ChainedDispatcher; import com.arsdigita.dispatcher.ChainedDispatcher;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.dispatcher.RequestContext;
import org.apache.logging.log4j.LogManager;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
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.logging.log4j.Logger;
/** /**
* Dispatches to a file stored under the CMS package root * Dispatches to a file stored under the CMS package root
* (<code>/packages/cms/www</code>). This includes both unmanaged * (<code>/packages/cms/www</code>). This includes both unmanaged files copied
* files copied or created directly in the file system, as well as * or created directly in the file system, as well as pages and assets published
* pages and assets published to the file system from CMS. * to the file system from CMS.
* *
* @author Karl Goldstein (karlg@arsdigita.com) * @author Karl Goldstein (karlg@arsdigita.com)
* @version $Revision$ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision$ $DateTime: 2004/08/17 23:15:09 $
* @version $Id$ * @version $Id$
**/ *
*/
public class FileDispatcher implements ChainedDispatcher { public class FileDispatcher implements ChainedDispatcher {
private static Logger s_log = private static final Logger LOGGER = LogManager.getLogger(
Logger.getLogger(ChainedDispatcher.class); ChainedDispatcher.class);
@Override
public int chainedDispatch(HttpServletRequest request, public int chainedDispatch(HttpServletRequest request,
HttpServletResponse response, HttpServletResponse response,
RequestContext context) RequestContext context)
@ -52,16 +59,18 @@ public class FileDispatcher implements ChainedDispatcher {
File jspFile = getPackageFile(context); File jspFile = getPackageFile(context);
if (jspFile.exists() && !jspFile.isDirectory()) { if (jspFile.exists() && !jspFile.isDirectory()) {
String packageURL = context.getPageBase() + context.getRemainingURLPart(); String packageURL = context.getPageBase() + context
s_log.debug ("DISPATCHING to " + packageURL); .getRemainingURLPart();
LOGGER.debug("DISPATCHING to " + packageURL);
// don't match folders, since they don't actually match a file // don't match folders, since they don't actually match a file
if ( !packageURL.endsWith("/")) { if (!packageURL.endsWith("/")) {
s_log.debug ("DISPATCHING to " + packageURL); LOGGER.debug("DISPATCHING to " + packageURL);
// Don't set caching headers - let JSP file do it if required // Don't set caching headers - let JSP file do it if required
//DispatcherHelper.maybeCacheDisable(response); //DispatcherHelper.maybeCacheDisable(response);
DispatcherHelper.setRequestContext(request, context); DispatcherHelper.setRequestContext(request, context);
DispatcherHelper.forwardRequestByPath(packageURL, request, response); DispatcherHelper.forwardRequestByPath(packageURL, request,
response);
return ChainedDispatcher.DISPATCH_BREAK; return ChainedDispatcher.DISPATCH_BREAK;
} }
} }
@ -71,18 +80,20 @@ public class FileDispatcher implements ChainedDispatcher {
/** /**
* Matches the request URL to a file in the package www directory. * Matches the request URL to a file in the package www directory.
**/ *
*/
private File getPackageFile(RequestContext appContext) { private File getPackageFile(RequestContext appContext) {
ServletContext servletContext = appContext.getServletContext(); ServletContext servletContext = appContext.getServletContext();
String filePath = appContext.getRemainingURLPart(); String filePath = appContext.getRemainingURLPart();
String packageDocRoot = String packageDocRoot = servletContext.getRealPath(appContext
servletContext.getRealPath(appContext.getPageBase()); .getPageBase());
File jspFile = new File(packageDocRoot, filePath); File jspFile = new File(packageDocRoot, filePath);
return jspFile; return jspFile;
} }
} }

View File

@ -21,9 +21,11 @@ package com.arsdigita.cms.dispatcher;
import com.arsdigita.dispatcher.ChainedDispatcher; import com.arsdigita.dispatcher.ChainedDispatcher;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.dispatcher.RequestContext;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.LoginSignal; import com.arsdigita.web.LoginSignal;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -33,7 +35,6 @@ 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.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.Shiro; import org.libreccm.security.Shiro;
@ -48,12 +49,11 @@ import org.librecms.dispatcher.ItemResolver;
* Dispatches to the JSP or Servlet for rendering a content item. * Dispatches to the JSP or Servlet for rendering a content item.
* *
* @author Karl Goldstein (karlg@arsdigita.com) * @author Karl Goldstein (karlg@arsdigita.com)
* @version $Revision$ $DateTime: 2004/08/17 23:15:09 $
* *
*/ */
public class ItemDispatcher implements ChainedDispatcher { public class ItemDispatcher implements ChainedDispatcher {
private static Logger s_log = Logger.getLogger(ItemDispatcher.class); private static Logger LOGGER = LogManager.getLogger(ItemDispatcher.class);
public static Map s_itemResolverCache = Collections.synchronizedMap( public static Map s_itemResolverCache = Collections.synchronizedMap(
new HashMap()); new HashMap());
@ -95,11 +95,11 @@ public class ItemDispatcher implements ChainedDispatcher {
String queryString = request.getQueryString(); String queryString = request.getQueryString();
String url = actx.getRemainingURLPart(); String url = actx.getRemainingURLPart();
s_log.info("Resolving item URL " + url); LOGGER.info("Resolving item URL " + 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"); LOGGER.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);
@ -110,7 +110,7 @@ public class ItemDispatcher implements ChainedDispatcher {
} else if (url.endsWith("/")) { } else if (url.endsWith("/")) {
url = "/" + url.substring(0, url.length() - 1); url = "/" + url.substring(0, url.length() - 1);
} else { } else {
s_log.warn("Fail: URL doesn't have right suffix."); LOGGER.warn("Fail: URL doesn't have right suffix.");
return ChainedDispatcher.DISPATCH_CONTINUE; return ChainedDispatcher.DISPATCH_CONTINUE;
} }
} }
@ -121,13 +121,13 @@ public class ItemDispatcher implements ChainedDispatcher {
final ContentItem item = getItem(section, url); final ContentItem item = getItem(section, url);
if (item == null) { if (item == null) {
s_log.warn("Fail: No live item found matching " + url); LOGGER.warn("Fail: No live item found matching " + url);
return ChainedDispatcher.DISPATCH_CONTINUE; return ChainedDispatcher.DISPATCH_CONTINUE;
} }
request.setAttribute(ContentSectionDispatcher.CONTENT_ITEM, item); request.setAttribute(ContentSectionDispatcher.CONTENT_ITEM, item);
s_log.debug("MATCHED " + item.getObjectId()); LOGGER.debug("MATCHED " + item.getObjectId());
// Work out how long to cache for.... // Work out how long to cache for....
// We take minimum(default timeout, lifecycle expiry) // We take minimum(default timeout, lifecycle expiry)
@ -216,7 +216,7 @@ public class ItemDispatcher implements ChainedDispatcher {
// look up folder if it's an index // look up folder if it's an index
url = url.substring(0, url.length() - INDEX_FILE.length()); url = url.substring(0, url.length() - INDEX_FILE.length());
s_log.info("Attempting to match folder " + url); LOGGER.info("Attempting to match folder " + url);
item = itemResolver.getItem(section, url, "live"); item = itemResolver.getItem(section, url, "live");
if (item != null) { if (item != null) {
hasPermission = permissionChecker.isPermitted( hasPermission = permissionChecker.isPermitted(

View File

@ -20,70 +20,72 @@ package com.arsdigita.cms.dispatcher;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentCenter;
import com.arsdigita.cms.ContentCenterServlet;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import javax.servlet.http.HttpServletRequest; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.assets.BinaryAsset; import org.librecms.assets.BinaryAsset;
import org.librecms.assets.Image; import org.librecms.assets.Image;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
/** /**
* <p>This class provides many utility functions for the Content Management * <p>
* This class provides many utility functions for the Content Management
* System.</p> * System.</p>
* Specifically used by various JSP templates. * Specifically used by various JSP templates.
* *
* @author Michael Pih (pihman@arsdigita.com) * @author Michael Pih (pihman@arsdigita.com)
* @version $Id$
*/ */
public class Utilities { public class Utilities {
public static final Logger LOGGER = LogManager.getLogger(Utilities.class);
// Used for caching util lookups // Used for caching util lookups
private static HashMap m_cache = new HashMap(); private static HashMap m_cache = new HashMap();
private static Date s_lastSectionRefresh = null; private static Date s_lastSectionRefresh = null;
private static Map s_sectionRefreshTimes = private static Map s_sectionRefreshTimes = Collections.synchronizedMap(
Collections.synchronizedMap(new HashMap()); new HashMap());
public static final Logger LOG = Logger.getLogger(Utilities.class);
/** /**
* Fetch the location of the CMS ContentCenter package. * Fetch the location of the CMS ContentCenter package.
*
* @return The URL of the CMS ContentCenter package * @return The URL of the CMS ContentCenter package
*
* @deprecated use ContentCenter.getURL() instead * @deprecated use ContentCenter.getURL() instead
*/ */
public static String getWorkspaceURL() { public static String getWorkspaceURL() {
return CmsConstants.CONTENT_CENTER_URL; return CmsConstants.CONTENT_CENTER_URL;
} }
/** /**
* Fetch the location (URL) of the CMS Services package. Caches the result. * Fetch the location (URL) of the CMS Services package. Caches the result.
*
* @return The URL of the CMS Services package * @return The URL of the CMS Services package
* @deprecated Use Service.getURL( instead *
* @deprecated Use Service.getURL( instead
*/ */
public static String getServiceURL() { public static String getServiceURL() {
String url = (String) m_cache.get(CmsConstants.SERVICE_PACKAGE_KEY); String url = (String) m_cache.get(CmsConstants.SERVICE_PACKAGE_KEY);
if ( url == null ) { if (url == null) {
// chris.gilbert@westsussex.gov.uk // chris.gilbert@westsussex.gov.uk
// We don't want application context in this url, especially when // We don't want application context in this url, especially when
// it gets cached in a static variable - if I have a // it gets cached in a static variable - if I have a
// file that is maintained by a non cms application eg // file that is maintained by a non cms application eg
// forum, then I can end up with a url that doesn't work // forum, then I can end up with a url that doesn't work
// and so breaks file links everywhere // and so breaks file links everywhere
// url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY); // url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY);
url = CmsConstants.SERVICE_URL; url = CmsConstants.SERVICE_URL;
m_cache.put(CmsConstants.SERVICE_PACKAGE_KEY, url); m_cache.put(CmsConstants.SERVICE_PACKAGE_KEY, url);
} }
@ -93,11 +95,12 @@ public class Utilities {
/** /**
* The URL to log out. * The URL to log out.
*
* @return The logout URL * @return The logout URL
*/ */
public static String getLogoutURL() { public static String getLogoutURL() {
//StringBuffer buf = new StringBuffer(getServiceURL()); //StringBuffer buf = new StringBuffer(getServiceURL());
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL ); StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
buf.append("logout"); buf.append("logout");
return buf.toString(); return buf.toString();
} }
@ -105,8 +108,10 @@ public class Utilities {
/** /**
* Construct a URL which serves a binary asset. * Construct a URL which serves a binary asset.
* *
* @param asset The binary asset * @param asset The binary asset
*
* @return the URL which will serve the specified binary asset * @return the URL which will serve the specified binary asset
*
* @deprecated Use Service.getAssetURL(BinaryAsset asset) instead * @deprecated Use Service.getAssetURL(BinaryAsset asset) instead
*/ */
public static String getAssetURL(BinaryAsset asset) { public static String getAssetURL(BinaryAsset asset) {
@ -116,38 +121,42 @@ public class Utilities {
/** /**
* Constuct a URL which serves a binary asset. * Constuct a URL which serves a binary asset.
* *
* @param assetId The asset ID * @param assetId The asset ID
*
* @return the URL which will serve the specified binary asset * @return the URL which will serve the specified binary asset
*
* @deprecated Use Service.getAssetURL(BigDecimal assetId) instead * @deprecated Use Service.getAssetURL(BigDecimal assetId) instead
*/ */
public static String getAssetURL(long assetId) { public static String getAssetURL(long assetId) {
// StringBuffer buf = new StringBuffer(getServiceURL()); // StringBuffer buf = new StringBuffer(getServiceURL());
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL ); StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
buf.append("stream/asset?"); buf.append("stream/asset?");
buf.append(CmsConstants.ASSET_ID).append("=").append(assetId); buf.append(CmsConstants.ASSET_ID).append("=").append(assetId);
return buf.toString(); return buf.toString();
} }
/** /**
* Construct a URL which serves an image. * Construct a URL which serves an image.
* *
* @param asset The image asset whose image is to be served * @param asset The image asset whose image is to be served
*
* @return the URL which will serve the specified image asset * @return the URL which will serve the specified image asset
*
* @deprecated Use Service.getImageURL(ImageAsset) instead! * @deprecated Use Service.getImageURL(ImageAsset) instead!
*/ */
public static String getImageURL(Image asset) { public static String getImageURL(Image asset) {
// StringBuffer buf = new StringBuffer(getServiceURL()); // StringBuffer buf = new StringBuffer(getServiceURL());
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL ); StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
buf.append("stream/image/?"); buf.append("stream/image/?");
buf.append(CmsConstants.IMAGE_ID).append("=").append(asset.getObjectId()); buf.append(CmsConstants.IMAGE_ID).append("=")
.append(asset.getObjectId());
return buf.toString(); return buf.toString();
} }
public static String getGlobalAssetsURL() { public static String getGlobalAssetsURL() {
return getWebappContext(); return getWebappContext();
} }
/** /**
* Fetch the context path of the request. This is typically "/". * Fetch the context path of the request. This is typically "/".
* *
@ -157,17 +166,16 @@ public class Utilities {
return DispatcherHelper.getWebappContext(); return DispatcherHelper.getWebappContext();
} }
/** /**
* Check for the last refresh on authoring kits or content types in * Check for the last refresh on authoring kits or content types in a
* a section. * section.
**/ *
*/
public static synchronized Date public static synchronized Date
getLastSectionRefresh(ContentSection section) { getLastSectionRefresh(ContentSection section) {
// cache by URL string instead of by section object to avoid // cache by URL string instead of by section object to avoid
// holding the reference. // holding the reference.
String sectionURL = section.getPrimaryUrl(); String sectionURL = section.getPrimaryUrl();
Date lastModified = (Date) s_sectionRefreshTimes.get(sectionURL); Date lastModified = (Date) s_sectionRefreshTimes.get(sectionURL);
@ -181,14 +189,14 @@ public class Utilities {
} }
/** /**
* Check for the last refresh on authoring kits or content types in * Check for the last refresh on authoring kits or content types in any
* any section. * section.
**/ *
*/
public static Date getLastSectionRefresh() { public static Date getLastSectionRefresh() {
// instantiate last refresh lazily to ensure that first result is // instantiate last refresh lazily to ensure that first result is
// predictable. // predictable.
if (s_lastSectionRefresh == null) { if (s_lastSectionRefresh == null) {
s_lastSectionRefresh = new Date(); s_lastSectionRefresh = new Date();
} }
@ -215,7 +223,7 @@ public class Utilities {
// section object to avoid holding the reference. This shouldn't // section object to avoid holding the reference. This shouldn't
// do any harm even if ContentSectionDispatcher is not being used. // do any harm even if ContentSectionDispatcher is not being used.
s_lastSectionRefresh = new Date(); s_lastSectionRefresh = new Date();
s_sectionRefreshTimes.put(section.getPrimaryUrl(), s_sectionRefreshTimes.put(section.getPrimaryUrl(),
s_lastSectionRefresh); s_lastSectionRefresh);
} }
@ -235,10 +243,11 @@ public class Utilities {
} }
/** /**
* Add the "pragma: no-cache" header to the HTTP response to make sure * Add the "pragma: no-cache" header to the HTTP response to make sure the
* the browser does not cache tha page * browser does not cache tha page
* *
* @param response The HTTP response * @param response The HTTP response
*
* @deprecated use * @deprecated use
* com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse) * com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse)
*/ */
@ -246,5 +255,4 @@ public class Utilities {
response.addHeader("pragma", "no-cache"); response.addHeader("pragma", "no-cache");
} }
} }

View File

@ -39,7 +39,6 @@ import com.arsdigita.toolbox.ui.Cancellable;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
/** /**
@ -50,8 +49,6 @@ import org.librecms.CmsConstants;
*/ */
public abstract class BaseForm extends Form implements Cancellable { public abstract class BaseForm extends Form implements Cancellable {
private static final Logger s_log = Logger.getLogger(BaseForm.class);
private final BodySection m_body; private final BodySection m_body;
private final BoxPanel m_actions; private final BoxPanel m_actions;
private Cancel m_cancel; private Cancel m_cancel;

View File

@ -25,18 +25,14 @@ import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.bebop.event.TreeExpansionEvent; import com.arsdigita.bebop.event.TreeExpansionEvent;
import com.arsdigita.bebop.event.TreeExpansionListener; import com.arsdigita.bebop.event.TreeExpansionListener;
import com.arsdigita.bebop.tree.TreeModelBuilder; import com.arsdigita.bebop.tree.TreeModelBuilder;
import org.apache.log4j.Logger;
/** /**
* A convenience class for CMS trees. * A convenience class for CMS trees.
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
public class BaseTree extends Tree { public class BaseTree extends Tree {
private static final Logger s_log = Logger.getLogger(BaseTree.class);
public BaseTree(final TreeModelBuilder builder) { public BaseTree(final TreeModelBuilder builder) {
super(builder); super(builder);

View File

@ -21,19 +21,11 @@ package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import org.apache.log4j.Logger;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
/**
*
* @version $Id$
*/
public class CcmObjectRequestLocal extends RequestLocal { public class CcmObjectRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger
(CcmObjectRequestLocal.class);
public final CcmObject getACSObject(final PageState state) { public final CcmObject getACSObject(final PageState state) {
return (CcmObject) get(state); return (CcmObject) get(state);
} }

View File

@ -21,17 +21,14 @@ package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.apache.log4j.Logger;
/** /**
* *
*/ */
public final class ContentSectionRequestLocal extends RequestLocal { public final class ContentSectionRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger
(ContentSectionRequestLocal.class);
@Override @Override
protected Object initialValue(final PageState state) { protected Object initialValue(final PageState state) {
return CMS.getContext().getContentSection(); return CMS.getContext().getContentSection();

View File

@ -25,27 +25,19 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.ui.item.ContentItemRequestLocal; import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
import com.arsdigita.dispatcher.AccessDeniedException; import com.arsdigita.dispatcher.AccessDeniedException;
import org.libreccm.security.User;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Web;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
/** /**
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
public class FormSecurityListener implements FormSubmissionListener { public class FormSecurityListener implements FormSubmissionListener {
private static Logger s_log = Logger.getLogger(FormSecurityListener.class);
private final String m_action; private final String m_action;
private final ContentItemRequestLocal m_item; private final ContentItemRequestLocal m_item;
@ -63,20 +55,21 @@ public class FormSecurityListener implements FormSubmissionListener {
@Override @Override
public final void submitted(final FormSectionEvent event) public final void submitted(final FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class); final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class);
if (m_item == null) { if (m_item == null) {
if (permissionChecker.isPermitted(m_action)) { if (permissionChecker.isPermitted(m_action)) {
return; return;
} }
} else { } else {
final ContentItem item = m_item.getContentItem(state); final ContentItem item = m_item.getContentItem(state);
if (permissionChecker.isPermitted(m_action, item)) { if (permissionChecker.isPermitted(m_action, item)) {
return; return;
} }
@ -84,4 +77,5 @@ public class FormSecurityListener implements FormSubmissionListener {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
} }

View File

@ -21,7 +21,6 @@ package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentCenter;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.UI; import com.arsdigita.ui.UI;
import com.arsdigita.ui.admin.AdminUiConstants; import com.arsdigita.ui.admin.AdminUiConstants;
@ -29,11 +28,9 @@ import com.arsdigita.ui.login.LoginServlet;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.web.ApplicationCreator;
import org.libreccm.web.ApplicationManager; import org.libreccm.web.ApplicationManager;
import org.libreccm.web.ApplicationRepository; import org.libreccm.web.ApplicationRepository;
import org.libreccm.web.ApplicationType; import org.libreccm.web.ApplicationType;
@ -50,12 +47,11 @@ import javax.servlet.http.HttpServletRequest;
* Global navigation elements for the CMS admin UIs.</p> * Global navigation elements for the CMS admin UIs.</p>
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
// Made public (instead of unspecified, resulting in protected) in 6.6.8 // Made public (instead of unspecified, resulting in protected) in 6.6.8
public class GlobalNavigation extends SimpleComponent { public class GlobalNavigation extends SimpleComponent {
private static final Logger s_log = Logger.getLogger(GlobalNavigation.class);
private final String m_adminPath; private final String m_adminPath;
private final String m_centerPath; private final String m_centerPath;
private final String m_changePasswordPath; private final String m_changePasswordPath;

View File

@ -30,6 +30,7 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.io.IOException; import java.io.IOException;
/** /**
@ -44,15 +45,12 @@ import java.io.IOException;
* you must hit the "up" arrow n/2 times where n is the number of items in the * you must hit the "up" arrow n/2 times where n is the number of items in the
* list. This clearly is not a good setup. * list. This clearly is not a good setup.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a> *
* @author Randy Graebner (randyg@alum.mit.edu) * @author Randy Graebner (randyg@alum.mit.edu)
* @version $Id: SortableList.java 1618 2007-09-13 12:14:51Z chrisg23 $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
public abstract class SortableList extends List { public abstract class SortableList extends List {
private static final org.apache.log4j.Logger s_log
= org.apache.log4j.Logger.getLogger(SortableList.class);
// It would be really nice if this used the save variable as is // It would be really nice if this used the save variable as is
// used by List but because List has it as private, we cannot do that. // used by List but because List has it as private, we cannot do that.
private static final String SELECT_EVENT = "s"; private static final String SELECT_EVENT = "s";
@ -67,11 +65,12 @@ public abstract class SortableList extends List {
this(model, false); this(model, false);
} }
public SortableList(ParameterSingleSelectionModel model, boolean suppressSort) { public SortableList(ParameterSingleSelectionModel model,
boolean suppressSort) {
super(model); super(model);
m_sortItems = !suppressSort; m_sortItems = !suppressSort;
} }
/** /**
* This geneates the XML as specified by the arguments pass in to the * This geneates the XML as specified by the arguments pass in to the
* constructor. * constructor.
@ -91,7 +90,8 @@ public abstract class SortableList extends List {
// because m.next() returned true, we know there are items // because m.next() returned true, we know there are items
// in the list // in the list
Element list = parent.newChildElement("cms:sortableList", CMS.CMS_XML_NS); Element list = parent
.newChildElement("cms:sortableList", CMS.CMS_XML_NS);
exportAttributes(list); exportAttributes(list);
Component c; Component c;
@ -99,7 +99,8 @@ public abstract class SortableList extends List {
int i = 0; int i = 0;
boolean hasNext; boolean hasNext;
do { do {
Element item = list.newChildElement(BebopConstants.BEBOP_CELL, BEBOP_XML_NS); Element item = list.newChildElement(BebopConstants.BEBOP_CELL,
BEBOP_XML_NS);
if (m_sortItems) { if (m_sortItems) {
item.addAttribute("configure", "true"); item.addAttribute("configure", "true");
@ -110,14 +111,15 @@ public abstract class SortableList extends List {
// Converting both keys to String for comparison // Converting both keys to String for comparison
// since ListModel.getKey returns a String // since ListModel.getKey returns a String
boolean selected = (selKey != null) boolean selected = (selKey != null)
&& key.equals(selKey.toString()); && key.equals(selKey.toString());
if (selected) { if (selected) {
item.addAttribute("selected", "selected"); item.addAttribute("selected", "selected");
} }
generateLabelXML(state, item, generateLabelXML(state, item,
new Label(new GlobalizedMessage(m.getElement().toString())), key, m.getElement()); new Label(new GlobalizedMessage(m.getElement()
.toString())), key, m.getElement());
hasNext = m.next(); hasNext = m.next();
@ -138,7 +140,7 @@ public abstract class SortableList extends List {
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("Caught IOException: " throw new IllegalStateException("Caught IOException: "
+ ex.getMessage()); + ex.getMessage());
} }
i++; i++;
} while (hasNext); } while (hasNext);
@ -147,9 +149,10 @@ public abstract class SortableList extends List {
} }
protected void generateLabelXML(PageState state, Element parent, protected void generateLabelXML(PageState state, Element parent,
Label label, String key, Object element) { Label label, String key, Object element) {
state.setControlEvent(this, SELECT_EVENT, key); state.setControlEvent(this, SELECT_EVENT, key);
Component c = new ControlLink(label); Component c = new ControlLink(label);
c.generateXML(state, parent); c.generateXML(state, parent);
} }
} }

View File

@ -38,7 +38,6 @@ import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
@ -54,14 +53,6 @@ public abstract class BasicItemForm extends FormSection
FormProcessListener, FormProcessListener,
FormValidationListener { FormValidationListener {
/**
* Internal logger instance to faciliate debugging. Enable logging output by
* editing /WEB-INF/conf/log4j.properties int hte runtime environment and
* set com.arsdigita.cms.ui.BasicItemForm=DEBUG by uncommenting or adding
* the line.
*/
private static final Logger s_log = Logger.getLogger(BasicItemForm.class);
private final ItemSelectionModel m_itemModel; private final ItemSelectionModel m_itemModel;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private final FormSection m_widgetSection; private final FormSection m_widgetSection;

View File

@ -30,7 +30,7 @@ import com.arsdigita.bebop.util.GlobalizationUtil;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.BaseForm; import com.arsdigita.cms.ui.BaseForm;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
@ -42,14 +42,11 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
/** /**
* TODO Needs a description. * TODO Needs a description.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Scott Seago * @author Scott Seago
* @version $Id: AddUseContextForm.java 2090 2010-04-17 08:04:14Z pboy $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
class AddUseContextForm extends BaseForm { class AddUseContextForm extends BaseForm {
private static final Logger s_log = Logger.getLogger(AddUseContextForm.class);
private final SingleSelectionModel m_model; private final SingleSelectionModel m_model;
private final Name m_useContext; private final Name m_useContext;

View File

@ -36,34 +36,31 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import java.util.Collection; import java.util.Collection;
/** /**
* A form which creates a new category. Extends the edit form for * A form which creates a new category. Extends the edit form for convenience.
* convenience. *
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Michael Pih * @author Michael Pih
* @author Stanislav Freidin &lt;sfreidin@redhat.com&gt; * @author Stanislav Freidin &lt;sfreidin@redhat.com&gt;
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: BaseCategoryForm.java 1951 2009-06-30 04:35:04Z terry $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
class BaseCategoryForm extends BaseForm { class BaseCategoryForm extends BaseForm {
private static final Logger s_log = Logger.getLogger(BaseCategoryForm.class);
final CategoryRequestLocal m_parent; final CategoryRequestLocal m_parent;
final TextField m_name; final TextField m_name;
final TextArea m_description; final TextArea m_description;
final RadioGroup m_isAbstract; final RadioGroup m_isAbstract;
final RadioGroup m_isVisible; final RadioGroup m_isVisible;
final RadioGroup m_isEnabled; final RadioGroup m_isEnabled;
private Label m_script = new Label( new GlobalizedMessage(String.format( private Label m_script = new Label(new GlobalizedMessage(String.format(
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>", "<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath())), Web.getWebappContextPath())),
false); false);
private final static String NAME = "name"; private final static String NAME = "name";
private final static String DESCRIPTION = "description"; private final static String DESCRIPTION = "description";
private final static String URL = "url"; private final static String URL = "url";
@ -87,9 +84,11 @@ class BaseCategoryForm extends BaseForm {
m_name.setSize(30); m_name.setSize(30);
m_name.setMaxLength(200); m_name.setMaxLength(200);
m_name.addValidationListener(new NotNullValidationListener()); m_name.addValidationListener(new NotNullValidationListener());
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + " defaulting = true; this.form." + URL m_name.setOnFocus("if (this.form." + URL + ".value == '') { "
+ ".value = urlize(this.value); }"); + " defaulting = true; this.form." + URL
m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }"); + ".value = urlize(this.value); }");
m_name.setOnKeyUp("if (defaulting) { this.form." + URL
+ ".value = urlize(this.value) }");
// is abstract? // is abstract?
m_isAbstract = new RadioGroup(IS_ABSTRACT); m_isAbstract = new RadioGroup(IS_ABSTRACT);
@ -109,7 +108,6 @@ class BaseCategoryForm extends BaseForm {
m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes")))); m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_enabled"), m_isEnabled); addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION)); m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
addField(gz("cms.ui.description"), m_description); addField(gz("cms.ui.description"), m_description);
@ -147,7 +145,7 @@ class BaseCategoryForm extends BaseForm {
@Override @Override
public final void validate(final ParameterEvent e) public final void validate(final ParameterEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final String title = (String) m_widget.getValue(state); final String title = (String) m_widget.getValue(state);
@ -158,11 +156,14 @@ class BaseCategoryForm extends BaseForm {
for (final Category child : children) { for (final Category child : children) {
String compField = child.getName(); String compField = child.getName();
if (compField.equalsIgnoreCase(title) if (compField.equalsIgnoreCase(title)
&& (m_category == null && (m_category == null
|| !m_category.getCategory(state).equals(child))) { || !m_category.getCategory(state).equals(child))) {
throw new FormProcessException(GlobalizationUtil.globalize("cms.ui.category.name_not_unique")); throw new FormProcessException(GlobalizationUtil.globalize(
"cms.ui.category.name_not_unique"));
} }
} }
} }
} }
} }

View File

@ -26,7 +26,9 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.dispatcher.AccessDeniedException; import com.arsdigita.dispatcher.AccessDeniedException;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
@ -39,13 +41,12 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
/** /**
* TODO Needs a description. * TODO Needs a description.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: CategoryAddForm.java 2090 2010-04-17 08:04:14Z pboy $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
final class CategoryAddForm extends BaseCategoryForm { final class CategoryAddForm extends BaseCategoryForm {
private static final Logger s_log = Logger.getLogger private static final Logger LOGGER = LogManager.getLogger
(CategoryAddForm.class); (CategoryAddForm.class);
private final SingleSelectionModel m_model; private final SingleSelectionModel m_model;
@ -66,7 +67,7 @@ final class CategoryAddForm extends BaseCategoryForm {
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
s_log.debug("Adding a category"); LOGGER.debug("Adding a category");
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class); final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
@ -84,8 +85,8 @@ final class CategoryAddForm extends BaseCategoryForm {
Assert.exists(parent, "Category parent"); Assert.exists(parent, "Category parent");
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Using parent category " + parent + " to " + LOGGER.debug("Using parent category " + parent + " to " +
"create new category"); "create new category");
} }

View File

@ -18,7 +18,11 @@
*/ */
package com.arsdigita.cms.ui.category; package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.*; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.GridPanel;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.form.FormErrorDisplay; import com.arsdigita.bebop.form.FormErrorDisplay;
@ -30,7 +34,6 @@ import com.arsdigita.bebop.util.GlobalizationUtil;
import com.arsdigita.cms.ui.CMSForm; import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
/** /**
@ -39,12 +42,9 @@ import org.libreccm.categorization.Category;
* *
* @author Michael Pih * @author Michael Pih
* @author Stanislav Freidin &lt;sfreidin@redhat.com&gt; * @author Stanislav Freidin &lt;sfreidin@redhat.com&gt;
* @version $Id: CategoryBaseForm.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
class CategoryBaseForm extends CMSForm { class CategoryBaseForm extends CMSForm {
private static final Logger s_log =
Logger.getLogger(CategoryBaseForm.class);
final CategoryRequestLocal m_parent; final CategoryRequestLocal m_parent;
final FormErrorDisplay m_errors; final FormErrorDisplay m_errors;

View File

@ -25,7 +25,9 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.dispatcher.AccessDeniedException; import com.arsdigita.dispatcher.AccessDeniedException;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
@ -37,13 +39,14 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
/** /**
* TODO Needs a description. * TODO Needs a description.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: CategoryEditForm.java 2090 2010-04-17 08:04:14Z pboy $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
final class CategoryEditForm extends BaseCategoryForm { final class CategoryEditForm extends BaseCategoryForm {
private static final Logger s_log = Logger.getLogger(CategoryEditForm.class); private static final Logger LOGGER = LogManager.getLogger(
CategoryEditForm.class);
private static final String NO = "no"; private static final String NO = "no";
private static final String YES = "yes"; private static final String YES = "yes";
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
@ -62,7 +65,7 @@ final class CategoryEditForm extends BaseCategoryForm {
@Override @Override
public final void init(final FormSectionEvent e) public final void init(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final Category category = m_category.getCategory(state); final Category category = m_category.getCategory(state);
@ -88,7 +91,6 @@ final class CategoryEditForm extends BaseCategoryForm {
m_isVisible.setValue(state, NO); m_isVisible.setValue(state, NO);
} }
if (category.isEnabled()) { if (category.isEnabled()) {
m_isEnabled.setValue(state, YES); m_isEnabled.setValue(state, YES);
} else { } else {
@ -102,21 +104,28 @@ final class CategoryEditForm extends BaseCategoryForm {
@Override @Override
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class); final PermissionChecker permissionChecker = cdiUtil.findBean(
final ConfigurationManager manager = cdiUtil.findBean(ConfigurationManager.class); PermissionChecker.class);
final KernelConfig config = manager.findConfiguration(KernelConfig.class); final ConfigurationManager manager = cdiUtil.findBean(
final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class); ConfigurationManager.class);
final KernelConfig config = manager.findConfiguration(
KernelConfig.class);
final CategoryRepository categoryRepository = cdiUtil.findBean(
CategoryRepository.class);
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final Category category = m_category.getCategory(state); final Category category = m_category.getCategory(state);
if (permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_CATEGORIES, category)) { if (permissionChecker.isPermitted(
AdminPrivileges.ADMINISTER_CATEGORIES, category)) {
category.setName((String) m_name.getValue(state)); category.setName((String) m_name.getValue(state));
final LocalizedString localizedDescription = new LocalizedString(); final LocalizedString localizedDescription
localizedDescription.addValue(config.getDefaultLocale() ,(String) m_description.getValue(state)); = new LocalizedString();
localizedDescription.addValue(config.getDefaultLocale(),
(String) m_description.getValue(
state));
category.setDescription(localizedDescription); category.setDescription(localizedDescription);
final String isAbstract = (String) m_isAbstract.getValue(state); final String isAbstract = (String) m_isAbstract.getValue(state);
@ -150,4 +159,5 @@ final class CategoryEditForm extends BaseCategoryForm {
} }
} }
} }

View File

@ -20,14 +20,11 @@ package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
class CategoryRequestLocal extends RequestLocal { class CategoryRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger
(CategoryRequestLocal.class);
public final Category getCategory(final PageState state) { public final Category getCategory(final PageState state) {
return (Category) get(state); return (Category) get(state);
} }

View File

@ -21,15 +21,15 @@ package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.SortableList; import com.arsdigita.cms.ui.SortableList;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.librecms.contentsection.ContentSection;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import java.math.BigDecimal;
/** /**
* This list offers the option for the code to provide the developer * This list offers the option for the code to provide the developer
@ -44,13 +44,14 @@ import java.math.BigDecimal;
* "up" arrow n/2 times where n is the number of items in the list. * "up" arrow n/2 times where n is the number of items in the list.
* This clearly is not a good setup. * This clearly is not a good setup.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Randy Graebner (randyg@alum.mit.edu) * @author Randy Graebner (randyg@alum.mit.edu)
* @version $Id: SortableCategoryList.java 1942 2009-05-29 07:53:23Z terry $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
abstract class SortableCategoryList extends SortableList { abstract class SortableCategoryList extends SortableList {
private static final Logger s_log = Logger.getLogger private static final Logger LOGGER = LogManager.getLogger
(SortableCategoryList.class); (SortableCategoryList.class);
public final static String CHILDREN = "ch"; public final static String CHILDREN = "ch";

View File

@ -24,7 +24,6 @@ import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.TabbedPane;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.LongParameter; import com.arsdigita.bebop.parameters.LongParameter;
import com.arsdigita.cms.ui.CMSApplicationPage; import com.arsdigita.cms.ui.CMSApplicationPage;
import com.arsdigita.cms.ui.GlobalNavigation; import com.arsdigita.cms.ui.GlobalNavigation;
@ -32,7 +31,6 @@ import com.arsdigita.cms.ui.WorkspaceContextBar;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.CcmObjectSelectionModel; import com.arsdigita.ui.CcmObjectSelectionModel;
import org.apache.log4j.Logger;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType; import org.librecms.contentsection.ContentType;
@ -56,12 +54,9 @@ import org.librecms.contentsection.ContentType;
* @author Jack Chung (flattop@arsdigita.com) * @author Jack Chung (flattop@arsdigita.com)
* @author Michael Pih (pihman@arsdigita.com) * @author Michael Pih (pihman@arsdigita.com)
* @author Peter Boy (pboy@barkhof.uni-bremen.de) * @author Peter Boy (pboy@barkhof.uni-bremen.de)
* @version $Id: MainPage.java pboy $
*/ */
public class MainPage extends CMSApplicationPage implements ActionListener { public class MainPage extends CMSApplicationPage implements ActionListener {
private static final Logger s_log = Logger.getLogger(MainPage.class);
private final static String XSL_CLASS = "CMS Admin"; private final static String XSL_CLASS = "CMS Admin";
private TabbedPane m_tabbedPane; private TabbedPane m_tabbedPane;
@ -114,15 +109,15 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
add(m_tabbedPane); add(m_tabbedPane);
// add(new DebugPanel()); // add(new DebugPanel());
} }
/** /**
* Creates, and then caches, the Tasks pane. Overriding this method to * Creates, and then caches, the Tasks pane. Overriding this method to
* return null will prevent this tab from appearing. * return null will prevent this tab from appearing.
*/ */
protected TasksPanel getTasksPane(CcmObjectSelectionModel<ContentType> typeModel, protected TasksPanel getTasksPane(
CcmObjectSelectionModel<ContentSection> sectionModel) { CcmObjectSelectionModel<ContentType> typeModel,
CcmObjectSelectionModel<ContentSection> sectionModel) {
if (m_tasks == null) { if (m_tasks == null) {
m_tasks = new TasksPanel(typeModel, sectionModel); m_tasks = new TasksPanel(typeModel, sectionModel);
} }
@ -149,7 +144,6 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
// //
// return m_IdSearch; // return m_IdSearch;
// } // }
/** /**
* Created the TabbedPane to use for this page. Sets the class attribute for * Created the TabbedPane to use for this page. Sets the class attribute for
* this tabbed pane. The default implementation uses a * this tabbed pane. The default implementation uses a
@ -165,7 +159,7 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
TabbedPane tabbedPane = new TabbedPane(); TabbedPane tabbedPane = new TabbedPane();
tabbedPane.setClassAttr(XSL_CLASS); tabbedPane.setClassAttr(XSL_CLASS);
Label taskLabel = new Label(new GlobalizedMessage( Label taskLabel = new Label(new GlobalizedMessage(
"cms.ui.contentcenter.mainpage.taskssections", "cms.ui.contentcenter.mainpage.taskssections",
CmsConstants.CMS_BUNDLE)); CmsConstants.CMS_BUNDLE));
Label searchLabel = new Label(new GlobalizedMessage( Label searchLabel = new Label(new GlobalizedMessage(
"cms.ui.contentcenter.mainpage.search", CmsConstants.CMS_BUNDLE)); "cms.ui.contentcenter.mainpage.search", CmsConstants.CMS_BUNDLE));
@ -228,7 +222,7 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
if (pane == m_tasks) { if (pane == m_tasks) {
m_tasks.reset(state); m_tasks.reset(state);
} }
// else if (pane == m_search) { // else if (pane == m_search) {
// m_search.reset(state); // m_search.reset(state);
// } else if (pane == m_IdSearch) { // } else if (pane == m_IdSearch) {

View File

@ -19,18 +19,11 @@
package com.arsdigita.cms.ui.contentcenter; package com.arsdigita.cms.ui.contentcenter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger;
import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Image;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -38,7 +31,6 @@ import com.arsdigita.bebop.PaginationModelBuilder;
import com.arsdigita.bebop.Paginator; import com.arsdigita.bebop.Paginator;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.ChangeEvent; import com.arsdigita.bebop.event.ChangeEvent;
@ -50,10 +42,6 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.CMSContainer; import com.arsdigita.cms.ui.CMSContainer;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.CcmObjectSelectionModel; import com.arsdigita.ui.CcmObjectSelectionModel;
import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
@ -66,7 +54,6 @@ import org.librecms.contentsection.ContentType;
*/ */
public class TasksPanel extends CMSContainer { public class TasksPanel extends CMSContainer {
private static Logger s_log = Logger.getLogger(TasksPanel.class);
// The default number of rows to show // The default number of rows to show
private static final int DEFAULT_MAX_ROWS = 15; private static final int DEFAULT_MAX_ROWS = 15;
// Number of tasks to show // Number of tasks to show

View File

@ -24,15 +24,12 @@ import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
class FolderAddForm extends FolderBaseForm { class FolderAddForm extends FolderBaseForm {
private static Logger s_log = Logger.getLogger(FolderAddForm.class);
private final SingleSelectionModel<Long> m_model; private final SingleSelectionModel<Long> m_model;
private final FolderRequestLocal m_parent; private final FolderRequestLocal m_parent;

View File

@ -36,12 +36,10 @@ import com.arsdigita.cms.ui.BaseDeleteForm;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.SelectionPanel; import com.arsdigita.toolbox.ui.SelectionPanel;
import org.apache.log4j.Logger;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import java.math.BigDecimal;
/** /**
* A pane that contains a folder tree on the left and a folder manipulator on * A pane that contains a folder tree on the left and a folder manipulator on
@ -51,8 +49,6 @@ import java.math.BigDecimal;
*/ */
public class FolderAdminPane extends SelectionPanel { public class FolderAdminPane extends SelectionPanel {
private static final Logger s_log = Logger.getLogger(FolderAdminPane.class);
private final FolderRequestLocal m_folder; private final FolderRequestLocal m_folder;
private final BigDecimalParameter m_param; private final BigDecimalParameter m_param;

View File

@ -26,24 +26,23 @@ import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.TrimmedStringParameter; import com.arsdigita.bebop.parameters.TrimmedStringParameter;
import org.librecms.contentsection.ContentItem;
import com.arsdigita.cms.ui.CMSForm; import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
/** /**
* Class FolderForm implements the basic form for creating or renaming folders. * Class FolderForm implements the basic form for creating or renaming folders.
* *
* @author Jon Orris &lt;jorris@redhat.com&gt; * @author Jon Orris &lt;jorris@redhat.com&gt;
* @version $Id$
*/ */
abstract class FolderBaseForm extends CMSForm { abstract class FolderBaseForm extends CMSForm {
private static Logger s_log = Logger.getLogger(FolderBaseForm.class); private static Logger LOGGER = LogManager.getLogger(FolderBaseForm.class);
public static final String NAME = "ContentItemName"; public static final String NAME = "ContentItemName";
public static final String TITLE = "ContentPageTitle"; public static final String TITLE = "ContentPageTitle";

View File

@ -48,7 +48,8 @@ import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.toolbox.ui.FormatStandards; import com.arsdigita.toolbox.ui.FormatStandards;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.auditing.CcmRevision; import org.libreccm.auditing.CcmRevision;
import java.util.ArrayList; import java.util.ArrayList;
@ -91,7 +92,9 @@ import java.util.Date;
*/ */
public class FolderBrowser extends Table { public class FolderBrowser extends Table {
private static final Logger s_log = Logger.getLogger(FolderBrowser.class); private static final Logger LOGGER = LogManager.getLogger(
FolderBrowser.class);
private static GlobalizedMessage[] s_headers = { private static GlobalizedMessage[] s_headers = {
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.name"),
globalize("cms.ui.folder.languages"), globalize("cms.ui.folder.languages"),
@ -551,20 +554,21 @@ public class FolderBrowser extends Table {
*/ */
private static class ActionCellRenderer implements TableCellRenderer { private static class ActionCellRenderer implements TableCellRenderer {
private static final Label s_noAction; private static final Logger LOGGER = LogManager.getLogger(
private static final ControlLink s_link;
private static final Logger logger = Logger.getLogger(
ActionCellRenderer.class); ActionCellRenderer.class);
private static final Label s_noAction;
private static final ControlLink s_link;
static { static {
logger.debug("Static initializer is starting..."); LOGGER.debug("Static initializer is starting...");
s_noAction = new Label("&nbsp;", false); s_noAction = new Label("&nbsp;", false);
s_noAction.lock(); s_noAction.lock();
s_link = new ControlLink( s_link = new ControlLink(
new Label(globalize("cms.ui.folder.delete"))); new Label(globalize("cms.ui.folder.delete")));
s_link.setConfirmation( s_link.setConfirmation(
globalize("cms.ui.folder.delete_confirmation")); globalize("cms.ui.folder.delete_confirmation"));
logger.debug("Static initializer finished."); LOGGER.debug("Static initializer finished.");
} }
@Override @Override
@ -760,8 +764,8 @@ public class FolderBrowser extends Table {
} }
public boolean isDeletable() { public boolean isDeletable() {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Checking to see if " + this + " is deletable"); LOGGER.debug("Checking to see if " + this + " is deletable");
} }
// if (m_itemColl.isFolder()) { // if (m_itemColl.isFolder()) {
@ -785,15 +789,15 @@ public class FolderBrowser extends Table {
// } else // } else
if (itemManager.isLive(m_itemColl.get(index))) { if (itemManager.isLive(m_itemColl.get(index))) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug( LOGGER.debug(
"This item has a live instance; it cannot be deleted"); "This item has a live instance; it cannot be deleted");
} }
return false; return false;
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug( LOGGER.debug(
"The item is not a folder and doesn't have a live instance; it may be deleted"); "The item is not a folder and doesn't have a live instance; it may be deleted");
} }
return true; return true;

View File

@ -18,21 +18,21 @@
*/ */
package com.arsdigita.cms.ui.folder; package com.arsdigita.cms.ui.folder;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
class FolderEditForm extends FolderBaseForm { class FolderEditForm extends FolderBaseForm {
private static Logger s_log = Logger.getLogger(FolderEditForm.class); private static Logger LOGGER = LogManager.getLogger(FolderEditForm.class);
private final FolderRequestLocal m_folder; private final FolderRequestLocal m_folder;

View File

@ -67,12 +67,13 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import org.apache.log4j.Logger;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -98,7 +99,6 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
* Browse folders and manipulate them with various actions (move/copy/delete). * Browse folders and manipulate them with various actions (move/copy/delete).
* *
* @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a> * @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a>
* @version $Id$
*/ */
@SuppressWarnings("PMD.BeanMembersShouldSerialize") @SuppressWarnings("PMD.BeanMembersShouldSerialize")
public class FolderManipulator extends SimpleContainer implements public class FolderManipulator extends SimpleContainer implements
@ -108,8 +108,9 @@ public class FolderManipulator extends SimpleContainer implements
Resettable { Resettable {
//public static final String RESOURCE_BUNDLE = "com.arsdigita.cms.ui.folder.CMSFolderResources"; //public static final String RESOURCE_BUNDLE = "com.arsdigita.cms.ui.folder.CMSFolderResources";
private static final Logger LOGGER = Logger.getLogger( private static final Logger LOGGER = LogManager.getLogger(
FolderManipulator.class); FolderManipulator.class);
private static final String ATOZ_FILTER_PARAM = "aToZfilter"; private static final String ATOZ_FILTER_PARAM = "aToZfilter";
private static final String ACTION_PARAM = "act"; private static final String ACTION_PARAM = "act";
private static final String FILTER_PARAM = "filter"; private static final String FILTER_PARAM = "filter";

View File

@ -22,18 +22,15 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.cms.ui.CcmObjectRequestLocal; import com.arsdigita.cms.ui.CcmObjectRequestLocal;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.Folder; import org.librecms.contentsection.Folder;
import java.util.Optional;
public class FolderRequestLocal extends CcmObjectRequestLocal { public class FolderRequestLocal extends CcmObjectRequestLocal {
private static final Logger s_log = Logger.getLogger(
FolderRequestLocal.class);
private final SingleSelectionModel m_model; private final SingleSelectionModel m_model;
public FolderRequestLocal(final SingleSelectionModel model) { public FolderRequestLocal(final SingleSelectionModel model) {
@ -57,7 +54,15 @@ public class FolderRequestLocal extends CcmObjectRequestLocal {
} }
public final Folder getFolder(final PageState state) { public final Folder getFolder(final PageState state) {
return (Folder) get(state); final Object object = get(state);
final Object selected;
if (object instanceof Optional) {
selected = ((Optional<?>) object).get();
} else {
selected = object;
}
return (Folder) selected;
} }
} }

View File

@ -24,7 +24,7 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.ui.CcmObjectSelectionModel; import com.arsdigita.ui.CcmObjectSelectionModel;
import org.apache.log4j.Category; import org.libreccm.categorization.Category;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.Folder; import org.librecms.contentsection.Folder;

View File

@ -22,7 +22,7 @@ import com.arsdigita.bebop.Tree;
public class FolderTree extends Tree { public class FolderTree extends Tree {
public FolderTree(FolderSelectionModel folderSel) { public FolderTree(final FolderSelectionModel folderSel) {
super(new FolderTreeModelBuilder()); super(new FolderTreeModelBuilder());
setSelectionModel(folderSel); setSelectionModel(folderSel);
} }

View File

@ -24,12 +24,17 @@ import com.arsdigita.bebop.tree.TreeModel;
import com.arsdigita.bebop.tree.TreeModelBuilder; import com.arsdigita.bebop.tree.TreeModelBuilder;
import com.arsdigita.bebop.tree.TreeNode; import com.arsdigita.bebop.tree.TreeNode;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.Folder;
/** /**
* A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees * A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees
@ -41,19 +46,17 @@ import org.libreccm.categorization.Category;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class FolderTreeModelBuilder extends LockableImpl public class FolderTreeModelBuilder extends LockableImpl
implements TreeModelBuilder { implements TreeModelBuilder {
private static final Logger s_log = Logger.getLogger(
FolderTreeModelBuilder.class);
/** /**
* Make a tree model that lists the hierarchy of folders underneath the * Make a tree model that lists the hierarchy of folders underneath the
* folder returned by {@link #getRoot getRoot}. * folder returned by {@link #getRoot getRoot}.
* *
* @param tree the tree in which the model is used * @param tree the tree in which the model is used
* @param state represents the current request * @param state represents the current request
*
* @return a tree model that lists the hierarchy of folders underneath the * @return a tree model that lists the hierarchy of folders underneath the
* folder returnedby {@link #getRoot getRoot}. * folder returned by {@link #getRoot getRoot}.
*/ */
@Override @Override
public TreeModel makeModel(final Tree tree, final PageState state) { public TreeModel makeModel(final Tree tree, final PageState state) {
@ -67,28 +70,35 @@ public class FolderTreeModelBuilder extends LockableImpl
@Override @Override
public boolean hasChildren(final TreeNode node, public boolean hasChildren(final TreeNode node,
final PageState state) { final PageState state) {
return !((Category) node.getElement()).getSubCategories(). final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
isEmpty(); final FolderTreeModelController controller = cdiUtil.findBean(
FolderTreeModelController.class);
return controller.hasChildren(node);
} }
@Override @Override
public Iterator getChildren(final TreeNode node, public Iterator<Folder> getChildren(final TreeNode node,
final PageState state) { final PageState state) {
final String nodeKey = node.getKey().toString(); final String nodeKey = node.getKey().toString();
// Always expand root node // Always expand root node
if (nodeKey.equals(getRoot(state).getKey().toString()) if (nodeKey.equals(getRoot(state).getKey().toString())
&& tree.isCollapsed(nodeKey, state)) { && tree.isCollapsed(nodeKey, state)) {
tree.expand(nodeKey, state); tree.expand(nodeKey, state);
} }
if (tree.isCollapsed(nodeKey, state)) { if (tree.isCollapsed(nodeKey, state)) {
return Collections.EMPTY_LIST.iterator(); return Collections.emptyIterator();
} }
return ((Category) node.getElement()).getSubCategories(). final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
iterator(); final FolderTreeModelController controller = cdiUtil.findBean(
FolderTreeModelController.class);
return controller.getChildren(node);
} }
}; };
/*return new DataQueryTreeModel(getRoot(state).getID(), /*return new DataQueryTreeModel(getRoot(state).getID(),
@ -140,20 +150,22 @@ public class FolderTreeModelBuilder extends LockableImpl
* Retrn the root folder for the tree model in the current request. * Retrn the root folder for the tree model in the current request.
* *
* @param state represents the current request * @param state represents the current request
*
* @return the root folder for the tree * @return the root folder for the tree
* @post return != null *
*/ */
protected Category getRootFolder(final PageState state) protected Folder getRootFolder(final PageState state)
throws IllegalStateException { throws IllegalStateException {
ContentSection sec = CMS.getContext().getContentSection();
return sec.getRootDocumentsFolder(); final ContentSection section = CMS.getContext().getContentSection();
return section.getRootDocumentsFolder();
} }
private class FolderTreeNode implements TreeNode { private class FolderTreeNode implements TreeNode {
private Category folder; private final Folder folder;
public FolderTreeNode(final Category folder) { public FolderTreeNode(final Folder folder) {
this.folder = folder; this.folder = folder;
} }

View File

@ -34,7 +34,6 @@ import com.arsdigita.cms.ui.FormSecurityListener;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
@ -49,9 +48,6 @@ import java.util.Locale;
*/ */
class BaseLifecycleForm extends BaseForm { class BaseLifecycleForm extends BaseForm {
private static final Logger s_log = Logger
.getLogger(BaseLifecycleForm.class);
final TextField m_name; final TextField m_name;
final TextArea m_description; final TextArea m_description;
@ -92,7 +88,7 @@ class BaseLifecycleForm extends BaseForm {
@Override @Override
public final void validate(final ParameterEvent e) public final void validate(final ParameterEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ConfigurationManager confManager = cdiUtil.findBean( final ConfigurationManager confManager = cdiUtil.findBean(

View File

@ -32,29 +32,27 @@ import com.arsdigita.cms.ui.BaseAdminPane;
import com.arsdigita.cms.ui.BaseDeleteForm; import com.arsdigita.cms.ui.BaseDeleteForm;
import com.arsdigita.cms.ui.FormSecurityListener; import com.arsdigita.cms.ui.FormSecurityListener;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSectionManager; import org.librecms.contentsection.ContentSectionManager;
import org.librecms.contentsection.privileges.AdminPrivileges; import org.librecms.contentsection.privileges.AdminPrivileges;
import org.librecms.lifecycle.Lifecycle;
import org.librecms.lifecycle.LifecycleDefinitionRepository; import org.librecms.lifecycle.LifecycleDefinitionRepository;
import java.math.BigDecimal;
/** /**
* <p>
* This class contains the split pane for the lifecycle administration * This class contains the split pane for the lifecycle administration
* interface.</p> * interface.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @author Michael Pih * @author Michael Pih
* @author Jack Chung * @author Jack Chung
* @author <a href="mailto:jross@redhat.com">Justin Ross</a> * @author <a href="mailto:jross@redhat.com">Justin Ross</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class LifecycleAdminPane extends BaseAdminPane { public class LifecycleAdminPane extends BaseAdminPane {
private static Logger s_log = Logger.getLogger(LifecycleAdminPane.class); private static Logger LOGGER = LogManager.getLogger(LifecycleAdminPane.class);
private final SingleSelectionModel m_model; private final SingleSelectionModel m_model;
private final LifecycleDefinitionRequestLocal m_definition; private final LifecycleDefinitionRequestLocal m_definition;

View File

@ -20,16 +20,14 @@ package com.arsdigita.cms.ui.lifecycle;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import org.librecms.lifecycle.LifecycleDefinition; import org.librecms.lifecycle.LifecycleDefinition;
import org.apache.log4j.Logger;
public abstract class LifecycleDefinitionRequestLocal extends RequestLocal { public abstract class LifecycleDefinitionRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger public final LifecycleDefinition getLifecycleDefinition(
(LifecycleDefinitionRequestLocal.class); final PageState state) {
public final LifecycleDefinition getLifecycleDefinition
(final PageState state) {
return (LifecycleDefinition) get(state); return (LifecycleDefinition) get(state);
} }
} }

View File

@ -28,10 +28,8 @@ import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.table.DefaultTableCellRenderer; import com.arsdigita.bebop.table.DefaultTableCellRenderer;
import com.arsdigita.cms.CMS;
import org.librecms.lifecycle.LifecycleDefinition; import org.librecms.lifecycle.LifecycleDefinition;
import org.librecms.lifecycle.PhaseDefinition;
import com.arsdigita.cms.ui.BaseItemPane; import com.arsdigita.cms.ui.BaseItemPane;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
@ -40,13 +38,9 @@ import com.arsdigita.toolbox.ui.Property;
import com.arsdigita.toolbox.ui.PropertyList; import com.arsdigita.toolbox.ui.PropertyList;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.AdminPrivileges; import org.librecms.contentsection.privileges.AdminPrivileges;
import org.librecms.lifecycle.PhaseDefinititionRepository; import org.librecms.lifecycle.PhaseDefinititionRepository;
@ -66,9 +60,6 @@ import java.util.Locale;
*/ */
class LifecycleItemPane extends BaseItemPane { class LifecycleItemPane extends BaseItemPane {
private static final Logger s_log = Logger
.getLogger(LifecycleItemPane.class);
private final LifecycleDefinitionRequestLocal m_cycle; private final LifecycleDefinitionRequestLocal m_cycle;
private final PhaseRequestLocal m_phase; private final PhaseRequestLocal m_phase;

View File

@ -20,13 +20,11 @@ package com.arsdigita.cms.ui.lifecycle;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import org.librecms.lifecycle.PhaseDefinition; import org.librecms.lifecycle.PhaseDefinition;
import org.apache.log4j.Logger;
public abstract class PhaseRequestLocal extends RequestLocal { public abstract class PhaseRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger
(PhaseRequestLocal.class);
public final PhaseDefinition getPhase(final PageState state) { public final PhaseDefinition getPhase(final PageState state) {
return (PhaseDefinition) get(state); return (PhaseDefinition) get(state);

View File

@ -63,10 +63,9 @@ import java.util.Map;
* @author sdeusch@arsdigita.com * @author sdeusch@arsdigita.com
* @authro <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @authro <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class CMSPermissionsPane extends SimpleContainer public class CMSPermissionsPane extends SimpleContainer implements Resettable,
implements Resettable, ActionListener,
ActionListener, RequestListener {
RequestListener {
// non-shared parameter models; leave package scope for access from its members. // non-shared parameter models; leave package scope for access from its members.
private ParameterModel searchString = new StringParameter( private ParameterModel searchString = new StringParameter(

View File

@ -205,7 +205,7 @@ class CMSPermissionsTables {
} }
if (type == DIRECT) { if (type == DIRECT) {
headers[privileges.length + 1] = PERM_TABLE_ACTIONS.localize() headers[privileges.length + 1] = PERM_TABLE_ACTIONS.localize()
+ ""; + "";
} }
return headers; return headers;
} }
@ -317,15 +317,13 @@ class CMSPermissionsTables {
public TableModel makeModel(final Table table, public TableModel makeModel(final Table table,
final PageState state) { final PageState state) {
final CcmObject object = parent.getObject(state); final CcmObject object = parent.getObject(state);
final List<Permission> permissions = object.getPermissions();
switch (m_type) { switch (m_type) {
case DIRECT: case DIRECT:
return new DirectPermissionsTableModel(permissions, return new DirectPermissionsTableModel(object);
object);
case INHERITED: case INHERITED:
return new DirectPermissionsTableModel(permissions, return new DirectPermissionsTableModel(
object); object);
default: default:
return null; return null;
} }
@ -340,9 +338,9 @@ class CMSPermissionsTables {
private final Iterator<Permission> iterator; private final Iterator<Permission> iterator;
private Permission currentPermission; private Permission currentPermission;
public DirectPermissionsTableModel(final List<Permission> permissions, public DirectPermissionsTableModel(final CcmObject object) {
final CcmObject object) { // this.iterator = permissions.iterator();
this.iterator = permissions.iterator(); throw new UnsupportedOperationException();
} }
@Override @Override
@ -442,9 +440,8 @@ class CMSPermissionsTables {
private final class InheritedPermissionsTableModel private final class InheritedPermissionsTableModel
extends DirectPermissionsTableModel { extends DirectPermissionsTableModel {
public InheritedPermissionsTableModel(final List<Permission> permissions, public InheritedPermissionsTableModel(final CcmObject object) {
final CcmObject object) { super(object);
super(permissions, object);
} }
@Override @Override
@ -547,106 +544,3 @@ class CMSPermissionsTables {
} }
} }
/**
* Utility class to encode a user privilege in the bebop table
*/
final class UserPrivilegeKey {
private final String objectId;
private final String granteeId;
private final String privilege;
private final boolean granted;
public UserPrivilegeKey(final Long objectId,
final Long granteeId,
final String privilege,
final boolean granted) {
this.objectId = objectId.toString();
this.granteeId = granteeId.toString();
this.privilege = privilege;
this.granted = granted;
}
@Override
public String toString() {
return String.format("%s{ %s }",
super.toString(),
String.join(".", privilege,
objectId,
granteeId,
Boolean.toString(granted)));
}
/**
* Decodes the information in a key into the helper class
*
* @see PermissionStatus
*/
static PermissionStatus undescribe(final String key) {
final int i = key.indexOf(".");
final int j = key.indexOf(".", i + 1);
final int k = key.lastIndexOf(".");
final String privilege = key.substring(0, i);
final Long oID = Long.parseLong(key.substring(i + 1, j));
final Long gID = Long.parseLong(key.substring(j + 1, k));
boolean granted = false;
final CMSUserObjectStruct uos;
try {
granted = Boolean.parseBoolean(key.substring(k + 1, k + 2));
uos = new CMSUserObjectStruct(gID, oID);
} catch (NumberFormatException ex) {
// cannot decode
throw new IllegalArgumentException(ex.getMessage());
}
return new PermissionStatus(privilege,
uos.getObject(),
uos.getRole(),
granted);
}
}
/**
* Structure to hold a permission and its current grant state
*/
final class PermissionStatus {
private final boolean granted;
private final CcmObject object;
private final Role role;
private final String privilege;
PermissionStatus(final String privilege,
final CcmObject object,
final Role role,
final boolean granted) {
this.granted = granted;
this.object = object;
this.role = role;
this.privilege = privilege;
}
boolean isGranted() {
return granted;
}
CcmObject getObject() {
return object;
}
Role getRole() {
return role;
}
String getPrivilege() {
return privilege;
}
}

View File

@ -33,7 +33,6 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.admin.GlobalizationUtil; import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionManager; import org.libreccm.security.PermissionManager;
import org.libreccm.security.Role; import org.libreccm.security.Role;
@ -41,19 +40,21 @@ import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.privileges.AdminPrivileges; import org.librecms.contentsection.privileges.AdminPrivileges;
import java.util.*; import java.util.Collection;
import java.util.List;
import java.util.TooManyListenersException;
/** /**
* For more detailed information see {@link com.arsdigita.bebop.Form}. * For more detailed information see {@link com.arsdigita.bebop.Form}.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a> * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: BaseRoleForm.java 287 2005-02-22 00:29:02Z sskracic $ *
*/ */
class BaseRoleForm extends BaseForm { class BaseRoleForm extends BaseForm {
private static final Logger s_log = Logger.getLogger(BaseRoleForm.class);
final Name m_name; final Name m_name;
final Description m_description; final Description m_description;
CheckboxGroup m_privileges; CheckboxGroup m_privileges;

View File

@ -24,28 +24,26 @@ import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.*;
import java.util.ArrayList;
import java.util.Arrays; import org.libreccm.security.PermissionManager;
import java.util.List; import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
/** /**
* Provides a {@link com.arsdigita.bebop.Form} for adding {@link Role roles}. * Provides a {@link com.arsdigita.bebop.Form} for adding {@link Role roles}.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Michael Pih * @author Michael Pih
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: RoleAddForm.java 287 2005-02-22 00:29:02Z sskracic $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
final class RoleAddForm extends BaseRoleForm { final class RoleAddForm extends BaseRoleForm {
private static final Logger s_log = Logger.getLogger(RoleAddForm.class);
private SingleSelectionModel m_model; private SingleSelectionModel m_model;
RoleAddForm(SingleSelectionModel model) { RoleAddForm(SingleSelectionModel model) {

View File

@ -24,27 +24,34 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.*; import org.libreccm.security.Permission;
import org.libreccm.security.PermissionManager;
import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* Represents a {@link com.arsdigita.bebop.Form Form} to edit {@link Role roles}. * Represents a {@link com.arsdigita.bebop.Form Form} to edit
* {@link Role roles}.
*
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Michael Pih * @author Michael Pih
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: RoleEditForm.java 287 2005-02-22 00:29:02Z sskracic $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
final class RoleEditForm extends BaseRoleForm { final class RoleEditForm extends BaseRoleForm {
private static final Logger s_log = Logger.getLogger(RoleEditForm.class); private static final Logger LOGGER = LogManager
.getLogger(RoleEditForm.class);
private final RoleRequestLocal m_role; private final RoleRequestLocal m_role;
@ -60,9 +67,11 @@ final class RoleEditForm extends BaseRoleForm {
} }
/** /**
* Sets the initial values of a {@link Role} which were received from the database. * Sets the initial values of a {@link Role} which were received from the
* database.
*/ */
private class InitListener implements FormInitListener { private class InitListener implements FormInitListener {
@Override @Override
public final void init(final FormSectionEvent e) { public final void init(final FormSectionEvent e) {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
@ -72,57 +81,71 @@ final class RoleEditForm extends BaseRoleForm {
m_description.setValue(state, role.getDescription()); m_description.setValue(state, role.getDescription());
final String[] permissions = role.getPermissions().stream(). final String[] permissions = role.getPermissions().stream().
map(Permission::getGrantedPrivilege).toArray(String[]::new); map(Permission::getGrantedPrivilege).toArray(String[]::new);
m_privileges.setValue(state, permissions); m_privileges.setValue(state, permissions);
} }
} }
/** /**
* Updates a role and it's permissions. It uses the {@link PermissionManager} to grant and revoke permissions * Updates a role and it's permissions. It uses the
* as needed. * {@link PermissionManager} to grant and revoke permissions as needed.
* *
* NOTE: The part about granting and revoking privileges is mostly identical to {@link RoleAddForm}. * NOTE: The part about granting and revoking privileges is mostly identical
* If you find any bugs or errors in this code, be sure to change it there accordingly. * to {@link RoleAddForm}. If you find any bugs or errors in this code, be
* sure to change it there accordingly.
*/ */
private class ProcessListener implements FormProcessListener { private class ProcessListener implements FormProcessListener {
@Override @Override
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final Role role = m_role.getRole(state); final Role role = m_role.getRole(state);
role.setName((String) m_name.getValue(state)); role.setName((String) m_name.getValue(state));
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionManager permissionManager = cdiUtil.findBean(PermissionManager.class); final PermissionManager permissionManager = cdiUtil.findBean(
final ConfigurationManager manager = cdiUtil.findBean(ConfigurationManager.class); PermissionManager.class);
final KernelConfig config = manager.findConfiguration(KernelConfig.class); final ConfigurationManager manager = cdiUtil.findBean(
final RoleRepository roleRepository = cdiUtil.findBean(RoleRepository.class); ConfigurationManager.class);
final KernelConfig config = manager.findConfiguration(
KernelConfig.class);
final RoleRepository roleRepository = cdiUtil.findBean(
RoleRepository.class);
LocalizedString localizedDescription = role.getDescription(); LocalizedString localizedDescription = role.getDescription();
localizedDescription.addValue(config.getDefaultLocale(), (String) m_description.getValue(state)); localizedDescription.addValue(config.getDefaultLocale(),
(String) m_description.getValue(state));
role.setDescription(localizedDescription); role.setDescription(localizedDescription);
//We don't now if the permissions list is empty, so we have to save beforehand to not lose data. //We don't now if the permissions list is empty, so we have to save beforehand to not lose data.
roleRepository.save(role); roleRepository.save(role);
List<Permission> newPermissions = new ArrayList<>(); List<Permission> newPermissions = new ArrayList<>();
String[] selectedPermissions = (String[]) m_privileges.getValue(state); String[] selectedPermissions = (String[]) m_privileges.getValue(
state);
for (Permission p : role.getPermissions()) { for (Permission p : role.getPermissions()) {
if (Arrays.stream(selectedPermissions).anyMatch(x -> x.equals(p.getGrantedPrivilege()))) { if (Arrays.stream(selectedPermissions).anyMatch(x -> x.equals(p
.getGrantedPrivilege()))) {
newPermissions.add(p); newPermissions.add(p);
} else { } else {
permissionManager.revokePrivilege(p.getGrantedPrivilege(), role); permissionManager.revokePrivilege(p.getGrantedPrivilege(),
role);
} }
} }
for (String s : selectedPermissions) { for (String s : selectedPermissions) {
if (newPermissions.stream().noneMatch(x -> x.getGrantedPrivilege().equals(s))) { if (newPermissions.stream().noneMatch(x -> x
.getGrantedPrivilege().equals(s))) {
permissionManager.grantPrivilege(s, role); permissionManager.grantPrivilege(s, role);
} }
} }
} }
} }
} }

View File

@ -29,7 +29,8 @@ import com.arsdigita.cms.ui.PartyAddForm;
import com.arsdigita.ui.admin.GlobalizationUtil; import com.arsdigita.ui.admin.GlobalizationUtil;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.*; import org.libreccm.security.*;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
@ -39,22 +40,21 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* Adds a form which can add {@link Party parties} to {@link Role roles}. * Adds a form which can add {@link Party parties} to {@link Role roles}. Also
* Also enables searching for parties. * enables searching for parties.
*
* NOTE: In earlier versions it was also possible to filter parties using
* {@link User} attributes such as username, name, last name, etc. This feature
* may be added later if still needed.
* *
* NOTE: In earlier versions it was also possible to filter
* parties using {@link User} attributes such as username, name, last name, etc.
* This feature may be added later if still needed.
* *
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
* @author Michael Pih * @author Michael Pih
* @author Uday Mathur * @author Uday Mathur
* @version $Id: RolePartyAddForm.java 287 2005-02-22 00:29:02Z sskracic $ * @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
*/ */
class RolePartyAddForm extends PartyAddForm { class RolePartyAddForm extends PartyAddForm {
private static Logger s_log = Logger.getLogger private static Logger LOGGER = LogManager.getLogger(RolePartyAddForm.class);
(RolePartyAddForm.class);
private SingleSelectionModel m_roles; private SingleSelectionModel m_roles;
@ -63,17 +63,17 @@ class RolePartyAddForm extends PartyAddForm {
m_roles = roles; m_roles = roles;
getForm().addSubmissionListener getForm().addSubmissionListener(new FormSecurityListener(
(new FormSecurityListener(AdminPrivileges.ADMINISTER_ROLES)); AdminPrivileges.ADMINISTER_ROLES));
} }
@Override @Override
protected List<Party> makeQuery(PageState s) { protected List<Party> makeQuery(PageState s) {
Assert.isTrue(m_roles.isSelected(s)); Assert.isTrue(m_roles.isSelected(s));
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class); final PartyRepository partyRepository = cdiUtil.findBean(
PartyRepository.class);
final String searchQuery = (String) getSearchWidget().getValue(s); final String searchQuery = (String) getSearchWidget().getValue(s);
@ -87,29 +87,32 @@ class RolePartyAddForm extends PartyAddForm {
Assert.isTrue(m_roles.isSelected(state)); Assert.isTrue(m_roles.isSelected(state));
String[] parties = (String[]) data.get("parties"); String[] parties = (String[]) data.get("parties");
s_log.debug("PARTIES = " + Arrays.toString(parties)); LOGGER.debug("PARTIES = " + Arrays.toString(parties));
if (parties == null) { if (parties == null) {
throw new FormProcessException(GlobalizationUtil.globalize( throw new FormProcessException(GlobalizationUtil.globalize(
"cms.ui.role.no_party_selected")); "cms.ui.role.no_party_selected"));
} }
final Long roleId = new Long((String) m_roles.getSelectedKey(state)); final Long roleId = new Long((String) m_roles.getSelectedKey(state));
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final RoleRepository roleRepository = cdiUtil.findBean(RoleRepository.class); final RoleRepository roleRepository = cdiUtil.findBean(
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class); RoleRepository.class);
final PartyRepository partyRepository = cdiUtil.findBean(
PartyRepository.class);
final RoleManager roleManager = cdiUtil.findBean(RoleManager.class); final RoleManager roleManager = cdiUtil.findBean(RoleManager.class);
final Role role = roleRepository.findById(roleId).get(); final Role role = roleRepository.findById(roleId).get();
// Add each checked party to the role // Add each checked party to the role
Party party; Party party;
for ( int i = 0; i < parties.length; i++ ) { for (int i = 0; i < parties.length; i++) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("parties[" + i + "] = " + parties[i]); LOGGER.debug("parties[" + i + "] = " + parties[i]);
} }
party = partyRepository.findByName(parties[i]).get(); party = partyRepository.findByName(parties[i]).get();
roleManager.assignRoleToParty(role, party); roleManager.assignRoleToParty(role, party);
} }
} }
} }

View File

@ -42,7 +42,8 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.toolbox.ui.ActionGroup; import com.arsdigita.toolbox.ui.ActionGroup;
import com.arsdigita.toolbox.ui.Cancellable; import com.arsdigita.toolbox.ui.Cancellable;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSectionManager; import org.librecms.contentsection.ContentSectionManager;
@ -60,8 +61,9 @@ import org.librecms.contentsection.ContentTypeManager;
*/ */
public final class ContentTypeAdminPane extends BaseAdminPane { public final class ContentTypeAdminPane extends BaseAdminPane {
private static final Logger s_log = Logger.getLogger( private static final Logger LOGGER = LogManager.getLogger(
ContentTypeAdminPane.class); ContentTypeAdminPane.class);
private final ACSObjectSelectionModel m_model; private final ACSObjectSelectionModel m_model;
private final ContentTypeRequestLocal m_type; private final ContentTypeRequestLocal m_type;
@ -252,8 +254,8 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
private void resetPane(final PageState state) { private void resetPane(final PageState state) {
getBody().reset(state); getBody().reset(state);
if (getSelectionModel().isSelected(state)) { if (getSelectionModel().isSelected(state)) {
s_log.debug("The selection model is selected; displaying " LOGGER.debug("The selection model is selected; displaying "
+ "the item pane"); + "the item pane");
getBody().push(state, getItemPane()); getBody().push(state, getItemPane());
} }
} }

View File

@ -43,7 +43,6 @@ import com.arsdigita.toolbox.ui.Cancellable;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.librecms.contentsection.ContentSectionManager; import org.librecms.contentsection.ContentSectionManager;
@ -57,7 +56,6 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
*/ */
final class ContentTypeItemPane extends BaseItemPane { final class ContentTypeItemPane extends BaseItemPane {
private static Logger s_log = Logger.getLogger(ContentTypeItemPane.class);
private final ACSObjectSelectionModel m_model; private final ACSObjectSelectionModel m_model;
private final ContentTypeRequestLocal m_type; private final ContentTypeRequestLocal m_type;
private final SimpleContainer m_detailPane; private final SimpleContainer m_detailPane;
@ -83,10 +81,10 @@ final class ContentTypeItemPane extends BaseItemPane {
// m_templates = new SectionTemplatesListing( // m_templates = new SectionTemplatesListing(
// new ContentSectionRequestLocal(), m_type); // new ContentSectionRequestLocal(), m_type);
m_permissions = new TypePermissionsTable( m_permissions = new TypePermissionsTable(
new ContentSectionRequestLocal(), m_type); new ContentSectionRequestLocal(), m_type);
final ActionLink templateAddLink = new ActionLink(new Label(gz( final ActionLink templateAddLink = new ActionLink(new Label(gz(
"cms.ui.type.template.add"))); "cms.ui.type.template.add")));
// ToDo // ToDo
// final TemplateCreate templateFormSection = new TemplateCreate(m_model); // final TemplateCreate templateFormSection = new TemplateCreate(m_model);
// final Form templateForm = new CancellableForm("AddTemplate", // final Form templateForm = new CancellableForm("AddTemplate",
@ -173,6 +171,7 @@ final class ContentTypeItemPane extends BaseItemPane {
public final boolean isCancelled(final PageState state) { public final boolean isCancelled(final PageState state) {
return m_cancel.isSelected(state); return m_cancel.isSelected(state);
} }
} }
private class SummarySection extends Section { private class SummarySection extends Section {
@ -189,6 +188,7 @@ final class ContentTypeItemPane extends BaseItemPane {
group.addAction(new TypeSecurityContainer(editLink)); group.addAction(new TypeSecurityContainer(editLink));
group.addAction(new TypeSecurityContainer(deleteLink)); group.addAction(new TypeSecurityContainer(deleteLink));
} }
} }
private class ElementSection extends Section { private class ElementSection extends Section {
@ -209,6 +209,7 @@ final class ContentTypeItemPane extends BaseItemPane {
// && !ContentSection.getConfig().getHideUDCTUI(); // && !ContentSection.getConfig().getHideUDCTUI();
return false; return false;
} }
} }
private class TemplateSection extends Section { private class TemplateSection extends Section {
@ -227,6 +228,7 @@ final class ContentTypeItemPane extends BaseItemPane {
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_model.isSelected(state) && !isDynamicType(state); return m_model.isSelected(state) && !isDynamicType(state);
} }
} }
private class PermissionsSection extends Section { private class PermissionsSection extends Section {
@ -245,6 +247,7 @@ final class ContentTypeItemPane extends BaseItemPane {
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_model.isSelected(state) && !isDynamicType(state); return m_model.isSelected(state) && !isDynamicType(state);
} }
} }
// private class RelationAttributeSection extends Section { // private class RelationAttributeSection extends Section {
@ -291,13 +294,14 @@ final class ContentTypeItemPane extends BaseItemPane {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
if (state.isVisibleOnPage(ContentTypeItemPane.this) if (state.isVisibleOnPage(ContentTypeItemPane.this)
&& m_model.isSelected(state) && m_model.isSelected(state)
&& !userCanEdit(state)) { && !userCanEdit(state)) {
// m_templates.getRemoveColumn().setVisible(state, false); // m_templates.getRemoveColumn().setVisible(state, false);
// m_templates.getDefaultColumn().setVisible(state, false); // m_templates.getDefaultColumn().setVisible(state, false);
// m_elements.getTable().getColumn(3).setVisible(state, false); // m_elements.getTable().getColumn(3).setVisible(state, false);
} }
} }
}); });
} }
@ -309,19 +313,19 @@ final class ContentTypeItemPane extends BaseItemPane {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentTypeManager typeManager = cdiUtil.findBean( final ContentTypeManager typeManager = cdiUtil.findBean(
ContentTypeManager.class); ContentTypeManager.class);
final ContentSectionManager sectionManager = cdiUtil.findBean( final ContentSectionManager sectionManager = cdiUtil.findBean(
ContentSectionManager.class); ContentSectionManager.class);
final ContentType type = m_type.getContentType(state); final ContentType type = m_type.getContentType(state);
final Class<? extends ContentItem> typeClass; final Class<? extends ContentItem> typeClass;
try { try {
typeClass = (Class<? extends ContentItem>) Class.forName( typeClass = (Class<? extends ContentItem>) Class.forName(
type.getContentItemClass()); type.getContentItemClass());
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
sectionManager.removeContentTypeFromSection(typeClass, section); sectionManager.removeContentTypeFromSection(typeClass, section);
} }
@ -329,11 +333,12 @@ final class ContentTypeItemPane extends BaseItemPane {
* Determine if the current user has access to edit the content type * Determine if the current user has access to edit the content type
*/ */
protected static boolean userCanEdit(final PageState state) { protected static boolean userCanEdit(final PageState state) {
final PermissionChecker permissionChecker = CdiUtil.createCdiUtil().findBean(PermissionChecker.class); final PermissionChecker permissionChecker = CdiUtil.createCdiUtil()
.findBean(PermissionChecker.class);
final ContentSection section = CMS.getContext().getContentSection(); final ContentSection section = CMS.getContext().getContentSection();
return permissionChecker.isPermitted( return permissionChecker.isPermitted(
AdminPrivileges.ADMINISTER_CONTENT_TYPES, section); AdminPrivileges.ADMINISTER_CONTENT_TYPES, section);
} }
/** /**
@ -346,4 +351,5 @@ final class ContentTypeItemPane extends BaseItemPane {
protected final boolean isDynamicType(final PageState state) { protected final boolean isDynamicType(final PageState state) {
return false; return false;
} }
} }

View File

@ -33,7 +33,6 @@ import org.libreccm.workflow.AssignableTask;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.UserRepository; import org.libreccm.security.UserRepository;
import org.libreccm.workflow.WorkflowManager; import org.libreccm.workflow.WorkflowManager;
@ -46,12 +45,9 @@ import java.util.List;
* *
* @author Uday Mathur * @author Uday Mathur
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a> * @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
* @version $Id$
*/ */
class TaskAddUser extends SimpleContainer { class TaskAddUser extends SimpleContainer {
private static final Logger s_log = Logger.getLogger(TaskAddUser.class);
private final TaskRequestLocal m_task; private final TaskRequestLocal m_task;
private SearchForm m_search; private SearchForm m_search;

View File

@ -36,6 +36,7 @@ import java.util.stream.Collectors;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EnumType; import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
@ -63,7 +64,7 @@ public class Folder extends Category implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@OneToOne @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "CONTENT_SECTION_ID") // @JoinColumn(name = "CONTENT_SECTION_ID")
@JoinTable(name = "FOLDER_CONTENT_SECTION_MAP", schema = DB_SCHEMA, @JoinTable(name = "FOLDER_CONTENT_SECTION_MAP", schema = DB_SCHEMA,
inverseJoinColumns = { inverseJoinColumns = {

View File

@ -20,7 +20,6 @@ package org.librecms.contentsection;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;

View File

@ -8,13 +8,14 @@
<jsp:directive.page import="com.arsdigita.dispatcher.*"/> <jsp:directive.page import="com.arsdigita.dispatcher.*"/>
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/> <jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
<jsp:directive.page import="com.arsdigita.web.Web"/> <jsp:directive.page import="com.arsdigita.web.Web"/>
<jsp:directive.page import="org.apache.log4j.Logger"/> <jsp:directive.page import="org.apache.logging.log4j.Logger"/>
<jsp:directive.page import="org.apache.logging.log4j.LogManager"/>
<jsp:directive.page import="java.util.Date"/> <jsp:directive.page import="java.util.Date"/>
<jsp:declaration> <jsp:declaration>
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger("content-section.www.admin.item.jsp"); LogManager.getLogger("content-section.www.admin.item.jsp");
private ContentItemPage itemPage = null; private ContentItemPage itemPage = null;
private Date timestamp = new Date(0); private Date timestamp = new Date(0);
</jsp:declaration> </jsp:declaration>

View File

@ -240,7 +240,7 @@ public class FolderManagerTest {
@InSequence(1500) @InSequence(1500)
public void createFolderEmptyName() { public void createFolderEmptyName() {
final Optional<Folder> parent = folderRepo.findById(-2005L); final Optional<Folder> parent = folderRepo.findById(-2005L);
assertThat(parent.isPresent(), is(false)); assertThat(parent.isPresent(), is(true));
final Folder test = folderManager.createFolder(" ", parent.get()); final Folder test = folderManager.createFolder(" ", parent.get());

View File

@ -85,10 +85,10 @@
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId> <artifactId>log4j-api</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId> <artifactId>log4j-1.2-api</artifactId>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>commons-beanutils</groupId> <groupId>commons-beanutils</groupId>

View File

@ -31,20 +31,15 @@ import com.arsdigita.bebop.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
/** /**
* Completable. * Completable.
* *
* @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a> * @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a>
* @version $Revision: #10 $ $Date: 2004/08/16 $
* @version $Id: Completable.java 287 2005-02-22 00:29:02Z sskracic $
**/ **/
public abstract class Completable implements Component { public abstract class Completable implements Component {
private final static Logger s_log = Logger.getLogger(Completable.class);
private ArrayList m_completionListeners = new ArrayList(); private ArrayList m_completionListeners = new ArrayList();
public Completable() { public Completable() {

View File

@ -21,7 +21,6 @@ package com.arsdigita.bebop;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
/** /**
@ -34,12 +33,6 @@ import org.apache.log4j.Logger;
*/ */
abstract public class DescriptiveComponent extends SimpleComponent { abstract public class DescriptiveComponent extends SimpleComponent {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.bebop.DescriptiveComponent=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(DescriptiveComponent.class);
/** Property to store informational text for the user about the Link, e.g. /** Property to store informational text for the user about the Link, e.g.
* how to use it, or when to use it (or not to use it). */ * how to use it, or when to use it (or not to use it). */
private GlobalizedMessage m_hint; //= GlobalizationUtil.globalize("bebop.hint.no_entry_yet"); private GlobalizedMessage m_hint; //= GlobalizationUtil.globalize("bebop.hint.no_entry_yet");

View File

@ -19,7 +19,6 @@
package com.arsdigita.bebop; package com.arsdigita.bebop;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
/** /**
* A component that gets its text entirely from a single XSL element. * A component that gets its text entirely from a single XSL element.
@ -29,9 +28,6 @@ import org.apache.log4j.Logger;
**/ **/
public class ElementComponent extends SimpleComponent { public class ElementComponent extends SimpleComponent {
private static final Logger s_log =
Logger.getLogger(ElementComponent.class.getName());
private String m_name; private String m_name;
private String m_uri; private String m_uri;

View File

@ -19,7 +19,9 @@
package com.arsdigita.bebop; package com.arsdigita.bebop;
import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.Hidden;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import com.arsdigita.bebop.util.Traversal; import com.arsdigita.bebop.util.Traversal;
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
@ -31,9 +33,10 @@ import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import java.util.Iterator; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.log4j.Logger; import java.util.Iterator;
/** /**
* Represents the visual structure of an HTML form. Forms can be constructed with a Container * Represents the visual structure of an HTML form. Forms can be constructed with a Container
@ -71,7 +74,6 @@ import org.apache.log4j.Logger;
* @author Rory Solomon * @author Rory Solomon
* @author David Lutterkort * @author David Lutterkort
* *
* @version $Id: Form.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public class Form extends FormSection implements BebopConstants { public class Form extends FormSection implements BebopConstants {
@ -80,7 +82,7 @@ public class Form extends FormSection implements BebopConstants {
* /WEB-INF/conf/log4j.properties int hte runtime environment and set * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* com.arsdigita.bebop.Form=DEBUG by uncommenting or adding the line. * com.arsdigita.bebop.Form=DEBUG by uncommenting or adding the line.
*/ */
private static final Logger s_log = Logger.getLogger(Form.class); private static final Logger LOGGER = LogManager.getLogger(Form.class);
/** /**
* Constant for specifying a <code>get</code> submission method for this form. See the <a href= * Constant for specifying a <code>get</code> submission method for this form. See the <a href=
@ -524,7 +526,7 @@ public class Form extends FormSection implements BebopConstants {
try { try {
return process(s); return process(s);
} catch (FormProcessException e) { } catch (FormProcessException e) {
s_log.error("Form Process exception", e); LOGGER.error("Form Process exception", e);
throw new UncheckedWrapperException("Form Process error: " throw new UncheckedWrapperException("Form Process error: "
+ e.getMessage(), e); + e.getMessage(), e);
} }

View File

@ -30,10 +30,13 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.Lockable; import com.arsdigita.util.Lockable;
import com.arsdigita.util.URLRewriter; import com.arsdigita.util.URLRewriter;
import com.arsdigita.web.RedirectSignal; import com.arsdigita.web.RedirectSignal;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* A container for two classes of * A container for two classes of
@ -62,11 +65,10 @@ import org.apache.log4j.Logger;
* @author Uday Mathur * @author Uday Mathur
* @author Stas Freidin * @author Stas Freidin
* @author Rory Solomon * @author Rory Solomon
* @version $Id: FormModel.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public class FormModel implements Lockable { public class FormModel implements Lockable {
private static final Logger s_log = Logger.getLogger(FormModel.class); private static final Logger LOGGER = LogManager.getLogger(FormModel.class);
private static final String MAGIC_TAG_PREFIX = "form."; private static final String MAGIC_TAG_PREFIX = "form.";
@ -147,8 +149,8 @@ public class FormModel implements Lockable {
parameter.setDefaultOverridesNull(m_defaultOverridesNull); parameter.setDefaultOverridesNull(m_defaultOverridesNull);
m_parameterModels.add(parameter); m_parameterModels.add(parameter);
if( s_log.isDebugEnabled() ) { if( LOGGER.isDebugEnabled() ) {
s_log.debug( "Added parameter: " + parameter.getName() + "[" + LOGGER.debug( "Added parameter: " + parameter.getName() + "[" +
parameter.getClass().getName() + "]" ); parameter.getClass().getName() + "]" );
} }
} }
@ -318,18 +320,18 @@ public class FormModel implements Lockable {
*/ */
void process(final PageState state, final FormData data) void process(final PageState state, final FormData data)
throws FormProcessException { throws FormProcessException {
s_log.debug("Processing the form model"); LOGGER.debug("Processing the form model");
final FormSectionEvent e = new FormSectionEvent(this, state, data); final FormSectionEvent e = new FormSectionEvent(this, state, data);
if (data.isSubmission()) { if (data.isSubmission()) {
s_log.debug("The request is a form submission; running " + LOGGER.debug("The request is a form submission; running " +
"submission listeners"); "submission listeners");
try { try {
fireSubmitted(e); fireSubmitted(e);
} catch (FormProcessException fpe) { } catch (FormProcessException fpe) {
s_log.debug("A FormProcessException was thrown while firing " + LOGGER.debug("A FormProcessException was thrown while firing " +
"submit; aborting further processing"); "submit; aborting further processing");
return; return;
} finally { } finally {
@ -337,39 +339,39 @@ public class FormModel implements Lockable {
try { try {
s_log.debug("Validating parameters"); LOGGER.debug("Validating parameters");
fireParameterValidation(e); fireParameterValidation(e);
s_log.debug("Validating form"); LOGGER.debug("Validating form");
fireFormValidation(e); fireFormValidation(e);
} finally { } finally {
} }
if (data.isValid()) { if (data.isValid()) {
s_log.debug("The form data is valid; running process " + LOGGER.debug("The form data is valid; running process " +
"listeners"); "listeners");
try { try {
fireFormProcess(e); fireFormProcess(e);
} catch (FormProcessException fpe) { } catch (FormProcessException fpe) {
s_log.debug("A FormProcessException was thrown while " + LOGGER.debug("A FormProcessException was thrown while " +
"initializing the form; storing the error", fpe); "initializing the form; storing the error", fpe);
data.addError("Initialization Aborted: " + fpe.getMessages()); data.addError("Initialization Aborted: " + fpe.getMessages());
} finally { } finally {
} }
} else { } else {
s_log.debug("The form data was not valid; this form " + LOGGER.debug("The form data was not valid; this form " +
"will not run its process listeners"); "will not run its process listeners");
} }
} else { } else {
s_log.debug("The request is not a form submission; " + LOGGER.debug("The request is not a form submission; " +
"running init listeners"); "running init listeners");
try { try {
fireFormInit(e); fireFormInit(e);
} catch (FormProcessException fpe) { } catch (FormProcessException fpe) {
s_log.debug("A FormProcessException was thrown while " + LOGGER.debug("A FormProcessException was thrown while " +
"initializing the form; storing the error", fpe); "initializing the form; storing the error", fpe);
data.addError("Initialization Aborted: " + fpe.getMessages()); data.addError("Initialization Aborted: " + fpe.getMessages());
@ -476,13 +478,13 @@ public class FormModel implements Lockable {
try { try {
((FormProcessListener) i.next()).process(e); ((FormProcessListener) i.next()).process(e);
} catch( RedirectSignal signal ) { } catch( RedirectSignal signal ) {
if( s_log.isDebugEnabled() ) { if( LOGGER.isDebugEnabled() ) {
s_log.debug( "Delaying redirect to " + LOGGER.debug( "Delaying redirect to " +
signal.getDestinationURL() ); signal.getDestinationURL() );
} }
if( null != redirect ) { if( null != redirect ) {
s_log.error( "Non-deterministic redirect. Ignoring earlier occurrence.", redirect ); LOGGER.error( "Non-deterministic redirect. Ignoring earlier occurrence.", redirect );
} }
redirect = signal; redirect = signal;

View File

@ -28,28 +28,29 @@ import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.Iterator; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.log4j.Logger; import java.util.Iterator;
/** /**
* A standalone section of a <code>Form</code>. A <code>FormSection</code> * A standalone section of a <code>Form</code>. A <code>FormSection</code>
* contains other Bebop components, most importantly * contains other Bebop components, most importantly <code>Widgets</code> and
* <code>Widgets</code> and associated listeners. It serves two purposes: * associated listeners. It serves two purposes:
* <UL> * <UL>
* <LI>Divides a form into visual sections</LI> * <LI>Divides a form into visual sections</LI>
* <LI>Serves as a container for form fragments that can function by themselves * <LI>Serves as a container for form fragments that can function by themselves
* and can be dropped into other forms</LI> * and can be dropped into other forms</LI>
* </UL> * </UL>
* <p>Since a <code>FormSection</code> has its own init, validation, and * <p>
* process listeners, it can do all of its processing without any intervention * Since a <code>FormSection</code> has its own init, validation, and process
* from the enclosing form. * listeners, it can do all of its processing without any intervention from the
* enclosing form.
* *
* Although a <code>FormSection</code> contains all the same pieces * Although a <code>FormSection</code> contains all the same pieces that a
* that a <code>Form</code> does, it can only be used if it is added * <code>Form</code> does, it can only be used if it is added directly or
* directly or indirectly to a <code>Form</code>. <code>FormSection</code>s * indirectly to a <code>Form</code>. <code>FormSection</code>s that are not
* that are not contained in a <code>Form</code> do not exhibit any useful * contained in a <code>Form</code> do not exhibit any useful behavior.
* behavior.
* *
* @see Form * @see Form
* @see FormModel * @see FormModel
@ -59,34 +60,41 @@ import org.apache.log4j.Logger;
* @author Stas Freidin * @author Stas Freidin
* @author Rory Solomon * @author Rory Solomon
* @author David Lutterkort * @author David Lutterkort
*
* @version $Id: FormSection.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public class FormSection extends DescriptiveComponent implements Container { public class FormSection extends DescriptiveComponent implements Container {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int the runtime environment * Internal logger instance to faciliate debugging. Enable logging output by
* and set com.arsdigita.subsite.FormSection=DEBUG * editing /WEB-INF/conf/log4j.properties int the runtime environment and
* by uncommenting or adding the line. */ * set com.arsdigita.subsite.FormSection=DEBUG by uncommenting or adding the
private static final Logger s_log = Logger.getLogger(FormSection.class); * line.
*/
private static final Logger LOGGER = LogManager.getLogger(FormSection.class);
/** Underlying <code>FormModel</code> that stores /**
* the parameter models for all the widgets in this form section. */ * Underlying <code>FormModel</code> that stores the parameter models for
* all the widgets in this form section.
*/
protected FormModel m_formModel; protected FormModel m_formModel;
/** The container to which all children are added. A /**
* <code>ColumnPanel</code> by default. */ * The container to which all children are added. A <code>ColumnPanel</code>
* by default.
*/
protected Container m_panel; protected Container m_panel;
/** Contains all the listeners that were added with the various /**
* addXXXListener methods. * Contains all the listeners that were added with the various
* We maintain our own list of listeners, so that we can re-send the * addXXXListener methods. We maintain our own list of listeners, so that we
* events the FormModel generates, but with us as the source, not the * can re-send the events the FormModel generates, but with us as the
* FormModel. */ * source, not the FormModel.
*/
private EventListenerList m_listeners; private EventListenerList m_listeners;
/** Listeners we attach to the FormModel to forward /**
* form model events to our listeners with the right source */ * Listeners we attach to the FormModel to forward form model events to our
* listeners with the right source
*/
private FormSubmissionListener m_forwardSubmission; private FormSubmissionListener m_forwardSubmission;
private FormInitListener m_forwardInit; private FormInitListener m_forwardInit;
@ -94,10 +102,11 @@ public class FormSection extends DescriptiveComponent implements Container {
private FormProcessListener m_forwardProcess; private FormProcessListener m_forwardProcess;
/** /**
* Constructs a new form section. Sets the implicit layout Container of * Constructs a new form section. Sets the implicit layout Container of this
* this <code>FormSection</code> to two column <code>ColumnPanel</code> * <code>FormSection</code> to two column <code>ColumnPanel</code> by
* by calling the 1-argument constructor. * calling the 1-argument constructor.
**/ *
*/
public FormSection() { public FormSection() {
this(new ColumnPanel(2, true)); this(new ColumnPanel(2, true));
} }
@ -105,24 +114,26 @@ public class FormSection extends DescriptiveComponent implements Container {
/** /**
* Constructs a new form section. Sets the form model of this * Constructs a new form section. Sets the form model of this
* <code>FormSection</code> to a new, anonymous FormModel. * <code>FormSection</code> to a new, anonymous FormModel.
* *
* @param panel * @param panel
**/ *
*/
public FormSection(Container panel) { public FormSection(Container panel) {
this(panel, new FormModel("anonymous")); this(panel, new FormModel("anonymous"));
} }
/** /**
* Constructs a new form section. Sets the implicit layout Container of * Constructs a new form section. Sets the implicit layout Container of this
* this <code>FormSection</code> to <code>panel</code>. Sets the form * <code>FormSection</code> to <code>panel</code>. Sets the form model of
* model of this <code>FormSection</code> to <code>model</code>. * this <code>FormSection</code> to <code>model</code>.
* *
* @param panel the container within this form section that holds the * @param panel the container within this form section that holds the
* components that are added to the form section with calls to the * components that are added to the form section with calls to
* <code>add</code> methods * the <code>add</code> methods
* *
* @param model the form model for this form section * @param model the form model for this form section
**/ *
*/
protected FormSection(Container panel, FormModel model) { protected FormSection(Container panel, FormModel model) {
super(); super();
m_panel = panel; m_panel = panel;
@ -135,17 +146,19 @@ public class FormSection extends DescriptiveComponent implements Container {
* initialized with the request parameters but before any of the init, * initialized with the request parameters but before any of the init,
* validation, or process listeners are run. The listener's * validation, or process listeners are run. The listener's
* <code>submitted</code> method may throw a * <code>submitted</code> method may throw a
* <code>FormProcessException</code> to signal that any further * <code>FormProcessException</code> to signal that any further processing
* processing of the form should be aborted. * of the form should be aborted.
* *
* @param listener a submission listener to run every time the form is * @param listener a submission listener to run every time the form is
* submitted * submitted
*
* @see FormModel#addSubmissionListener * @see FormModel#addSubmissionListener
* @pre listener != null * @pre listener != null
*/ */
public void addSubmissionListener(FormSubmissionListener listener) { public void addSubmissionListener(FormSubmissionListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding submission listener " + listener + " to " + this); LOGGER.debug("Adding submission listener " + listener + " to "
+ this);
} }
Assert.exists(listener, "Submission Listener"); Assert.exists(listener, "Submission Listener");
@ -155,15 +168,15 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Removes the specified submission listener from the * Removes the specified submission listener from the list of submission
* list of submission listeners (if it had previously been added). * listeners (if it had previously been added).
* *
* @param listener the submission listener to remove * @param listener the submission listener to remove
*/ */
public void removeSubmissionListener(FormSubmissionListener listener) { public void removeSubmissionListener(FormSubmissionListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing submission listener " + listener + " from " LOGGER.debug("Removing submission listener " + listener + " from "
+ this); + this);
} }
Assert.exists(listener, "Submission Listener"); Assert.exists(listener, "Submission Listener");
@ -176,28 +189,29 @@ public class FormSection extends DescriptiveComponent implements Container {
* listeners. * listeners.
* *
* @param e the event to pass to the listeners * @param e the event to pass to the listeners
*
* @throws FormProcessException if one of the listeners throws such an * @throws FormProcessException if one of the listeners throws such an
* exception. * exception.
*/ */
protected void fireSubmitted(FormSectionEvent e) protected void fireSubmitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
Assert.exists(e.getFormData(), "FormData"); Assert.exists(e.getFormData(), "FormData");
FormProcessException delayedException = null; FormProcessException delayedException = null;
Iterator i = m_listeners.getListenerIterator( Iterator i = m_listeners.getListenerIterator(
FormSubmissionListener.class); FormSubmissionListener.class);
while (i.hasNext()) { while (i.hasNext()) {
final FormSubmissionListener listener = (FormSubmissionListener) i. final FormSubmissionListener listener = (FormSubmissionListener) i.
next(); next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing submission listener " + listener); LOGGER.debug("Firing submission listener " + listener);
} }
try { try {
listener.submitted(e); listener.submitted(e);
} catch (FormProcessException ex) { } catch (FormProcessException ex) {
s_log.debug(ex); LOGGER.debug(ex);
delayedException = ex; delayedException = ex;
} }
} }
@ -207,7 +221,7 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* *
*/ */
protected void forwardSubmission() { protected void forwardSubmission() {
if (m_forwardSubmission == null) { if (m_forwardSubmission == null) {
@ -221,35 +235,36 @@ public class FormSection extends DescriptiveComponent implements Container {
* form section. * form section.
* *
* @return a submission listener that forwards submission events to this * @return a submission listener that forwards submission events to this
* form section. * form section.
*/ */
protected FormSubmissionListener createSubmissionListener() { protected FormSubmissionListener createSubmissionListener() {
return new FormSubmissionListener() { return new FormSubmissionListener() {
@Override @Override
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
fireSubmitted(new FormSectionEvent(FormSection.this, fireSubmitted(new FormSectionEvent(FormSection.this,
e.getPageState(), e.getPageState(),
e.getFormData())); e.getFormData()));
} }
}; };
} }
/** /**
* Adds a listener for form initialization events. Initialization * Adds a listener for form initialization events. Initialization events
* events occur when a form is initially requested by the user, but * occur when a form is initially requested by the user, but not when the
* not when the form is subsequently submitted. They typically * form is subsequently submitted. They typically perform actions such as
* perform actions such as querying the database for existing values * querying the database for existing values to set up an edit form, or
* to set up an edit form, or obtaining a sequence value to set up a * obtaining a sequence value to set up a create form.
* create form.
* *
* @param listener an instance of a class that implements the * @param listener an instance of a class that implements the
* <code>FormInitListener</code> interface * <code>FormInitListener</code> interface
* */ *
*/
public void addInitListener(FormInitListener listener) { public void addInitListener(FormInitListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding init listener " + listener + " to " + this); LOGGER.debug("Adding init listener " + listener + " to " + this);
} }
Assert.exists(listener, "FormInitListener"); Assert.exists(listener, "FormInitListener");
@ -259,14 +274,14 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Removes the specified init listener from the * Removes the specified init listener from the list of init listeners (if
* list of init listeners (if it had previously been added). * it had previously been added).
* *
* @param listener the init listener to remove * @param listener the init listener to remove
*/ */
public void removeInitListener(FormInitListener listener) { public void removeInitListener(FormInitListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing init listener " + listener + " from " + this); LOGGER.debug("Removing init listener " + listener + " from " + this);
} }
Assert.exists(listener, "Init Listener"); Assert.exists(listener, "Init Listener");
@ -275,12 +290,12 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Calls the <code>init</code> method on all registered init * Calls the <code>init</code> method on all registered init listeners.
* listeners.
* *
* @param e the event to pass to the listeners * @param e the event to pass to the listeners
*
* @throws FormProcessException if one of the listeners throws such an * @throws FormProcessException if one of the listeners throws such an
* exception. * exception.
*/ */
protected void fireInit(FormSectionEvent e) throws FormProcessException { protected void fireInit(FormSectionEvent e) throws FormProcessException {
Assert.exists(e.getFormData(), "FormData"); Assert.exists(e.getFormData(), "FormData");
@ -289,8 +304,8 @@ public class FormSection extends DescriptiveComponent implements Container {
while (i.hasNext()) { while (i.hasNext()) {
final FormInitListener listener = (FormInitListener) i.next(); final FormInitListener listener = (FormInitListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing init listener " + listener); LOGGER.debug("Firing init listener " + listener);
} }
listener.init(e); listener.init(e);
@ -298,7 +313,7 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* *
*/ */
protected void forwardInit() { protected void forwardInit() {
if (m_forwardInit == null) { if (m_forwardInit == null) {
@ -308,22 +323,21 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Creates the init listener that forwards init events to this form * Creates the init listener that forwards init events to this form section.
* section.
* *
* @return an init listener that forwards init events to this * @return an init listener that forwards init events to this form section.
* form section.
*/ */
protected FormInitListener createInitListener() { protected FormInitListener createInitListener() {
return new FormInitListener() { return new FormInitListener() {
@Override @Override
public void init(FormSectionEvent e) public void init(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
fireInit(new FormSectionEvent(FormSection.this, fireInit(new FormSectionEvent(FormSection.this,
e.getPageState(), e.getPageState(),
e.getFormData())); e.getFormData()));
} }
}; };
} }
@ -342,20 +356,23 @@ public class FormSection extends DescriptiveComponent implements Container {
e.getPageState(), e.getPageState(),
e.getFormData())); e.getFormData()));
} }
}; };
} }
/** /**
* Adds a validation listener, implementing a custom validation * Adds a validation listener, implementing a custom validation check that
* check that applies to the form as a whole. Useful for checks * applies to the form as a whole. Useful for checks that require
* that require examination of the values of more than one parameter. * examination of the values of more than one parameter.
* *
* @param listener an instance of a class that implements the * @param listener an instance of a class that implements the
* <code>FormValidationListener</code> interface * <code>FormValidationListener</code> interface
* */ *
*/
public void addValidationListener(FormValidationListener listener) { public void addValidationListener(FormValidationListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding validation listener " + listener + " to " + this); LOGGER.debug("Adding validation listener " + listener + " to "
+ this);
} }
Assert.exists(listener, "FormValidationListener"); Assert.exists(listener, "FormValidationListener");
@ -365,15 +382,15 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Removes the specified validation listener from the * Removes the specified validation listener from the list of validation
* list of validation listeners (if it had previously been added). * listeners (if it had previously been added).
* *
* @param listener a validation listener * @param listener a validation listener
*/ */
public void removeValidationListener(FormValidationListener listener) { public void removeValidationListener(FormValidationListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing validation listener " + listener + " from " LOGGER.debug("Removing validation listener " + listener + " from "
+ this); + this);
} }
Assert.exists(listener, "Validation Listener"); Assert.exists(listener, "Validation Listener");
@ -391,19 +408,19 @@ public class FormSection extends DescriptiveComponent implements Container {
FormData data = e.getFormData(); FormData data = e.getFormData();
Assert.exists(data, "FormData"); Assert.exists(data, "FormData");
Iterator i = m_listeners.getListenerIterator( Iterator i = m_listeners.getListenerIterator(
FormValidationListener.class); FormValidationListener.class);
while (i.hasNext()) { while (i.hasNext()) {
try { try {
final FormValidationListener listener = final FormValidationListener listener
(FormValidationListener) i.next(); = (FormValidationListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing validation listener " + listener); LOGGER.debug("Firing validation listener " + listener);
} }
listener.validate(e); listener.validate(e);
} catch (FormProcessException fpe) { } catch (FormProcessException fpe) {
s_log.debug(fpe); LOGGER.debug(fpe);
data.addError(fpe.getGlobalizedMessage()); data.addError(fpe.getGlobalizedMessage());
} }
} }
@ -421,7 +438,7 @@ public class FormSection extends DescriptiveComponent implements Container {
* form section. * form section.
* *
* @return a validation listener that forwards validation events to this * @return a validation listener that forwards validation events to this
* form section. * form section.
*/ */
protected FormValidationListener createValidationListener() { protected FormValidationListener createValidationListener() {
return new FormValidationListener() { return new FormValidationListener() {
@ -432,23 +449,26 @@ public class FormSection extends DescriptiveComponent implements Container {
e.getPageState(), e.getPageState(),
e.getFormData())); e.getFormData()));
} }
}; };
} }
/** /**
* Adds a listener for form processing events. <p>Process events * Adds a listener for form processing events.
* only occur after a form submission has been successfully * <p>
* validated. They are typically used to perform a database * Process events only occur after a form submission has been successfully
* transaction or other operation based on the submitted data. * validated. They are typically used to perform a database transaction or
* <p>Process listeners are executed in the order in which * other operation based on the submitted data.
* they are added. * <p>
* Process listeners are executed in the order in which they are added.
* *
* @param listener an instance of a class that implements the * @param listener an instance of a class that implements the
* <code>FormProcessListener</code> interface * <code>FormProcessListener</code> interface
* */ *
*/
public void addProcessListener(final FormProcessListener listener) { public void addProcessListener(final FormProcessListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding process listener " + listener + " to " + this); LOGGER.debug("Adding process listener " + listener + " to " + this);
} }
Assert.exists(listener, "FormProcessListener"); Assert.exists(listener, "FormProcessListener");
@ -459,15 +479,15 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Removes the specified process listener from the * Removes the specified process listener from the list of process listeners
* list of process listeners (if it had previously been added). * (if it had previously been added).
* *
* @param listener the process listener to remove * @param listener the process listener to remove
*/ */
public void removeProcessListener(FormProcessListener listener) { public void removeProcessListener(FormProcessListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing process listener " + listener + " from " LOGGER.debug("Removing process listener " + listener + " from "
+ this); + this);
} }
Assert.exists(listener, "Process Listener"); Assert.exists(listener, "Process Listener");
@ -488,11 +508,12 @@ public class FormSection extends DescriptiveComponent implements Container {
@Override @Override
public void process(FormSectionEvent e) public void process(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
fireProcess(new FormSectionEvent(FormSection.this, fireProcess(new FormSectionEvent(FormSection.this,
e.getPageState(), e.getPageState(),
e.getFormData())); e.getFormData()));
} }
}; };
} }
@ -501,18 +522,19 @@ public class FormSection extends DescriptiveComponent implements Container {
* listeners. * listeners.
* *
* @param e the event to pass to the listeners * @param e the event to pass to the listeners
*
* @throws FormProcessException if one of the listeners throws such an * @throws FormProcessException if one of the listeners throws such an
* exception. * exception.
*/ */
protected void fireProcess(FormSectionEvent e) protected void fireProcess(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
Assert.exists(e.getFormData(), "FormData"); Assert.exists(e.getFormData(), "FormData");
Iterator i = m_listeners.getListenerIterator(FormProcessListener.class); Iterator i = m_listeners.getListenerIterator(FormProcessListener.class);
while (i.hasNext()) { while (i.hasNext()) {
final FormProcessListener listener = (FormProcessListener) i.next(); final FormProcessListener listener = (FormProcessListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing process listener " + listener); LOGGER.debug("Firing process listener " + listener);
} }
listener.process(e); listener.process(e);
@ -521,30 +543,33 @@ public class FormSection extends DescriptiveComponent implements Container {
/** /**
* Since a form section cannot be processed, always throws an error. * Since a form section cannot be processed, always throws an error.
* (Processing of form sections is done by the form in which the * (Processing of form sections is done by the form in which the section is
* section is contained.) * contained.)
* *
* @param data * @param data
* @return *
* @throws javax.servlet.ServletException because processing a form section * @return
* is not meaningful. *
* @throws javax.servlet.ServletException because processing a form section
* is not meaningful.
*/ */
public FormData process(PageState data) public FormData process(PageState data)
throws javax.servlet.ServletException { throws javax.servlet.ServletException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* Adds a listener for form cancellation events. Cancellation * Adds a listener for form cancellation events. Cancellation listeners are
* listeners are typically used to clean-up page state and * typically used to clean-up page state and potentially intermediate
* potentially intermediate changes to the database. * changes to the database.
* *
* @param listener an instance of a class that implements the * @param listener an instance of a class that implements the
* <code>FormCancelListener</code> interface * <code>FormCancelListener</code> interface
* */ *
*/
public void addCancelListener(FormCancelListener listener) { public void addCancelListener(FormCancelListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding cancel listener " + listener + " to " + this); LOGGER.debug("Adding cancel listener " + listener + " to " + this);
} }
Assert.exists(listener, "FormCancelListener"); Assert.exists(listener, "FormCancelListener");
@ -553,14 +578,15 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Removes the specified cancellation listener from the * Removes the specified cancellation listener from the list of cancellation
* list of cancellation listeners (if it had previously been added). * listeners (if it had previously been added).
* *
* @param listener the cancellation listener to remove * @param listener the cancellation listener to remove
*/ */
public void removeCancelListener(FormCancelListener listener) { public void removeCancelListener(FormCancelListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing cancel listener " + listener + " from " + this); LOGGER.debug("Removing cancel listener " + listener + " from "
+ this);
} }
Assert.exists(listener, "Cancel Listener"); Assert.exists(listener, "Cancel Listener");
@ -573,18 +599,19 @@ public class FormSection extends DescriptiveComponent implements Container {
* listeners. * listeners.
* *
* @param e the event to pass to the listeners * @param e the event to pass to the listeners
*
* @throws FormProcessException if one of the listeners throws such an * @throws FormProcessException if one of the listeners throws such an
* exception. * exception.
*/ */
protected void fireCancel(FormSectionEvent e) protected void fireCancel(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
Assert.exists(e.getFormData(), "FormData"); Assert.exists(e.getFormData(), "FormData");
Iterator i = m_listeners.getListenerIterator(FormCancelListener.class); Iterator i = m_listeners.getListenerIterator(FormCancelListener.class);
while (i.hasNext()) { while (i.hasNext()) {
final FormCancelListener listener = (FormCancelListener) i.next(); final FormCancelListener listener = (FormCancelListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing cancel listener " + listener); LOGGER.debug("Firing cancel listener " + listener);
} }
listener.cancel(e); listener.cancel(e);
@ -592,15 +619,15 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Traverses the children this FormSection, collecting parameter models * Traverses the children this FormSection, collecting parameter models and
* and listeners into the supplied FormModel. Sets implicit pointers * listeners into the supplied FormModel. Sets implicit pointers of widgets
* of widgets in this FormSection to the supplied Form. * in this FormSection to the supplied Form.
* *
* @param f pointer to the form that is set inside Widgets within this * @param f pointer to the form that is set inside Widgets within this
* FormSection * FormSection
* @param m the FormModel in which to merge ParameterModels and * @param m the FormModel in which to merge ParameterModels and Listeners
* Listeners *
* */ */
@Override @Override
public void register(Form f, FormModel m) { public void register(Form f, FormModel m) {
m.mergeModel(getModel()); m.mergeModel(getModel());
@ -610,14 +637,16 @@ public class FormSection extends DescriptiveComponent implements Container {
* Accessor method for this form's FormModel. * Accessor method for this form's FormModel.
* *
* @return FormModel The model of this form. * @return FormModel The model of this form.
* */ *
*/
protected final FormModel getModel() { protected final FormModel getModel() {
return m_formModel; return m_formModel;
} }
/** /**
* Locks this FormSection, its FormModel, and the implicit Container. * Locks this FormSection, its FormModel, and the implicit Container.
* */ *
*/
@Override @Override
public void lock() { public void lock() {
m_formModel.lock(); m_formModel.lock();
@ -636,19 +665,19 @@ public class FormSection extends DescriptiveComponent implements Container {
* *
* This must not be final, because MetaFrom needs to override it. * This must not be final, because MetaFrom needs to override it.
* *
* @return * @return
*/ */
public Container getPanel() { public Container getPanel() {
return m_panel; return m_panel;
} }
/** /**
* Returns an iterator over the children of this component. If the * Returns an iterator over the children of this component. If the component
* component has no children, returns an empty iterator (not * has no children, returns an empty iterator (not <code>null</code> !).
* <code>null</code> !).
* *
* @post return != null * @post return != null
* */ *
*/
@Override @Override
public Iterator children() { public Iterator children() {
return m_panel.children(); return m_panel.children();
@ -659,12 +688,14 @@ public class FormSection extends DescriptiveComponent implements Container {
* <code>parent</code>. Uses the request values stored in * <code>parent</code>. Uses the request values stored in
* <code>state</code>.</p> * <code>state</code>.</p>
* *
* <p> This method generates DOM to be used with the XSLT template * <p>
* to produce the appropriate output.</p> * This method generates DOM to be used with the XSLT template to produce
* the appropriate output.</p>
* *
* @param pageState the state of the current page * @param pageState the state of the current page
* @param parent the node that will be used to write to * @param parent the node that will be used to write to
* */ *
*/
@Override @Override
public void generateXML(PageState pageState, Element parent) { public void generateXML(PageState pageState, Element parent) {
if (isVisible(pageState)) { if (isVisible(pageState)) {
@ -677,20 +708,21 @@ public class FormSection extends DescriptiveComponent implements Container {
* Adds a component to this container. * Adds a component to this container.
* *
* @param pc the component to add to this container * @param pc the component to add to this container
* */ *
*/
@Override @Override
public void add(Component pc) { public void add(Component pc) {
m_panel.add(pc); m_panel.add(pc);
} }
/** /**
* Adds a component with the specified layout constraints to this * Adds a component with the specified layout constraints to this container.
* container. Layout constraints are defined in each layout container as * Layout constraints are defined in each layout container as static ints.
* static ints. Use a bitwise OR to specify multiple constraints. * Use a bitwise OR to specify multiple constraints.
* *
* @param pc the component to add to this container * @param pc the component to add to this container
* @param constraints layout constraints (a bitwise OR of static ints in * @param constraints layout constraints (a bitwise OR of static ints in the
* the particular layout) * particular layout)
*/ */
@Override @Override
public void add(Component pc, int constraints) { public void add(Component pc, int constraints) {
@ -698,41 +730,40 @@ public class FormSection extends DescriptiveComponent implements Container {
} }
/** /**
* Returns <code>true</code> if this list contains the * Returns <code>true</code> if this list contains the specified element.
* specified element. More * More formally, returns true if and only if this list contains at least
* formally, returns true if and only if this list contains at least
* one element e such that (o==null ? e==null : o.equals(e)). * one element e such that (o==null ? e==null : o.equals(e)).
* *
* This method returns <code>true</code> only if the component has * This method returns <code>true</code> only if the component has been
* been directly * directly added to this container. If this container contains another
* added to this container. If this container contains another
* container that contains this component, this method returns * container that contains this component, this method returns
* <code>false</code>. * <code>false</code>.
* *
* @param o element whose presence in this container is to be tested * @param o element whose presence in this container is to be tested
* *
* @return <code>true</code> if this Container contains the * @return <code>true</code> if this Container contains the specified
* specified component directly; <code>false</code> otherwise. * component directly; <code>false</code> otherwise.
* *
* */ *
*/
@Override @Override
public boolean contains(Object o) { public boolean contains(Object o) {
return m_panel.contains(o); return m_panel.contains(o);
} }
/** /**
* Returns the * Returns the Component at the specified position. Each call to add()
* Component at the specified position. Each call to add() * increments the index. This method should be used in conjunction with
* increments the index. This method should be used in conjunction * indexOf
* with indexOf
* *
* @param index The index of the item to be retrieved from this * @param index The index of the item to be retrieved from this Container.
* Container. Since the user has no control over the index of added * Since the user has no control over the index of added
* components (other than counting each call to add), this method * components (other than counting each call to add), this
* should be used in conjunction with indexOf. * method should be used in conjunction with indexOf.
* *
* @return the component at the specified position in this container * @return the component at the specified position in this container
* */ *
*/
@Override @Override
public Component get(int index) { public Component get(int index) {
return (Component) m_panel.get(index); return (Component) m_panel.get(index);
@ -744,10 +775,10 @@ public class FormSection extends DescriptiveComponent implements Container {
* *
* @param pc component to search for * @param pc component to search for
* *
* @return the index in this list of the first occurrence of * @return the index in this list of the first occurrence of the specified
* the specified element, or -1 if this list does not contain this * element, or -1 if this list does not contain this element.
* element. *
* */ */
@Override @Override
public int indexOf(Component pc) { public int indexOf(Component pc) {
return m_panel.indexOf(pc); return m_panel.indexOf(pc);
@ -757,8 +788,9 @@ public class FormSection extends DescriptiveComponent implements Container {
* Determines whether the container contains any components. * Determines whether the container contains any components.
* *
* @return <code>true</code> if this container contains no components * @return <code>true</code> if this container contains no components
* <code>false</code> otherwise. * <code>false</code> otherwise.
* */ *
*/
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return m_panel.isEmpty(); return m_panel.isEmpty();
@ -769,9 +801,11 @@ public class FormSection extends DescriptiveComponent implements Container {
* recursively count the components indirectly contained in this container. * recursively count the components indirectly contained in this container.
* *
* @return the number of components directly in this container. * @return the number of components directly in this container.
* */ *
*/
@Override @Override
public int size() { public int size() {
return m_panel.size(); return m_panel.size();
} }
} }

View File

@ -18,8 +18,6 @@
*/ */
package com.arsdigita.bebop; package com.arsdigita.bebop;
import org.apache.log4j.Logger;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Widget; import com.arsdigita.bebop.form.Widget;
@ -27,6 +25,9 @@ import com.arsdigita.bebop.parameters.BooleanParameter;
import com.arsdigita.bebop.util.Traversal; import com.arsdigita.bebop.util.Traversal;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* The FormStep class modifies the behavior of FormSection with respect to * The FormStep class modifies the behavior of FormSection with respect to
* listener firing. Instead of firing init listeners the first time the * listener firing. Instead of firing init listeners the first time the
@ -34,31 +35,29 @@ import com.arsdigita.xml.Element;
* listeners the first time the FormStep itself is displayed on the page. The * listeners the first time the FormStep itself is displayed on the page. The
* process, validate, and submission listeners are then fired on every * process, validate, and submission listeners are then fired on every
* submission following the one in which the init listeners were fired. This * submission following the one in which the init listeners were fired. This
* behavior is useful when used in conjunction with {@link MultiStepForm} or * behavior is useful when used in conjunction with {@link MultiStepForm} or its
* its subclasses to provide initialization in later steps of a multi step * subclasses to provide initialization in later steps of a multi step form that
* form that depends on the values entered in earlier steps. * depends on the values entered in earlier steps.
* *
* updated chris.gilbert@westsussex.gov.uk - support for session based wizards * updated chris.gilbert@westsussex.gov.uk - support for session based wizards
* (which enable use of actionlinks in wizard) * (which enable use of actionlinks in wizard)
*
* @see Wizard * @see Wizard
* @see MultiStepForm * @see MultiStepForm
* *
* @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a> * @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a>
* @version $Id: FormStep.java 1414 2006-12-07 14:24:10Z chrisgilbert23 $ *
**/ */
public class FormStep extends FormSection { public class FormStep extends FormSection {
private final static Logger s_log = Logger.getLogger(FormStep.class);
private final static Logger LOGGER = LogManager.getLogger(FormStep.class);
private Form m_form = null; private Form m_form = null;
// cg - changed to using a parameter that is stored in pagestate so that if there are links // cg - changed to using a parameter that is stored in pagestate so that if there are links
// within the form then the init status of the steps is not lost // within the form then the init status of the steps is not lost
// private Hidden m_initialized; // private Hidden m_initialized;
private BooleanParameter m_initialized; private BooleanParameter m_initialized;
/** /**
* Constructs a new FormStep with the given name. The name must uniquely * Constructs a new FormStep with the given name. The name must uniquely
@ -66,8 +65,8 @@ public class FormStep extends FormSection {
* *
* @param name A name that uniquely identifies this FormStep within it's * @param name A name that uniquely identifies this FormStep within it's
* enclosing Form. * enclosing Form.
**/ *
*/
public FormStep(String name) { public FormStep(String name) {
addInitialized(name); addInitialized(name);
} }
@ -76,11 +75,11 @@ public class FormStep extends FormSection {
* Constructs a new FormStep with the given name. The name must uniquely * Constructs a new FormStep with the given name. The name must uniquely
* identify this FormStep within it's enclosing Form. * identify this FormStep within it's enclosing Form.
* *
* @param name A name that uniquely identifies this FormStep within it's * @param name A name that uniquely identifies this FormStep within it's
* enclosing Form. * enclosing Form.
* @param panel The container used to back this FormStep. * @param panel The container used to back this FormStep.
**/ *
*/
public FormStep(String name, Container panel) { public FormStep(String name, Container panel) {
super(panel); super(panel);
addInitialized(name); addInitialized(name);
@ -93,14 +92,16 @@ public class FormStep extends FormSection {
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addComponentStateParam(this, m_initialized); p.addComponentStateParam(this, m_initialized);
Traversal trav = new Traversal () { Traversal trav = new Traversal() {
protected void act(Component c) {
if (c instanceof Widget) { protected void act(Component c) {
((Widget) c).setValidateInvisible(false); if (c instanceof Widget) {
} ((Widget) c).setValidateInvisible(false);
} }
}; }
};
trav.preorder(this); trav.preorder(this);
} }
@ -111,17 +112,18 @@ public class FormStep extends FormSection {
} }
private void addInitialized(String name) { private void addInitialized(String name) {
// m_initialized = new Hidden(new BooleanParameter(name)); // m_initialized = new Hidden(new BooleanParameter(name));
// add(m_initialized); // add(m_initialized);
m_initialized = new BooleanParameter(name); m_initialized = new BooleanParameter(name);
m_initialized.setDefaultValue(Boolean.FALSE); m_initialized.setDefaultValue(Boolean.FALSE);
} }
public boolean isInitialized(PageState ps) { public boolean isInitialized(PageState ps) {
// Object init = m_initialized.getValue(ps); // Object init = m_initialized.getValue(ps);
Boolean init = (Boolean)ps.getValue(m_initialized); Boolean init = (Boolean) ps.getValue(m_initialized);
if (init == null) { if (init == null) {
s_log.debug("init for step " + m_initialized.getName() + " is null. returning true"); LOGGER.debug("init for step " + m_initialized.getName()
+ " is null. returning true");
// happens if step state is stored in session - // happens if step state is stored in session -
// form containing this step clears session // form containing this step clears session
// info when processed, but fireProcess invoked // info when processed, but fireProcess invoked
@ -142,8 +144,11 @@ public class FormStep extends FormSection {
// Turn off forwarding of init events. // Turn off forwarding of init events.
protected FormInitListener createInitListener() { protected FormInitListener createInitListener() {
return new FormInitListener() { return new FormInitListener() {
public void init(FormSectionEvent evt) { }
}; public void init(FormSectionEvent evt) {
}
};
} }
protected void fireSubmitted(FormSectionEvent evt) protected void fireSubmitted(FormSectionEvent evt)
@ -161,11 +166,11 @@ public class FormStep extends FormSection {
protected void fireProcess(FormSectionEvent evt) protected void fireProcess(FormSectionEvent evt)
throws FormProcessException { throws FormProcessException {
s_log.debug("fireprocess invoked on Formstep " + m_initialized.getName()); LOGGER.debug("fireprocess invoked on Formstep " + m_initialized
.getName());
if (isInitialized(evt.getPageState())) { if (isInitialized(evt.getPageState())) {
super.fireProcess(evt); super.fireProcess(evt);
} }
} }
@ -176,7 +181,7 @@ public class FormStep extends FormSection {
fireInit(new FormSectionEvent(this, ps, fd)); fireInit(new FormSectionEvent(this, ps, fd));
setInitialized(ps); setInitialized(ps);
} catch (FormProcessException ex) { } catch (FormProcessException ex) {
s_log.debug("initialization aborted", ex); LOGGER.debug("initialization aborted", ex);
fd.addError("Initialization Aborted: " + ex.getMessages()); fd.addError("Initialization Aborted: " + ex.getMessages());
} }
} }

View File

@ -20,19 +20,23 @@ package com.arsdigita.bebop;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import com.arsdigita.web.ParameterMap; import com.arsdigita.web.ParameterMap;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* A URL on a page. May contain a label, an image, or any other component. * A URL on a page. May contain a label, an image, or any other component. A
* A Link is a BaseLink that manages URL variables. * Link is a BaseLink that manages URL variables.
* *
* <p> <b>Example:</b> The common usage for a Link component is * <p>
* illustrated in the code fragment below: * <b>Example:</b> The common usage for a Link component is illustrated in the
* code fragment below:
* *
* <pre> * <pre>
* Page p = new Page("Link Example"); * Page p = new Page("Link Example");
@ -41,16 +45,16 @@ import org.apache.log4j.Logger;
* p.add(link); * p.add(link);
* </pre> * </pre>
* *
* <p> The target of the link above will be rendered in HTML as: * <p>
* The target of the link above will be rendered in HTML as:
* <tt>href="path/to/target/?foo=1"</tt> * <tt>href="path/to/target/?foo=1"</tt>
* If either the link text or the URL needs to be changed for a link * If either the link text or the URL needs to be changed for a link within a
* within a locked page, a {@link PrintListener} should be used. * locked page, a {@link PrintListener} should be used.
*
* @version $Id$
*/ */
public class Link extends BaseLink { public class Link extends BaseLink {
private static final Logger s_log = Logger.getLogger(ParameterMap.class); private static final Logger LOGGER = LogManager
.getLogger(ParameterMap.class);
private static final String FRAME_TARGET_ATTR = "target"; private static final String FRAME_TARGET_ATTR = "target";
@ -63,29 +67,33 @@ public class Link extends BaseLink {
protected final String TYPE_LINK = "link"; protected final String TYPE_LINK = "link";
/** /**
* <p>Passing this value to {@link #setTargetFrame setTargetFrame} will * <p>
* create a link that opens a new browser window whenever it is clicked. * Passing this value to {@link #setTargetFrame setTargetFrame} will create
*</p> * a link that opens a new browser window whenever it is clicked.
* </p>
* *
* @see #setTargetFrame * @see #setTargetFrame
*/ */
public static final String NEW_FRAME = "_blank"; public static final String NEW_FRAME = "_blank";
/** initialization steps common to all constructors */ /**
* initialization steps common to all constructors
*/
private void init() { private void init() {
setTypeAttr(TYPE_LINK); setTypeAttr(TYPE_LINK);
} }
/** /**
* Constructor creates a link taking url as the target and display it to * Constructor creates a link taking url as the target and display it to the
* the user at the same time. It is the only allowed way to present the * user at the same time. It is the only allowed way to present the user
* user with a not globlized information. The implementation currently * with a not globlized information. The implementation currently miss-uses
* miss-uses the Label component to display just a not globalized String * the Label component to display just a not globalized String which is
* which is deprecated. * deprecated.
* *
* @param url * @param url
*
* @deprecated use BaseLink(Component,url) instead with a Label using a * @deprecated use BaseLink(Component,url) instead with a Label using a
* GlobalizedMessage instead * GlobalizedMessage instead
*/ */
public Link(final String url) { public Link(final String url) {
super(new Label(url), url); super(new Label(url), url);
@ -93,18 +101,19 @@ public class Link extends BaseLink {
/** /**
* Constructor, creates a link with a globalized label or an image as label. * Constructor, creates a link with a globalized label or an image as label.
*
* @param child The <tt>Component</tt> parameter in this constructor is
* usually a {@link Label} or {@link Image}.
* @param url Starting with release 5.2, this method prefixes the passed-in
* url with the path to the CCM dispatcher. Code using this
* constructor should not prefix <code>url</code> with the
* webapp context path or the dispatcher servlet path.
* *
* The vast majority of CCM UI code expects to link through * @param child The <tt>Component</tt> parameter in this constructor is
* the dispatcher. Code that does not should use the * usually a {@link Label} or {@link Image}.
* <code>Link</code> constructor taking a <code>URL</code>. * @param url Starting with release 5.2, this method prefixes the
* @see #Link(String,URL) * passed-in url with the path to the CCM dispatcher. Code
* using this constructor should not prefix <code>url</code>
* with the webapp context path or the dispatcher servlet path.
*
* The vast majority of CCM UI code expects to link through the dispatcher.
* Code that does not should use the <code>Link</code> constructor taking a
* <code>URL</code>.
*
* @see #Link(String,URL)
*/ */
public Link(Component child, String url) { public Link(Component child, String url) {
super(child, url); super(child, url);
@ -113,12 +122,11 @@ public class Link extends BaseLink {
/** /**
* Constructors with <tt>PrintListener</tt> parameters allow for a * Constructors with <tt>PrintListener</tt> parameters allow for a
* {@link PrintListener} to be set for the Link, without the need * {@link PrintListener} to be set for the Link, without the need to make a
* to make a separate call to the <tt>addPrintListener</tt> method. * separate call to the <tt>addPrintListener</tt> method. PrintListeners are
* PrintListeners are a convenient way to alter underlying Link * a convenient way to alter underlying Link attributes such as Link text or
* attributes such as Link text or target URL within a locked page * target URL within a locked page on a per request basis.
* on a per request basis. *
*
* @param child * @param child
* @param l * @param l
*/ */
@ -128,31 +136,29 @@ public class Link extends BaseLink {
init(); init();
} }
/** /**
* Constructors with <tt>PrintListener</tt> parameters allow for a * Constructors with <tt>PrintListener</tt> parameters allow for a
* {@link PrintListener} to be set for the Link, without the need to make a * {@link PrintListener} to be set for the Link, without the need to make a
* separate call to the <tt>addPrintListener</tt> method. PrintListeners * separate call to the <tt>addPrintListener</tt> method. PrintListeners are
* are a convenient way to alter underlying Link attributes such as Link * a convenient way to alter underlying Link attributes such as Link text or
* text or target URL within a locked page on a per request basis. * target URL within a locked page on a per request basis.
* *
* @deprecated refactor to use Link(Component,PrintListener) to provide a * @deprecated refactor to use Link(Component,PrintListener) to provide a
* globalized label for the link. * globalized label for the link.
*/ */
public Link(String label, PrintListener l) { public Link(String label, PrintListener l) {
super(label,l); super(label, l);
init(); init();
} }
/** /**
* Constructors with <tt>PrintListener</tt> parameters allow for a * Constructors with <tt>PrintListener</tt> parameters allow for a
* {@link PrintListener} to be set for the Link, without the need to make a * {@link PrintListener} to be set for the Link, without the need to make a
* separate call to the <tt>addPrintListener</tt> method. PrintListeners * separate call to the <tt>addPrintListener</tt> method. PrintListeners are
* are a convenient way to alter underlying Link attributes such as Link * a convenient way to alter underlying Link attributes such as Link text or
* text or target URL within a locked page on a per request basis. * target URL within a locked page on a per request basis.
* *
* @param listener PrintListener, may be used to change either the Display * @param listener PrintListener, may be used to change either the Display
* text or the url within a locked page. * text or the url within a locked page.
*/ */
@ -163,23 +169,25 @@ public class Link extends BaseLink {
} }
/** /**
* <p>This constructor is a common one for a Link component, as it allows * <p>
* for the Link text and the target URL to be set at the same time during * This constructor is a common one for a Link component, as it allows for
* the Link text and the target URL to be set at the same time during
* construction.</p> * construction.</p>
* *
* <p>Starting with release 5.2, this method prefixes the * <p>
* passed-in <code>url</code> with the path to the CCM dispatcher. * Starting with release 5.2, this method prefixes the passed-in
* Code using this constructor should not prefix <code>url</code> * <code>url</code> with the path to the CCM dispatcher. Code using this
* with the webapp context path or the dispatcher servlet * constructor should not prefix <code>url</code> with the webapp context
* path.</p> * path or the dispatcher servlet path.</p>
* *
* <p>The vast majority of CCM UI code expects to link through the * <p>
* dispatcher. Code that does not should use the * The vast majority of CCM UI code expects to link through the dispatcher.
* <code>Link</code> constructor taking a <code>URL</code>.</p> * Code that does not should use the <code>Link</code> constructor taking a
* <code>URL</code>.</p>
* *
* @see #Link(String,URL) * @see #Link(String,URL)
* @deprecated refactor to use Link(Component,PrintListener) to provide a * @deprecated refactor to use Link(Component,PrintListener) to provide a
* globalized label for the link. * globalized label for the link.
*/ */
public Link(String label, String url) { public Link(String label, String url) {
super(label, url); super(label, url);
@ -188,17 +196,19 @@ public class Link extends BaseLink {
} }
/** /**
* <p>Constructs a Link using a <code>URL</code>. When this constructor is * <p>
* Constructs a Link using a <code>URL</code>. When this constructor is
* used, the method {@link #setVar(String,String)} and its deprecated * used, the method {@link #setVar(String,String)} and its deprecated
* equivalent have no effect on the resulting hyperlink. Instead, use the * equivalent have no effect on the resulting hyperlink. Instead, use the
* <code>ParameterMap</code> argument to <code>URL</code>.</p> * <code>ParameterMap</code> argument to <code>URL</code>.</p>
* *
* @see com.arsdigita.web.URL * @see com.arsdigita.web.URL
* @see com.arsdigita.web.ParameterMap * @see com.arsdigita.web.ParameterMap
* @param label a <code>String</code> of label text * @param label a <code>String</code> of label text
* @param url a <code>URL</code> for the link's target * @param url a <code>URL</code> for the link's target
* @deprecated refactor to use Link(Component,URL) to provide a *
* globalized label for the link. * @deprecated refactor to use Link(Component,URL) to provide a globalized
* label for the link.
*/ */
public Link(String label, URL url) { public Link(String label, URL url) {
super(label, url.toString()); super(label, url.toString());
@ -218,14 +228,15 @@ public class Link extends BaseLink {
} }
/** /**
* Sets a query variable and its value. Overwrites any values that may * Sets a query variable and its value. Overwrites any values that may have
* have been set previously under the specified name. * been set previously under the specified name.
* <p> * <p>
* All the variables set with this method are appended to the * All the variables set with this method are appended to the query string
* query string in the URL that is output for this <code>Link</code>. * in the URL that is output for this <code>Link</code>.
* *
* @param name the name of the query * @param name the name of the query
* @param value the value for the query * @param value the value for the query
*
* @pre name != null * @pre name != null
*/ */
public void setVar(String name, String value) { public void setVar(String name, String value) {
@ -242,38 +253,36 @@ public class Link extends BaseLink {
// public void addURLVars(String name, String value) { // public void addURLVars(String name, String value) {
// setVar(name, value); // setVar(name, value);
// } // }
/** /**
* *
* @return * @return may be this method should be deprecated as well as addURLVars?
* may be this method should be deprecated as well as addURLVars?
*/ */
public String getURLVarString() { public String getURLVarString() {
return m_params.toString(); return m_params.toString();
} }
/** /**
* <p>Get the "target" attribute of the link, which determines * <p>
* which browser frame will load the new page when this link is * Get the "target" attribute of the link, which determines which browser
* clicked.</p> * frame will load the new page when this link is clicked.</p>
*/ */
public String getTargetFrame() { public String getTargetFrame() {
return getAttribute(FRAME_TARGET_ATTR); return getAttribute(FRAME_TARGET_ATTR);
} }
/** /**
* <p>Set the "target" attribute of the link, which determines * <p>
* which browser frame will load the new page when this link is * Set the "target" attribute of the link, which determines which browser
* clicked.</p> * frame will load the new page when this link is clicked.</p>
*/ */
public void setTargetFrame(String frameName) { public void setTargetFrame(String frameName) {
setAttribute(FRAME_TARGET_ATTR, frameName); setAttribute(FRAME_TARGET_ATTR, frameName);
} }
/** /**
* *
* @param state * @param state
* @param parent * @param parent
*/ */
protected void generateURL(PageState state, Element parent) { protected void generateURL(PageState state, Element parent) {
parent.addAttribute("href", prepareURL(state, getTarget())); parent.addAttribute("href", prepareURL(state, getTarget()));
@ -302,22 +311,22 @@ public class Link extends BaseLink {
if (location.indexOf("?") == -1) { if (location.indexOf("?") == -1) {
// m_params adds the "?" as needed. // m_params adds the "?" as needed.
return resp.encodeURL(location + m_params); return resp.encodeURL(location + m_params);
} else { } else {
// The location already includes a query string, so // The location already includes a query string, so
// append to it without including a "?". // append to it without including a "?".
if (location.endsWith("&")) { if (location.endsWith("&")) {
return resp.encodeURL(location + return resp.encodeURL(location + m_params.getQueryString());
m_params.getQueryString());
} else { } else {
return resp.encodeURL(location + return resp.encodeURL(location + "&" + m_params
"&" + m_params.getQueryString()); .getQueryString());
} }
} }
} else { } else {
return m_webURL.toString(); return m_webURL.toString();
} }
} }
} }

View File

@ -21,30 +21,33 @@ package com.arsdigita.bebop;
import com.arsdigita.bebop.event.ChangeEvent; import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener; import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
/** /**
* ModalContainer is a container that manages visibility for a set of * ModalContainer is a container that manages visibility for a set of
* components. It allows only one of its children to be visible. One of its * components. It allows only one of its children to be visible. One of its
* children can be selected as the default visible component. If none is * children can be selected as the default visible component. If none is
* selected the child with index equal to zero is used. The modal container * selected the child with index equal to zero is used. The modal container sets
* sets the appropriate default and PageState-based visibility for its * the appropriate default and PageState-based visibility for its children.
* children.
* *
* @author Archit Shah * @author Archit Shah
* @version $Id$ *
**/ */
public class ModalContainer extends SimpleContainer implements Resettable { public class ModalContainer extends SimpleContainer implements Resettable {
private static final Logger s_log = Logger.getLogger(ModalContainer.class); private static final Logger LOGGER = LogManager.getLogger(
ModalContainer.class);
private int m_default = 0; private int m_default = 0;
private ArrayList m_changeListeners = new ArrayList(); private ArrayList m_changeListeners = new ArrayList();
public ModalContainer() { public ModalContainer() {
super(); super();
} }
@ -58,12 +61,12 @@ public class ModalContainer extends SimpleContainer implements Resettable {
* *
* Used here to set the visibility of the component. * Used here to set the visibility of the component.
* *
* The super class' method is empty, so the rule "Always call * The super class' method is empty, so the rule "Always call
* <code>super.register</code> when you override <code>register</code> * <code>super.register</code> when you override <code>register</code>
* doessn't apply here. * doessn't apply here.
* *
* @pre p != null * @pre p != null
* @param p * @param p
*/ */
@Override @Override
public void register(Page p) { public void register(Page p) {
@ -94,7 +97,7 @@ public class ModalContainer extends SimpleContainer implements Resettable {
} }
public void setVisibleComponent(PageState state, Component c) { public void setVisibleComponent(PageState state, Component c) {
s_log.debug("changing visibility"); LOGGER.debug("changing visibility");
Component old = getVisibleComponent(state); Component old = getVisibleComponent(state);
try { try {
@ -104,7 +107,7 @@ public class ModalContainer extends SimpleContainer implements Resettable {
// visibility of the components. don't have to do anything // visibility of the components. don't have to do anything
} }
c.setVisible(state, true); c.setVisible(state, true);
if (old!=c) { if (old != c) {
Iterator listeners = m_changeListeners.iterator(); Iterator listeners = m_changeListeners.iterator();
while (listeners.hasNext()) { while (listeners.hasNext()) {
ChangeListener l = (ChangeListener) listeners.next(); ChangeListener l = (ChangeListener) listeners.next();
@ -117,7 +120,9 @@ public class ModalContainer extends SimpleContainer implements Resettable {
Iterator it = children(); Iterator it = children();
while (it.hasNext()) { while (it.hasNext()) {
Component c = (Component) it.next(); Component c = (Component) it.next();
if (c.isVisible(state)) { return c; } if (c.isVisible(state)) {
return c;
}
} }
return null; return null;
@ -126,7 +131,8 @@ public class ModalContainer extends SimpleContainer implements Resettable {
/** /**
* Makes the next component in a wizard sequence visible while hiding all * Makes the next component in a wizard sequence visible while hiding all
* other components. * other components.
**/ *
*/
public void next(PageState state) { public void next(PageState state) {
setVisibleComponent(state, setVisibleComponent(state,
get(indexOf(getVisibleComponent(state)) + 1)); get(indexOf(getVisibleComponent(state)) + 1));
@ -135,7 +141,8 @@ public class ModalContainer extends SimpleContainer implements Resettable {
/** /**
* Makes the previous component in a wizard sequence visible while hiding * Makes the previous component in a wizard sequence visible while hiding
* all other components. * all other components.
**/ *
*/
public void previous(PageState state) { public void previous(PageState state) {
setVisibleComponent(state, setVisibleComponent(state,
get(indexOf(getVisibleComponent(state)) - 1)); get(indexOf(getVisibleComponent(state)) - 1));
@ -147,33 +154,35 @@ public class ModalContainer extends SimpleContainer implements Resettable {
* @param state * @param state
* @param index 0 based index of component * @param index 0 based index of component
*/ */
public void jumpTo (PageState state, int index) { public void jumpTo(PageState state, int index) {
setVisibleComponent(state, get(index)); setVisibleComponent(state, get(index));
} }
/** /**
* Makes the specified component visible * Makes the specified component visible
* *
*/ */
public void jumpTo (PageState state, Component comp) { public void jumpTo(PageState state, Component comp) {
setVisibleComponent(state, get(indexOf(comp))); setVisibleComponent(state, get(indexOf(comp)));
} }
/** /**
* Resets the container to display the default component. * Resets the container to display the default component.
**/ *
*/
public void reset(PageState state) { public void reset(PageState state) {
setVisibleComponent(state, getDefaultComponent()); setVisibleComponent(state, getDefaultComponent());
} }
/** /**
* Adds a listener that is called whenever this container's mode * Adds a listener that is called whenever this container's mode (i.e.,
* (i.e., visible component) is changed using setVisibleComponent(). * visible component) is changed using setVisibleComponent().
**/ *
*/
public void addModeChangeListener(ChangeListener cl) { public void addModeChangeListener(ChangeListener cl) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
m_changeListeners.add(cl); m_changeListeners.add(cl);
} }
} }

View File

@ -32,6 +32,9 @@ import com.arsdigita.util.SystemInformation;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.BitSet; import java.util.BitSet;
import java.util.Collection; import java.util.Collection;
@ -50,8 +53,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
/** /**
* The top-level container for all Bebop components and containers. * The top-level container for all Bebop components and containers.
* *
@ -73,15 +74,13 @@ import org.apache.log4j.Logger;
* @author David Lutterkort * @author David Lutterkort
* @author Stanislav Freidin * @author Stanislav Freidin
* @author Uday Mathur * @author Uday Mathur
*
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
*/ */
public class Page extends SimpleComponent implements Container { public class Page extends SimpleComponent implements Container {
/** /**
* Class specific logger instance. * Class specific logger instance.
*/ */
private static final Logger s_log = Logger.getLogger(Page.class); private static final Logger LOGGER = LogManager.getLogger(Page.class);
/** /**
* The delimiter character for components naming * The delimiter character for components naming
*/ */
@ -104,12 +103,12 @@ public class Page extends SimpleComponent implements Container {
static final Collection CONTROL_EVENT_KEYS; static final Collection CONTROL_EVENT_KEYS;
static { static {
s_log.debug("Static initalizer is starting..."); LOGGER.debug("Static initalizer is starting...");
CONTROL_EVENT_KEYS = new ArrayList(3); CONTROL_EVENT_KEYS = new ArrayList(3);
CONTROL_EVENT_KEYS.add(SELECTED); CONTROL_EVENT_KEYS.add(SELECTED);
CONTROL_EVENT_KEYS.add(CONTROL_EVENT); CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
CONTROL_EVENT_KEYS.add(CONTROL_VALUE); CONTROL_EVENT_KEYS.add(CONTROL_VALUE);
s_log.debug("Static initalizer finished."); LOGGER.debug("Static initalizer finished.");
} }
/** /**
@ -761,7 +760,7 @@ public class Page extends SimpleComponent implements Container {
}; };
if (m_panel == null) { if (m_panel == null) {
s_log.warn("m_panel is null"); LOGGER.warn("m_panel is null");
} }
componentRegistrar.preorder(m_panel); componentRegistrar.preorder(m_panel);
if (m_errorDisplay != null) { if (m_errorDisplay != null) {
@ -872,8 +871,8 @@ public class Page extends SimpleComponent implements Container {
final ActionListener listener = (ActionListener) i.next(); final ActionListener listener = (ActionListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing action listener " + listener); LOGGER.debug("Firing action listener " + listener);
} }
listener.actionPerformed(e); listener.actionPerformed(e);
@ -899,8 +898,8 @@ public class Page extends SimpleComponent implements Container {
final RequestListener listener = (RequestListener) i.next(); final RequestListener listener = (RequestListener) i.next();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Firing request listener " + listener); LOGGER.debug("Firing request listener " + listener);
} }
listener.pageRequested(e); listener.pageRequested(e);
@ -962,7 +961,7 @@ public class Page extends SimpleComponent implements Container {
if (!stateContains(c)) { if (!stateContains(c)) {
if (c == null) { if (c == null) {
s_log.error("c is null"); LOGGER.error("c is null");
} /*else { } /*else {
s_log.error("c: " + c.toString()); s_log.error("c: " + c.toString());
}*/ }*/
@ -1007,7 +1006,7 @@ public class Page extends SimpleComponent implements Container {
} }
if (!m_stateModel.containsFormParam(p)) { if (!m_stateModel.containsFormParam(p)) {
String name = parameterName(c, p.getName()); String name = parameterName(c, p.getName());
s_log.debug(String LOGGER.debug(String
.format("Setting name of parameter to add to '%s'", .format("Setting name of parameter to add to '%s'",
name)); name));
p.setName(name); p.setName(name);
@ -1334,7 +1333,7 @@ public class Page extends SimpleComponent implements Container {
String componentId = (String) it.next(); String componentId = (String) it.next();
hashString.append(componentId); hashString.append(componentId);
} }
s_log.debug("Time to create hashCode for page: " + (new Date().getTime() LOGGER.debug("Time to create hashCode for page: " + (new Date().getTime()
- start. - start.
getTime())); getTime()));
return hashString.toString(); return hashString.toString();

View File

@ -30,6 +30,10 @@ import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.BitSet; import java.util.BitSet;
@ -37,11 +41,11 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
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 javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
/** /**
* <p>The request-specific data (state) for a {@link Page}. All * <p>The request-specific data (state) for a {@link Page}. All
@ -153,12 +157,11 @@ import org.apache.log4j.Logger;
* *
* @author David Lutterkort * @author David Lutterkort
* @author Uday Mathur * @author Uday Mathur
* @version $Id$
*/ */
public class PageState { public class PageState {
/** Class specific logger instance. */ /** Class specific logger instance. */
private static final Logger s_log = Logger.getLogger(PageState.class); private static final Logger LOGGER = LogManager.getLogger(PageState.class);
/** The underlying Page object. */ /** The underlying Page object. */
private Page m_page; private Page m_page;
@ -501,8 +504,8 @@ public class PageState {
return; return;
m_invisible.set(i); m_invisible.set(i);
} }
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Marking visibility parameter as dirty " + m_request + " because of component " + c); LOGGER.info("Marking visibility parameter as dirty " + m_request + " because of component " + c);
} }
// Do this only in toURL since the RLE is expensive // Do this only in toURL since the RLE is expensive
//m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible)); //m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible));
@ -884,7 +887,7 @@ public class PageState {
final ParameterMap params = new ParameterMap(); final ParameterMap params = new ParameterMap();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
dumpVisibility(); dumpVisibility();
} }
@ -917,8 +920,8 @@ public class PageState {
private void synchronizeVisibility() { private void synchronizeVisibility() {
if (m_visibilityDirty) { if (m_visibilityDirty) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Encoding visibility parameter " + m_request); LOGGER.info("Encoding visibility parameter " + m_request);
} }
m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible)); m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible));
m_visibilityDirty = false; m_visibilityDirty = false;
@ -935,30 +938,30 @@ public class PageState {
BitSet difference = (BitSet)current.clone(); BitSet difference = (BitSet)current.clone();
difference.xor(base); difference.xor(base);
s_log.debug("Current: " + current.toString()); LOGGER.debug("Current: " + current.toString());
s_log.debug("Default: " + base.toString()); LOGGER.debug("Default: " + base.toString());
s_log.debug("Difference: " + difference.toString()); LOGGER.debug("Difference: " + difference.toString());
s_log.debug("Current RAW: " + raw.marshal(current)); LOGGER.debug("Current RAW: " + raw.marshal(current));
s_log.debug("Default RAW: " + raw.marshal(base)); LOGGER.debug("Default RAW: " + raw.marshal(base));
s_log.debug("Difference RAW: " + raw.marshal(difference)); LOGGER.debug("Difference RAW: " + raw.marshal(difference));
s_log.debug("Current DGAP: " + dgap.marshal(current)); LOGGER.debug("Current DGAP: " + dgap.marshal(current));
s_log.debug("Default DGAP: " + dgap.marshal(base)); LOGGER.debug("Default DGAP: " + dgap.marshal(base));
s_log.debug("Difference DGAP: " + dgap.marshal(difference)); LOGGER.debug("Difference DGAP: " + dgap.marshal(difference));
s_log.debug("Current Result: " + dgap.unmarshal(dgap.marshal(current))); LOGGER.debug("Current Result: " + dgap.unmarshal(dgap.marshal(current)));
s_log.debug("Default Result: " + dgap.unmarshal(dgap.marshal(base))); LOGGER.debug("Default Result: " + dgap.unmarshal(dgap.marshal(base)));
s_log.debug("Difference Result: " + dgap.unmarshal(dgap.marshal(difference))); LOGGER.debug("Difference Result: " + dgap.unmarshal(dgap.marshal(difference)));
if (!current.equals(dgap.unmarshal(dgap.marshal(current)))) { if (!current.equals(dgap.unmarshal(dgap.marshal(current)))) {
s_log.debug("Broken marshal/unmarshal for current"); LOGGER.debug("Broken marshal/unmarshal for current");
} }
if (!base.equals(dgap.unmarshal(dgap.marshal(base)))) { if (!base.equals(dgap.unmarshal(dgap.marshal(base)))) {
s_log.debug("Broken marshal/unmarshal for default"); LOGGER.debug("Broken marshal/unmarshal for default");
} }
if (!difference.equals(dgap.unmarshal(dgap.marshal(difference)))) { if (!difference.equals(dgap.unmarshal(dgap.marshal(difference)))) {
s_log.debug("Broken marshal/unmarshal for difference"); LOGGER.debug("Broken marshal/unmarshal for difference");
} }
} }

View File

@ -26,41 +26,42 @@ import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/* FIXME: Add methods for using images in the tab strip */ /* FIXME: Add methods for using images in the tab strip */
/** /**
* A tabbed pane that lets the user switch between components by * A tabbed pane that lets the user switch between components by clicking on a
* clicking on a given title in the tab strip. * given title in the tab strip.
* <p> * <p>
* Tabs (components) are added using the {@link #addTab addTab} method. Each * Tabs (components) are added using the {@link #addTab addTab} method. Each
* entry consists of a label (which is a string) and the {@link Component} * entry consists of a label (which is a string) and the {@link Component} that
* that is displayed if the user clicks on the label. * is displayed if the user clicks on the label.
* <p> * <p>
* There is always exactly one component that is currently visible, the component * There is always exactly one component that is currently visible, the
* that is returned by {@link #getCurrentPane}. Without user interaction, * component that is returned by {@link #getCurrentPane}. Without user
* this is the default pane -- that was set by {@link #setDefaultPane} -- or, if * interaction, this is the default pane -- that was set by
* none has been set, the first component that was added to the <code>TabbedPane</code>. * {@link #setDefaultPane} -- or, if none has been set, the first component that
* was added to the <code>TabbedPane</code>.
* <p> * <p>
* *
* @author David Lutterkort * @author David Lutterkort
* @author Stanislav Freidin * @author Stanislav Freidin
* @author Uday Mathur * @author Uday Mathur
* @version $Id$ * @version $Id$
*/ */
public class TabbedPane extends SimpleContainer { public class TabbedPane extends SimpleContainer {
private static final String CURRENT_PANE = "pane"; private static final String CURRENT_PANE = "pane";
/** /**
* The name for the event to change the selected pane. * The name for the event to change the selected pane. The value is the
* The value is the index of the pane * index of the pane
*/ */
private static final String SELECT_EVENT = "select"; private static final String SELECT_EVENT = "select";
@ -68,8 +69,8 @@ public class TabbedPane extends SimpleContainer {
private IntegerParameter m_currentPaneParam; private IntegerParameter m_currentPaneParam;
private List m_actionListeners; private List m_actionListeners;
private static final Logger s_log = private static final Logger LOGGER = LogManager.getLogger(TabbedPane.class
Logger.getLogger(TabbedPane.class.getName()); .getName());
/** /**
* Constructs an empty TabbedPane. * Constructs an empty TabbedPane.
@ -79,9 +80,11 @@ public class TabbedPane extends SimpleContainer {
} }
/** /**
* Registers with the specified root container. Adds a state * Registers with the specified root container. Adds a state parameter to
* parameter to keep track of the visible component to the page. * keep track of the visible component to the page.
*
* @param p the root container to register with * @param p the root container to register with
*
* @pre p != null * @pre p != null
*/ */
public void register(Page p) { public void register(Page p) {
@ -92,7 +95,7 @@ public class TabbedPane extends SimpleContainer {
// in the list // in the list
Iterator i = children(); Iterator i = children();
if (!i.hasNext()) { if (!i.hasNext()) {
s_log.warn("TabbedPane registered with no panes"); LOGGER.warn("TabbedPane registered with no panes");
} else if (m_defaultPane == null) { } else if (m_defaultPane == null) {
setDefaultPaneIndex(0); setDefaultPaneIndex(0);
} }
@ -104,8 +107,7 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Adds a new pane to the dialog. Assigns a rather unhelpful default label * Adds a new pane to the dialog. Assigns a rather unhelpful default label
* (the pane number) to the component. Use {@link #addTab addTab} * (the pane number) to the component. Use {@link #addTab addTab} instead.
* instead.
* *
* @pre pc != null * @pre pc != null
*/ */
@ -114,21 +116,23 @@ public class TabbedPane extends SimpleContainer {
} }
/** /**
* Adds a new pane with layout constraints to the dialog. Ignores * Adds a new pane with layout constraints to the dialog. Ignores the
* the constraints. Assigns a rather unhelpful default label * constraints. Assigns a rather unhelpful default label (the pane number)
* (the pane number) to the component. Use {@link #addTab * to the component. Use {@link #addTab
* addTab} instead. * addTab} instead.
* *
* @pre pc != null */ * @pre pc != null
*/
public void add(Component pc, int constraints) { public void add(Component pc, int constraints) {
add(pc); add(pc);
} }
/** /**
* Adds a tab and its associated component. * Adds a tab and its associated component.
*
* @param label the text to display in the tab strip * @param label the text to display in the tab strip
* @param c the component to display when the user clicks on the * @param c the component to display when the user clicks on the
* <code>label</code> in the tab strip * <code>label</code> in the tab strip
* *
* @pre label != null && c != null * @pre label != null && c != null
*/ */
@ -139,9 +143,10 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Adds a tab and its associated component. * Adds a tab and its associated component.
*
* @param label the text to display in the tab strip * @param label the text to display in the tab strip
* @param c the component to display when the user clicks on the * @param c the component to display when the user clicks on the
* <code>label</code> in the tab strip * <code>label</code> in the tab strip
* *
* @pre label != null && c != null * @pre label != null && c != null
*/ */
@ -152,6 +157,7 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Adds an <code>ActionListener</code>, which is run whenever {@link * Adds an <code>ActionListener</code>, which is run whenever {@link
* #respond respond} is called. * #respond respond} is called.
*
* @param 1 the action listener * @param 1 the action listener
* *
* @pre l != null * @pre l != null
@ -160,7 +166,7 @@ public class TabbedPane extends SimpleContainer {
*/ */
public void addActionListener(ActionListener l) { public void addActionListener(ActionListener l) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if ( m_actionListeners == null ) { if (m_actionListeners == null) {
m_actionListeners = new ArrayList(); m_actionListeners = new ArrayList();
} }
m_actionListeners.add(l); m_actionListeners.add(l);
@ -168,12 +174,14 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Removes a previously added <code>ActionListener</code>. * Removes a previously added <code>ActionListener</code>.
*
* @param 1 the action listener to remove * @param 1 the action listener to remove
*
* @see #addActionListener addActionListener * @see #addActionListener addActionListener
*/ */
public void removeActionListener(ActionListener l) { public void removeActionListener(ActionListener l) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if ( m_actionListeners == null ) { if (m_actionListeners == null) {
return; return;
} }
m_actionListeners.remove(l); m_actionListeners.remove(l);
@ -183,7 +191,9 @@ public class TabbedPane extends SimpleContainer {
* Fires an <code>ActionEvent</code>. All registered * Fires an <code>ActionEvent</code>. All registered
* <code>ActionListener</code>s are run. The source of the event is the * <code>ActionListener</code>s are run. The source of the event is the
* <code>TabbedPane</code>. * <code>TabbedPane</code>.
*
* @param state the current page state * @param state the current page state
*
* @pre state != null * @pre state != null
* @see #respond respond * @see #respond respond
*/ */
@ -192,8 +202,8 @@ public class TabbedPane extends SimpleContainer {
if (m_actionListeners == null) { if (m_actionListeners == null) {
return; return;
} }
for (Iterator i=m_actionListeners.iterator(); i.hasNext(); ) { for (Iterator i = m_actionListeners.iterator(); i.hasNext();) {
if ( e == null ) { if (e == null) {
e = new ActionEvent(this, state); e = new ActionEvent(this, state);
} }
((ActionListener) i.next()).actionPerformed(e); ((ActionListener) i.next()).actionPerformed(e);
@ -203,16 +213,18 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Sets the index of the default pane, which is visible until the user * Sets the index of the default pane, which is visible until the user
* clicks on another label in the tab strip. * clicks on another label in the tab strip.
*
* @param i the index of the default pane * @param i the index of the default pane
*/ */
protected void setDefaultPaneIndex(int i) { protected void setDefaultPaneIndex(int i) {
m_currentPaneParam.setDefaultValue(new Integer(i)); m_currentPaneParam.setDefaultValue(new Integer(i));
m_defaultPane = (Pane)get(i); m_defaultPane = (Pane) get(i);
} }
/** /**
* Sets the default pane, which is visible until the user * Sets the default pane, which is visible until the user clicks on another
* clicks on another label in the tab strip. * label in the tab strip.
*
* @param pane the component to display as the default pane * @param pane the component to display as the default pane
* *
* @pre findPane(pane) != -1 * @pre findPane(pane) != -1
@ -270,15 +282,18 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Find the pane whose body is the specified component * Find the pane whose body is the specified component
*
* @param c the component * @param c the component
*
* @return the pane index on success, -1 if no such pane exists * @return the pane index on success, -1 if no such pane exists
*/ */
protected int findPane(Component c) { protected int findPane(Component c) {
int index = 0; int index = 0;
for(Iterator i = children(); i.hasNext(); index++) { for (Iterator i = children(); i.hasNext(); index++) {
Pane p = (Pane)i.next(); Pane p = (Pane) i.next();
if(p.getComponent() == c) if (p.getComponent() == c) {
return index; return index;
}
} }
return -1; return -1;
@ -286,21 +301,19 @@ public class TabbedPane extends SimpleContainer {
private int findPaneSafe(Component c) { private int findPaneSafe(Component c) {
int i = findPane(c); int i = findPane(c);
if ( i == -1 ) { if (i == -1) {
throw new IllegalArgumentException throw new IllegalArgumentException(
("Pane not part of this tabbed dialog"); "Pane not part of this tabbed dialog");
} }
return i; return i;
} }
/** /**
* Gets the default pane. If no default pane has been set explicitly, the * Gets the default pane. If no default pane has been set explicitly, the
* first pane is returned. * first pane is returned.
* *
* @return the default pane, or <code>null</code> if there are no * @return the default pane, or <code>null</code> if there are no panes.
* panes.
*/ */
public Component getDefaultPane() { public Component getDefaultPane() {
return m_defaultPane.getComponent(); return m_defaultPane.getComponent();
@ -308,13 +321,14 @@ public class TabbedPane extends SimpleContainer {
/** /**
* Gets the pane with the specified label. * Gets the pane with the specified label.
* @return the pane with the specified label, or <code>null</code> *
* if a pane with that label does not exist. * @return the pane with the specified label, or <code>null</code> if a pane
* with that label does not exist.
*/ */
public Component getPane(Component label) { public Component getPane(Component label) {
for (Iterator i = children(); i.hasNext();) { for (Iterator i = children(); i.hasNext();) {
Pane p = (Pane) i.next(); Pane p = (Pane) i.next();
if ( p.getLabel().equals(label) ) { if (p.getLabel().equals(label)) {
return p.getComponent(); return p.getComponent();
} }
} }
@ -322,11 +336,12 @@ public class TabbedPane extends SimpleContainer {
} }
/** /**
* Gets the pane with the specified key in its label. * Gets the pane with the specified key in its label. Returns null if a pane
* Returns null if a pane with that label does not exist. * with that label does not exist. This function exists for backward
* This function exists for backward compatibility. * compatibility.
* @return the pane with the specified label, or <code>null</code> *
* if a pane with that label does not exist. * @return the pane with the specified label, or <code>null</code> if a pane
* with that label does not exist.
*/ */
public Component getPane(String label) { public Component getPane(String label) {
@ -334,7 +349,7 @@ public class TabbedPane extends SimpleContainer {
Pane p = (Pane) i.next(); Pane p = (Pane) i.next();
Component pLabel = p.getLabel(); Component pLabel = p.getLabel();
if (pLabel instanceof Label if (pLabel instanceof Label
&& ((Label)pLabel).getLabel().equals(label) ) { && ((Label) pLabel).getLabel().equals(label)) {
return p.getComponent(); return p.getComponent();
} }
} }
@ -351,24 +366,24 @@ public class TabbedPane extends SimpleContainer {
} }
/** /**
* Get the currently visible <code>Pane</code>, the tab label together * Get the currently visible <code>Pane</code>, the tab label together with
* with its component. * its component.
*/ */
private Pane getCurrent(PageState data) { private Pane getCurrent(PageState data) {
Integer i = (Integer) data.getValue(m_currentPaneParam); Integer i = (Integer) data.getValue(m_currentPaneParam);
if (i == null) { if (i == null) {
if (m_defaultPane!=null) { if (m_defaultPane != null) {
return m_defaultPane; return m_defaultPane;
} else { } else {
return (Pane)get(0); return (Pane) get(0);
} }
} }
return (Pane)get(i.intValue()); return (Pane) get(i.intValue());
} }
public void setSelectedIndex(PageState state, int index) { public void setSelectedIndex(PageState state, int index) {
if ( index != getSelectedIndex(state) ) { if (index != getSelectedIndex(state)) {
getCurrentPane(state).setVisible(state, false); getCurrentPane(state).setVisible(state, false);
state.setValue(m_currentPaneParam, new Integer(index)); state.setValue(m_currentPaneParam, new Integer(index));
getCurrentPane(state).setVisible(state, true); getCurrentPane(state).setVisible(state, true);
@ -377,28 +392,31 @@ public class TabbedPane extends SimpleContainer {
public int getSelectedIndex(PageState state) { public int getSelectedIndex(PageState state) {
Integer current = (Integer) state.getValue(m_currentPaneParam); Integer current = (Integer) state.getValue(m_currentPaneParam);
if ( current == null ) { if (current == null) {
return -1; return -1;
} }
return current.intValue(); return current.intValue();
} }
/** /**
* Builds a DOM representing the header for the tab strip. Marks the current pane. * Builds a DOM representing the header for the tab strip. Marks the current
* pane.
*/ */
protected void generateTabs(PageState data, Element parent) { protected void generateTabs(PageState data, Element parent) {
Element strip = parent.newChildElement("bebop:tabStrip", BEBOP_XML_NS); Element strip = parent.newChildElement("bebop:tabStrip", BEBOP_XML_NS);
exportAttributes(strip); exportAttributes(strip);
Pane current = getCurrent(data); Pane current = getCurrent(data);
strip.addAttribute("selected",current.getComponent().getClass().getName()); strip.addAttribute("selected", current.getComponent().getClass()
.getName());
Iterator tabs; Iterator tabs;
int i; int i;
for (tabs = children(), i = 0; tabs.hasNext(); i++) { for (tabs = children(), i = 0; tabs.hasNext(); i++) {
Pane pane = (Pane)tabs.next(); Pane pane = (Pane) tabs.next();
// Skip hidden tabs // Skip hidden tabs
if(!pane.isVisible(data)) continue; if (!pane.isVisible(data)) {
continue;
}
data.setControlEvent(this, SELECT_EVENT, String.valueOf(i)); data.setControlEvent(this, SELECT_EVENT, String.valueOf(i));
@ -413,7 +431,8 @@ public class TabbedPane extends SimpleContainer {
//TODO cat.error("cannot get stateAsURL from "+data); //TODO cat.error("cannot get stateAsURL from "+data);
} }
} }
String key = ((Label) pane.getLabel()).getGlobalizedMessage().getKey(); String key = ((Label) pane.getLabel()).getGlobalizedMessage()
.getKey();
tab.addAttribute("key", key.substring(key.lastIndexOf(".") + 1)); tab.addAttribute("key", key.substring(key.lastIndexOf(".") + 1));
pane.getLabel().generateXML(data, tab); pane.getLabel().generateXML(data, tab);
} }
@ -421,10 +440,12 @@ public class TabbedPane extends SimpleContainer {
} }
/** /**
* Services the request by building a DOM tree with the tabs * Services the request by building a DOM tree with the tabs themselves and
* themselves and then the included page. * then the included page.
* <p>Generates a DOM fragment: * <p>
* <p><code><pre> * Generates a DOM fragment:
* <p>
* <code><pre>
* &lt;bebop:tabbedPane> * &lt;bebop:tabbedPane>
* &lt;bebop:tabStrip> * &lt;bebop:tabStrip>
* &lt;bebop:tab [href="..."] [current="t|f"]> .. label .. &lt;/bebop:tab> * &lt;bebop:tab [href="..."] [current="t|f"]> .. label .. &lt;/bebop:tab>
@ -438,12 +459,14 @@ public class TabbedPane extends SimpleContainer {
* </pre></code> * </pre></code>
*/ */
public void generateXML(PageState state, Element parent) { public void generateXML(PageState state, Element parent) {
if ( isVisible(state) && !isEmpty()) { if (isVisible(state) && !isEmpty()) {
Element tabbed = parent.newChildElement("bebop:tabbedPane", BEBOP_XML_NS); Element tabbed = parent.newChildElement("bebop:tabbedPane",
BEBOP_XML_NS);
generateTabs(state, tabbed); generateTabs(state, tabbed);
exportAttributes(tabbed); exportAttributes(tabbed);
Element pane = tabbed.newChildElement("bebop:currentPane", BEBOP_XML_NS); Element pane = tabbed.newChildElement("bebop:currentPane",
BEBOP_XML_NS);
exportAttributes(pane); exportAttributes(pane);
getCurrentPane(state).generateXML(state, pane); getCurrentPane(state).generateXML(state, pane);
} }
@ -460,11 +483,10 @@ public class TabbedPane extends SimpleContainer {
* @pre state != null * @pre state != null
*/ */
public void respond(PageState state) public void respond(PageState state)
throws ServletException throws ServletException {
{
String event = state.getControlEventName(); String event = state.getControlEventName();
if ( SELECT_EVENT.equals(event)) { if (SELECT_EVENT.equals(event)) {
String value = state.getControlEventValue(); String value = state.getControlEventValue();
setSelectedIndex(state, Integer.parseInt(value)); setSelectedIndex(state, Integer.parseInt(value));
} else { } else {
@ -477,6 +499,7 @@ public class TabbedPane extends SimpleContainer {
* Associates a label with the component * Associates a label with the component
*/ */
private class Pane extends SimpleContainer { private class Pane extends SimpleContainer {
private Component m_label; private Component m_label;
private Component m_component; private Component m_component;
@ -494,5 +517,7 @@ public class TabbedPane extends SimpleContainer {
public final Component getComponent() { public final Component getComponent() {
return m_component; return m_component;
} }
} }
} }

View File

@ -38,16 +38,16 @@ import com.arsdigita.bebop.table.TableModelBuilder;
import static com.arsdigita.bebop.util.BebopConstants.*; import static com.arsdigita.bebop.util.BebopConstants.*;
import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/** /**
* Displays statically or dynamically generated data in tabular form. * Displays statically or dynamically generated data in tabular form.
* The data is retrieved from a <code>TableModel</code>. * The data is retrieved from a <code>TableModel</code>.
@ -97,11 +97,11 @@ import org.apache.log4j.Logger;
* @see TableColumnModel * @see TableColumnModel
* *
* @author David Lutterkort * @author David Lutterkort
* @version $Id$
*/ */
public class Table extends SimpleComponent { public class Table extends SimpleComponent {
private static final Logger logger = Logger.getLogger(Table.class); private static final Logger LOGGER = LogManager.getLogger(Table.class);
// Names for HTML Attributes // Names for HTML Attributes
private static final String WIDTH = "width"; private static final String WIDTH = "width";
private static final String CELL_SPACING = "cellspacing"; private static final String CELL_SPACING = "cellspacing";
@ -710,7 +710,7 @@ public class Table extends SimpleComponent {
final int modelSize = getColumnModel().size(); final int modelSize = getColumnModel().size();
int row = 0; int row = 0;
logger.debug("Creating table rows..."); LOGGER.debug("Creating table rows...");
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
do { do {
long rowStart = System.currentTimeMillis(); long rowStart = System.currentTimeMillis();
@ -753,17 +753,17 @@ public class Table extends SimpleComponent {
long begin = System.currentTimeMillis(); long begin = System.currentTimeMillis();
r.getComponent(this, s, value, selected, key, row, i). r.getComponent(this, s, value, selected, key, row, i).
generateXML(s, cell); generateXML(s, cell);
logger.debug(String.format("until here i needed %d ms", LOGGER.debug(String.format("until here i needed %d ms",
System.currentTimeMillis() System.currentTimeMillis()
- begin)); - begin));
} }
} }
row += 1; row += 1;
logger.debug( LOGGER.debug(
String.format("Created row in %d ms", String.format("Created row in %d ms",
System.currentTimeMillis() - rowStart)); System.currentTimeMillis() - rowStart));
} while (model.nextRow()); } while (model.nextRow());
logger.debug(String.format("Build table rows in %d ms", LOGGER.debug(String.format("Build table rows in %d ms",
System.currentTimeMillis() - start)); System.currentTimeMillis() - start));
} else if (m_emptyView != null) { } else if (m_emptyView != null) {
m_emptyView.generateXML(s, p); m_emptyView.generateXML(s, p);

View File

@ -38,18 +38,18 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
/** /**
* Used to print a tree structure. Nodes can be in expanded or * Used to print a tree structure. Nodes can be in expanded or collapsed state.
* collapsed state. <code>Tree</code> uses the getChildren() and * <code>Tree</code> uses the getChildren() and getRoot() methods from
* getRoot() methods from TreeModel and traverses the iterator to get * TreeModel and traverses the iterator to get to all the nodes.
* to all the nodes.
* *
* This class keeps track of which nodes are expanded and collapsed * This class keeps track of which nodes are expanded and collapsed and the
* and the hierarchy of nodes, and displays the tree correspondingly. * hierarchy of nodes, and displays the tree correspondingly.
* *
* @author David Lutterkort * @author David Lutterkort
* @author Stanislav Freidin * @author Stanislav Freidin
@ -58,11 +58,10 @@ import org.apache.log4j.Logger;
*/ */
public class Tree extends SimpleComponent implements Resettable { public class Tree extends SimpleComponent implements Resettable {
private static final Logger s_log = private static final Logger LOGGER = LogManager.getLogger(Tree.class);
Logger.getLogger(Tree.class);
private static final boolean s_selectAttributeEnabled = private static final boolean s_selectAttributeEnabled = BebopConfig
BebopConfig.getConfig().isTreeSelectEnabled(); .getConfig().isTreeSelectEnabled();
// Any node id in the currentState is equivalent // Any node id in the currentState is equivalent
// to that node being expanded. If node id is // to that node being expanded. If node id is
@ -96,8 +95,8 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Constructs a new <code>Tree</code> using the specified * Constructs a new <code>Tree</code> using the specified
* {@link TreeModelBuilder}. The {@link TreeModelBuilder} will * {@link TreeModelBuilder}. The {@link TreeModelBuilder} will instantiate a
* instantiate a {@link TreeModel} during each request. * {@link TreeModel} during each request.
* *
* @param b the {@link TreeModelBuilder} * @param b the {@link TreeModelBuilder}
*/ */
@ -106,31 +105,34 @@ public class Tree extends SimpleComponent implements Resettable {
m_currentState = new StringParameter(CURRENT_STATE); m_currentState = new StringParameter(CURRENT_STATE);
m_builder = b; m_builder = b;
m_renderer = new DefaultTreeCellRenderer(); m_renderer = new DefaultTreeCellRenderer();
m_selection = new ParameterSingleSelectionModel(new StringParameter(SELECT)); m_selection = new ParameterSingleSelectionModel(new StringParameter(
SELECT));
m_listeners = new EventListenerList(); m_listeners = new EventListenerList();
m_model = new RequestLocal() { m_model = new RequestLocal() {
protected Object initialValue(PageState s) {
return getModelBuilder().makeModel(Tree.this, s); protected Object initialValue(PageState s) {
} return getModelBuilder().makeModel(Tree.this, s);
}; }
};
m_tree = null; m_tree = null;
} }
/** /**
* Deprecated constructor that takes a default {@link TreeModel} * Deprecated constructor that takes a default {@link TreeModel} and wraps
* and wraps it in a dummy TreeModelBuilder. * it in a dummy TreeModelBuilder.
* *
* @param t the TreeModel * @param t the TreeModel
*
* @deprecated This constructor has been deprecated in favor of * @deprecated This constructor has been deprecated in favor of
* <code>Tree(TreeModelBuilder b)</code>. It is not practical * <code>Tree(TreeModelBuilder b)</code>. It is not practical to hardwire
* to hardwire the <code>TreeModel</code> into the <code>Tree</code>, * the <code>TreeModel</code> into the <code>Tree</code>, since the model
* since the model may change during each request. It is possible * may change during each request. It is possible to write the
* to write the model-instantiation code in * model-instantiation code in {@link TreeModel#getRoot(PageState)}, but the
* {@link TreeModel#getRoot(PageState)}, but the * {@link TreeModelBuilder} fits better into the pattern which has already
* {@link TreeModelBuilder} fits better into the pattern which has * been established by {@link List} and {@link Table}
* already been established by {@link List} and {@link Table}
*/ */
public Tree(TreeModel t) { public Tree(TreeModel t) {
this(new WrapperModelBuilder()); this(new WrapperModelBuilder());
@ -160,6 +162,7 @@ public class Tree extends SimpleComponent implements Resettable {
* Returns the tree model used for this tree. * Returns the tree model used for this tree.
* *
* @return a <code>TreeModel</code>. * @return a <code>TreeModel</code>.
*
* @see #setTreeModel setTreeModel * @see #setTreeModel setTreeModel
* @see TreeModel * @see TreeModel
* @deprecated Use {@link #getTreeModel(PageState)} instead * @deprecated Use {@link #getTreeModel(PageState)} instead
@ -169,18 +172,17 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Returns the {@link TreeModel} used by the tree for the current * Returns the {@link TreeModel} used by the tree for the current request.
* request.
* *
* @param s the page state * @param s the page state
*/ */
public TreeModel getTreeModel(PageState s) { public TreeModel getTreeModel(PageState s) {
return (TreeModel)m_model.get(s); return (TreeModel) m_model.get(s);
} }
/** /**
* @return the {@link TreeModelBuilder} used to build the tree model * @return the {@link TreeModelBuilder} used to build the tree model for
* for this tree. * this tree.
*/ */
public final TreeModelBuilder getModelBuilder() { public final TreeModelBuilder getModelBuilder() {
return m_builder; return m_builder;
@ -198,6 +200,7 @@ public class Tree extends SimpleComponent implements Resettable {
* Sets the tree model used for this tree. * Sets the tree model used for this tree.
* *
* @return a <code>TreeModel</code>. * @return a <code>TreeModel</code>.
*
* @see #setTreeModel setTreeModel * @see #setTreeModel setTreeModel
* @see TreeModel * @see TreeModel
*/ */
@ -207,22 +210,20 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Sets the selection model, which keeps track of which node is * Sets the selection model, which keeps track of which node is currently
* currently selected. It can be used to manipulate the selection * selected. It can be used to manipulate the selection programmatically.
* programmatically.
* *
* @param m the new selection model * @param m the new selection model
*/ */
public void setSelectionModel(SingleSelectionModel m) { public void setSelectionModel(SingleSelectionModel m) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
m_selection = m; m_selection = m;
s_log.debug("New model: " + m); LOGGER.debug("New model: " + m);
} }
/** /**
* Gets the selection model, which keeps track of which node is * Gets the selection model, which keeps track of which node is currently
* currently selected. It can be used to manipulate the selection * selected. It can be used to manipulate the selection programmatically.
* programmatically.
* *
* @return the model used by the tree to keep track of the selected node. * @return the model used by the tree to keep track of the selected node.
*/ */
@ -231,11 +232,13 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Gets the key for the selected node. This will only be a valid key * Gets the key for the selected node. This will only be a valid key if
* if {@link #isSelected isSelected} is <code>true</code>. * {@link #isSelected isSelected} is <code>true</code>.
* *
* @param state represents the state of the current request * @param state represents the state of the current request
*
* @return the key for the selected node. * @return the key for the selected node.
*
* @pre isSelected(state) * @pre isSelected(state)
*/ */
public Object getSelectedKey(PageState state) { public Object getSelectedKey(PageState state) {
@ -243,12 +246,13 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Sets the selection to the one with the specified key. If * Sets the selection to the one with the specified key. If <code>key</code>
* <code>key</code> was not selected already, fires the {@link * was not selected already, fires the {@link
* ChangeEvent}. * ChangeEvent}.
* *
* @param state represents the state of the current request * @param state represents the state of the current request
* @param key the key for the selected node * @param key the key for the selected node
*
* @see #fireStateChanged fireStateChanged * @see #fireStateChanged fireStateChanged
*/ */
public void setSelectedKey(PageState state, Object key) { public void setSelectedKey(PageState state, Object key) {
@ -259,8 +263,9 @@ public class Tree extends SimpleComponent implements Resettable {
* Returns <code>true</code> if one of the nodes is currently selected. * Returns <code>true</code> if one of the nodes is currently selected.
* *
* @param state represents the state of the current request * @param state represents the state of the current request
*
* @return <code>true</code> if one of the nodes is selected; * @return <code>true</code> if one of the nodes is selected;
* <code>false</code> otherwise. * <code>false</code> otherwise.
*/ */
public boolean isSelected(PageState state) { public boolean isSelected(PageState state) {
return m_selection.isSelected(state); return m_selection.isSelected(state);
@ -270,6 +275,7 @@ public class Tree extends SimpleComponent implements Resettable {
* Clears the selection in the request represented by <code>state</code>. * Clears the selection in the request represented by <code>state</code>.
* *
* @param state represents the state of the current request * @param state represents the state of the current request
*
* @post ! isSelected(state) * @post ! isSelected(state)
*/ */
public void clearSelection(PageState state) { public void clearSelection(PageState state) {
@ -277,8 +283,7 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Tells whether the tree has state on the request for tree node * Tells whether the tree has state on the request for tree node expansion.
* expansion.
*/ */
public final boolean hasExpansionState(final PageState state) { public final boolean hasExpansionState(final PageState state) {
return state.getValue(m_currentState) != null; return state.getValue(m_currentState) != null;
@ -294,17 +299,19 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Creates the change listener used for forwarding change events fired by * Creates the change listener used for forwarding change events fired by
* the selection model to change listeners registered with the tree. The * the selection model to change listeners registered with the tree. The
* returned change listener refires the event with the tree, * returned change listener refires the event with the tree, rather than the
* rather than the selection model, as source. * selection model, as source.
* *
* @return the change listener used internally by the tree. * @return the change listener used internally by the tree.
*/ */
protected ChangeListener createChangeListener() { protected ChangeListener createChangeListener() {
return new ChangeListener() { return new ChangeListener() {
public void stateChanged(ChangeEvent e) {
fireStateChanged(e.getPageState()); public void stateChanged(ChangeEvent e) {
} fireStateChanged(e.getPageState());
}; }
};
} }
/** /**
@ -312,17 +319,18 @@ public class Tree extends SimpleComponent implements Resettable {
* tree node changes during the processing of a request. The change event * tree node changes during the processing of a request. The change event
* that listeners receive names the tree as the source. * that listeners receive names the tree as the source.
* *
* @param l the change listener to run when the selected item changes in * @param l the change listener to run when the selected item changes in a
* a request * request
*
* @pre ! isLocked() * @pre ! isLocked()
*/ */
public void addChangeListener(ChangeListener l) { public void addChangeListener(ChangeListener l) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if ( m_changeListener == null ) { if (m_changeListener == null) {
m_changeListener = createChangeListener(); m_changeListener = createChangeListener();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Adding listener " + l + " to " + this); LOGGER.debug("Adding listener " + l + " to " + this);
} }
m_selection.addChangeListener(m_changeListener); m_selection.addChangeListener(m_changeListener);
@ -331,37 +339,35 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Removes a change listener. The listener should have been previously * Removes a change listener. The listener should have been previously added
* added with {@link #addChangeListener addChangeListener}, although no * with {@link #addChangeListener addChangeListener}, although no error is
* error is signalled if the change listener is not found among the * signalled if the change listener is not found among the tree's listeners.
* tree's listeners.
* *
* @param l the change listener to remove from the tree * @param l the change listener to remove from the tree
*/ */
public void removeChangeListener(ChangeListener l) { public void removeChangeListener(ChangeListener l) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Removing listener " + l + " from " + this); LOGGER.debug("Removing listener " + l + " from " + this);
} }
m_listeners.remove(ChangeListener.class, l); m_listeners.remove(ChangeListener.class, l);
} }
/** /**
* Fires a change event to signal that the selected list item has changed * Fires a change event to signal that the selected list item has changed in
* in the request represented by <code>state</code>. The source of the * the request represented by <code>state</code>. The source of the event is
* event is the tree. * the tree.
* *
* @param state represents the state of the current request * @param state represents the state of the current request
*/ */
protected void fireStateChanged(PageState state) { protected void fireStateChanged(PageState state) {
Iterator Iterator i = m_listeners.getListenerIterator(ChangeListener.class);
i=m_listeners.getListenerIterator(ChangeListener.class);
ChangeEvent e = null; ChangeEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
if ( e == null ) { if (e == null) {
e = new ChangeEvent(this, state); e = new ChangeEvent(this, state);
} }
((ChangeListener) i.next()).stateChanged(e); ((ChangeListener) i.next()).stateChanged(e);
@ -369,10 +375,9 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Adds a listener that is notified whenever a user clicks on any part * Adds a listener that is notified whenever a user clicks on any part of
* of the tree, either to expand or collapse a node, or to select a * the tree, either to expand or collapse a node, or to select a node. The
* node. The listener is run whenever {@link #respond respond} is * listener is run whenever {@link #respond respond} is called.
* called.
* *
* @pre l != null * @pre l != null
* @pre ! isLocked() * @pre ! isLocked()
@ -384,6 +389,7 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Removes a previously added <code>ActionListener</code>. * Removes a previously added <code>ActionListener</code>.
*
* @see #addActionListener addActionListener * @see #addActionListener addActionListener
*/ */
public void removeActionListener(ActionListener l) { public void removeActionListener(ActionListener l) {
@ -392,19 +398,18 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Notifies listeners that some part of the tree was clicked by the * Notifies listeners that some part of the tree was clicked by the user.
* user. The source of the event is the tree. * The source of the event is the tree.
* *
* @pre data != null * @pre data != null
* @see #respond respond * @see #respond respond
*/ */
protected void fireActionEvent(PageState data) { protected void fireActionEvent(PageState data) {
Iterator Iterator i = m_listeners.getListenerIterator(ActionListener.class);
i=m_listeners.getListenerIterator(ActionListener.class);
ActionEvent e = null; ActionEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
if ( e == null ) { if (e == null) {
e = new ActionEvent(this, data); e = new ActionEvent(this, data);
} }
((ActionListener) i.next()).actionPerformed(e); ((ActionListener) i.next()).actionPerformed(e);
@ -444,12 +449,12 @@ public class Tree extends SimpleComponent implements Resettable {
* @pre nodeKey != null * @pre nodeKey != null
*/ */
protected void fireTreeExpanded(PageState state, Object nodeKey) { protected void fireTreeExpanded(PageState state, Object nodeKey) {
Iterator i = Iterator i = m_listeners
m_listeners.getListenerIterator(TreeExpansionListener.class); .getListenerIterator(TreeExpansionListener.class);
TreeExpansionEvent e = null; TreeExpansionEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
if ( e == null ) { if (e == null) {
e = new TreeExpansionEvent(this, state, nodeKey); e = new TreeExpansionEvent(this, state, nodeKey);
} }
((TreeExpansionListener) i.next()).treeExpanded(e); ((TreeExpansionListener) i.next()).treeExpanded(e);
@ -465,12 +470,12 @@ public class Tree extends SimpleComponent implements Resettable {
* @pre nodeKey != null * @pre nodeKey != null
*/ */
protected void fireTreeCollapsed(PageState state, Object nodeKey) { protected void fireTreeCollapsed(PageState state, Object nodeKey) {
Iterator i = Iterator i = m_listeners
m_listeners.getListenerIterator(TreeExpansionListener.class); .getListenerIterator(TreeExpansionListener.class);
TreeExpansionEvent e = null; TreeExpansionEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
if ( e == null ) { if (e == null) {
e = new TreeExpansionEvent(this, state, nodeKey); e = new TreeExpansionEvent(this, state, nodeKey);
} }
((TreeExpansionListener) i.next()).treeCollapsed(e); ((TreeExpansionListener) i.next()).treeCollapsed(e);
@ -478,8 +483,8 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Notifies the <code>Tree</code> that a node has been selected. * Notifies the <code>Tree</code> that a node has been selected. Changes the
* Changes the currently selected tree component. * currently selected tree component.
*/ */
public void respond(PageState data) throws javax.servlet.ServletException { public void respond(PageState data) throws javax.servlet.ServletException {
String action = data.getControlEventName(); String action = data.getControlEventName();
@ -489,10 +494,11 @@ public class Tree extends SimpleComponent implements Resettable {
expand(node, data); expand(node, data);
} else if (COLLAPSE_EVENT.equals(action)) { } else if (COLLAPSE_EVENT.equals(action)) {
collapse(node, data); collapse(node, data);
} else if ( SELECT_EVENT.equals(action) ) { } else if (SELECT_EVENT.equals(action)) {
setSelectedKey(data, data.getControlEventValue()); setSelectedKey(data, data.getControlEventValue());
} else { } else {
throw new javax.servlet.ServletException("Unknown event '" + action + "'"); throw new javax.servlet.ServletException("Unknown event '" + action
+ "'");
} }
fireActionEvent(data); fireActionEvent(data);
} }
@ -500,11 +506,11 @@ public class Tree extends SimpleComponent implements Resettable {
////////////////////////////// //////////////////////////////
// MANAGE TREE'S NODE STATE // // MANAGE TREE'S NODE STATE //
////////////////////////////// //////////////////////////////
/** /**
* Determines whether the node at the specified display row is collapsed. * Determines whether the node at the specified display row is collapsed.
* @return <code>true</code> if the node at the specified display row is collapsed; *
* <code>false</code> otherwise. * @return <code>true</code> if the node at the specified display row is
* collapsed; <code>false</code> otherwise.
*/ */
public boolean isCollapsed(String nodeKey, PageState data) { public boolean isCollapsed(String nodeKey, PageState data) {
String stateString = (String) data.getValue(m_currentState); String stateString = (String) data.getValue(m_currentState);
@ -524,9 +530,8 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Collapses a node in the tree and makes its children visible. * Collapses a node in the tree and makes its children visible.
* *
* @param nodeKey the key that the tree model uses to identify the * @param nodeKey the key that the tree model uses to identify the node
* node * @param data represents the current request
* @param data represents the current request
* *
* @pre nodeKey != null * @pre nodeKey != null
* @pre data != null * @pre data != null
@ -546,10 +551,11 @@ public class Tree extends SimpleComponent implements Resettable {
// Found it; it should currently be expanded, so collapse it // Found it; it should currently be expanded, so collapse it
if (idIndex != -1) { if (idIndex != -1) {
newCurrentState newCurrentState
.append(stateString.substring(0,idIndex)) .append(stateString.substring(0, idIndex))
.append(" "); .append(" ");
if (stateString.length() > (idIndex + idLength)) { if (stateString.length() > (idIndex + idLength)) {
newCurrentState.append(stateString.substring(idIndex+idLength)); newCurrentState.append(stateString.substring(idIndex
+ idLength));
} }
data.setValue(m_currentState, newCurrentState.toString()); data.setValue(m_currentState, newCurrentState.toString());
fireTreeCollapsed(data, nodeKey); fireTreeCollapsed(data, nodeKey);
@ -560,9 +566,8 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Expands a node in the tree and makes its children visible. * Expands a node in the tree and makes its children visible.
* *
* @param nodeKey the key that the tree model uses to identify the * @param nodeKey the key that the tree model uses to identify the node
* node * @param data represents the current request
* @param data represents the current request
* *
* @pre nodeKey != null * @pre nodeKey != null
* @pre data != null * @pre data != null
@ -598,7 +603,6 @@ public class Tree extends SimpleComponent implements Resettable {
///////////////////////////////////////////// /////////////////////////////////////////////
// PRINT THE TREE DIRECTLY OR GENERATE DOM // // PRINT THE TREE DIRECTLY OR GENERATE DOM //
///////////////////////////////////////////// /////////////////////////////////////////////
/** /**
* Returns the renderer currently used to render tree nodes. * Returns the renderer currently used to render tree nodes.
* *
@ -619,9 +623,11 @@ public class Tree extends SimpleComponent implements Resettable {
m_renderer = r; m_renderer = r;
} }
private boolean hasSelectedChild(TreeModel tree, TreeNode node, PageState data, Object selKey) { private boolean hasSelectedChild(TreeModel tree, TreeNode node,
PageState data, Object selKey) {
String nodeKey = (String) node.getKey(); String nodeKey = (String) node.getKey();
if ( (selKey != null) && (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey)) ) { if ((selKey != null) && (selKey.equals(nodeKey) || selKey.toString()
.equals(nodeKey))) {
return true; return true;
} }
Iterator i = tree.getChildren(node, data); Iterator i = tree.getChildren(node, data);
@ -631,7 +637,8 @@ public class Tree extends SimpleComponent implements Resettable {
// At this point we should close the opened DataQuery pointed to by Iterator (i). // At this point we should close the opened DataQuery pointed to by Iterator (i).
// Since the data query is wrapped within DataQueryIterator, we don't have // Since the data query is wrapped within DataQueryIterator, we don't have
// access to it directly, so this looks like the only viable option ... // access to it directly, so this looks like the only viable option ...
while (i.hasNext()) { } while (i.hasNext()) {
}
return true; return true;
} }
} }
@ -643,14 +650,15 @@ public class Tree extends SimpleComponent implements Resettable {
* *
*/ */
protected void generateTree(PageState data, Element parent, TreeNode node, protected void generateTree(PageState data, Element parent, TreeNode node,
TreeModel tree) { TreeModel tree) {
Element t_node = parent.newChildElement ("bebop:t_node", BEBOP_XML_NS); Element t_node = parent.newChildElement("bebop:t_node", BEBOP_XML_NS);
String nodeKey = (String) node.getKey(); String nodeKey = node.getKey().toString();
Object selKey = getSelectedKey(data); Object selKey = getSelectedKey(data);
boolean isSelected = (selKey != null) boolean isSelected = (selKey != null)
&& (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey)); && (selKey.equals(nodeKey) || selKey.toString()
.equals(nodeKey));
boolean hasChildren = tree.hasChildren(node, data); boolean hasChildren = tree.hasChildren(node, data);
if (s_selectAttributeEnabled) { if (s_selectAttributeEnabled) {
@ -658,36 +666,44 @@ public class Tree extends SimpleComponent implements Resettable {
if (!isSelected && hasChildren) { if (!isSelected && hasChildren) {
hasSelectedChild = hasSelectedChild(tree, node, data, selKey); hasSelectedChild = hasSelectedChild(tree, node, data, selKey);
} }
t_node.addAttribute("isSelected", String.valueOf(isSelected | hasSelectedChild)); t_node.addAttribute("isSelected", String.valueOf(isSelected
| hasSelectedChild));
} }
if (hasChildren) { if (hasChildren) {
boolean collapsed = isCollapsed(nodeKey,data); boolean collapsed = isCollapsed(nodeKey, data);
data.setControlEvent(this, collapsed ? EXPAND_EVENT : COLLAPSE_EVENT, nodeKey); data
.setControlEvent(this, collapsed ? EXPAND_EVENT : COLLAPSE_EVENT,
nodeKey);
try { try {
t_node.addAttribute("href", data.stateAsURL()); t_node.addAttribute("href", data.stateAsURL());
} catch (java.io.IOException ioe) { } catch (java.io.IOException ioe) {
// TODO: stateAsURL failed // TODO: stateAsURL failed
} }
data.clearControlEvent(); data.clearControlEvent();
if ( collapsed ) { if (collapsed) {
// Collapsed // Collapsed
t_node.addAttribute("collapsed", "t"); t_node.addAttribute("collapsed", "t");
data.setControlEvent(this, SELECT_EVENT, nodeKey); data.setControlEvent(this, SELECT_EVENT, nodeKey);
Component c = getCellRenderer().getComponent(this, data, Component c = getCellRenderer().getComponent(this, data,
node.getElement(), isSelected, NOT_EXPANDED, NOT_LEAF, node.getElement(),
nodeKey); isSelected,
NOT_EXPANDED,
NOT_LEAF,
nodeKey);
c.generateXML(data, t_node); c.generateXML(data, t_node);
} else { } else {
// Expanded // Expanded
t_node.addAttribute("expanded", "t"); t_node.addAttribute("expanded", "t");
data.setControlEvent(this, SELECT_EVENT, nodeKey); data.setControlEvent(this, SELECT_EVENT, nodeKey);
Component c = getCellRenderer().getComponent(this, data, Component c = getCellRenderer().getComponent(this, data,
node.getElement(), isSelected, EXPANDED, NOT_LEAF, node.getElement(),
nodeKey); isSelected,
EXPANDED, NOT_LEAF,
nodeKey);
c.generateXML(data, t_node); c.generateXML(data, t_node);
t_node.addAttribute("indentStart", "t"); t_node.addAttribute("indentStart", "t");
for(Iterator i = tree.getChildren(node,data); i.hasNext(); ) { for (Iterator i = tree.getChildren(node, data); i.hasNext();) {
generateTree(data, t_node, (TreeNode) i.next(), tree); generateTree(data, t_node, (TreeNode) i.next(), tree);
} }
t_node.addAttribute("indentClose", "t"); t_node.addAttribute("indentClose", "t");
@ -697,24 +713,27 @@ public class Tree extends SimpleComponent implements Resettable {
t_node.addAttribute("childless", "t"); t_node.addAttribute("childless", "t");
data.setControlEvent(this, SELECT_EVENT, nodeKey); data.setControlEvent(this, SELECT_EVENT, nodeKey);
Component c = getCellRenderer().getComponent(this, data, Component c = getCellRenderer().getComponent(this, data,
node.getElement(), isSelected, NOT_EXPANDED, LEAF, nodeKey); node.getElement(),
isSelected,
NOT_EXPANDED, LEAF,
nodeKey);
c.generateXML(data, t_node); c.generateXML(data, t_node);
} }
} }
/** /**
* Services the request by building a DOM tree with the nodes * Services the request by building a DOM tree with the nodes first and then
* first and then the included page. * the included page.
*/ */
public void generateXML(PageState data, Element parent) { public void generateXML(PageState data, Element parent) {
TreeModel tree = getTreeModel(data); TreeModel tree = getTreeModel(data);
if ( ! isVisible(data) ) { if (!isVisible(data)) {
return; return;
} }
treeElement = parent.newChildElement ("bebop:tree", BEBOP_XML_NS); treeElement = parent.newChildElement("bebop:tree", BEBOP_XML_NS);
exportAttributes(treeElement); exportAttributes(treeElement);
TreeNode _rootNode = tree.getRoot(data); TreeNode _rootNode = tree.getRoot(data);
@ -725,14 +744,16 @@ public class Tree extends SimpleComponent implements Resettable {
/** /**
* Manage the selected item by manipulating the state parameter. * Manage the selected item by manipulating the state parameter.
* *
* @deprecated The {@link ParameterSingleSelectionModel} contains * @deprecated The {@link ParameterSingleSelectionModel} contains all the
* all the functionality of this class * functionality of this class
*/ */
public static class TreeSingleSelectionModel public static class TreeSingleSelectionModel
extends ParameterSingleSelectionModel { extends ParameterSingleSelectionModel {
public TreeSingleSelectionModel(ParameterModel m) { public TreeSingleSelectionModel(ParameterModel m) {
super(m); super(m);
} }
} }
/** /**
@ -744,8 +765,8 @@ public class Tree extends SimpleComponent implements Resettable {
} }
/** /**
* Returns the tree model of the tree. A wrapper class to make * Returns the tree model of the tree. A wrapper class to make deprecated
* deprecated constructor work. * constructor work.
*/ */
private static class WrapperModelBuilder extends LockableImpl private static class WrapperModelBuilder extends LockableImpl
implements TreeModelBuilder { implements TreeModelBuilder {
@ -757,6 +778,7 @@ public class Tree extends SimpleComponent implements Resettable {
public TreeModel makeModel(Tree t, PageState s) { public TreeModel makeModel(Tree t, PageState s) {
return t.getTreeModel(); return t.getTreeModel();
} }
} }
} }

View File

@ -37,7 +37,6 @@ import java.util.List;
import java.util.Iterator; import java.util.Iterator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger;
/** /**
* <p>Multiple select widget pair for knowledge types. This FormStep * <p>Multiple select widget pair for knowledge types. This FormStep
@ -68,9 +67,6 @@ import org.apache.log4j.Logger;
*/ */
public class MultipleSelectPairWidget extends FormStep { public class MultipleSelectPairWidget extends FormStep {
private static final Logger s_log =
Logger.getLogger(MultipleSelectPairWidget.class);
private Hidden m_addSelectOptions; private Hidden m_addSelectOptions;
private Hidden m_removeSelectOptions; private Hidden m_removeSelectOptions;
private MultipleSelect m_addSelect; private MultipleSelect m_addSelect;

View File

@ -29,6 +29,9 @@ import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.text.Collator; import java.text.Collator;
import java.util.Iterator; import java.util.Iterator;
@ -40,7 +43,6 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
@ -51,11 +53,10 @@ import org.libreccm.l10n.GlobalizationHelper;
* @author Uday Mathur * @author Uday Mathur
* @author Rory Solomon * @author Rory Solomon
* @author Michael Pih * @author Michael Pih
* @version $Id$
*/ */
public abstract class OptionGroup extends Widget implements BebopConstants { public abstract class OptionGroup extends Widget implements BebopConstants {
private static final Logger LOGGER = Logger.getLogger(OptionGroup.class); private static final Logger LOGGER = LogManager.getLogger(OptionGroup.class);
/** /**
* The XML element to be used by individual options belonging to this group. * The XML element to be used by individual options belonging to this group.

View File

@ -36,8 +36,11 @@ import com.arsdigita.bebop.parameters.ParameterData;
// in a constant which is used when generating XML // in a constant which is used when generating XML
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
import org.apache.log4j.Logger;
/** /**
* Search and select Bebop widget. This widget is used to allow a user to search * Search and select Bebop widget. This widget is used to allow a user to search
@ -47,18 +50,17 @@ import org.apache.log4j.Logger;
* once the user submits the form, allowing them then to choose the items they * once the user submits the form, allowing them then to choose the items they
* desire. * desire.
* <p> * <p>
* The datasource for SearchAndSelect is provided by an implentation of the * The data source for SearchAndSelect is provided by an implementation of the
* SearchAndSelectModel interface. SAMPLE IMPLEMENTATION GOES HERE * SearchAndSelectModel interface. SAMPLE IMPLEMENTATION GOES HERE
* *
* @author Patrick McNeill * @author Patrick McNeill
* @version $Id$
* @since 4.5 * @since 4.5
*/ */
public class SearchAndSelect extends FormSection public class SearchAndSelect extends FormSection implements BebopConstants,
implements BebopConstants, PrintListener { PrintListener {
private static final Logger s_cat private static final Logger LOGGER = LogManager.getLogger(
= Logger.getLogger(SearchAndSelect.class); SearchAndSelect.class);
protected String m_name; protected String m_name;
// name of this super-widget // name of this super-widget
@ -120,7 +122,7 @@ public class SearchAndSelect extends FormSection
m_outputSelectWidget = new CheckboxGroup(getName() + ".select"); m_outputSelectWidget = new CheckboxGroup(getName() + ".select");
} else { } else {
m_outputSelectWidget m_outputSelectWidget
= new MultipleSelect(getName() + ".select"); = new MultipleSelect(getName() + ".select");
} }
} else { } else {
m_outputSelectWidget = new SingleSelect(getName() + ".select"); m_outputSelectWidget = new SingleSelect(getName() + ".select");
@ -130,15 +132,16 @@ public class SearchAndSelect extends FormSection
try { try {
m_outputSelectWidget.addPrintListener(this); m_outputSelectWidget.addPrintListener(this);
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
s_cat.error("Could not add print listener", e); LOGGER.error("Could not add print listener", e);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
s_cat.error("Could not add print listener", e); LOGGER.error("Could not add print listener", e);
} }
} }
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
if (m_results == null) { if (m_results == null) {
m_results = m_listener.getModel(new PageEvent(this, e.getPageState())); m_results = m_listener.getModel(
new PageEvent(this, e.getPageState()));
} }
if (m_results == null) { if (m_results == null) {
@ -149,9 +152,9 @@ public class SearchAndSelect extends FormSection
if (m_isSearchLocked if (m_isSearchLocked
|| (((!m_oldValue.equals("") || (((!m_oldValue.equals("")
&& m_oldValue.equals(m_value)) && m_oldValue.equals(m_value))
|| (m_maxViewableResults >= m_results.resultsCount())) || (m_maxViewableResults >= m_results.resultsCount()))
&& (m_results.resultsCount() > 0))) { && (m_results.resultsCount() > 0))) {
OptionGroup outputWidget = (OptionGroup) e.getTarget(); OptionGroup outputWidget = (OptionGroup) e.getTarget();
outputWidget.clearOptions(); outputWidget.clearOptions();
@ -162,9 +165,9 @@ public class SearchAndSelect extends FormSection
for (int i = 0; i < m_results.resultsCount(); i++) { for (int i = 0; i < m_results.resultsCount(); i++) {
outputWidget.addOption( outputWidget.addOption(
new Option(m_results.getID(i), m_results.getLabel(i))); new Option(m_results.getID(i), m_results.getLabel(i)));
s_cat.debug(" " + m_results.getID(i)); LOGGER.debug(" " + m_results.getID(i));
} }
} }
} }
@ -182,12 +185,12 @@ public class SearchAndSelect extends FormSection
* Create a new SearchAndSelect widget with the specified name and * Create a new SearchAndSelect widget with the specified name and
* SearchAndSelectModel. * SearchAndSelectModel.
* *
* @param name the name of the widget * @param name the name of the widget
* @param isMultiple whether or not the widget accepts multiple values * @param isMultiple whether or not the widget accepts multiple values
* @param useCheckboxes use checkboxes or a multiselect * @param useCheckboxes use checkboxes or a multiselect
*/ */
public SearchAndSelect(String name, public SearchAndSelect(String name,
boolean isMultiple) { boolean isMultiple) {
this(name, isMultiple, false); this(name, isMultiple, false);
} }
@ -195,13 +198,13 @@ public class SearchAndSelect extends FormSection
* Create a new SearchAndSelect widget with the specified name and * Create a new SearchAndSelect widget with the specified name and
* SearchAndSelectModel. * SearchAndSelectModel.
* *
* @param name the name of the widget * @param name the name of the widget
* @param isMultiple whether or not the widget accepts multiple values * @param isMultiple whether or not the widget accepts multiple values
* @param useCheckboxes use checkboxes or a multiselect * @param useCheckboxes use checkboxes or a multiselect
*/ */
public SearchAndSelect(String name, public SearchAndSelect(String name,
boolean isMultiple, boolean isMultiple,
boolean useCheckboxes) { boolean useCheckboxes) {
super(new SimpleContainer()); super(new SimpleContainer());
@ -219,12 +222,13 @@ public class SearchAndSelect extends FormSection
* user as the error field is also used as a help field. * user as the error field is also used as a help field.
*/ */
super.addValidationListener(new FormValidationListener() { super.addValidationListener(new FormValidationListener() {
@Override @Override
public void validate(FormSectionEvent e) { public void validate(FormSectionEvent e) {
FormData data = e.getFormData(); FormData data = e.getFormData();
m_results = m_listener.getModel( m_results = m_listener.getModel(
new PageEvent(m_this, e.getPageState())); new PageEvent(m_this, e.getPageState()));
if (m_results == null) { if (m_results == null) {
return; return;
@ -244,7 +248,7 @@ public class SearchAndSelect extends FormSection
if (m_isMultiple) { if (m_isMultiple) {
String[] tmpArray = (String[]) data String[] tmpArray = (String[]) data
.get(getName() + ".select"); .get(getName() + ".select");
if (tmpArray == null) { if (tmpArray == null) {
m_value = ""; m_value = "";
} else { } else {
@ -286,22 +290,22 @@ public class SearchAndSelect extends FormSection
if (m_isSearchLocked) { if (m_isSearchLocked) {
if (!m_isMultiple) { if (!m_isMultiple) {
StringParameter param StringParameter param
= new StringParameter(getName()); = new StringParameter(getName());
data.setParameter(getName(), data.setParameter(getName(),
new ParameterData(param, m_value)); new ParameterData(param, m_value));
} else { } else {
ArrayParameter param ArrayParameter param
= new ArrayParameter(getName()); = new ArrayParameter(getName());
String[] tmpArray = (String[]) data String[] tmpArray = (String[]) data
.get(getName() + ".select"); .get(getName() + ".select");
if (tmpArray == null) { if (tmpArray == null) {
tmpArray = new String[0]; tmpArray = new String[0];
} }
data.setParameter(getName(), data.setParameter(getName(),
new ParameterData(param, tmpArray)); new ParameterData(param, tmpArray));
} }
return; return;
@ -311,10 +315,12 @@ public class SearchAndSelect extends FormSection
m_results.setQuery(oldQuery); m_results.setQuery(oldQuery);
} }
}); });
} }
public final void setSearchAndSelectListener(SearchAndSelectListener listener) { public final void setSearchAndSelectListener(
SearchAndSelectListener listener) {
m_listener = listener; m_listener = listener;
} }
@ -406,7 +412,7 @@ public class SearchAndSelect extends FormSection
* textbox, checkbox group, or select, and possibly some number of * textbox, checkbox group, or select, and possibly some number of
* formErrors. * formErrors.
* *
* @param state the state of the page * @param state the state of the page
* @param parent the parent widget * @param parent the parent widget
*/ */
public void generateXML(PageState state, Element parent) { public void generateXML(PageState state, Element parent) {
@ -420,9 +426,9 @@ public class SearchAndSelect extends FormSection
if (m_isSearchLocked if (m_isSearchLocked
|| (((!m_oldValue.equals("") || (((!m_oldValue.equals("")
&& m_oldValue.equals(m_value)) && m_oldValue.equals(m_value))
|| (m_maxViewableResults >= m_results.resultsCount())) || (m_maxViewableResults >= m_results.resultsCount()))
&& (m_results.resultsCount() > 0))) { && (m_results.resultsCount() > 0))) {
m_outputSelectWidget.generateXML(state, parent); m_outputSelectWidget.generateXML(state, parent);
} else { } else {
m_outputTextWidget.generateXML(state, parent); m_outputTextWidget.generateXML(state, parent);
@ -441,7 +447,7 @@ public class SearchAndSelect extends FormSection
* error generator. Basically, the m_results field won't be available * error generator. Basically, the m_results field won't be available
* outside this class, so this needs to be internal. * outside this class, so this needs to be internal.
* *
* @param state the state of the page * @param state the state of the page
* @param parent the parent widget * @param parent the parent widget
*/ */
protected void generateErrors(PageState state, Element parent) { protected void generateErrors(PageState state, Element parent) {
@ -453,29 +459,33 @@ public class SearchAndSelect extends FormSection
if (m_results.resultsCount() > m_maxViewableResults) { if (m_results.resultsCount() > m_maxViewableResults) {
Element error = parent.newChildElement("bebop:formErrors", BEBOP_XML_NS); Element error = parent.newChildElement("bebop:formErrors",
BEBOP_XML_NS);
if ((curValue == null) || (curValue.equals(""))) { if ((curValue == null) || (curValue.equals(""))) {
error.addAttribute("message", error.addAttribute("message",
"Please enter a comma-delimited search"); "Please enter a comma-delimited search");
} else if ((!m_oldValue.equals(curValue)) } else if ((!m_oldValue.equals(curValue))
&& !m_isSearchLocked) { && !m_isSearchLocked) {
error.addAttribute("message", error.addAttribute("message",
"Your search returned " "Your search returned "
+ m_results.resultsCount() + " matches. " + m_results.resultsCount()
+ "Please refine your search or leave the " + " matches. "
+ "search as it is to see all results."); + "Please refine your search or leave the "
+ "search as it is to see all results.");
} }
} }
if (m_results.resultsCount() == 0) { if (m_results.resultsCount() == 0) {
if (!curValue.equals("")) { if (!curValue.equals("")) {
Element error = parent.newChildElement("bebop:formErrors", BEBOP_XML_NS); Element error = parent.newChildElement("bebop:formErrors",
BEBOP_XML_NS);
error.addAttribute("message", error.addAttribute("message",
"Your search returned no matches. Please " "Your search returned no matches. Please "
+ "try again"); + "try again");
} else { } else {
Element error = parent.newChildElement("bebop:formErrors", BEBOP_XML_NS); Element error = parent.newChildElement("bebop:formErrors",
BEBOP_XML_NS);
error.addAttribute("message", "WARNING -- NO DATA FOUND"); error.addAttribute("message", "WARNING -- NO DATA FOUND");
} }
} }

View File

@ -24,8 +24,6 @@ import java.util.TooManyListenersException;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import com.arsdigita.bebop.DescriptiveComponent; import com.arsdigita.bebop.DescriptiveComponent;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
@ -46,39 +44,33 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* <p>
* A class representing a widget in the graphical representation of a form. * A class representing a widget in the graphical representation of a form.
* </p>
* *
* <p>
* A widget may correspond to a standard HTML form element, or to a more * A widget may correspond to a standard HTML form element, or to a more
* specific element or set of elements, such as a date widget that allows * specific element or set of elements, such as a date widget that allows
* input of month, day and year (and possibly time as well).</p> * input of month, day and year (and possibly time as well).
* *
* <p>
* This class and its subclasses provide methods to set all element attributes * This class and its subclasses provide methods to set all element attributes
* except for <code>VALUE</code>, which is typically dependent on the request. * except for <code>VALUE</code>, which is typically dependent on the request.
* At the time of a request, a widget object merges a dynamically specified * At the time of a request, a widget object merges a dynamically specified
* value or set of values with its own set of persistent attributes to render * value or set of values with its own set of persistent attributes to render
* the final HTML for the widget. Other dynamic attributes may be associated with * the final HTML for the widget. Other dynamic attributes may be associated with
* the form component via a <code>WidgetPeer</code> associated with the widget. * the form component via a <code>WidgetPeer</code> associated with the widget.
* </p> *
* <p>
* The parent class provides the Label (the localized title) for the widget as * The parent class provides the Label (the localized title) for the widget as
* well as a (localized) hint as a kind of online manual for the user. * well as a (localized) hint as a kind of online manual for the user.
* </p>
* *
* @author Karl Goldstein * @author Karl Goldstein
* @author Uday Mathur * @author Uday Mathur
* @author Rory Solomon * @author Rory Solomon
* @version $Id$
*/ */
public abstract class Widget extends DescriptiveComponent public abstract class Widget extends DescriptiveComponent
implements Cloneable, BebopConstants { implements Cloneable, BebopConstants {
private static final Logger s_log = Logger.getLogger(Widget.class);
private ParameterModel m_parameterModel; private ParameterModel m_parameterModel;
private final EventListenerList m_listeners = new EventListenerList(); private final EventListenerList m_listeners = new EventListenerList();
private ParameterListener m_forwardParameter = null; private ParameterListener m_forwardParameter = null;

View File

@ -34,6 +34,9 @@ import com.arsdigita.web.TransformationDebugger;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -54,7 +57,6 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
@ -70,18 +72,18 @@ import org.libreccm.l10n.GlobalizationHelper;
* <em>package</em> mounted on each site node. * <em>package</em> mounted on each site node.
* *
* @author Bill Schneider * @author Bill Schneider
* @version $Id: PageTransformer.java 2071 2010-01-28 18:24:06Z pboy $
*/ */
public class PageTransformer implements PresentationManager { public class PageTransformer implements PresentationManager {
private static final Logger s_log = Logger.getLogger(PageTransformer.class); private static final Logger LOGGER = LogManager.getLogger(PageTransformer.class);
// this keeps track of all of the XSLParameters that can be added to // this keeps track of all of the XSLParameters that can be added to
// stylesheets // stylesheets
private static final HashMap s_XSLParameters = new HashMap(); private static final HashMap s_XSLParameters = new HashMap();
// load the default xsl parameter generators // load the default xsl parameter generators
static { static {
s_log.debug("Static initalizer starting..."); LOGGER.debug("Static initalizer starting...");
registerXSLParameterGenerator("contextPath", registerXSLParameterGenerator("contextPath",
new XSLParameterGenerator() { new XSLParameterGenerator() {
@ -284,7 +286,7 @@ public class PageTransformer implements PresentationManager {
}); });
s_log.debug("Static initalizer finished."); LOGGER.debug("Static initalizer finished.");
} }
// XXX These need to move somewhere else. // XXX These need to move somewhere else.
@ -345,7 +347,7 @@ public class PageTransformer implements PresentationManager {
try { try {
return resp.getWriter(); return resp.getWriter();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
s_log.warn("Using getOutputStream instead of getWriter"); LOGGER.warn("Using getOutputStream instead of getWriter");
try { try {
return new PrintWriter(new OutputStreamWriter(resp. return new PrintWriter(new OutputStreamWriter(resp.
@ -402,7 +404,7 @@ public class PageTransformer implements PresentationManager {
.getDefaultCharset(DispatcherHelper.getNegotiatedLocale()); .getDefaultCharset(DispatcherHelper.getNegotiatedLocale());
final String output = req.getParameter("output"); final String output = req.getParameter("output");
s_log.info("output=" + output); LOGGER.info("output=" + output);
if (output == null) { if (output == null) {

View File

@ -24,7 +24,6 @@ package com.arsdigita.bebop.parameters;
* *
* @author Karl Goldstein * @author Karl Goldstein
* @author Uday Mathur * @author Uday Mathur
* @version $Id$
*/ */
public class IntegerParameter extends NumberParameter { public class IntegerParameter extends NumberParameter {
@ -32,6 +31,7 @@ public class IntegerParameter extends NumberParameter {
super(name); super(name);
} }
@Override
public Object unmarshal(String encoded) { public Object unmarshal(String encoded) {
if( encoded == null || encoded.length() == 0 ) { if( encoded == null || encoded.length() == 0 ) {
return null; return null;

View File

@ -31,8 +31,6 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import java.util.Objects; import java.util.Objects;
/** /**
@ -42,13 +40,9 @@ import java.util.Objects;
* @author Karl Goldstein * @author Karl Goldstein
* @author Uday Mathur * @author Uday Mathur
* *
* @version $Id$
*/ */
public abstract class ParameterModel implements Lockable { public abstract class ParameterModel implements Lockable {
private static final Logger s_log = Logger
.getLogger(ParameterModel.class.getName());
/** /**
* The name of this ParameterModel. The constructor will throw an * The name of this ParameterModel. The constructor will throw an
* exception if the specified name is null * exception if the specified name is null

View File

@ -34,7 +34,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.apache.log4j.Logger;
import org.w3c.tidy.Tidy; import org.w3c.tidy.Tidy;
/** /**
@ -76,14 +75,9 @@ import org.w3c.tidy.Tidy;
* providing a validation listener based on JTidy. </p> * providing a validation listener based on JTidy. </p>
* *
* @author Vadim Nasardinov (vadimn@redhat.com) * @author Vadim Nasardinov (vadimn@redhat.com)
* @version $Id$
* @since 2002-08-16 21:46:25 -0400
**/ **/
public class TidyHTMLValidationListener implements ParameterListener { public class TidyHTMLValidationListener implements ParameterListener {
private static final Logger s_log =
Logger.getLogger(TidyHTMLValidationListener.class);
private static String LINE_SEPARATOR = System.getProperty("line.separator"); private static String LINE_SEPARATOR = System.getProperty("line.separator");
private static LockableProperties s_tidyProperties; private static LockableProperties s_tidyProperties;

View File

@ -21,15 +21,15 @@ package com.arsdigita.bebop.parameters;
import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.parameters.ParameterData;
import org.apache.logging.log4j.LogManager;
import org.apache.oro.text.perl.Perl5Util; import org.apache.oro.text.perl.Perl5Util;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
public class WordValidationListener implements ParameterListener { public class WordValidationListener implements ParameterListener {
private static final Logger s_log =
Logger.getLogger( WordValidationListener.class ); private static final Logger LOGGER = LogManager.getLogger( WordValidationListener.class );
public void validate(ParameterEvent e) public void validate(ParameterEvent e)
throws FormProcessException { throws FormProcessException {
@ -39,8 +39,8 @@ public class WordValidationListener implements ParameterListener {
if( null == value ) return; if( null == value ) return;
if( s_log.isDebugEnabled() ) { if( LOGGER.isDebugEnabled() ) {
s_log.debug( "Name: " + d.getName() + ", Value: " + value ); LOGGER.debug( "Name: " + d.getName() + ", Value: " + value );
} }
Perl5Util re = new Perl5Util(); Perl5Util re = new Perl5Util();

View File

@ -21,8 +21,11 @@ package com.arsdigita.bebop.util;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* <p></p> * <p></p>
@ -34,10 +37,10 @@ import org.apache.log4j.Logger;
* This filter may be used to skip only individual components or entire * This filter may be used to skip only individual components or entire
* subtrees. The default filter matches all components.</p> * subtrees. The default filter matches all components.</p>
* *
* @version $Id: Traversal.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public abstract class Traversal { public abstract class Traversal {
private static final Logger s_log = Logger.getLogger(Traversal.class);
private static final Logger LOGGER = LogManager.getLogger(Traversal.class);
/** /**
* If <code>test</code> returns <code>PERFORM_ACTION</code>, * If <code>test</code> returns <code>PERFORM_ACTION</code>,
@ -63,7 +66,7 @@ public abstract class Traversal {
private Set m_visiting = null; private Set m_visiting = null;
{ {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
m_visiting = new HashSet(); m_visiting = new HashSet();
} }
} }
@ -84,8 +87,8 @@ public abstract class Traversal {
* *
* @param c the component on which to call {@link #act}. */ * @param c the component on which to call {@link #act}. */
public void preorder(Component c) { public void preorder(Component c) {
if (s_log.isDebugEnabled() && m_visiting.contains(c)) { if (LOGGER.isDebugEnabled() && m_visiting.contains(c)) {
s_log.debug("Cycle detected at component " + c + LOGGER.debug("Cycle detected at component " + c +
"; visiting nodes: " + m_visiting); "; visiting nodes: " + m_visiting);
throw new IllegalStateException throw new IllegalStateException
("Component " + c + " is part of a cycle"); ("Component " + c + " is part of a cycle");
@ -100,7 +103,7 @@ public abstract class Traversal {
} }
if (flag != SKIP_SUBTREE) { if (flag != SKIP_SUBTREE) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
m_visiting.add(c); m_visiting.add(c);
} }
@ -109,7 +112,7 @@ public abstract class Traversal {
} }
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
m_visiting.remove(c); m_visiting.remove(c);
} }
} }

View File

@ -36,7 +36,8 @@ import javax.servlet.http.HttpSession;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
@ -81,7 +82,7 @@ import org.xml.sax.helpers.DefaultHandler;
public abstract class BaseDispatcherServlet extends HttpServlet public abstract class BaseDispatcherServlet extends HttpServlet
implements Dispatcher, DispatcherConstants { implements Dispatcher, DispatcherConstants {
private static final Logger s_log = Logger.getLogger( private static final Logger LOGGER = LogManager.getLogger(
BaseDispatcherServlet.class); BaseDispatcherServlet.class);
private final static int NOT_FOUND = 0; private final static int NOT_FOUND = 0;
private final static int STATIC_FILE = 1; private final static int STATIC_FILE = 1;
@ -99,9 +100,10 @@ public abstract class BaseDispatcherServlet extends HttpServlet
* list of active requests * list of active requests
*/ */
private static Vector s_activeList = new Vector(); private static Vector s_activeList = new Vector();
private static final long serialVersionUID = 7349556332411247334L;
static { static {
s_log.debug("Static initalizer starting..."); LOGGER.debug("Static initalizer starting...");
// Add the basic request listeners. // Add the basic request listeners.
BaseDispatcherServlet.addRequestListener(new RequestListener() { BaseDispatcherServlet.addRequestListener(new RequestListener() {
@ -136,7 +138,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
}); });
s_log.debug("Static initalizer finished."); LOGGER.debug("Static initalizer finished.");
} }
private List m_welcomeFiles = new ArrayList(); private List m_welcomeFiles = new ArrayList();
@ -157,11 +159,11 @@ public abstract class BaseDispatcherServlet extends HttpServlet
SAXParser parser = spf.newSAXParser(); SAXParser parser = spf.newSAXParser();
parser.parse(file, new WebXMLReader()); parser.parse(file, new WebXMLReader());
} catch (SAXException se) { } catch (SAXException se) {
s_log.error("error in init", se); LOGGER.error("error in init", se);
} catch (ParserConfigurationException pce) { } catch (ParserConfigurationException pce) {
s_log.error("error in init", pce); LOGGER.error("error in init", pce);
} catch (IOException ioe) { } catch (IOException ioe) {
s_log.error("error in init", ioe); LOGGER.error("error in init", ioe);
} }
// default to index.jsp, index.html // default to index.jsp, index.html
if (m_welcomeFiles.isEmpty()) { if (m_welcomeFiles.isEmpty()) {
@ -225,8 +227,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet
public void service(HttpServletRequest req, HttpServletResponse resp) public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException { throws ServletException, IOException {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("\n*** *** *** *** *** ***\n" LOGGER.debug("\n*** *** *** *** *** ***\n"
+ "Servicing request for URL '" + req + "Servicing request for URL '" + req
.getRequestURI() .getRequestURI()
+ "'\n" + "*** *** *** *** *** ***"); + "'\n" + "*** *** *** *** *** ***");
@ -268,7 +270,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
// (defer serving concrete JSPs until after listeners run) // (defer serving concrete JSPs until after listeners run)
int concreteFileType = concreteFileType(req); int concreteFileType = concreteFileType(req);
if (concreteFileType == STATIC_FILE) { if (concreteFileType == STATIC_FILE) {
s_log.debug("Setting world cache headers on static file"); LOGGER.debug("Setting world cache headers on static file");
DispatcherHelper.cacheForWorld(resp); DispatcherHelper.cacheForWorld(resp);
DispatcherHelper.forwardRequestByName("default", req, resp, DispatcherHelper.forwardRequestByName("default", req, resp,
getServletContext()); getServletContext());
@ -294,7 +296,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
StartRequestRecord srr = startRequest(req, resp); StartRequestRecord srr = startRequest(req, resp);
reqCtx = srr.m_reqCtx; reqCtx = srr.m_reqCtx;
req = srr.m_req; req = srr.m_req;
s_log.debug("After startRequest the request is now " + req); LOGGER.debug("After startRequest the request is now " + req);
} catch (RedirectException re) { } catch (RedirectException re) {
final String url = re.getRedirectURL(); final String url = re.getRedirectURL();
@ -347,7 +349,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
// try to commit // try to commit
finishedNormal = true; finishedNormal = true;
} catch (IOException ioe) { } catch (IOException ioe) {
s_log.error("error in BaseDispatcherServlet", ioe); LOGGER.error("error in BaseDispatcherServlet", ioe);
throw ioe; throw ioe;
} catch (ServletException se) { } catch (ServletException se) {
// SDM #140226, improved handling of // SDM #140226, improved handling of
@ -368,17 +370,17 @@ public abstract class BaseDispatcherServlet extends HttpServlet
finishedNormal = true; finishedNormal = true;
} else if (rootError != null } else if (rootError != null
&& (rootError instanceof RedirectSignal)) { && (rootError instanceof RedirectSignal)) {
s_log.debug("rethrowing RedirectSignal", rootError); LOGGER.debug("rethrowing RedirectSignal", rootError);
throw (RedirectSignal) rootError; throw (RedirectSignal) rootError;
} else { } else {
s_log.error("error in BaseDispatcherServlet", rootError); LOGGER.error("error in BaseDispatcherServlet", rootError);
throw new ServletException(rootError); throw new ServletException(rootError);
} }
} catch (RuntimeException re) { } catch (RuntimeException re) {
s_log.error("error in BaseDispatcherServlet", re); LOGGER.error("error in BaseDispatcherServlet", re);
throw re; throw re;
} catch (Error error) { } catch (Error error) {
s_log.error("error in BaseDispatcherServlet", error); LOGGER.error("error in BaseDispatcherServlet", error);
throw error; throw error;
} finally { } finally {
if (!reentrant) { if (!reentrant) {
@ -449,7 +451,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
try { try {
((RequestListener) s_listenerList.get(i)).requestFinished(evt); ((RequestListener) s_listenerList.get(i)).requestFinished(evt);
} catch (Exception e) { } catch (Exception e) {
s_log.error("Error running request finished listener " LOGGER.error("Error running request finished listener "
+ s_listenerList. + s_listenerList.
get(i) + " (#" + i + ")", e); get(i) + " (#" + i + ")", e);
} }

View File

@ -29,6 +29,8 @@ import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import org.apache.logging.log4j.LogManager;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -49,7 +51,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext; import javax.servlet.jsp.PageContext;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -59,7 +61,6 @@ import java.net.URLEncoder;
* *
* @author Bill Schneider * @author Bill Schneider
* @since 4.5 * @since 4.5
* @version $Id$
*/ */
public final class DispatcherHelper implements DispatcherConstants { public final class DispatcherHelper implements DispatcherConstants {
@ -69,7 +70,7 @@ public final class DispatcherHelper implements DispatcherConstants {
* set com.arsdigita.dispatcher.DispatcherHelper=DEBUG by uncommenting or * set com.arsdigita.dispatcher.DispatcherHelper=DEBUG by uncommenting or
* adding the line. * adding the line.
*/ */
private static final Logger s_log = Logger.getLogger(DispatcherHelper.class); private static final Logger LOGGER = LogManager.getLogger(DispatcherHelper.class);
private static String s_webappCtx; private static String s_webappCtx;
private static String s_staticURL; private static String s_staticURL;
private static boolean s_cachingActive; private static boolean s_cachingActive;
@ -215,7 +216,7 @@ public final class DispatcherHelper implements DispatcherConstants {
// Of course if the request disappears off to a 3rd // Of course if the request disappears off to a 3rd
// party servlet we're screwed // party servlet we're screwed
req = restoreOriginalRequest(req); req = restoreOriginalRequest(req);
s_log.debug("Forwarding the request object " + req); LOGGER.debug("Forwarding the request object " + req);
if (attr != null) { if (attr != null) {
rd.include(req, resp); rd.include(req, resp);
req.setAttribute(INCLUDE_URI, attr); req.setAttribute(INCLUDE_URI, attr);
@ -397,7 +398,7 @@ public final class DispatcherHelper implements DispatcherConstants {
RequestContext actx) RequestContext actx)
throws RedirectException, DirectoryListingException, throws RedirectException, DirectoryListingException,
java.io.FileNotFoundException { java.io.FileNotFoundException {
s_log.debug("Resolving abstract file"); LOGGER.debug("Resolving abstract file");
File dirToSearch = null; File dirToSearch = null;
String fStr = abstractFile.getAbsolutePath(); String fStr = abstractFile.getAbsolutePath();
@ -539,7 +540,7 @@ public final class DispatcherHelper implements DispatcherConstants {
.restoreRequestWrapper(orig); .restoreRequestWrapper(orig);
if (previous instanceof MultipartHttpServletRequest) { if (previous instanceof MultipartHttpServletRequest) {
s_log.debug("Build new multipart request from previous " LOGGER.debug("Build new multipart request from previous "
+ previous + " and current " + orig); + previous + " and current " + orig);
MultipartHttpServletRequest previousmp MultipartHttpServletRequest previousmp
@ -551,9 +552,9 @@ public final class DispatcherHelper implements DispatcherConstants {
DispatcherHelper.saveOriginalRequest(sreq, DispatcherHelper.saveOriginalRequest(sreq,
orig); orig);
s_log.debug("The main request is now " + sreq); LOGGER.debug("The main request is now " + sreq);
} else { } else {
s_log.debug( LOGGER.debug(
"The request is a new multipart; wrapping the request " "The request is a new multipart; wrapping the request "
+ "object"); + "object");
try { try {
@ -565,7 +566,7 @@ public final class DispatcherHelper implements DispatcherConstants {
DispatcherHelper.saveOriginalRequest(sreq, orig); DispatcherHelper.saveOriginalRequest(sreq, orig);
} }
} else { } else {
s_log.debug("The request is not multipart; proceeding " LOGGER.debug("The request is not multipart; proceeding "
+ "without wrapping the request"); + "without wrapping the request");
} }
return sreq; return sreq;
@ -634,8 +635,8 @@ public final class DispatcherHelper implements DispatcherConstants {
public static void sendExternalRedirect(HttpServletResponse resp, public static void sendExternalRedirect(HttpServletResponse resp,
String url) String url)
throws IOException { throws IOException {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Redirecting to URL '" + url + "'", new Throwable()); LOGGER.debug("Redirecting to URL '" + url + "'", new Throwable());
} }
if (StringUtils.emptyString(url)) { if (StringUtils.emptyString(url)) {
@ -670,23 +671,23 @@ public final class DispatcherHelper implements DispatcherConstants {
if (sep == -1) { if (sep == -1) {
destination = URL.there(req, url); destination = URL.there(req, url);
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Setting destination to " + destination); LOGGER.debug("Setting destination to " + destination);
} }
} else { } else {
final ParameterMap params = ParameterMap.fromString(url final ParameterMap params = ParameterMap.fromString(url
.substring(sep + 1)); .substring(sep + 1));
destination = URL.there(req, url.substring(0, sep), params); destination = URL.there(req, url.substring(0, sep), params);
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Setting destination with map to " LOGGER.debug("Setting destination with map to "
+ destination); + destination);
} }
} }
throw new RedirectSignal(destination, true); throw new RedirectSignal(destination, true);
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Redirecting to URL without using URL.there. " LOGGER.debug("Redirecting to URL without using URL.there. "
+ "URL is " + url); + "URL is " + url);
} }
throw new RedirectSignal(url, true); throw new RedirectSignal(url, true);
@ -844,7 +845,7 @@ public final class DispatcherHelper implements DispatcherConstants {
webappCtx = "/" + webappCtx; webappCtx = "/" + webappCtx;
} }
s_webappCtx = webappCtx; s_webappCtx = webappCtx;
s_log.warn("webappContext set to '" + webappCtx + "'"); LOGGER.warn("webappContext set to '" + webappCtx + "'");
} }
/** /**
@ -871,7 +872,7 @@ public final class DispatcherHelper implements DispatcherConstants {
s_webappCtx = ""; s_webappCtx = "";
} }
if (!s_webappCtx.equals(webappCtx)) { if (!s_webappCtx.equals(webappCtx)) {
s_log.warn( LOGGER.warn(
"webappContext changed. Expected='" + s_webappCtx "webappContext changed. Expected='" + s_webappCtx
+ "' found='" + webappCtx + "' found='" + webappCtx
+ "'.\nPerhaps the enterprise.init " + "'.\nPerhaps the enterprise.init "
@ -967,7 +968,7 @@ public final class DispatcherHelper implements DispatcherConstants {
// XXX Probably need to assert here if isCommitted() returns true. // XXX Probably need to assert here if isCommitted() returns true.
// But first need to figure out what is setting Cache-Control. // But first need to figure out what is setting Cache-Control.
if (response.containsHeader("Cache-Control")) { if (response.containsHeader("Cache-Control")) {
s_log.warn("Cache-Control has already been set. Overwriting."); LOGGER.warn("Cache-Control has already been set. Overwriting.");
} }
forceCacheDisable(response); forceCacheDisable(response);
@ -983,7 +984,7 @@ public final class DispatcherHelper implements DispatcherConstants {
return; return;
} }
s_log.info("Setting cache control to disable"); LOGGER.info("Setting cache control to disable");
// Aggressively defeat caching - works even for HTTP 0.9 proxies/clients! // Aggressively defeat caching - works even for HTTP 0.9 proxies/clients!
response.setHeader("Pragma", "no-cache"); response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "must-revalidate, no-cache"); response.setHeader("Cache-Control", "must-revalidate, no-cache");
@ -1058,7 +1059,7 @@ public final class DispatcherHelper implements DispatcherConstants {
Assert.isTrue(!response.containsHeader("Cache-Control"), Assert.isTrue(!response.containsHeader("Cache-Control"),
"Caching headers have already been set"); "Caching headers have already been set");
s_log.info("Setting cache control to user"); LOGGER.info("Setting cache control to user");
// For HTTP/1.1 user agents, we tell them only cache // For HTTP/1.1 user agents, we tell them only cache
// for the original person making the request // for the original person making the request
@ -1158,7 +1159,7 @@ public final class DispatcherHelper implements DispatcherConstants {
Calendar expires = Calendar.getInstance(); Calendar expires = Calendar.getInstance();
expires.add(Calendar.SECOND, maxage); expires.add(Calendar.SECOND, maxage);
s_log.info("Setting cache control to world"); LOGGER.info("Setting cache control to world");
response.setHeader("Cache-Control", "public, max-age=" + maxage); response.setHeader("Cache-Control", "public, max-age=" + maxage);
response.setHeader("Expires", response.setHeader("Expires",
rfc1123_formatter.format(expires.getTime())); rfc1123_formatter.format(expires.getTime()));

View File

@ -22,7 +22,8 @@ import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* Implements a request context for the site map application * Implements a request context for the site map application
@ -30,12 +31,11 @@ import org.apache.log4j.Logger;
* for an incoming request. * for an incoming request.
* *
* @author Bill Schneider * @author Bill Schneider
* @version $Id$
* @since 4.5 * @since 4.5
*/ */
public class InitialRequestContext implements RequestContext { public class InitialRequestContext implements RequestContext {
private static final Logger s_log = Logger.getLogger private static final Logger LOGGER = LogManager.getLogger
(InitialRequestContext.class); (InitialRequestContext.class);
private String m_urlSoFar; private String m_urlSoFar;
@ -105,25 +105,25 @@ public class InitialRequestContext implements RequestContext {
*/ */
void initializeURLFromRequest(HttpServletRequest request, void initializeURLFromRequest(HttpServletRequest request,
boolean preserveOriginalURL) { boolean preserveOriginalURL) {
s_log.debug("Initializing processed and remaining URL parts."); LOGGER.debug("Initializing processed and remaining URL parts.");
String requestUrl = DispatcherHelper.getCurrentResourcePath(request); String requestUrl = DispatcherHelper.getCurrentResourcePath(request);
m_urlSoFar = request.getContextPath(); m_urlSoFar = request.getContextPath();
m_urlRemainder = requestUrl; m_urlRemainder = requestUrl;
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
String contextPath = request.getContextPath(); String contextPath = request.getContextPath();
s_log.debug("contextPath: " + contextPath); LOGGER.debug("contextPath: " + contextPath);
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
String servletPath = request.getServletPath(); String servletPath = request.getServletPath();
s_log.debug("servletPath: " + servletPath); LOGGER.debug("servletPath: " + servletPath);
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
String pathInfo = request.getPathInfo(); String pathInfo = request.getPathInfo();
s_log.debug("pathInfo: " + pathInfo); LOGGER.debug("pathInfo: " + pathInfo);
} }
final String debugURL = "/debug"; final String debugURL = "/debug";
@ -147,14 +147,14 @@ public class InitialRequestContext implements RequestContext {
m_urlRemainder = m_urlRemainder.substring(debugURLXSL.length()); m_urlRemainder = m_urlRemainder.substring(debugURLXSL.length());
} }
if (!preserveOriginalURL) { if (!preserveOriginalURL) {
s_log.debug("Overwriting original URL, since the caller did not " + LOGGER.debug("Overwriting original URL, since the caller did not " +
"ask to preserve it"); "ask to preserve it");
m_originalUrl = m_urlSoFar + m_urlRemainder; m_originalUrl = m_urlSoFar + m_urlRemainder;
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Set processed URL to '" + m_urlSoFar + "'"); LOGGER.debug("Set processed URL to '" + m_urlSoFar + "'");
s_log.debug("Set remaining URL to '" + m_urlRemainder + "'"); LOGGER.debug("Set remaining URL to '" + m_urlRemainder + "'");
} }
} }

View File

@ -20,11 +20,14 @@ package com.arsdigita.dispatcher;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
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.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* Basic dispatcher class for dispatching URLs to JSP or * Basic dispatcher class for dispatching URLs to JSP or
@ -64,10 +67,11 @@ import org.apache.log4j.Logger;
public class JSPApplicationDispatcher extends BaseDispatcherServlet public class JSPApplicationDispatcher extends BaseDispatcherServlet
implements Dispatcher { implements Dispatcher {
private static final Logger s_log = Logger.getLogger private static final Logger LOGGER = LogManager.getLogger
(JSPApplicationDispatcher.class); (JSPApplicationDispatcher.class);
private static JSPApplicationDispatcher s_instance = newInstance(); private static JSPApplicationDispatcher s_instance = newInstance();
private static final long serialVersionUID = 1662461509796743896L;
/** /**
* Returns a new instance of a JSPApplicationDispatcher. * Returns a new instance of a JSPApplicationDispatcher.
@ -108,8 +112,8 @@ public class JSPApplicationDispatcher extends BaseDispatcherServlet
ServletContext sctx = actx.getServletContext(); ServletContext sctx = actx.getServletContext();
String remainingURL = actx.getRemainingURLPart(); String remainingURL = actx.getRemainingURLPart();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("I think the remaining URL is '" + remainingURL + "'"); LOGGER.debug("I think the remaining URL is '" + remainingURL + "'");
} }
// This is where we forward a request from /foo1/bar.ext or // This is where we forward a request from /foo1/bar.ext or
@ -120,19 +124,19 @@ public class JSPApplicationDispatcher extends BaseDispatcherServlet
actx.getPageBase() + actx.getPageBase() +
actx.getRemainingURLPart(); actx.getRemainingURLPart();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Looking for a concrete resource under the web app " + LOGGER.debug("Looking for a concrete resource under the web app " +
"context at '" + concreteURL + "'"); "context at '" + concreteURL + "'");
} }
File concreteFile = new File(sctx.getRealPath(concreteURL)); File concreteFile = new File(sctx.getRealPath(concreteURL));
if (concreteFile.exists()) { if (concreteFile.exists()) {
s_log.debug("Resource was found; forwarding"); LOGGER.debug("Resource was found; forwarding");
DispatcherHelper.setRequestContext(req, actx); DispatcherHelper.setRequestContext(req, actx);
DispatcherHelper.forwardRequestByPath(concreteURL, req, resp); DispatcherHelper.forwardRequestByPath(concreteURL, req, resp);
} else { } else {
s_log.debug("Resource not found"); LOGGER.debug("Resource not found");
resp.sendError(HttpServletResponse.SC_NOT_FOUND); resp.sendError(HttpServletResponse.SC_NOT_FOUND);
} }
} }

View File

@ -42,11 +42,13 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.log4j.Category;
import com.arsdigita.globalization.Globalization; import com.arsdigita.globalization.Globalization;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Collection; import java.util.Collection;
import javax.servlet.AsyncContext; import javax.servlet.AsyncContext;
@ -68,13 +70,11 @@ import javax.servlet.http.Part;
* @author Karl Goldstein * @author Karl Goldstein
* @author Michael Pih * @author Michael Pih
* @author Uday Mathur * @author Uday Mathur
* @version $Id: MultipartHttpServletRequest.java 1512 2007-03-22 02:36:06Z
* apevec $
* @since 4.5 * @since 4.5
*/ */
public class MultipartHttpServletRequest implements HttpServletRequest { public class MultipartHttpServletRequest implements HttpServletRequest {
private static final Category s_log = Category.getInstance( private static final Logger LOGGER = LogManager.getLogger(
MultipartHttpServletRequest.class); MultipartHttpServletRequest.class);
private HttpServletRequest m_request; private HttpServletRequest m_request;
@ -532,7 +532,7 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
} }
@Override @Override
public void login(final String username, public void login(final String username,
final String password) throws ServletException { final String password) throws ServletException {
m_request.login(username, password); m_request.login(username, password);
} }
@ -575,7 +575,7 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
@Override @Override
public AsyncContext startAsync(final ServletRequest servletRequest, public AsyncContext startAsync(final ServletRequest servletRequest,
final ServletResponse servletResponse) final ServletResponse servletResponse)
throws IllegalStateException { throws IllegalStateException {
return m_request.startAsync(servletRequest, servletResponse); return m_request.startAsync(servletRequest, servletResponse);
} }

View File

@ -25,35 +25,35 @@ import com.arsdigita.dispatcher.RequestContext;
//import com.arsdigita.persistence.Session; //import com.arsdigita.persistence.Session;
//import com.arsdigita.persistence.SessionManager; //import com.arsdigita.persistence.SessionManager;
//import com.arsdigita.persistence.TransactionContext; //import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.util.Assert;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* <p> * <p>
* Utilities for the globalization process. The methods in this class make * Utilities for the globalization process. The methods in this class make use
* use of the assumption that the ACS handles all locale and resource * of the assumption that the ACS handles all locale and resource negotiation so
* negotiation so that the application developer doesn't have to worry about * that the application developer doesn't have to worry about it.
* it.
* </p> * </p>
* *
* @version $Id$ * @version $Id$
*/ */
public class Globalization { public class Globalization {
private static final Logger s_log = Logger.getLogger(Globalization.class); private static final Logger LOGGER = LogManager.getLogger(
Globalization.class);
public static final String ENCODING_PARAM_NAME = "g11n.enc"; public static final String ENCODING_PARAM_NAME = "g11n.enc";
/** /**
* The default encoding for parameterts, as specified by the * The default encoding for parameterts, as specified by the servlet spec
* servlet spec
*/ */
public static final String DEFAULT_PARAM_ENCODING = "ISO-8859-1"; public static final String DEFAULT_PARAM_ENCODING = "ISO-8859-1";
@ -64,11 +64,10 @@ public class Globalization {
public static final String DEFAULT_ENCODING = "ISO-8859-1"; public static final String DEFAULT_ENCODING = "ISO-8859-1";
// private static Map s_localeToCharsetMap; // private static Map s_localeToCharsetMap;
private static String s_defaultCharset = DEFAULT_ENCODING; private static String s_defaultCharset = DEFAULT_ENCODING;
private static boolean initialized = false; private static boolean initialized = false;
static void init() { static void init() {
if (initialized) { if (initialized) {
return; return;
@ -77,7 +76,6 @@ public class Globalization {
initialized = true; initialized = true;
} }
// // Load the Locale to Charset Map from persistent storage. // // Load the Locale to Charset Map from persistent storage.
// public static void loadLocaleToCharsetMap() { // public static void loadLocaleToCharsetMap() {
// // retrieve all Locale objects that have a defaultCharset associated // // retrieve all Locale objects that have a defaultCharset associated
@ -123,11 +121,10 @@ public class Globalization {
// } // }
// } // }
// } // }
static void setDefaultCharset(String encoding) { static void setDefaultCharset(String encoding) {
s_defaultCharset = encoding; s_defaultCharset = encoding;
} }
/** /**
* Get the default character set for encoding data * Get the default character set for encoding data
* *
@ -183,11 +180,11 @@ public class Globalization {
// } // }
// return getDefaultCharset(); // return getDefaultCharset();
} }
/** /**
* Get the default character set for the request. First * Get the default character set for the request. First tries the
* tries the getCharacterENcoding() method, then falls * getCharacterENcoding() method, then falls back on the
* back on the DEFAULT_PARAM_ENCODING * DEFAULT_PARAM_ENCODING
* *
* @return String the character set * @return String the character set
*/ */
@ -198,9 +195,9 @@ public class Globalization {
} }
return charset; return charset;
} }
/** /**
* Get the best locale for this request. * Get the best locale for this request.
*/ */
private static java.util.Locale getLocale(HttpServletRequest req) { private static java.util.Locale getLocale(HttpServletRequest req) {
java.util.Locale l = DispatcherHelper.getNegotiatedLocale(); java.util.Locale l = DispatcherHelper.getNegotiatedLocale();
@ -215,57 +212,56 @@ public class Globalization {
/** /**
* <p> * <p>
* Decode the value of an HttpServletRequest parameter. The value is * Decode the value of an HttpServletRequest parameter. The value is decoded
* decoded appropriately (lets hope so anyway). * appropriately (lets hope so anyway).
* </p> * </p>
* *
* @param r The HttpServletRequest for which to get the value. * @param r The HttpServletRequest for which to get the value.
* @param name The name of the parameter to retrieve. * @param name The name of the parameter to retrieve.
* *
* @return String The decoded value of the parameter. * @return String The decoded value of the parameter.
*/ */
public static final String decodeParameter( public static final String decodeParameter(
HttpServletRequest r, String name HttpServletRequest r, String name
) { ) {
String re = r.getParameter(Globalization.ENCODING_PARAM_NAME); String re = r.getParameter(Globalization.ENCODING_PARAM_NAME);
String original = r.getParameter(name); String original = r.getParameter(name);
String real = null; String real = null;
if (re == null || if (re == null || re.length() == 0) {
re.length() == 0) { if (LOGGER.isDebugEnabled()) {
if (s_log.isDebugEnabled()) { LOGGER.debug(ENCODING_PARAM_NAME + " is not set, using locale "
s_log.debug(ENCODING_PARAM_NAME + " is not set, using locale " + + "default encoding for parameter " + name);
"default encoding for parameter " + name);
} }
re = getDefaultCharset(getLocale(r)); re = getDefaultCharset(getLocale(r));
} }
if (original == null || if (original == null || original.length() == 0) {
original.length() == 0) { if (LOGGER.isDebugEnabled()) {
if (s_log.isDebugEnabled()) { LOGGER.debug("Parameter " + name + " has no value");
s_log.debug("Parameter " + name + " has no value");
} }
real = original; real = original;
} else if (getDefaultCharset(r).equals(re)) { } else if (getDefaultCharset(r).equals(re)) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Parameter " + name + " is already in correct encoding"); LOGGER.debug("Parameter " + name
+ " is already in correct encoding");
} }
real = original; real = original;
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Parameter " + name + " is being converted from " + LOGGER.debug("Parameter " + name + " is being converted from "
getDefaultCharset(r) + " into " + re); + getDefaultCharset(r) + " into " + re);
} }
try { try {
real = new String real = new String(original.getBytes(getDefaultCharset(r)),
(original.getBytes(getDefaultCharset(r)), re);
re);
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
s_log.warn("encoding " + re + " is not supported, falling back on system default"); LOGGER.warn("encoding " + re
+ " is not supported, falling back on system default");
real = original; real = original;
} }
} }
return real; return real;
} }
@ -278,46 +274,46 @@ public class Globalization {
* *
* @return String[] The decoded parameters. * @return String[] The decoded parameters.
*/ */
public static final String[] decodeParameters public static final String[] decodeParameters(HttpServletRequest r,
(HttpServletRequest r, String name) { String name) {
String re = r.getParameter(Globalization.ENCODING_PARAM_NAME); String re = r.getParameter(Globalization.ENCODING_PARAM_NAME);
String[] originals = r.getParameterValues(name); String[] originals = r.getParameterValues(name);
String[] real = null; String[] real = null;
if (re == null || if (re == null || re.length() == 0) {
re.length() == 0) { if (LOGGER.isDebugEnabled()) {
if (s_log.isDebugEnabled()) { LOGGER.debug(ENCODING_PARAM_NAME + " is not set, using locale "
s_log.debug(ENCODING_PARAM_NAME + " is not set, using locale " + + "default encoding for parameter " + name);
"default encoding for parameter " + name);
} }
re = getDefaultCharset(getLocale(r)); re = getDefaultCharset(getLocale(r));
} }
if (originals == null || if (originals == null || originals.length == 0) {
originals.length == 0) { if (LOGGER.isDebugEnabled()) {
if (s_log.isDebugEnabled()) { LOGGER.debug("Parameter " + name + " has no value");
s_log.debug("Parameter " + name + " has no value");
} }
real = originals; real = originals;
} else if (getDefaultCharset(r).equals(re)) { } else if (getDefaultCharset(r).equals(re)) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Parameter " + name + " is already in correct encoding"); LOGGER.debug("Parameter " + name
+ " is already in correct encoding");
} }
real = originals; real = originals;
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Parameter " + name + " is being converted from " + LOGGER.debug("Parameter " + name + " is being converted from "
getDefaultCharset(r) + " into " + re); + getDefaultCharset(r) + " into " + re);
} }
try { try {
real = new String[originals.length]; real = new String[originals.length];
for (int i = 0; i < originals.length; i++) { for (int i = 0; i < originals.length; i++) {
real[i] = new String real[i] = new String(originals[i].getBytes(
(originals[i].getBytes(getDefaultCharset(r)), getDefaultCharset(r)),
re); re);
} }
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
s_log.warn("encoding " + re + " is not supported, falling back on system default"); LOGGER.warn("encoding " + re
+ " is not supported, falling back on system default");
real = originals; real = originals;
} }
} }
@ -356,13 +352,13 @@ public class Globalization {
rb = rc.getResourceBundle(); rb = rc.getResourceBundle();
if (rb != null) { if (rb != null) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info(rb.getClass().getName() + LOGGER.info(rb.getClass().getName()
" is the chosen ResourceBundle."); + " is the chosen ResourceBundle.");
} }
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("No matching ResourceBundle found"); LOGGER.debug("No matching ResourceBundle found");
} }
} }
@ -375,7 +371,7 @@ public class Globalization {
* appropriate Locale and key. * appropriate Locale and key.
* </p> * </p>
* *
* @param r The current HttpServletRequest. * @param r The current HttpServletRequest.
* @param key The key used to select the appropriate Object * @param key The key used to select the appropriate Object
* *
* @return The localized Object * @return The localized Object
@ -390,7 +386,6 @@ public class Globalization {
// If the key does not contain a '#' character, then use the // If the key does not contain a '#' character, then use the
// HttpServletRequest alone to determine the appropriate // HttpServletRequest alone to determine the appropriate
// ResourceBundle. // ResourceBundle.
int separator = key.indexOf('#'); int separator = key.indexOf('#');
if (separator < 0) { if (separator < 0) {
rb = getResourceBundle(r); rb = getResourceBundle(r);
@ -415,14 +410,14 @@ public class Globalization {
if (rb != null) { if (rb != null) {
l7dObject = rb.getObject(key); l7dObject = rb.getObject(key);
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("No ResourceBundle available"); LOGGER.debug("No ResourceBundle available");
} }
} }
} catch (MissingResourceException e) { } catch (MissingResourceException e) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Key " + key + " was not found in the " + LOGGER.debug("Key " + key + " was not found in the "
"ResourceBundle"); + "ResourceBundle");
} }
} }
@ -431,11 +426,11 @@ public class Globalization {
/** /**
* <p> * <p>
* Get a String from the appropriate ResourceBundle based on the * Get a String from the appropriate ResourceBundle based on the appropriate
* appropriate Locale and key. * Locale and key.
* </p> * </p>
* *
* @param r The current HttpServletRequest. * @param r The current HttpServletRequest.
* @param key The key used to select the appropriate String * @param key The key used to select the appropriate String
* *
* @return The localized String * @return The localized String
@ -450,12 +445,12 @@ public class Globalization {
/** /**
* <p> * <p>
* Get a parameterized String (for doing MessageFormatting) from the * Get a parameterized String (for doing MessageFormatting) from the
* appropraite ResourceBundle based on the appropriate Locale and key. * appropraite ResourceBundle based on the appropriate Locale and key. Then
* Then interpolate the values for the other keys passed. * interpolate the values for the other keys passed.
* </p> * </p>
* *
* @param r The current HttpServletRequest. * @param r The current HttpServletRequest.
* @param key The key used to select the appropriate String * @param key The key used to select the appropriate String
* @param arguments A Object[] containing the other keys to localize and * @param arguments A Object[] containing the other keys to localize and
* interpolate into the parameterized string. It may also * interpolate into the parameterized string. It may also
* contain other Objects beside Strings, such as Date * contain other Objects beside Strings, such as Date
@ -491,26 +486,25 @@ public class Globalization {
* default ResourceBundle in another language * default ResourceBundle in another language
* </p> * </p>
* *
* @param targetBundle The ResourceBundle we are looking for. * @param targetBundle The ResourceBundle we are looking for.
* @param locale The Locale object representing the language we want. * @param locale The Locale object representing the language we want.
* @param defaultLocale The Locale object representing the default language. * @param defaultLocale The Locale object representing the default language.
*/ */
public static ResourceBundle getBundleNoFallback public static ResourceBundle getBundleNoFallback(String targetBundle,
(String targetBundle, java.util.Locale locale, java.util.Locale locale,
java.util.Locale defaultLocale) { java.util.Locale defaultLocale) {
ResourceBundle bundle = null; ResourceBundle bundle = null;
if (locale == null) { if (locale == null) {
locale = locale = (defaultLocale != null) ? defaultLocale : java.util.Locale
(defaultLocale != null) ? .getDefault();
defaultLocale : java.util.Locale.getDefault();
} }
try { try {
bundle = ResourceBundle.getBundle(targetBundle, locale); bundle = ResourceBundle.getBundle(targetBundle, locale);
} catch (MissingResourceException e) { } catch (MissingResourceException e) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Didn't find ResourceBundle for " + targetBundle); LOGGER.info("Didn't find ResourceBundle for " + targetBundle);
} }
} }
@ -519,19 +513,17 @@ public class Globalization {
// Make sure that if we found a ResourceBundle it is either in the // Make sure that if we found a ResourceBundle it is either in the
// language we were looking for or, by coincidence, the target // language we were looking for or, by coincidence, the target
// language happens to match the default language for the system. // language happens to match the default language for the system.
if (bundle != null ) { if (bundle != null) {
if ( if (targetLanguage.equals(bundle.getLocale().getLanguage())
targetLanguage.equals(bundle.getLocale().getLanguage()) || || targetLanguage.equals(defaultLocale.getLanguage())) {
targetLanguage.equals(defaultLocale.getLanguage()) if (LOGGER.isInfoEnabled()) {
) { LOGGER.info("Found matching ResourceBundle for "
if (s_log.isInfoEnabled()) { + targetBundle);
s_log.info("Found matching ResourceBundle for " +
targetBundle);
} }
} else { } else {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Found non-matching ResourceBundle for " + LOGGER.info("Found non-matching ResourceBundle for "
targetBundle); + targetBundle);
} }
bundle = null; bundle = null;
} }
@ -539,4 +531,5 @@ public class Globalization {
return bundle; return bundle;
} }
} }

View File

@ -25,7 +25,8 @@ import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
@ -52,7 +53,7 @@ public class GlobalizedMessage {
* /WEB-INF/conf/log4j.properties int hte runtime environment and set * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* com.arsdigita.globalization.GlobalizedMessage=DEBUG by uncommenting or adding the line. * com.arsdigita.globalization.GlobalizedMessage=DEBUG by uncommenting or adding the line.
*/ */
private static final Logger LOGGER = Logger.getLogger(GlobalizedMessage.class.getName()); private static final Logger LOGGER = LogManager.getLogger(GlobalizedMessage.class.getName());
private String m_key = ""; private String m_key = "";
private String m_bundleName = ""; private String m_bundleName = "";
/** /**

View File

@ -31,11 +31,9 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.lang.reflect.Constructor;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.core.CcmObjectRepository; import org.libreccm.core.CcmObjectRepository;

View File

@ -25,7 +25,8 @@ import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* <p>CCMResourceManager Runtime environment repository object, stores essential * <p>CCMResourceManager Runtime environment repository object, stores essential
@ -62,11 +63,10 @@ import org.apache.log4j.Logger;
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* rewritten by * rewritten by
* @author pboy &lt;pboy@barkhof.uni-bremen.de&gt; * @author pboy &lt;pboy@barkhof.uni-bremen.de&gt;
* @version $Id$
*/ */
public final class CCMResourceManager { public final class CCMResourceManager {
private static final Logger s_log = Logger.getLogger(CCMResourceManager.class); private static final Logger LOGGER = LogManager.getLogger(CCMResourceManager.class);
private static CCMResourceManager s_ccm; private static CCMResourceManager s_ccm;
@ -100,7 +100,7 @@ public final class CCMResourceManager {
} }
else { else {
// baseDir already set, silently discard // baseDir already set, silently discard
s_log.info("baseDir already set as " + m_baseDir + ". Discarded."); LOGGER.info("baseDir already set as " + m_baseDir + ". Discarded.");
} }
} }
@ -308,7 +308,7 @@ public final class CCMResourceManager {
*/ */
private final void storeBaseDir(String baseDirName) { private final void storeBaseDir(String baseDirName) {
s_log.debug("storeBaseDir: BaseDir name is given as " + baseDirName ); LOGGER.debug("storeBaseDir: BaseDir name is given as " + baseDirName );
m_baseDir = new File(baseDirName); m_baseDir = new File(baseDirName);
// eventually: check if dir exists, create it if not. // eventually: check if dir exists, create it if not.

View File

@ -25,7 +25,8 @@ import com.arsdigita.web.Web;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**
@ -37,7 +38,8 @@ public class ApplicationPatternGenerator implements PatternGenerator {
/** /**
* Private logger instance for debugging purpose * Private logger instance for debugging purpose
*/ */
private static final Logger s_log = Logger.getLogger(PatternGenerator.class); private static final Logger LOGGER = LogManager.getLogger(
PatternGenerator.class);
/** /**
* Implementation of the Interface class. * Implementation of the Interface class.
@ -51,18 +53,18 @@ public class ApplicationPatternGenerator implements PatternGenerator {
public String[] generateValues(String key, public String[] generateValues(String key,
HttpServletRequest req) { HttpServletRequest req) {
s_log.debug("Processing Application with key: " + key); LOGGER.debug("Processing Application with key: " + key);
final CcmApplication app = Web.getWebContext().getApplication(); final CcmApplication app = Web.getWebContext().getApplication();
if (app != null) { if (app != null) {
String[] returnValue = {app.getApplicationType()}; String[] returnValue = {app.getApplicationType()};
s_log.debug("Found application >>" + returnValue LOGGER.debug("Found application >>" + returnValue
+ "<< in Application."); + "<< in Application.");
return returnValue; return returnValue;
} }
s_log.debug("ApplicationType for >>" + key LOGGER.debug("ApplicationType for >>" + key
+ "<< not found. Trying SiteNodes instead."); + "<< not found. Trying SiteNodes instead.");
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No ApplicationType found for type name " + key); "No ApplicationType found for type name " + key);

View File

@ -19,12 +19,12 @@
package com.arsdigita.templating; package com.arsdigita.templating;
import com.arsdigita.util.servlet.HttpHost; import com.arsdigita.util.servlet.HttpHost;
import com.arsdigita.web.Web;
import com.arsdigita.web.WebConfig; import com.arsdigita.web.WebConfig;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* Generates a set of patterns corresponding to the current host name. (actually * Generates a set of patterns corresponding to the current host name. (actually
@ -39,7 +39,7 @@ public class HostPatternGenerator implements PatternGenerator {
* set com.arsdigita.templating.HostPatternGenerator=DEBUG by uncommenting * set com.arsdigita.templating.HostPatternGenerator=DEBUG by uncommenting
* or adding the line. * or adding the line.
*/ */
private static final Logger s_log = Logger.getLogger( private static final Logger LOGGER = LogManager.getLogger(
HostPatternGenerator.class); HostPatternGenerator.class);
/** /**
@ -61,8 +61,8 @@ public class HostPatternGenerator implements PatternGenerator {
WebConfig.getConfig().getHostPort()); WebConfig.getConfig().getHostPort());
final String hostName = host.toString(); final String hostName = host.toString();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Generating Values for key: " + key + " [" LOGGER.debug("Generating Values for key: " + key + " ["
+ "Hostname retrieved: >>" + hostName + "<<]"); + "Hostname retrieved: >>" + hostName + "<<]");
} }

View File

@ -29,6 +29,8 @@ import com.arsdigita.web.WebConfig;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.Level;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@ -43,8 +45,8 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import org.apache.log4j.Level; import org.apache.logging.log4j.Logger;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
/** /**
* An entry-point class for the functions of the templating package. The class * An entry-point class for the functions of the templating package. The class
@ -55,7 +57,6 @@ import org.apache.log4j.Logger;
* *
* @author Dan Berrange * @author Dan Berrange
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
public class Templating { public class Templating {
@ -65,7 +66,7 @@ public class Templating {
* set com.arsdigita.templating.Templating=DEBUG by uncommenting it or * set com.arsdigita.templating.Templating=DEBUG by uncommenting it or
* adding the line. * adding the line.
*/ */
private static final Logger s_log = Logger.getLogger(Templating.class); private static final Logger LOGGER = LogManager.getLogger(Templating.class);
/** /**
* This is the name of the attribute that is set in the request whose value, * This is the name of the attribute that is set in the request whose value,
@ -81,7 +82,7 @@ public class Templating {
.getConfig(); .getConfig();
static { static {
s_log.debug("Static initalizer starting..."); LOGGER.debug("Static initalizer starting...");
Exceptions.registerUnwrapper( Exceptions.registerUnwrapper(
TransformerException.class, TransformerException.class,
@ -104,7 +105,7 @@ public class Templating {
setting = s_config.getStylesheetCacheAge(); setting = s_config.getStylesheetCacheAge();
int cacheAge = (setting == null ? 60 * 60 * 24 * 3 : setting.intValue()); int cacheAge = (setting == null ? 60 * 60 * 24 * 3 : setting.intValue());
s_log.debug("Static initalizer finished..."); LOGGER.debug("Static initalizer finished...");
} }
/** /**
@ -183,8 +184,8 @@ public class Templating {
boolean fancyErrors, boolean fancyErrors,
boolean useCache) { boolean useCache) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Getting template for URL " + source); LOGGER.debug("Getting template for URL " + source);
} }
Assert.exists(source, URL.class); Assert.exists(source, URL.class);
@ -192,9 +193,9 @@ public class Templating {
XSLTemplate template = null; XSLTemplate template = null;
if (template == null) { if (template == null) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("The template for URL " + source + " is not " LOGGER.info("The template for URL " + source + " is not "
+ "cached; creating and caching it now"); + "cached; creating and caching it now");
} }
if (fancyErrors) { if (fancyErrors) {
@ -212,9 +213,9 @@ public class Templating {
// Debug mode should be captured at a lower level, // Debug mode should be captured at a lower level,
// probably on UtilConfig. // probably on UtilConfig.
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Template " + template + " has been modified; " LOGGER.info("Template " + template + " has been modified; "
+ "recreating it from scratch"); + "recreating it from scratch");
} }
if (fancyErrors) { if (fancyErrors) {
@ -274,8 +275,8 @@ public class Templating {
* @param source the <code>URL</code> to the top-level template resource * @param source the <code>URL</code> to the top-level template resource
*/ */
public static synchronized void purgeTemplate(final URL source) { public static synchronized void purgeTemplate(final URL source) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Purging cached template for URL " + source); LOGGER.debug("Purging cached template for URL " + source);
} }
Assert.exists(source, URL.class); Assert.exists(source, URL.class);
@ -286,8 +287,8 @@ public class Templating {
* regenerated on-demand as each gets requested. * regenerated on-demand as each gets requested.
*/ */
public static synchronized void purgeTemplates() { public static synchronized void purgeTemplates() {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Purging all cached templates"); LOGGER.debug("Purging all cached templates");
} }
} }
@ -312,8 +313,8 @@ public class Templating {
"http://www.w3.org/1999/XSL/Transform"); "http://www.w3.org/1999/XSL/Transform");
imp.addAttribute("href", path.toString()); imp.addAttribute("href", path.toString());
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("Adding import for " + path.toString()); LOGGER.info("Adding import for " + path.toString());
} }
} }
@ -324,8 +325,8 @@ public class Templating {
throw new UncheckedWrapperException("cannot build document", ex); throw new UncheckedWrapperException("cannot build document", ex);
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("XSL is " + doc.toString(true)); LOGGER.debug("XSL is " + doc.toString(true));
} }
return new ByteArrayInputStream(doc.toString(true).getBytes()); return new ByteArrayInputStream(doc.toString(true).getBytes());
@ -379,16 +380,17 @@ public class Templating {
// and unrestricted access. The complete code should get refactored to // and unrestricted access. The complete code should get refactored to
// use ServletContext#getResource(path) // use ServletContext#getResource(path)
String installContext = Web.getWebappContextPath(); String installContext = Web.getWebappContextPath();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Installation context is >" + installContext + "<."); LOGGER.debug("Installation context is >" + installContext + "<.");
} }
if (!installContext.equals("")) { if (!installContext.equals("")) {
// CCM is installed into a non-ROOT context // CCM is installed into a non-ROOT context
if (localPath.startsWith(installContext)) { if (localPath.startsWith(installContext)) {
// remove webapp context part // remove webapp context part
localPath = localPath.substring(installContext.length()); localPath = localPath.substring(installContext.length());
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("WebApp context removed: >>" + localPath + "<<"); LOGGER
.debug("WebApp context removed: >>" + localPath + "<<");
} }
} }
} }
@ -401,8 +403,8 @@ public class Templating {
// A virtual path to the ResourceServlet // A virtual path to the ResourceServlet
localPath = localPath.substring("/resource".length()); //remove virtual part localPath = localPath.substring("/resource".length()); //remove virtual part
URL newURL = Web.findResource(localPath); //without host part here! URL newURL = Web.findResource(localPath); //without host part here!
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log. LOGGER.
debug("Transforming resource " + url + " to " debug("Transforming resource " + url + " to "
+ newURL); + newURL);
} }
@ -415,24 +417,24 @@ public class Templating {
if (file.exists()) { if (file.exists()) {
try { try {
URL newURL = file.toURL(); URL newURL = file.toURL();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Transforming resource " + url + " to " LOGGER.debug("Transforming resource " + url + " to "
+ newURL); + newURL);
} }
return newURL; return newURL;
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
} else if (s_log.isDebugEnabled()) { } else if (LOGGER.isDebugEnabled()) {
s_log.debug("File " + filename LOGGER.debug("File " + filename
+ " doesn't exist on disk"); + " doesn't exist on disk");
} }
} }
} else // url is not the (local) running CCM host, no transformation } else // url is not the (local) running CCM host, no transformation
// is done // is done
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("URL " + url + " is not local"); LOGGER.debug("URL " + url + " is not local");
} }
return url; // returns the original, unmodified url here return url; // returns the original, unmodified url here
} }
@ -445,9 +447,8 @@ public class Templating {
*/ */
class LoggingErrorListener implements ErrorListener { class LoggingErrorListener implements ErrorListener {
private static final Logger s_log private static final Logger LOGGER = LogManager.getLogger(
= Logger.getLogger( LoggingErrorListener.class);
LoggingErrorListener.class);
private final ArrayList m_errors; private final ArrayList m_errors;
LoggingErrorListener() { LoggingErrorListener() {
@ -474,10 +475,10 @@ class LoggingErrorListener implements ErrorListener {
} }
private void log(Level level, TransformerException ex) { private void log(Level level, TransformerException ex) {
s_log.log(level, "Transformer " + level + ": " LOGGER.log(level, "Transformer " + level + ": "
+ ex.getLocationAsString() + ": " + ex. + ex.getLocationAsString() + ": " + ex.
getMessage(), getMessage(),
ex); ex);
m_errors.add(ex); m_errors.add(ex);
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.templating; package com.arsdigita.templating;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.StringUtils; import com.arsdigita.util.StringUtils;
@ -26,130 +25,123 @@ import com.arsdigita.web.Web;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**
* Generates a set of pattern values based on the URL path info for the current * Generates a set of pattern values based on the URL path info for the current
* request. Slashes in the request are translated into hyphens; the file * request. Slashes in the request are translated into hyphens; the file
* extension is stripped; any 'index' is removed, except for the top level. * extension is stripped; any 'index' is removed, except for the top level.
* *
* So some examples: * So some examples:
* *
* /content/admin/item.jsp -> { "admin-item", "admin", "index" } * /content/admin/item.jsp -> { "admin-item", "admin", "index" }
* /content/admin/index.jsp -> { "admin", "index" } * /content/admin/index.jsp -> { "admin", "index" } /content/admin/ -> {
* /content/admin/ -> { "admin", "index" } * "admin", "index" } /content/index.jsp -> { "index" } /content/ -> { "index" }
* /content/index.jsp -> { "index" }
* /content/ -> { "index" }
*/ */
public class URLPatternGenerator implements PatternGenerator { public class URLPatternGenerator implements PatternGenerator {
private static final Logger s_log = private static final Logger LOGGER = LogManager.getLogger(
Logger.getLogger(URLPatternGenerator.class); URLPatternGenerator.class);
private static final String DEFAULT_URL_MATCH = "index"; private static final String DEFAULT_URL_MATCH = "index";
/** /**
* *
* @param key * @param key
* @param req * @param req
* @return *
* @return
*/ */
public String[] generateValues(String key, public String[] generateValues(String key,
HttpServletRequest req) { HttpServletRequest req) {
String path = getPath(); String path = getPath();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Substituting values for url " + path); LOGGER.debug("Substituting values for url " + path);
} }
// Check for a file extension & strip it. // Check for a file extension & strip it.
int dotIndex = path.lastIndexOf("."); int dotIndex = path.lastIndexOf(".");
int slashIndex = path.lastIndexOf("/"); int slashIndex = path.lastIndexOf("/");
if (dotIndex > -1 if (dotIndex > -1
&& dotIndex > slashIndex) { && dotIndex > slashIndex) {
path = path.substring(0, dotIndex); path = path.substring(0, dotIndex);
} }
// Strip '/index' if any // Strip '/index' if any
if (path != null && if (path != null && path.endsWith("/" + DEFAULT_URL_MATCH)) {
path.endsWith("/" + DEFAULT_URL_MATCH)) { path = path.substring(0, path.length() - DEFAULT_URL_MATCH.length());
path = path.substring(0, path.length() -
DEFAULT_URL_MATCH.length());
} }
// Now strip trailing & leading slash // Now strip trailing & leading slash
if (path != null && if (path != null && path.startsWith("/")) {
path.startsWith("/")) {
path = path.substring(1); path = path.substring(1);
} }
if (path != null && if (path != null && path.endsWith("/")) {
path.endsWith("/")) { path = path.substring(0, path.length() - 1);
path = path.substring(0, path.length()-1);
} }
if (path == null) { if (path == null) {
path = ""; path = "";
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Normalized path is '" + path + "'"); LOGGER.debug("Normalized path is '" + path + "'");
} }
String[] bits = StringUtils.split(path, '/'); String[] bits = StringUtils.split(path, '/');
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
for (int i = 0 ; i < bits.length ; i++) { for (int i = 0; i < bits.length; i++) {
s_log.debug(" -> '" + bits[i] + "'"); LOGGER.debug(" -> '" + bits[i] + "'");
} }
} }
// Now we've cut off the file extension, it's time to do the // Now we've cut off the file extension, it's time to do the
// funky concatenation trick. // funky concatenation trick.
for (int i = 1; i < bits.length; i++) { for (int i = 1; i < bits.length; i++) {
bits[i] = bits[i-1] + "-" + bits[i]; bits[i] = bits[i - 1] + "-" + bits[i];
} }
// Now we have to reverse it, so matching goes from most specific // Now we have to reverse it, so matching goes from most specific
// to most general & add in the default 'index' match // to most general & add in the default 'index' match
String[] reverseBits = new String[bits.length + 1];
String[] reverseBits = new String[bits.length+1];
for ( int i = bits.length - 1, j = 0; i > -1; i--,j++ ) {
reverseBits[j] = bits [i];
}
reverseBits[reverseBits.length-1] = DEFAULT_URL_MATCH;
if (s_log.isDebugEnabled()) { for (int i = bits.length - 1, j = 0; i > -1; i--, j++) {
s_log.debug("After concatenation & reversing"); reverseBits[j] = bits[i];
for (int i = 0 ; i < reverseBits.length ; i++) { }
s_log.debug(" -> '" + reverseBits[i] + "'"); reverseBits[reverseBits.length - 1] = DEFAULT_URL_MATCH;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("After concatenation & reversing");
for (int i = 0; i < reverseBits.length; i++) {
LOGGER.debug(" -> '" + reverseBits[i] + "'");
} }
} }
return reverseBits; return reverseBits;
} }
private String getPath() { private String getPath() {
String base = getBasePath(); String base = getBasePath();
String url = Web.getWebContext().getRequestURL().getPathInfo(); String url = Web.getWebContext().getRequestURL().getPathInfo();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Base is " + base + " url is " + url); LOGGER.debug("Base is " + base + " url is " + url);
} }
Assert.isTrue(url.startsWith(base), "URL " + url + " starts with " + base); Assert.isTrue(url.startsWith(base), "URL " + url + " starts with "
+ base);
return url.substring(base.length()-1);
return url.substring(base.length() - 1);
} }
/** /**
* Provides the base URL of the application in the current Web request * Provides the base URL of the application in the current Web request (i.e.
* (i.e. application's PrimaryURL). If no application can be found or * application's PrimaryURL). If no application can be found or no
no PrimaryURL can be determined ROOT ("/") is returned. * PrimaryURL can be determined ROOT ("/") is returned. *
* XXX fix me, why can't we get this from Web.getWebContext().getRequestURL
XXX fix me, why can't we get this from Web.getWebContext().getRequestURL *
*
* @return primary url of an application or ROOT * @return primary url of an application or ROOT
*/ */
private String getBasePath() { private String getBasePath() {

View File

@ -22,7 +22,8 @@ import com.arsdigita.web.Web;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
/** /**
@ -37,7 +38,7 @@ public class WebAppPatternGenerator implements PatternGenerator {
* set com.arsdigita.templating.WebAppPatternGenerator=DEBUG by uncommenting * set com.arsdigita.templating.WebAppPatternGenerator=DEBUG by uncommenting
* or adding the line. * or adding the line.
*/ */
private static final Logger s_log = Logger.getLogger( private static final Logger LOGGER = LogManager.getLogger(
WebAppPatternGenerator.class); WebAppPatternGenerator.class);
/** /**
@ -66,8 +67,8 @@ public class WebAppPatternGenerator implements PatternGenerator {
ctx = ctx.substring(1); ctx = ctx.substring(1);
} }
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Generating Values key: " + key + " [" LOGGER.debug("Generating Values key: " + key + " ["
+ "Web.getWebContext(): " + Web.getWebContext() + " ," + "Web.getWebContext(): " + Web.getWebContext() + " ,"
+ "Application: " + Web.getWebContext().getApplication() + "Application: " + Web.getWebContext().getApplication()
+ "," + "ContextPath: >" + ctx + "<]"); + "," + "ContextPath: >" + ctx + "<]");

View File

@ -44,8 +44,9 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -54,31 +55,33 @@ import org.w3c.dom.Document;
* transformers. * transformers.
* *
* @author Dan Berrange * @author Dan Berrange
* @version $Id$
*/ */
public final class XSLTemplate { public final class XSLTemplate {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment * Internal logger instance to faciliate debugging. Enable logging output by
* and set com.arsdigita.templating.XSLTemplate=DEBUG by uncommenting * editing /WEB-INF/conf/log4j.properties int hte runtime environment and
* or adding the line. */ * set com.arsdigita.templating.XSLTemplate=DEBUG by uncommenting or adding
private static final Logger s_log = Logger.getLogger(XSLTemplate.class); * the line.
*/
private static final Logger LOGGER = LogManager.getLogger(XSLTemplate.class);
/** Property containing the URL to the XSL source file or create this /**
* instance */ * Property containing the URL to the XSL source file or create this
* instance
*/
private final URL m_source; private final URL m_source;
private final Templates m_templates; private final Templates m_templates;
private final List m_dependents; private final List m_dependents;
private final Date m_created; private final Date m_created;
/** /**
* Creates and loads a new template from <code>source</code>, * Creates and loads a new template from <code>source</code>, using
* using <code>listener</code> to handle any errors. * <code>listener</code> to handle any errors.
* *
* @param source A <code>URL</code> pointing to the template * @param source A <code>URL</code> pointing to the template source text
* source text * @param listener A <code>ErrorListener</code> to customize behavior on
* @param listener A <code>ErrorListener</code> to customize * error
* behavior on error
*/ */
public XSLTemplate(final URL source, public XSLTemplate(final URL source,
final ErrorListener listener) { final ErrorListener listener) {
@ -92,17 +95,16 @@ public final class XSLTemplate {
final SimpleURIResolver resolver = new SimpleURIResolver(); final SimpleURIResolver resolver = new SimpleURIResolver();
try { try {
s_log.debug("Getting new templates object"); LOGGER.debug("Getting new templates object");
final TransformerFactory factory = final TransformerFactory factory = TransformerFactory.newInstance();
TransformerFactory.newInstance();
factory.setURIResolver(resolver); factory.setURIResolver(resolver);
factory.setErrorListener(listener); factory.setErrorListener(listener);
m_templates = factory.newTemplates(resolver.resolve(m_source. m_templates = factory.newTemplates(resolver.resolve(m_source.
toString(), null)); toString(), null));
s_log.debug("Done getting new templates"); LOGGER.debug("Done getting new templates");
} catch (TransformerConfigurationException ex) { } catch (TransformerConfigurationException ex) {
throw new WrappedTransformerException(ex); throw new WrappedTransformerException(ex);
} catch (TransformerException ex) { } catch (TransformerException ex) {
@ -119,11 +121,10 @@ public final class XSLTemplate {
} }
/** /**
* Creates and loads a new template from <code>source</code> using * Creates and loads a new template from <code>source</code> using the
* the default <code>ErrorListener</code>. * default <code>ErrorListener</code>.
* *
* @param source A <code>URL</code> pointing to the template * @param source A <code>URL</code> pointing to the template source text
* source text
*/ */
public XSLTemplate(final URL source) { public XSLTemplate(final URL source) {
this(source, new Log4JErrorListener()); this(source, new Log4JErrorListener());
@ -132,8 +133,8 @@ public final class XSLTemplate {
/** /**
* Gets the <code>URL</code> of the template source. * Gets the <code>URL</code> of the template source.
* *
* @return The <code>URL</code> location of the template source; * @return The <code>URL</code> location of the template source; it cannot
* it cannot be null * be null
*/ */
public final URL getSource() { public final URL getSource() {
return m_source; return m_source;
@ -142,8 +143,8 @@ public final class XSLTemplate {
/** /**
* Gets a list of all dependent stylesheet files. * Gets a list of all dependent stylesheet files.
* *
* @return A <code>List</code> of <code>URL</code>s to dependent * @return A <code>List</code> of <code>URL</code>s to dependent stylesheet
* stylesheet files; it cannot be null * files; it cannot be null
*/ */
public final List getDependents() { public final List getDependents() {
return m_dependents; return m_dependents;
@ -156,7 +157,7 @@ public final class XSLTemplate {
* @return The new <code>Transformer</code>; it cannot be null * @return The new <code>Transformer</code>; it cannot be null
*/ */
public final synchronized Transformer newTransformer() { public final synchronized Transformer newTransformer() {
s_log.debug("Generating new transformer"); LOGGER.debug("Generating new transformer");
try { try {
return m_templates.newTransformer(); return m_templates.newTransformer();
@ -167,23 +168,23 @@ public final class XSLTemplate {
/** /**
* Transforms the <code>source</code> document and sends it to * Transforms the <code>source</code> document and sends it to
* <code>result</code>. If there are errors, * <code>result</code>. If there are errors, <code>listener</code> handles
* <code>listener</code> handles them. This method internally * them. This method internally creates and uses a new
* creates and uses a new <code>Transformer</code>. * <code>Transformer</code>.
* *
* @param source The <code>Source</code> to be transformed; it * @param source The <code>Source</code> to be transformed; it cannot be
* cannot be null * null
* @param result The <code>Result</code> to capture the * @param result The <code>Result</code> to capture the transformed
* transformed product; it cannot be null * product; it cannot be null
* @param listener A <code>ErrorListener</code> to handle * @param listener A <code>ErrorListener</code> to handle transformation
* transformation errors; it cannot be null * errors; it cannot be null
*/ */
public final void transform(final Source source, public final void transform(final Source source,
final Result result, final Result result,
final ErrorListener listener) { final ErrorListener listener) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Transforming " + source + " and sending it to " LOGGER.debug("Transforming " + source + " and sending it to "
+ result + " using error listener " + listener); + result + " using error listener " + listener);
} }
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
@ -196,11 +197,11 @@ public final class XSLTemplate {
final Transformer transformer = newTransformer(); final Transformer transformer = newTransformer();
transformer.setErrorListener(listener); transformer.setErrorListener(listener);
s_log.debug("Transforming the XML source document"); LOGGER.debug("Transforming the XML source document");
transformer.transform(source, result); transformer.transform(source, result);
s_log.debug("Finished transforming"); LOGGER.debug("Finished transforming");
} catch (TransformerConfigurationException tce) { } catch (TransformerConfigurationException tce) {
throw new WrappedTransformerException(tce); throw new WrappedTransformerException(tce);
} catch (TransformerException te) { } catch (TransformerException te) {
@ -210,13 +211,13 @@ public final class XSLTemplate {
/** /**
* Transforms the <code>source</code> document and sends it to * Transforms the <code>source</code> document and sends it to
* <code>result</code>. This method internally creates and uses a * <code>result</code>. This method internally creates and uses a new
* new <code>Transformer</code>. * <code>Transformer</code>.
* *
* @param source The <code>Source</code> to be transformed; it * @param source The <code>Source</code> to be transformed; it cannot be
* cannot be null * null
* @param result The <code>Result</code> to capture the * @param result The <code>Result</code> to capture the transformed product;
* transformed product; it cannot be null * it cannot be null
*/ */
public final void transform(final Source source, public final void transform(final Source source,
final Result result) { final Result result) {
@ -225,15 +226,14 @@ public final class XSLTemplate {
/** /**
* Transforms <code>doc</code> and streams the result to * Transforms <code>doc</code> and streams the result to
* <code>writer</code>. If there are errors, * <code>writer</code>. If there are errors, <code>listener</code> handles
* <code>listener</code> handles them. * them.
* *
* @param doc The <code>Document</code> to transform; it cannot be * @param doc The <code>Document</code> to transform; it cannot be null
* null * @param writer The <code>PrintWriter</code> to receive the transformed
* @param writer The <code>PrintWriter</code> to receive the * result; it cannot be null
* transformed result; it cannot be null * @param listener A <code>ErrorListener</code> to handle any errors; it
* @param listener A <code>ErrorListener</code> to handle any * cannot be null
* errors; it cannot be null
*/ */
public final void transform(final Document doc, public final void transform(final Document doc,
final PrintWriter writer, final PrintWriter writer,
@ -254,10 +254,9 @@ public final class XSLTemplate {
* Transforms <code>doc</code> and streams the result to * Transforms <code>doc</code> and streams the result to
* <code>writer</code>. * <code>writer</code>.
* *
* @param doc The <code>Document</code> to transform; it cannot be * @param doc The <code>Document</code> to transform; it cannot be null
* null * @param writer The <code>PrintWriter</code> to receive the transformed
* @param writer The <code>PrintWriter</code> to receive the * result; it cannot be null
* transformed result; it cannot be null
*/ */
public final void transform(final Document doc, public final void transform(final Document doc,
final PrintWriter writer) { final PrintWriter writer) {
@ -265,82 +264,81 @@ public final class XSLTemplate {
} }
/** /**
* Checks whether the XSL files associated with the template have * Checks whether the XSL files associated with the template have been
* been modified. * modified.
* *
* @return <code>true</code> if any dependent files have been * @return <code>true</code> if any dependent files have been modified,
* modified, otherwise <code>false</code> * otherwise <code>false</code>
*/ */
public final boolean isModified() { public final boolean isModified() {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Checking if the XSL files for " + this.getSource().toString() + " " LOGGER.debug("Checking if the XSL files for " + this.getSource()
+ "have been modified and need to be re-read"); .toString() + " "
+ "have been modified and need to be re-read");
} }
final Iterator iter = m_dependents.iterator(); final Iterator iter = m_dependents.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final URL url = Templating.transformURL((URL) iter.next()); final URL url = Templating.transformURL((URL) iter.next());
Assert.exists(url, URL.class); Assert.exists(url, URL.class);
if (url.getProtocol().equals("file")) { if (url.getProtocol().equals("file")) {
final File file = new File(url.getPath()); final File file = new File(url.getPath());
if (file.lastModified() > m_created.getTime()) { if (file.lastModified() > m_created.getTime()) {
if (s_log.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
s_log.info("File " + file + " was modified " + file. LOGGER.info("File " + file + " was modified " + file.
lastModified()); lastModified());
} }
return true; return true;
} }
} else { } else {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("The URL is not to a file; assuming " + url LOGGER.debug("The URL is not to a file; assuming " + url
+ " is not modified"); + " is not modified");
} }
} }
} }
s_log.debug("No files were modified"); LOGGER.debug("No files were modified");
return false; return false;
} }
/** /**
* Creates a ZIP file containing this stylesheet and * Creates a ZIP file containing this stylesheet and all dependant's. NB,
* all dependant's. NB, this method assumes that all * this method assumes that all stylesheets live in the same URL protocol.
* stylesheets live in the same URL protocol. If the * If the protocol a file is different from the protocol of the top level,
* protocol a file is different from the protocol * then this file will be excluded from the ZIP. In practice this limitation
* of the top level, then this file will be excluded * is not critical, because XSL files should always use relative imports,
* from the ZIP. In practice this limitation is not * which implies all imported files will be in the same URL space.
* critical, because XSL files should always use *
* relative imports, which implies all imported files * @param os the output stream to write the ZIP to
* will be in the same URL space.
*
* @param os the output stream to write the ZIP to
* @param base the base directory in which the files will extract * @param base the base directory in which the files will extract
*
* @throws java.io.IOException * @throws java.io.IOException
*/ */
public void toZIP(OutputStream os, public void toZIP(OutputStream os,
String base) String base)
throws IOException { throws IOException {
final ZipOutputStream zos = new ZipOutputStream(os); final ZipOutputStream zos = new ZipOutputStream(os);
URL src = getSource(); URL src = getSource();
String srcProto = src.getProtocol(); String srcProto = src.getProtocol();
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Outputting files for " + src); LOGGER.debug("Outputting files for " + src);
} }
final Iterator sheets = getDependents().iterator(); final Iterator sheets = getDependents().iterator();
while (sheets.hasNext()) { while (sheets.hasNext()) {
URL xsl = (URL) sheets.next(); URL xsl = (URL) sheets.next();
if (xsl.getProtocol().equals(srcProto)) { if (xsl.getProtocol().equals(srcProto)) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Outputting file " + xsl); LOGGER.debug("Outputting file " + xsl);
} }
String path = xsl.getPath(); String path = xsl.getPath();
if (path.startsWith("/")) { if (path.startsWith("/")) {
@ -351,8 +349,8 @@ public final class XSLTemplate {
IO.copy(xsl.openStream(), zos); IO.copy(xsl.openStream(), zos);
} else { } else {
s_log.warn("Not outputting file " + xsl LOGGER.warn("Not outputting file " + xsl
+ " because its not under protocol " + srcProto); + " because its not under protocol " + srcProto);
} }
} }
zos.finish(); zos.finish();
@ -372,14 +370,16 @@ public final class XSLTemplate {
@Override @Override
public void fatalError(TransformerException e) throws public void fatalError(TransformerException e) throws
TransformerException { TransformerException {
log(Level.FATAL, e); log(Level.FATAL, e);
} }
private static void log(Level level, TransformerException ex) { private static void log(Level level, TransformerException ex) {
s_log.log(level, "Transformer " + level + ": " + ex. LOGGER.log(level, "Transformer " + level + ": " + ex.
getLocationAsString() + ": " + ex.getMessage(), getLocationAsString() + ": " + ex.getMessage(),
ex); ex);
} }
} }
} }

View File

@ -24,18 +24,17 @@ import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.Iterator; import java.util.Iterator;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* <p>A simple layout panel with top, bottom, left, right, and body * A simple layout panel with top, bottom, left, right, and body sections.</p>
* sections.</p>
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
public class ActionGroup extends ComponentSet { public class ActionGroup extends ComponentSet {
private static final Logger s_log = Logger.getLogger(ActionGroup.class); private static final Logger LOGGER = LogManager.getLogger(ActionGroup.class);
private Component m_subject; private Component m_subject;
private final ArrayList m_actions = new ArrayList(); private final ArrayList m_actions = new ArrayList();
@ -57,7 +56,7 @@ public class ActionGroup extends ComponentSet {
Assert.exists(action, "Component action"); Assert.exists(action, "Component action");
Assert.isUnlocked(this); Assert.isUnlocked(this);
m_actions.add(new Object[] {action, clacc}); m_actions.add(new Object[]{action, clacc});
add(action); add(action);
} }
@ -67,24 +66,24 @@ public class ActionGroup extends ComponentSet {
public final void generateXML(final PageState state, final Element parent) { public final void generateXML(final PageState state, final Element parent) {
if (isVisible(state)) { if (isVisible(state)) {
final Element layout = parent.newChildElement final Element layout = parent.newChildElement("bebop:actionGroup",
("bebop:actionGroup", BEBOP_XML_NS); BEBOP_XML_NS);
final Element subject = layout.newChildElement final Element subject = layout.newChildElement("bebop:subject",
("bebop:subject", BEBOP_XML_NS); BEBOP_XML_NS);
if (m_subject != null) { if (m_subject != null) {
m_subject.generateXML(state, subject); m_subject.generateXML(state, subject);
} }
for (Iterator iter = m_actions.iterator(); iter.hasNext(); ) { for (Iterator iter = m_actions.iterator(); iter.hasNext();) {
final Object[] spec = (Object[]) iter.next(); final Object[] spec = (Object[]) iter.next();
final Component component = (Component) spec[0]; final Component component = (Component) spec[0];
final String clacc = (String) spec[1]; final String clacc = (String) spec[1];
if (component.isVisible(state)) { if (component.isVisible(state)) {
final Element action = layout.newChildElement final Element action = layout
("bebop:action", BEBOP_XML_NS); .newChildElement("bebop:action", BEBOP_XML_NS);
if (clacc != null) { if (clacc != null) {
action.addAttribute("class", clacc); action.addAttribute("class", clacc);
@ -95,4 +94,5 @@ public class ActionGroup extends ComponentSet {
} }
} }
} }
} }

View File

@ -25,17 +25,18 @@ import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.SequentialMap; import com.arsdigita.util.SequentialMap;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.logging.log4j.LogManager;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
/** import org.apache.logging.log4j.Logger;
*
* @version $Id$
*/
public abstract class ComponentMap extends SimpleComponent public abstract class ComponentMap extends SimpleComponent
implements Resettable { implements Resettable {
private static final Logger s_log = Logger.getLogger(ComponentMap.class); private static final Logger LOGGER = LogManager
.getLogger(ComponentMap.class);
private final SequentialMap m_components; private final SequentialMap m_components;
@ -48,7 +49,7 @@ public abstract class ComponentMap extends SimpleComponent
} }
public void reset(final PageState state) { public void reset(final PageState state) {
s_log.debug("Resetting my children"); LOGGER.debug("Resetting my children");
final Iterator iter = children(); final Iterator iter = children();
@ -82,4 +83,5 @@ public abstract class ComponentMap extends SimpleComponent
public abstract void generateXML(final PageState state, public abstract void generateXML(final PageState state,
final Element parent); final Element parent);
} }

View File

@ -26,7 +26,8 @@ import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/** /**
* *
@ -35,7 +36,7 @@ import org.apache.log4j.Logger;
public class ComponentSet extends SimpleComponent public class ComponentSet extends SimpleComponent
implements Resettable { implements Resettable {
private static final Logger s_log = Logger.getLogger(ComponentSet.class); private static final Logger LOGGER = LogManager.getLogger(ComponentSet.class);
private final ArrayList m_components; private final ArrayList m_components;
@ -44,7 +45,7 @@ public class ComponentSet extends SimpleComponent
} }
public void reset(final PageState state) { public void reset(final PageState state) {
s_log.debug("Resetting children"); LOGGER.debug("Resetting children");
final Iterator iter = children(); final Iterator iter = children();

View File

@ -24,18 +24,17 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* <p>A simple layout panel with top, bottom, left, right, and body * A simple layout panel with top, bottom, left, right, and body sections.
* sections.</p>
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id$
*/ */
public class LayoutPanel extends ComponentMap { public class LayoutPanel extends ComponentMap {
private static final Logger s_log = Logger.getLogger(LayoutPanel.class); private static final Logger LOGGER = LogManager.getLogger(LayoutPanel.class);
public final void setTop(final Component top) { public final void setTop(final Component top) {
put("top", top); put("top", top);
@ -60,8 +59,8 @@ public class LayoutPanel extends ComponentMap {
@Override @Override
public void generateXML(final PageState state, final Element parent) { public void generateXML(final PageState state, final Element parent) {
if (isVisible(state)) { if (isVisible(state)) {
final Element layout = parent.newChildElement final Element layout = parent.newChildElement("bebop:layoutPanel",
("bebop:layoutPanel", BEBOP_XML_NS); BEBOP_XML_NS);
section(state, layout, "top"); section(state, layout, "top");
section(state, layout, "left"); section(state, layout, "left");
@ -77,10 +76,11 @@ public class LayoutPanel extends ComponentMap {
final Component section = get(key); final Component section = get(key);
if (section != null) { if (section != null) {
final Element elem = parent.newChildElement final Element elem = parent.newChildElement("bebop:" + key,
("bebop:" + key, BEBOP_XML_NS); BEBOP_XML_NS);
section.generateXML(state, elem); section.generateXML(state, elem);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More