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-94f89814c4dfccm-docs
parent
7b1d0fd625
commit
21b149905d
|
|
@ -55,6 +55,16 @@
|
|||
</dependency>
|
||||
<!-- 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>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,20 @@
|
|||
<Root level="warn">
|
||||
<AppenderRef ref="Console"/>
|
||||
</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"
|
||||
level="debug">
|
||||
</Logger>
|
||||
|
|
@ -52,10 +66,10 @@
|
|||
level="debug">
|
||||
</Logger>
|
||||
<Logger name="org.librecms.contentsection.ContentSectionServlet"
|
||||
level="debug">
|
||||
level="debug">
|
||||
</Logger>
|
||||
<Logger name="com.arsdigita.web.DefaultApplicationFileResolver"
|
||||
level="debug">
|
||||
level="debug">
|
||||
</Logger>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -28,13 +28,16 @@
|
|||
|
||||
<properties>
|
||||
<!-- 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.id.new_generator_mappings" value="true"/>
|
||||
<property name="hibernate.id.new_generator_mappings" value="true" />
|
||||
<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
|
||||
We are using the ValidityAuditStrategy here because it is faster
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <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
|
||||
* @see com.arsdigita.kernel.Kernel
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class CMS {
|
||||
|
||||
/**
|
||||
* Private Logger instance for debugging purpose.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(CMS.class);
|
||||
|
||||
/**
|
||||
* The CMS XML namespace.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ package com.arsdigita.cms;
|
|||
|
||||
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.ContentSection;
|
||||
|
||||
|
|
@ -43,11 +44,10 @@ import org.librecms.contentsection.ContentSection;
|
|||
* @see com.arsdigita.cms.CMS
|
||||
*
|
||||
* @author Daniel Berrange
|
||||
* @version $Id$
|
||||
*/
|
||||
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 ContentItem m_item = null;
|
||||
|
|
@ -102,8 +102,8 @@ public final class CMSContext {
|
|||
public final void setContentSection(final ContentSection section) {
|
||||
m_section = section;
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Content section set to " + section);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Content section set to " + section);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,8 +123,8 @@ public final class CMSContext {
|
|||
public final ContentItem getContentItem() {
|
||||
// removing this which is necessarily true in ContentList
|
||||
//Assert.exists(m_item, "item");
|
||||
if (s_log.isDebugEnabled() && m_item == null) {
|
||||
s_log.debug("Content item is null");
|
||||
if (LOGGER.isDebugEnabled() && m_item == null) {
|
||||
LOGGER.debug("Content item is null");
|
||||
}
|
||||
return m_item;
|
||||
}
|
||||
|
|
@ -136,8 +136,8 @@ public final class CMSContext {
|
|||
public final void setContentItem(final ContentItem item) {
|
||||
m_item = item;
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Content item set to " + item);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Content item set to " + item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,8 +166,8 @@ public final class CMSContext {
|
|||
public final void setSecurityManager(final SecurityManager security) {
|
||||
m_security = security;
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Security manager set to " + security);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Security manager set to " + security);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import com.arsdigita.web.LoginSignal;
|
||||
import com.arsdigita.web.URL;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -37,7 +40,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
|
|
@ -119,7 +121,7 @@ import org.librecms.dispatcher.ItemResolver;
|
|||
*/
|
||||
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
|
||||
= "com.arsdigita.cms.dispatcher.section";
|
||||
|
|
@ -170,8 +172,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
HttpServletResponse response,
|
||||
RequestContext actx)
|
||||
throws IOException, ServletException {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Dispatching request for " + new URL(request)
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Dispatching request for " + new URL(request)
|
||||
.toDebugString());
|
||||
}
|
||||
|
||||
|
|
@ -182,10 +184,10 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
processedUrl = processedUrl.substring(webappURLContext.length());
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Determined the path to the current site node; it "
|
||||
+ "is '" + processedUrl + "' according to the "
|
||||
+ "request context");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Determined the path to the current site node; it "
|
||||
+ "is '" + processedUrl + "' according to the "
|
||||
+ "request context");
|
||||
}
|
||||
|
||||
// This is the path within the site node.
|
||||
|
|
@ -200,9 +202,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
remainingUrl = "index";
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Determined the path after the current site node; "
|
||||
+ "it is '" + remainingUrl + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Determined the path after the current site node; "
|
||||
+ "it is '" + remainingUrl + "'");
|
||||
}
|
||||
|
||||
// Fetch the current content section.
|
||||
|
|
@ -214,8 +216,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
}
|
||||
request.setAttribute(CONTENT_SECTION, section);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Found content section '" + section + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Found content section '" + section + "'");
|
||||
}
|
||||
|
||||
// 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).
|
||||
// KG: This hack will be replaced by a ChainedDispatcher
|
||||
try {
|
||||
s_log.debug("Looking for a site node asset");
|
||||
LOGGER.debug("Looking for a site node asset");
|
||||
|
||||
String siteNodeAssetURL = getSiteNodeAsset(request, actx);
|
||||
if (siteNodeAssetURL != null) {
|
||||
s_log.debug("Site node asset found at '" + siteNodeAssetURL
|
||||
+ "'");
|
||||
LOGGER.debug("Site node asset found at '" + siteNodeAssetURL
|
||||
+ "'");
|
||||
|
||||
DispatcherHelper.cacheDisable(response);
|
||||
DispatcherHelper.setRequestContext(request, actx);
|
||||
|
|
@ -238,8 +240,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
return;
|
||||
}
|
||||
|
||||
s_log.debug("No site node asset found; proceeding with normal "
|
||||
+ "dispatching");
|
||||
LOGGER.debug("No site node asset found; proceeding with normal "
|
||||
+ "dispatching");
|
||||
} catch (RedirectException e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
|
|
@ -247,26 +249,26 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
// Fetch the requested resource (if any).
|
||||
ResourceHandler resource = getResource(section, remainingUrl);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got a resource '" + resource + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Got a resource '" + resource + "'");
|
||||
}
|
||||
|
||||
if (resource != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Found resource '" + remainingUrl + "'; "
|
||||
+ "dispatching to it");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Found resource '" + remainingUrl + "'; "
|
||||
+ "dispatching to it");
|
||||
}
|
||||
|
||||
s_log.info("resource dispatch for " + remainingUrl);
|
||||
LOGGER.info("resource dispatch for " + remainingUrl);
|
||||
// Found resource, now serve it.
|
||||
// NB, ResouceHandler implementations should take care of caching options
|
||||
resource.dispatch(request, response, actx);
|
||||
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No resource found at '" + remainingUrl + "'; "
|
||||
+ "searching for a previewable content item at "
|
||||
+ "this path");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No resource found at '" + remainingUrl + "'; "
|
||||
+ "searching for a previewable content item at "
|
||||
+ "this path");
|
||||
}
|
||||
|
||||
// If the remaining URL starts with "preview/", then try and
|
||||
|
|
@ -301,16 +303,16 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
}
|
||||
|
||||
if (item != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Found item " + item + "; serving it");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Found item " + item + "; serving it");
|
||||
}
|
||||
|
||||
DispatcherHelper.cacheDisable(response);
|
||||
preview(request, response, actx);
|
||||
} else {
|
||||
s_log.debug("No item to preview found; falling back to "
|
||||
+ "JSP dispatcher to look for some concrete "
|
||||
+ "resource in the file system");
|
||||
LOGGER.debug("No item to preview found; falling back to "
|
||||
+ "JSP dispatcher to look for some concrete "
|
||||
+ "resource in the file system");
|
||||
|
||||
// If no resource was found, look for a JSP page.
|
||||
JSPApplicationDispatcher jsp = JSPApplicationDispatcher
|
||||
|
|
@ -338,8 +340,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
}
|
||||
|
||||
if (url.equals(ADMIN_URL)) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Resolving admin URL '" + url + "'");
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Resolving admin URL '" + url + "'");
|
||||
}
|
||||
|
||||
dispatch(request, response, actx);
|
||||
|
|
@ -362,6 +364,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
* @param request The HTTP request
|
||||
* @param response The HTTP response
|
||||
* @param actx The request context
|
||||
*
|
||||
* @throws javax.servlet.ServletException
|
||||
*
|
||||
*/
|
||||
|
|
@ -472,9 +475,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
*/
|
||||
protected ResourceHandler getResource(ContentSection section, String url)
|
||||
throws ServletException {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Searching for a resource for the URL fragment '" + url
|
||||
+ "' under " + section);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Searching for a resource for the URL fragment '" + url
|
||||
+ "' under " + 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
|
||||
*/
|
||||
public static PageResolver getPageResolver(ContentSection section) {
|
||||
s_log.debug("Getting the page resolver");
|
||||
LOGGER.debug("Getting the page resolver");
|
||||
|
||||
final String name = section.getLabel();
|
||||
PageResolver pr = (PageResolver) s_pageResolverCache.get(name);
|
||||
|
||||
if (pr == null) {
|
||||
s_log.debug("The page resolver was not cached; fetching a new "
|
||||
+ "one and placing it in the cache");
|
||||
LOGGER.debug("The page resolver was not cached; fetching a new "
|
||||
+ "one and placing it in the cache");
|
||||
|
||||
final String pageResolverClassName = section.getPageResolverClass();
|
||||
final PageResolver pageResolver;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ import com.arsdigita.web.Web;
|
|||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
@ -38,7 +41,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.Shiro;
|
||||
|
|
@ -68,11 +70,10 @@ import java.util.Optional;
|
|||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @author Uday Mathur (umathur@arsdigita.com)
|
||||
* @version $Id$
|
||||
*/
|
||||
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. */
|
||||
public final static String ASSETS = "ASSETS";
|
||||
|
|
@ -157,10 +158,10 @@ public class CMSPage extends Page implements ResourceHandler {
|
|||
*/
|
||||
@Override
|
||||
public synchronized void init() {
|
||||
s_log.debug("Initializing the page");
|
||||
LOGGER.debug("Initializing the page");
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.web.Web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -34,10 +33,8 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentSectionConfig;
|
||||
|
||||
/**
|
||||
* This is the dispatcher for content-sections. It maintains a
|
||||
|
|
@ -56,13 +53,6 @@ public class ContentItemDispatcher implements Dispatcher {
|
|||
/** */
|
||||
protected ItemXML m_itemXML;
|
||||
|
||||
|
||||
/**
|
||||
* Private Logger instance for debugging purpose.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
ContentItemDispatcher.class.getName());
|
||||
|
||||
/**
|
||||
* */
|
||||
public ContentItemDispatcher() {
|
||||
|
|
|
|||
|
|
@ -21,29 +21,36 @@ package com.arsdigita.cms.dispatcher;
|
|||
import com.arsdigita.dispatcher.ChainedDispatcher;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.dispatcher.RequestContext;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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
|
||||
* (<code>/packages/cms/www</code>). This includes both unmanaged
|
||||
* files copied or created directly in the file system, as well as
|
||||
* pages and assets published to the file system from CMS.
|
||||
* (<code>/packages/cms/www</code>). This includes both unmanaged files copied
|
||||
* or created directly in the file system, as well as pages and assets published
|
||||
* to the file system from CMS.
|
||||
*
|
||||
* @author Karl Goldstein (karlg@arsdigita.com)
|
||||
* @version $Revision$ $DateTime: 2004/08/17 23:15:09 $
|
||||
* @version $Id$
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public class FileDispatcher implements ChainedDispatcher {
|
||||
|
||||
private static Logger s_log =
|
||||
Logger.getLogger(ChainedDispatcher.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ChainedDispatcher.class);
|
||||
|
||||
@Override
|
||||
public int chainedDispatch(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
RequestContext context)
|
||||
|
|
@ -52,16 +59,18 @@ public class FileDispatcher implements ChainedDispatcher {
|
|||
File jspFile = getPackageFile(context);
|
||||
|
||||
if (jspFile.exists() && !jspFile.isDirectory()) {
|
||||
String packageURL = context.getPageBase() + context.getRemainingURLPart();
|
||||
s_log.debug ("DISPATCHING to " + packageURL);
|
||||
String packageURL = context.getPageBase() + context
|
||||
.getRemainingURLPart();
|
||||
LOGGER.debug("DISPATCHING to " + packageURL);
|
||||
|
||||
// don't match folders, since they don't actually match a file
|
||||
if ( !packageURL.endsWith("/")) {
|
||||
s_log.debug ("DISPATCHING to " + packageURL);
|
||||
if (!packageURL.endsWith("/")) {
|
||||
LOGGER.debug("DISPATCHING to " + packageURL);
|
||||
// Don't set caching headers - let JSP file do it if required
|
||||
//DispatcherHelper.maybeCacheDisable(response);
|
||||
DispatcherHelper.setRequestContext(request, context);
|
||||
DispatcherHelper.forwardRequestByPath(packageURL, request, response);
|
||||
DispatcherHelper.forwardRequestByPath(packageURL, request,
|
||||
response);
|
||||
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.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
private File getPackageFile(RequestContext appContext) {
|
||||
|
||||
ServletContext servletContext = appContext.getServletContext();
|
||||
|
||||
String filePath = appContext.getRemainingURLPart();
|
||||
|
||||
String packageDocRoot =
|
||||
servletContext.getRealPath(appContext.getPageBase());
|
||||
String packageDocRoot = servletContext.getRealPath(appContext
|
||||
.getPageBase());
|
||||
|
||||
File jspFile = new File(packageDocRoot, filePath);
|
||||
|
||||
return jspFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ package com.arsdigita.cms.dispatcher;
|
|||
import com.arsdigita.dispatcher.ChainedDispatcher;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.dispatcher.RequestContext;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.LoginSignal;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -33,7 +35,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
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.
|
||||
*
|
||||
* @author Karl Goldstein (karlg@arsdigita.com)
|
||||
* @version $Revision$ $DateTime: 2004/08/17 23:15:09 $
|
||||
*
|
||||
*/
|
||||
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(
|
||||
new HashMap());
|
||||
|
|
@ -95,11 +95,11 @@ public class ItemDispatcher implements ChainedDispatcher {
|
|||
String queryString = request.getQueryString();
|
||||
String url = actx.getRemainingURLPart();
|
||||
|
||||
s_log.info("Resolving item URL " + url);
|
||||
LOGGER.info("Resolving item URL " + url);
|
||||
|
||||
if (url.endsWith(XML_SUFFIX)) {
|
||||
request.setAttribute(XML_MODE, Boolean.TRUE);
|
||||
s_log.debug("StraightXML Requested");
|
||||
LOGGER.debug("StraightXML Requested");
|
||||
url = "/" + url.substring(0, url.length() - XML_SUFFIX.length());
|
||||
} else {
|
||||
request.setAttribute(XML_MODE, Boolean.FALSE);
|
||||
|
|
@ -110,7 +110,7 @@ public class ItemDispatcher implements ChainedDispatcher {
|
|||
} else if (url.endsWith("/")) {
|
||||
url = "/" + url.substring(0, url.length() - 1);
|
||||
} else {
|
||||
s_log.warn("Fail: URL doesn't have right suffix.");
|
||||
LOGGER.warn("Fail: URL doesn't have right suffix.");
|
||||
return ChainedDispatcher.DISPATCH_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,13 +121,13 @@ public class ItemDispatcher implements ChainedDispatcher {
|
|||
|
||||
final ContentItem item = getItem(section, url);
|
||||
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;
|
||||
}
|
||||
|
||||
request.setAttribute(ContentSectionDispatcher.CONTENT_ITEM, item);
|
||||
|
||||
s_log.debug("MATCHED " + item.getObjectId());
|
||||
LOGGER.debug("MATCHED " + item.getObjectId());
|
||||
|
||||
// Work out how long to cache for....
|
||||
// We take minimum(default timeout, lifecycle expiry)
|
||||
|
|
@ -216,7 +216,7 @@ public class ItemDispatcher implements ChainedDispatcher {
|
|||
|
||||
// look up folder if it's an index
|
||||
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");
|
||||
if (item != null) {
|
||||
hasPermission = permissionChecker.isPermitted(
|
||||
|
|
|
|||
|
|
@ -20,70 +20,72 @@ package com.arsdigita.cms.dispatcher;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentCenter;
|
||||
import com.arsdigita.cms.ContentCenterServlet;
|
||||
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 java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.assets.BinaryAsset;
|
||||
import org.librecms.assets.Image;
|
||||
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>
|
||||
* Specifically used by various JSP templates.
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Utilities {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(Utilities.class);
|
||||
|
||||
// Used for caching util lookups
|
||||
private static HashMap m_cache = new HashMap();
|
||||
|
||||
private static Date s_lastSectionRefresh = null;
|
||||
private static Map s_sectionRefreshTimes =
|
||||
Collections.synchronizedMap(new HashMap());
|
||||
|
||||
public static final Logger LOG = Logger.getLogger(Utilities.class);
|
||||
private static Map s_sectionRefreshTimes = Collections.synchronizedMap(
|
||||
new HashMap());
|
||||
|
||||
/**
|
||||
* Fetch the location of the CMS ContentCenter package.
|
||||
*
|
||||
* @return The URL of the CMS ContentCenter package
|
||||
*
|
||||
* @deprecated use ContentCenter.getURL() instead
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return The URL of the CMS Services package
|
||||
* @deprecated Use Service.getURL( instead
|
||||
*
|
||||
* @deprecated Use Service.getURL( instead
|
||||
*/
|
||||
public static String getServiceURL() {
|
||||
String url = (String) m_cache.get(CmsConstants.SERVICE_PACKAGE_KEY);
|
||||
if ( url == null ) {
|
||||
// chris.gilbert@westsussex.gov.uk
|
||||
if (url == null) {
|
||||
// chris.gilbert@westsussex.gov.uk
|
||||
// We don't want application context in this url, especially when
|
||||
// it gets cached in a static variable - if I have a
|
||||
// file that is maintained by a non cms application eg
|
||||
// forum, then I can end up with a url that doesn't work
|
||||
// and so breaks file links everywhere
|
||||
// url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY);
|
||||
// url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY);
|
||||
url = CmsConstants.SERVICE_URL;
|
||||
m_cache.put(CmsConstants.SERVICE_PACKAGE_KEY, url);
|
||||
}
|
||||
|
|
@ -93,11 +95,12 @@ public class Utilities {
|
|||
|
||||
/**
|
||||
* The URL to log out.
|
||||
*
|
||||
* @return The logout URL
|
||||
*/
|
||||
public static String getLogoutURL() {
|
||||
//StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL );
|
||||
//StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
|
||||
buf.append("logout");
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
@ -105,8 +108,10 @@ public class Utilities {
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @deprecated Use Service.getAssetURL(BinaryAsset asset) instead
|
||||
*/
|
||||
public static String getAssetURL(BinaryAsset asset) {
|
||||
|
|
@ -116,38 +121,42 @@ public class Utilities {
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @deprecated Use Service.getAssetURL(BigDecimal assetId) instead
|
||||
*/
|
||||
public static String getAssetURL(long assetId) {
|
||||
// StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL );
|
||||
// StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
|
||||
buf.append("stream/asset?");
|
||||
buf.append(CmsConstants.ASSET_ID).append("=").append(assetId);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @deprecated Use Service.getImageURL(ImageAsset) instead!
|
||||
*/
|
||||
public static String getImageURL(Image asset) {
|
||||
// StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL );
|
||||
// StringBuffer buf = new StringBuffer(getServiceURL());
|
||||
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL);
|
||||
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();
|
||||
}
|
||||
|
||||
public static String getGlobalAssetsURL() {
|
||||
return getWebappContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the context path of the request. This is typically "/".
|
||||
*
|
||||
|
|
@ -157,17 +166,16 @@ public class Utilities {
|
|||
return DispatcherHelper.getWebappContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for the last refresh on authoring kits or content types in
|
||||
* a section.
|
||||
**/
|
||||
* Check for the last refresh on authoring kits or content types in a
|
||||
* section.
|
||||
*
|
||||
*/
|
||||
public static synchronized Date
|
||||
getLastSectionRefresh(ContentSection section) {
|
||||
|
||||
// cache by URL string instead of by section object to avoid
|
||||
// holding the reference.
|
||||
|
||||
String sectionURL = section.getPrimaryUrl();
|
||||
|
||||
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
|
||||
* any section.
|
||||
**/
|
||||
* Check for the last refresh on authoring kits or content types in any
|
||||
* section.
|
||||
*
|
||||
*/
|
||||
public static Date getLastSectionRefresh() {
|
||||
|
||||
// instantiate last refresh lazily to ensure that first result is
|
||||
// predictable.
|
||||
|
||||
if (s_lastSectionRefresh == null) {
|
||||
s_lastSectionRefresh = new Date();
|
||||
}
|
||||
|
|
@ -215,7 +223,7 @@ public class Utilities {
|
|||
// section object to avoid holding the reference. This shouldn't
|
||||
// do any harm even if ContentSectionDispatcher is not being used.
|
||||
s_lastSectionRefresh = new Date();
|
||||
s_sectionRefreshTimes.put(section.getPrimaryUrl(),
|
||||
s_sectionRefreshTimes.put(section.getPrimaryUrl(),
|
||||
s_lastSectionRefresh);
|
||||
}
|
||||
|
||||
|
|
@ -235,10 +243,11 @@ public class Utilities {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add the "pragma: no-cache" header to the HTTP response to make sure
|
||||
* the browser does not cache tha page
|
||||
* Add the "pragma: no-cache" header to the HTTP response to make sure the
|
||||
* browser does not cache tha page
|
||||
*
|
||||
* @param response The HTTP response
|
||||
*
|
||||
* @deprecated use
|
||||
* com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse)
|
||||
*/
|
||||
|
|
@ -246,5 +255,4 @@ public class Utilities {
|
|||
response.addHeader("pragma", "no-cache");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import com.arsdigita.toolbox.ui.Cancellable;
|
|||
import com.arsdigita.toolbox.ui.Section;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.librecms.CmsConstants;
|
||||
|
||||
/**
|
||||
|
|
@ -50,8 +49,6 @@ import org.librecms.CmsConstants;
|
|||
*/
|
||||
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 BoxPanel m_actions;
|
||||
private Cancel m_cancel;
|
||||
|
|
|
|||
|
|
@ -25,18 +25,14 @@ import com.arsdigita.bebop.event.ChangeListener;
|
|||
import com.arsdigita.bebop.event.TreeExpansionEvent;
|
||||
import com.arsdigita.bebop.event.TreeExpansionListener;
|
||||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A convenience class for CMS trees.
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BaseTree extends Tree {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(BaseTree.class);
|
||||
|
||||
public BaseTree(final TreeModelBuilder builder) {
|
||||
super(builder);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,19 +21,11 @@ package com.arsdigita.cms.ui;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.core.CcmObject;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CcmObjectRequestLocal extends RequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(CcmObjectRequestLocal.class);
|
||||
|
||||
public final CcmObject getACSObject(final PageState state) {
|
||||
return (CcmObject) get(state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,17 +21,14 @@ package com.arsdigita.cms.ui;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
import com.arsdigita.cms.CMS;
|
||||
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final class ContentSectionRequestLocal extends RequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(ContentSectionRequestLocal.class);
|
||||
|
||||
@Override
|
||||
protected Object initialValue(final PageState state) {
|
||||
return CMS.getContext().getContentSection();
|
||||
|
|
|
|||
|
|
@ -25,27 +25,19 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
|
|||
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
|
||||
import com.arsdigita.dispatcher.AccessDeniedException;
|
||||
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.Web;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
|
||||
/**
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FormSecurityListener implements FormSubmissionListener {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(FormSecurityListener.class);
|
||||
|
||||
private final String m_action;
|
||||
private final ContentItemRequestLocal m_item;
|
||||
|
||||
|
|
@ -63,20 +55,21 @@ public class FormSecurityListener implements FormSubmissionListener {
|
|||
|
||||
@Override
|
||||
public final void submitted(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
|
||||
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
|
||||
if (m_item == null) {
|
||||
if (permissionChecker.isPermitted(m_action)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
final ContentItem item = m_item.getContentItem(state);
|
||||
|
||||
|
||||
if (permissionChecker.isPermitted(m_action, item)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -84,4 +77,5 @@ public class FormSecurityListener implements FormSubmissionListener {
|
|||
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package com.arsdigita.cms.ui;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentCenter;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.ui.UI;
|
||||
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||
|
|
@ -29,11 +28,9 @@ import com.arsdigita.ui.login.LoginServlet;
|
|||
import com.arsdigita.web.URL;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.web.ApplicationCreator;
|
||||
import org.libreccm.web.ApplicationManager;
|
||||
import org.libreccm.web.ApplicationRepository;
|
||||
import org.libreccm.web.ApplicationType;
|
||||
|
|
@ -50,12 +47,11 @@ import javax.servlet.http.HttpServletRequest;
|
|||
* Global navigation elements for the CMS admin UIs.</p>
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
// Made public (instead of unspecified, resulting in protected) in 6.6.8
|
||||
public class GlobalNavigation extends SimpleComponent {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(GlobalNavigation.class);
|
||||
|
||||
private final String m_adminPath;
|
||||
private final String m_centerPath;
|
||||
private final String m_changePasswordPath;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.arsdigita.cms.CMS;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
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
|
||||
* 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)
|
||||
* @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 {
|
||||
|
||||
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
|
||||
// used by List but because List has it as private, we cannot do that.
|
||||
private static final String SELECT_EVENT = "s";
|
||||
|
|
@ -67,11 +65,12 @@ public abstract class SortableList extends List {
|
|||
this(model, false);
|
||||
}
|
||||
|
||||
public SortableList(ParameterSingleSelectionModel model, boolean suppressSort) {
|
||||
public SortableList(ParameterSingleSelectionModel model,
|
||||
boolean suppressSort) {
|
||||
super(model);
|
||||
m_sortItems = !suppressSort;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This geneates the XML as specified by the arguments pass in to the
|
||||
* constructor.
|
||||
|
|
@ -91,7 +90,8 @@ public abstract class SortableList extends List {
|
|||
|
||||
// because m.next() returned true, we know there are items
|
||||
// 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);
|
||||
|
||||
Component c;
|
||||
|
|
@ -99,7 +99,8 @@ public abstract class SortableList extends List {
|
|||
int i = 0;
|
||||
boolean hasNext;
|
||||
do {
|
||||
Element item = list.newChildElement(BebopConstants.BEBOP_CELL, BEBOP_XML_NS);
|
||||
Element item = list.newChildElement(BebopConstants.BEBOP_CELL,
|
||||
BEBOP_XML_NS);
|
||||
if (m_sortItems) {
|
||||
|
||||
item.addAttribute("configure", "true");
|
||||
|
|
@ -110,14 +111,15 @@ public abstract class SortableList extends List {
|
|||
// Converting both keys to String for comparison
|
||||
// since ListModel.getKey returns a String
|
||||
boolean selected = (selKey != null)
|
||||
&& key.equals(selKey.toString());
|
||||
&& key.equals(selKey.toString());
|
||||
|
||||
if (selected) {
|
||||
item.addAttribute("selected", "selected");
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
@ -138,7 +140,7 @@ public abstract class SortableList extends List {
|
|||
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("Caught IOException: "
|
||||
+ ex.getMessage());
|
||||
+ ex.getMessage());
|
||||
}
|
||||
i++;
|
||||
} while (hasNext);
|
||||
|
|
@ -147,9 +149,10 @@ public abstract class SortableList extends List {
|
|||
}
|
||||
|
||||
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);
|
||||
Component c = new ControlLink(label);
|
||||
c.generateXML(state, parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import com.arsdigita.cms.ItemSelectionModel;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.librecms.CmsConstants;
|
||||
|
||||
|
|
@ -54,14 +53,6 @@ public abstract class BasicItemForm extends FormSection
|
|||
FormProcessListener,
|
||||
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 SaveCancelSection m_saveCancelSection;
|
||||
private final FormSection m_widgetSection;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.arsdigita.bebop.util.GlobalizationUtil;
|
|||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ui.BaseForm;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
|
|
@ -42,14 +42,11 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
|
|||
/**
|
||||
* TODO Needs a description.
|
||||
*
|
||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(AddUseContextForm.class);
|
||||
|
||||
private final SingleSelectionModel m_model;
|
||||
|
||||
private final Name m_useContext;
|
||||
|
|
|
|||
|
|
@ -36,34 +36,31 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
|||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A form which creates a new category. Extends the edit form for
|
||||
* convenience.
|
||||
* A form which creates a new category. Extends the edit form for convenience.
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||
* @author Michael Pih
|
||||
* @author Stanislav Freidin <sfreidin@redhat.com>
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(BaseCategoryForm.class);
|
||||
final CategoryRequestLocal m_parent;
|
||||
final TextField m_name;
|
||||
final TextArea m_description;
|
||||
final RadioGroup m_isAbstract;
|
||||
final RadioGroup m_isVisible;
|
||||
final RadioGroup m_isEnabled;
|
||||
private Label m_script = new Label( new GlobalizedMessage(String.format(
|
||||
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
|
||||
Web.getWebappContextPath())),
|
||||
false);
|
||||
private Label m_script = new Label(new GlobalizedMessage(String.format(
|
||||
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
|
||||
Web.getWebappContextPath())),
|
||||
false);
|
||||
private final static String NAME = "name";
|
||||
private final static String DESCRIPTION = "description";
|
||||
private final static String URL = "url";
|
||||
|
|
@ -87,9 +84,11 @@ class BaseCategoryForm extends BaseForm {
|
|||
m_name.setSize(30);
|
||||
m_name.setMaxLength(200);
|
||||
m_name.addValidationListener(new NotNullValidationListener());
|
||||
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + " defaulting = true; this.form." + URL
|
||||
+ ".value = urlize(this.value); }");
|
||||
m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
|
||||
m_name.setOnFocus("if (this.form." + URL + ".value == '') { "
|
||||
+ " defaulting = true; this.form." + URL
|
||||
+ ".value = urlize(this.value); }");
|
||||
m_name.setOnKeyUp("if (defaulting) { this.form." + URL
|
||||
+ ".value = urlize(this.value) }");
|
||||
|
||||
// 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"))));
|
||||
addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
|
||||
|
||||
|
||||
m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
|
||||
addField(gz("cms.ui.description"), m_description);
|
||||
|
||||
|
|
@ -147,7 +145,7 @@ class BaseCategoryForm extends BaseForm {
|
|||
|
||||
@Override
|
||||
public final void validate(final ParameterEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
final String title = (String) m_widget.getValue(state);
|
||||
|
||||
|
|
@ -158,11 +156,14 @@ class BaseCategoryForm extends BaseForm {
|
|||
for (final Category child : children) {
|
||||
String compField = child.getName();
|
||||
if (compField.equalsIgnoreCase(title)
|
||||
&& (m_category == null
|
||||
|| !m_category.getCategory(state).equals(child))) {
|
||||
throw new FormProcessException(GlobalizationUtil.globalize("cms.ui.category.name_not_unique"));
|
||||
&& (m_category == null
|
||||
|| !m_category.getCategory(state).equals(child))) {
|
||||
throw new FormProcessException(GlobalizationUtil.globalize(
|
||||
"cms.ui.category.name_not_unique"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ import com.arsdigita.bebop.event.FormSectionEvent;
|
|||
import com.arsdigita.dispatcher.AccessDeniedException;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
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.CategoryManager;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
|
|
@ -39,13 +41,12 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
|
|||
/**
|
||||
* TODO Needs a description.
|
||||
*
|
||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
private static final Logger LOGGER = LogManager.getLogger
|
||||
(CategoryAddForm.class);
|
||||
|
||||
private final SingleSelectionModel m_model;
|
||||
|
|
@ -66,7 +67,7 @@ final class CategoryAddForm extends BaseCategoryForm {
|
|||
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
s_log.debug("Adding a category");
|
||||
LOGGER.debug("Adding a category");
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
|
||||
|
|
@ -84,8 +85,8 @@ final class CategoryAddForm extends BaseCategoryForm {
|
|||
|
||||
Assert.exists(parent, "Category parent");
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Using parent category " + parent + " to " +
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Using parent category " + parent + " to " +
|
||||
"create new category");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@
|
|||
*/
|
||||
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.ParameterListener;
|
||||
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.globalization.GlobalizedMessage;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
/**
|
||||
|
|
@ -39,12 +42,9 @@ import org.libreccm.categorization.Category;
|
|||
*
|
||||
* @author Michael Pih
|
||||
* @author Stanislav Freidin <sfreidin@redhat.com>
|
||||
* @version $Id: CategoryBaseForm.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
class CategoryBaseForm extends CMSForm {
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(CategoryBaseForm.class);
|
||||
|
||||
|
||||
final CategoryRequestLocal m_parent;
|
||||
|
||||
final FormErrorDisplay m_errors;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ import com.arsdigita.bebop.event.FormProcessListener;
|
|||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.dispatcher.AccessDeniedException;
|
||||
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.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
|
@ -37,13 +39,14 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
|
|||
/**
|
||||
* TODO Needs a description.
|
||||
*
|
||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @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 {
|
||||
|
||||
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 YES = "yes";
|
||||
private final CategoryRequestLocal m_category;
|
||||
|
|
@ -62,7 +65,7 @@ final class CategoryEditForm extends BaseCategoryForm {
|
|||
|
||||
@Override
|
||||
public final void init(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
|
|
@ -88,7 +91,6 @@ final class CategoryEditForm extends BaseCategoryForm {
|
|||
m_isVisible.setValue(state, NO);
|
||||
}
|
||||
|
||||
|
||||
if (category.isEnabled()) {
|
||||
m_isEnabled.setValue(state, YES);
|
||||
} else {
|
||||
|
|
@ -102,21 +104,28 @@ final class CategoryEditForm extends BaseCategoryForm {
|
|||
|
||||
@Override
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
|
||||
final ConfigurationManager manager = cdiUtil.findBean(ConfigurationManager.class);
|
||||
final KernelConfig config = manager.findConfiguration(KernelConfig.class);
|
||||
final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
|
||||
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
final ConfigurationManager manager = cdiUtil.findBean(
|
||||
ConfigurationManager.class);
|
||||
final KernelConfig config = manager.findConfiguration(
|
||||
KernelConfig.class);
|
||||
final CategoryRepository categoryRepository = cdiUtil.findBean(
|
||||
CategoryRepository.class);
|
||||
|
||||
final PageState state = e.getPageState();
|
||||
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));
|
||||
final LocalizedString localizedDescription = new LocalizedString();
|
||||
localizedDescription.addValue(config.getDefaultLocale() ,(String) m_description.getValue(state));
|
||||
final LocalizedString localizedDescription
|
||||
= new LocalizedString();
|
||||
localizedDescription.addValue(config.getDefaultLocale(),
|
||||
(String) m_description.getValue(
|
||||
state));
|
||||
category.setDescription(localizedDescription);
|
||||
|
||||
final String isAbstract = (String) m_isAbstract.getValue(state);
|
||||
|
|
@ -150,4 +159,5 @@ final class CategoryEditForm extends BaseCategoryForm {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,11 @@ package com.arsdigita.cms.ui.category;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
class CategoryRequestLocal extends RequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(CategoryRequestLocal.class);
|
||||
|
||||
public final Category getCategory(final PageState state) {
|
||||
return (Category) get(state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ package com.arsdigita.cms.ui.category;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.cms.CMS;
|
||||
|
||||
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.librecms.contentsection.ContentSection;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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)
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
private static final Logger LOGGER = LogManager.getLogger
|
||||
(SortableCategoryList.class);
|
||||
|
||||
public final static String CHILDREN = "ch";
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.arsdigita.bebop.SimpleContainer;
|
|||
import com.arsdigita.bebop.TabbedPane;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.LongParameter;
|
||||
import com.arsdigita.cms.ui.CMSApplicationPage;
|
||||
import com.arsdigita.cms.ui.GlobalNavigation;
|
||||
|
|
@ -32,7 +31,6 @@ import com.arsdigita.cms.ui.WorkspaceContextBar;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.ui.CcmObjectSelectionModel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentType;
|
||||
|
|
@ -56,12 +54,9 @@ import org.librecms.contentsection.ContentType;
|
|||
* @author Jack Chung (flattop@arsdigita.com)
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @author Peter Boy (pboy@barkhof.uni-bremen.de)
|
||||
* @version $Id: MainPage.java pboy $
|
||||
*/
|
||||
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 TabbedPane m_tabbedPane;
|
||||
|
|
@ -114,15 +109,15 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
add(m_tabbedPane);
|
||||
|
||||
// add(new DebugPanel());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates, and then caches, the Tasks pane. Overriding this method to
|
||||
* return null will prevent this tab from appearing.
|
||||
*/
|
||||
protected TasksPanel getTasksPane(CcmObjectSelectionModel<ContentType> typeModel,
|
||||
CcmObjectSelectionModel<ContentSection> sectionModel) {
|
||||
protected TasksPanel getTasksPane(
|
||||
CcmObjectSelectionModel<ContentType> typeModel,
|
||||
CcmObjectSelectionModel<ContentSection> sectionModel) {
|
||||
if (m_tasks == null) {
|
||||
m_tasks = new TasksPanel(typeModel, sectionModel);
|
||||
}
|
||||
|
|
@ -149,7 +144,6 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
//
|
||||
// return m_IdSearch;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Created the TabbedPane to use for this page. Sets the class attribute for
|
||||
* this tabbed pane. The default implementation uses a
|
||||
|
|
@ -165,7 +159,7 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
TabbedPane tabbedPane = new TabbedPane();
|
||||
tabbedPane.setClassAttr(XSL_CLASS);
|
||||
Label taskLabel = new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.mainpage.taskssections",
|
||||
"cms.ui.contentcenter.mainpage.taskssections",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
Label searchLabel = new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.mainpage.search", CmsConstants.CMS_BUNDLE));
|
||||
|
|
@ -228,7 +222,7 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
|
||||
if (pane == m_tasks) {
|
||||
m_tasks.reset(state);
|
||||
}
|
||||
}
|
||||
// else if (pane == m_search) {
|
||||
// m_search.reset(state);
|
||||
// } else if (pane == m_IdSearch) {
|
||||
|
|
|
|||
|
|
@ -19,18 +19,11 @@
|
|||
package com.arsdigita.cms.ui.contentcenter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.bebop.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Image;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
|
|
@ -38,7 +31,6 @@ import com.arsdigita.bebop.PaginationModelBuilder;
|
|||
import com.arsdigita.bebop.Paginator;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
|
|
@ -50,10 +42,6 @@ import com.arsdigita.cms.CMS;
|
|||
import com.arsdigita.cms.ui.CMSContainer;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
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 org.librecms.CmsConstants;
|
||||
|
|
@ -66,7 +54,6 @@ import org.librecms.contentsection.ContentType;
|
|||
*/
|
||||
public class TasksPanel extends CMSContainer {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(TasksPanel.class);
|
||||
// The default number of rows to show
|
||||
private static final int DEFAULT_MAX_ROWS = 15;
|
||||
// Number of tasks to show
|
||||
|
|
|
|||
|
|
@ -24,15 +24,12 @@ import com.arsdigita.bebop.SingleSelectionModel;
|
|||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
||||
class FolderAddForm extends FolderBaseForm {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(FolderAddForm.class);
|
||||
|
||||
private final SingleSelectionModel<Long> m_model;
|
||||
private final FolderRequestLocal m_parent;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,10 @@ import com.arsdigita.cms.ui.BaseDeleteForm;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.SelectionPanel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.librecms.CmsConstants;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(FolderAdminPane.class);
|
||||
|
||||
private final FolderRequestLocal m_folder;
|
||||
|
||||
private final BigDecimalParameter m_param;
|
||||
|
|
|
|||
|
|
@ -26,24 +26,23 @@ import com.arsdigita.bebop.form.TextField;
|
|||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
|
||||
import com.arsdigita.cms.ui.CMSForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Class FolderForm implements the basic form for creating or renaming folders.
|
||||
*
|
||||
* @author Jon Orris <jorris@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
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 TITLE = "ContentPageTitle";
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ import com.arsdigita.kernel.KernelConfig;
|
|||
import com.arsdigita.toolbox.ui.FormatStandards;
|
||||
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 java.util.ArrayList;
|
||||
|
|
@ -91,7 +92,9 @@ import java.util.Date;
|
|||
*/
|
||||
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 = {
|
||||
globalize("cms.ui.folder.name"),
|
||||
globalize("cms.ui.folder.languages"),
|
||||
|
|
@ -551,20 +554,21 @@ public class FolderBrowser extends Table {
|
|||
*/
|
||||
private static class ActionCellRenderer implements TableCellRenderer {
|
||||
|
||||
private static final Label s_noAction;
|
||||
private static final ControlLink s_link;
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ActionCellRenderer.class);
|
||||
|
||||
private static final Label s_noAction;
|
||||
private static final ControlLink s_link;
|
||||
|
||||
static {
|
||||
logger.debug("Static initializer is starting...");
|
||||
LOGGER.debug("Static initializer is starting...");
|
||||
s_noAction = new Label(" ", false);
|
||||
s_noAction.lock();
|
||||
s_link = new ControlLink(
|
||||
new Label(globalize("cms.ui.folder.delete")));
|
||||
s_link.setConfirmation(
|
||||
globalize("cms.ui.folder.delete_confirmation"));
|
||||
logger.debug("Static initializer finished.");
|
||||
LOGGER.debug("Static initializer finished.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -760,8 +764,8 @@ public class FolderBrowser extends Table {
|
|||
}
|
||||
|
||||
public boolean isDeletable() {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Checking to see if " + this + " is deletable");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Checking to see if " + this + " is deletable");
|
||||
}
|
||||
|
||||
// if (m_itemColl.isFolder()) {
|
||||
|
|
@ -785,15 +789,15 @@ public class FolderBrowser extends Table {
|
|||
// } else
|
||||
if (itemManager.isLive(m_itemColl.get(index))) {
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug(
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"This item has a live instance; it cannot be deleted");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug(
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"The item is not a folder and doesn't have a live instance; it may be deleted");
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -18,21 +18,21 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.folder;
|
||||
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
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.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,12 +67,13 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.Web;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
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).
|
||||
*
|
||||
* @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
|
||||
public class FolderManipulator extends SimpleContainer implements
|
||||
|
|
@ -108,8 +108,9 @@ public class FolderManipulator extends SimpleContainer implements
|
|||
Resettable {
|
||||
|
||||
//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);
|
||||
|
||||
private static final String ATOZ_FILTER_PARAM = "aToZfilter";
|
||||
private static final String ACTION_PARAM = "act";
|
||||
private static final String FILTER_PARAM = "filter";
|
||||
|
|
|
|||
|
|
@ -22,18 +22,15 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.cms.ui.CcmObjectRequestLocal;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.librecms.contentsection.Folder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class FolderRequestLocal extends CcmObjectRequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
FolderRequestLocal.class);
|
||||
|
||||
private final SingleSelectionModel m_model;
|
||||
|
||||
public FolderRequestLocal(final SingleSelectionModel model) {
|
||||
|
|
@ -57,7 +54,15 @@ public class FolderRequestLocal extends CcmObjectRequestLocal {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.arsdigita.cms.CMS;
|
|||
|
||||
import com.arsdigita.ui.CcmObjectSelectionModel;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.Folder;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import com.arsdigita.bebop.Tree;
|
|||
|
||||
public class FolderTree extends Tree {
|
||||
|
||||
public FolderTree(FolderSelectionModel folderSel) {
|
||||
public FolderTree(final FolderSelectionModel folderSel) {
|
||||
super(new FolderTreeModelBuilder());
|
||||
setSelectionModel(folderSel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,17 @@ import com.arsdigita.bebop.tree.TreeModel;
|
|||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||
import com.arsdigita.bebop.tree.TreeNode;
|
||||
import com.arsdigita.cms.CMS;
|
||||
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
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
|
||||
|
|
@ -41,19 +46,17 @@ import org.libreccm.categorization.Category;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class FolderTreeModelBuilder extends LockableImpl
|
||||
implements TreeModelBuilder {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
FolderTreeModelBuilder.class);
|
||||
implements TreeModelBuilder {
|
||||
|
||||
/**
|
||||
* Make a tree model that lists the hierarchy of folders underneath the
|
||||
* 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
|
||||
*
|
||||
* @return a tree model that lists the hierarchy of folders underneath the
|
||||
* folder returnedby {@link #getRoot getRoot}.
|
||||
* folder returned by {@link #getRoot getRoot}.
|
||||
*/
|
||||
@Override
|
||||
public TreeModel makeModel(final Tree tree, final PageState state) {
|
||||
|
|
@ -67,28 +70,35 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
@Override
|
||||
public boolean hasChildren(final TreeNode node,
|
||||
final PageState state) {
|
||||
return !((Category) node.getElement()).getSubCategories().
|
||||
isEmpty();
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final FolderTreeModelController controller = cdiUtil.findBean(
|
||||
FolderTreeModelController.class);
|
||||
|
||||
return controller.hasChildren(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator getChildren(final TreeNode node,
|
||||
final PageState state) {
|
||||
public Iterator<Folder> getChildren(final TreeNode node,
|
||||
final PageState state) {
|
||||
final String nodeKey = node.getKey().toString();
|
||||
|
||||
// Always expand root node
|
||||
if (nodeKey.equals(getRoot(state).getKey().toString())
|
||||
&& tree.isCollapsed(nodeKey, state)) {
|
||||
&& tree.isCollapsed(nodeKey, state)) {
|
||||
tree.expand(nodeKey, state);
|
||||
}
|
||||
|
||||
if (tree.isCollapsed(nodeKey, state)) {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
return ((Category) node.getElement()).getSubCategories().
|
||||
iterator();
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final FolderTreeModelController controller = cdiUtil.findBean(
|
||||
FolderTreeModelController.class);
|
||||
|
||||
return controller.getChildren(node);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*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.
|
||||
*
|
||||
* @param state represents the current request
|
||||
*
|
||||
* @return the root folder for the tree
|
||||
* @post return != null
|
||||
*
|
||||
*/
|
||||
protected Category getRootFolder(final PageState state)
|
||||
throws IllegalStateException {
|
||||
ContentSection sec = CMS.getContext().getContentSection();
|
||||
return sec.getRootDocumentsFolder();
|
||||
protected Folder getRootFolder(final PageState state)
|
||||
throws IllegalStateException {
|
||||
|
||||
final ContentSection section = CMS.getContext().getContentSection();
|
||||
return section.getRootDocumentsFolder();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import com.arsdigita.cms.ui.FormSecurityListener;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.librecms.CmsConstants;
|
||||
|
|
@ -49,9 +48,6 @@ import java.util.Locale;
|
|||
*/
|
||||
class BaseLifecycleForm extends BaseForm {
|
||||
|
||||
private static final Logger s_log = Logger
|
||||
.getLogger(BaseLifecycleForm.class);
|
||||
|
||||
final TextField m_name;
|
||||
final TextArea m_description;
|
||||
|
||||
|
|
@ -92,7 +88,7 @@ class BaseLifecycleForm extends BaseForm {
|
|||
@Override
|
||||
public final void validate(final ParameterEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
|
||||
final PageState state = e.getPageState();
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ConfigurationManager confManager = cdiUtil.findBean(
|
||||
|
|
|
|||
|
|
@ -32,29 +32,27 @@ import com.arsdigita.cms.ui.BaseAdminPane;
|
|||
import com.arsdigita.cms.ui.BaseDeleteForm;
|
||||
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.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentSectionManager;
|
||||
import org.librecms.contentsection.privileges.AdminPrivileges;
|
||||
import org.librecms.lifecycle.Lifecycle;
|
||||
import org.librecms.lifecycle.LifecycleDefinitionRepository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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 Jack Chung
|
||||
* @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 {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(LifecycleAdminPane.class);
|
||||
private static Logger LOGGER = LogManager.getLogger(LifecycleAdminPane.class);
|
||||
|
||||
private final SingleSelectionModel m_model;
|
||||
private final LifecycleDefinitionRequestLocal m_definition;
|
||||
|
|
|
|||
|
|
@ -20,16 +20,14 @@ package com.arsdigita.cms.ui.lifecycle;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
|
||||
import org.librecms.lifecycle.LifecycleDefinition;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class LifecycleDefinitionRequestLocal extends RequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(LifecycleDefinitionRequestLocal.class);
|
||||
|
||||
public final LifecycleDefinition getLifecycleDefinition
|
||||
(final PageState state) {
|
||||
public final LifecycleDefinition getLifecycleDefinition(
|
||||
final PageState state) {
|
||||
return (LifecycleDefinition) get(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,8 @@ import com.arsdigita.bebop.Table;
|
|||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
|
||||
import com.arsdigita.cms.CMS;
|
||||
|
||||
import org.librecms.lifecycle.LifecycleDefinition;
|
||||
import org.librecms.lifecycle.PhaseDefinition;
|
||||
|
||||
import com.arsdigita.cms.ui.BaseItemPane;
|
||||
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.Section;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.privileges.AdminPrivileges;
|
||||
import org.librecms.lifecycle.PhaseDefinititionRepository;
|
||||
|
||||
|
|
@ -66,9 +60,6 @@ import java.util.Locale;
|
|||
*/
|
||||
class LifecycleItemPane extends BaseItemPane {
|
||||
|
||||
private static final Logger s_log = Logger
|
||||
.getLogger(LifecycleItemPane.class);
|
||||
|
||||
private final LifecycleDefinitionRequestLocal m_cycle;
|
||||
private final PhaseRequestLocal m_phase;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,11 @@ package com.arsdigita.cms.ui.lifecycle;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
|
||||
import org.librecms.lifecycle.PhaseDefinition;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class PhaseRequestLocal extends RequestLocal {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(PhaseRequestLocal.class);
|
||||
|
||||
public final PhaseDefinition getPhase(final PageState state) {
|
||||
return (PhaseDefinition) get(state);
|
||||
|
|
|
|||
|
|
@ -63,10 +63,9 @@ import java.util.Map;
|
|||
* @author sdeusch@arsdigita.com
|
||||
* @authro <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CMSPermissionsPane extends SimpleContainer
|
||||
implements Resettable,
|
||||
ActionListener,
|
||||
RequestListener {
|
||||
public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
||||
ActionListener,
|
||||
RequestListener {
|
||||
|
||||
// non-shared parameter models; leave package scope for access from its members.
|
||||
private ParameterModel searchString = new StringParameter(
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class CMSPermissionsTables {
|
|||
}
|
||||
if (type == DIRECT) {
|
||||
headers[privileges.length + 1] = PERM_TABLE_ACTIONS.localize()
|
||||
+ "";
|
||||
+ "";
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
|
@ -317,15 +317,13 @@ class CMSPermissionsTables {
|
|||
public TableModel makeModel(final Table table,
|
||||
final PageState state) {
|
||||
final CcmObject object = parent.getObject(state);
|
||||
final List<Permission> permissions = object.getPermissions();
|
||||
|
||||
switch (m_type) {
|
||||
case DIRECT:
|
||||
return new DirectPermissionsTableModel(permissions,
|
||||
object);
|
||||
return new DirectPermissionsTableModel(object);
|
||||
case INHERITED:
|
||||
return new DirectPermissionsTableModel(permissions,
|
||||
object);
|
||||
return new DirectPermissionsTableModel(
|
||||
object);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
@ -340,9 +338,9 @@ class CMSPermissionsTables {
|
|||
private final Iterator<Permission> iterator;
|
||||
private Permission currentPermission;
|
||||
|
||||
public DirectPermissionsTableModel(final List<Permission> permissions,
|
||||
final CcmObject object) {
|
||||
this.iterator = permissions.iterator();
|
||||
public DirectPermissionsTableModel(final CcmObject object) {
|
||||
// this.iterator = permissions.iterator();
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -442,9 +440,8 @@ class CMSPermissionsTables {
|
|||
private final class InheritedPermissionsTableModel
|
||||
extends DirectPermissionsTableModel {
|
||||
|
||||
public InheritedPermissionsTableModel(final List<Permission> permissions,
|
||||
final CcmObject object) {
|
||||
super(permissions, object);
|
||||
public InheritedPermissionsTableModel(final CcmObject object) {
|
||||
super(object);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
|||
import com.arsdigita.ui.admin.GlobalizationUtil;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.libreccm.security.Role;
|
||||
|
|
@ -41,19 +40,21 @@ import org.librecms.CmsConstants;
|
|||
import org.librecms.contentsection.ContentSection;
|
||||
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}.
|
||||
*
|
||||
* @author <a href="mailto:yannick.buelter@yabue.de">Yannick Bülter</a>
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id: BaseRoleForm.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*
|
||||
*/
|
||||
class BaseRoleForm extends BaseForm {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(BaseRoleForm.class);
|
||||
|
||||
final Name m_name;
|
||||
final Description m_description;
|
||||
CheckboxGroup m_privileges;
|
||||
|
|
|
|||
|
|
@ -24,28 +24,26 @@ import com.arsdigita.bebop.SingleSelectionModel;
|
|||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.libreccm.security.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
|
||||
/**
|
||||
* 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 Justin Ross <jross@redhat.com>
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(RoleAddForm.class);
|
||||
|
||||
private SingleSelectionModel m_model;
|
||||
|
||||
RoleAddForm(SingleSelectionModel model) {
|
||||
|
|
|
|||
|
|
@ -24,27 +24,34 @@ import com.arsdigita.bebop.event.FormInitListener;
|
|||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
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.configuration.ConfigurationManager;
|
||||
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.Arrays;
|
||||
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 Justin Ross <jross@redhat.com>
|
||||
* @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 {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(RoleEditForm.class);
|
||||
private static final Logger LOGGER = LogManager
|
||||
.getLogger(RoleEditForm.class);
|
||||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public final void init(final FormSectionEvent e) {
|
||||
final PageState state = e.getPageState();
|
||||
|
|
@ -72,57 +81,71 @@ final class RoleEditForm extends BaseRoleForm {
|
|||
m_description.setValue(state, role.getDescription());
|
||||
|
||||
final String[] permissions = role.getPermissions().stream().
|
||||
map(Permission::getGrantedPrivilege).toArray(String[]::new);
|
||||
map(Permission::getGrantedPrivilege).toArray(String[]::new);
|
||||
|
||||
m_privileges.setValue(state, permissions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a role and it's permissions. It uses the {@link PermissionManager} to grant and revoke permissions
|
||||
* as needed.
|
||||
* Updates a role and it's permissions. It uses the
|
||||
* {@link PermissionManager} to grant and revoke permissions as needed.
|
||||
*
|
||||
* NOTE: The part about granting and revoking privileges is mostly identical to {@link RoleAddForm}.
|
||||
* If you find any bugs or errors in this code, be sure to change it there accordingly.
|
||||
* NOTE: The part about granting and revoking privileges is mostly identical
|
||||
* 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 {
|
||||
|
||||
@Override
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
|
||||
final Role role = m_role.getRole(state);
|
||||
role.setName((String) m_name.getValue(state));
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionManager permissionManager = cdiUtil.findBean(PermissionManager.class);
|
||||
final ConfigurationManager manager = cdiUtil.findBean(ConfigurationManager.class);
|
||||
final KernelConfig config = manager.findConfiguration(KernelConfig.class);
|
||||
final RoleRepository roleRepository = cdiUtil.findBean(RoleRepository.class);
|
||||
final PermissionManager permissionManager = cdiUtil.findBean(
|
||||
PermissionManager.class);
|
||||
final ConfigurationManager manager = cdiUtil.findBean(
|
||||
ConfigurationManager.class);
|
||||
final KernelConfig config = manager.findConfiguration(
|
||||
KernelConfig.class);
|
||||
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
|
||||
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);
|
||||
|
||||
//We don't now if the permissions list is empty, so we have to save beforehand to not lose data.
|
||||
roleRepository.save(role);
|
||||
|
||||
List<Permission> newPermissions = new ArrayList<>();
|
||||
String[] selectedPermissions = (String[]) m_privileges.getValue(state);
|
||||
String[] selectedPermissions = (String[]) m_privileges.getValue(
|
||||
state);
|
||||
|
||||
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);
|
||||
} else {
|
||||
permissionManager.revokePrivilege(p.getGrantedPrivilege(), role);
|
||||
permissionManager.revokePrivilege(p.getGrantedPrivilege(),
|
||||
role);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ import com.arsdigita.cms.ui.PartyAddForm;
|
|||
import com.arsdigita.ui.admin.GlobalizationUtil;
|
||||
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.security.*;
|
||||
import org.librecms.CmsConstants;
|
||||
|
|
@ -39,22 +40,21 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Adds a form which can add {@link Party parties} to {@link Role roles}.
|
||||
* Also enables searching for parties.
|
||||
* Adds a form which can add {@link Party parties} to {@link Role roles}. Also
|
||||
* 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 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 {
|
||||
|
||||
private static Logger s_log = Logger.getLogger
|
||||
(RolePartyAddForm.class);
|
||||
private static Logger LOGGER = LogManager.getLogger(RolePartyAddForm.class);
|
||||
|
||||
private SingleSelectionModel m_roles;
|
||||
|
||||
|
|
@ -63,17 +63,17 @@ class RolePartyAddForm extends PartyAddForm {
|
|||
|
||||
m_roles = roles;
|
||||
|
||||
getForm().addSubmissionListener
|
||||
(new FormSecurityListener(AdminPrivileges.ADMINISTER_ROLES));
|
||||
getForm().addSubmissionListener(new FormSecurityListener(
|
||||
AdminPrivileges.ADMINISTER_ROLES));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Party> makeQuery(PageState s) {
|
||||
Assert.isTrue(m_roles.isSelected(s));
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -87,29 +87,32 @@ class RolePartyAddForm extends PartyAddForm {
|
|||
Assert.isTrue(m_roles.isSelected(state));
|
||||
|
||||
String[] parties = (String[]) data.get("parties");
|
||||
s_log.debug("PARTIES = " + Arrays.toString(parties));
|
||||
LOGGER.debug("PARTIES = " + Arrays.toString(parties));
|
||||
if (parties == null) {
|
||||
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 CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final RoleRepository roleRepository = cdiUtil.findBean(RoleRepository.class);
|
||||
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class);
|
||||
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
final PartyRepository partyRepository = cdiUtil.findBean(
|
||||
PartyRepository.class);
|
||||
final RoleManager roleManager = cdiUtil.findBean(RoleManager.class);
|
||||
|
||||
final Role role = roleRepository.findById(roleId).get();
|
||||
|
||||
// Add each checked party to the role
|
||||
Party party;
|
||||
for ( int i = 0; i < parties.length; i++ ) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("parties[" + i + "] = " + parties[i]);
|
||||
for (int i = 0; i < parties.length; i++) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("parties[" + i + "] = " + parties[i]);
|
||||
}
|
||||
party = partyRepository.findByName(parties[i]).get();
|
||||
roleManager.assignRoleToParty(role, party);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|||
import com.arsdigita.toolbox.ui.ActionGroup;
|
||||
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.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentSectionManager;
|
||||
|
|
@ -60,8 +61,9 @@ import org.librecms.contentsection.ContentTypeManager;
|
|||
*/
|
||||
public final class ContentTypeAdminPane extends BaseAdminPane {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ContentTypeAdminPane.class);
|
||||
|
||||
private final ACSObjectSelectionModel m_model;
|
||||
private final ContentTypeRequestLocal m_type;
|
||||
|
||||
|
|
@ -252,8 +254,8 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
|
|||
private void resetPane(final PageState state) {
|
||||
getBody().reset(state);
|
||||
if (getSelectionModel().isSelected(state)) {
|
||||
s_log.debug("The selection model is selected; displaying "
|
||||
+ "the item pane");
|
||||
LOGGER.debug("The selection model is selected; displaying "
|
||||
+ "the item pane");
|
||||
getBody().push(state, getItemPane());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import com.arsdigita.toolbox.ui.Cancellable;
|
|||
import com.arsdigita.toolbox.ui.Section;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.contentsection.ContentSectionManager;
|
||||
|
|
@ -57,7 +56,6 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
|
|||
*/
|
||||
final class ContentTypeItemPane extends BaseItemPane {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(ContentTypeItemPane.class);
|
||||
private final ACSObjectSelectionModel m_model;
|
||||
private final ContentTypeRequestLocal m_type;
|
||||
private final SimpleContainer m_detailPane;
|
||||
|
|
@ -83,10 +81,10 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
// m_templates = new SectionTemplatesListing(
|
||||
// new ContentSectionRequestLocal(), m_type);
|
||||
m_permissions = new TypePermissionsTable(
|
||||
new ContentSectionRequestLocal(), m_type);
|
||||
new ContentSectionRequestLocal(), m_type);
|
||||
|
||||
final ActionLink templateAddLink = new ActionLink(new Label(gz(
|
||||
"cms.ui.type.template.add")));
|
||||
"cms.ui.type.template.add")));
|
||||
// ToDo
|
||||
// final TemplateCreate templateFormSection = new TemplateCreate(m_model);
|
||||
// final Form templateForm = new CancellableForm("AddTemplate",
|
||||
|
|
@ -173,6 +171,7 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
public final boolean isCancelled(final PageState state) {
|
||||
return m_cancel.isSelected(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SummarySection extends Section {
|
||||
|
|
@ -189,6 +188,7 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
group.addAction(new TypeSecurityContainer(editLink));
|
||||
group.addAction(new TypeSecurityContainer(deleteLink));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ElementSection extends Section {
|
||||
|
|
@ -209,6 +209,7 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
// && !ContentSection.getConfig().getHideUDCTUI();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class TemplateSection extends Section {
|
||||
|
|
@ -227,6 +228,7 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
public final boolean isVisible(final PageState state) {
|
||||
return m_model.isSelected(state) && !isDynamicType(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class PermissionsSection extends Section {
|
||||
|
|
@ -245,6 +247,7 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
public final boolean isVisible(final PageState state) {
|
||||
return m_model.isSelected(state) && !isDynamicType(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// private class RelationAttributeSection extends Section {
|
||||
|
|
@ -291,13 +294,14 @@ final class ContentTypeItemPane extends BaseItemPane {
|
|||
final PageState state = event.getPageState();
|
||||
|
||||
if (state.isVisibleOnPage(ContentTypeItemPane.this)
|
||||
&& m_model.isSelected(state)
|
||||
&& !userCanEdit(state)) {
|
||||
&& m_model.isSelected(state)
|
||||
&& !userCanEdit(state)) {
|
||||
// m_templates.getRemoveColumn().setVisible(state, false);
|
||||
// m_templates.getDefaultColumn().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 ContentTypeManager typeManager = cdiUtil.findBean(
|
||||
ContentTypeManager.class);
|
||||
ContentTypeManager.class);
|
||||
final ContentSectionManager sectionManager = cdiUtil.findBean(
|
||||
ContentSectionManager.class);
|
||||
ContentSectionManager.class);
|
||||
|
||||
final ContentType type = m_type.getContentType(state);
|
||||
final Class<? extends ContentItem> typeClass;
|
||||
try {
|
||||
typeClass = (Class<? extends ContentItem>) Class.forName(
|
||||
type.getContentItemClass());
|
||||
type.getContentItemClass());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
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();
|
||||
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import org.libreccm.workflow.AssignableTask;
|
|||
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.UserRepository;
|
||||
import org.libreccm.workflow.WorkflowManager;
|
||||
|
|
@ -46,12 +45,9 @@ import java.util.List;
|
|||
*
|
||||
* @author Uday Mathur
|
||||
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
class TaskAddUser extends SimpleContainer {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(TaskAddUser.class);
|
||||
|
||||
private final TaskRequestLocal m_task;
|
||||
|
||||
private SearchForm m_search;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import java.util.stream.Collectors;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
|
|
@ -63,7 +64,7 @@ public class Folder extends Category implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@OneToOne
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
// @JoinColumn(name = "CONTENT_SECTION_ID")
|
||||
@JoinTable(name = "FOLDER_CONTENT_SECTION_MAP", schema = DB_SCHEMA,
|
||||
inverseJoinColumns = {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.librecms.contentsection;
|
|||
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.libreccm.categorization.Categorization;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@
|
|||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.LoginSignal"/>
|
||||
<jsp:directive.page import="com.arsdigita.web.Web"/>
|
||||
<jsp:directive.page import="org.apache.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:declaration>
|
||||
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 Date timestamp = new Date(0);
|
||||
</jsp:declaration>
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ public class FolderManagerTest {
|
|||
@InSequence(1500)
|
||||
public void createFolderEmptyName() {
|
||||
final Optional<Folder> parent = folderRepo.findById(-2005L);
|
||||
assertThat(parent.isPresent(), is(false));
|
||||
assertThat(parent.isPresent(), is(true));
|
||||
|
||||
final Folder test = folderManager.createFolder(" ", parent.get());
|
||||
|
||||
|
|
|
|||
|
|
@ -85,10 +85,10 @@
|
|||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-1.2-api</artifactId>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
|
|
|
|||
|
|
@ -31,20 +31,15 @@ import com.arsdigita.bebop.event.ActionListener;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Completable.
|
||||
*
|
||||
* @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 {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(Completable.class);
|
||||
|
||||
private ArrayList m_completionListeners = new ArrayList();
|
||||
|
||||
public Completable() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package com.arsdigita.bebop;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
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 {
|
||||
|
||||
/** 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.
|
||||
* 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");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
package com.arsdigita.bebop;
|
||||
|
||||
import com.arsdigita.xml.Element;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(ElementComponent.class.getName());
|
||||
|
||||
private String m_name;
|
||||
private String m_uri;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
package com.arsdigita.bebop;
|
||||
|
||||
import com.arsdigita.bebop.form.Hidden;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import com.arsdigita.bebop.util.Traversal;
|
||||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
|
|
@ -31,9 +33,10 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import com.arsdigita.xml.Element;
|
||||
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
|
||||
|
|
@ -71,7 +74,6 @@ import org.apache.log4j.Logger;
|
|||
* @author Rory Solomon
|
||||
* @author David Lutterkort
|
||||
*
|
||||
* @version $Id: Form.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
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
|
||||
* 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=
|
||||
|
|
@ -524,7 +526,7 @@ public class Form extends FormSection implements BebopConstants {
|
|||
try {
|
||||
return process(s);
|
||||
} catch (FormProcessException e) {
|
||||
s_log.error("Form Process exception", e);
|
||||
LOGGER.error("Form Process exception", e);
|
||||
throw new UncheckedWrapperException("Form Process error: "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,13 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.util.Lockable;
|
||||
import com.arsdigita.util.URLRewriter;
|
||||
import com.arsdigita.web.RedirectSignal;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A container for two classes of
|
||||
|
|
@ -62,11 +65,10 @@ import org.apache.log4j.Logger;
|
|||
* @author Uday Mathur
|
||||
* @author Stas Freidin
|
||||
* @author Rory Solomon
|
||||
* @version $Id: FormModel.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
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.";
|
||||
|
||||
|
|
@ -147,8 +149,8 @@ public class FormModel implements Lockable {
|
|||
parameter.setDefaultOverridesNull(m_defaultOverridesNull);
|
||||
m_parameterModels.add(parameter);
|
||||
|
||||
if( s_log.isDebugEnabled() ) {
|
||||
s_log.debug( "Added parameter: " + parameter.getName() + "[" +
|
||||
if( LOGGER.isDebugEnabled() ) {
|
||||
LOGGER.debug( "Added parameter: " + parameter.getName() + "[" +
|
||||
parameter.getClass().getName() + "]" );
|
||||
}
|
||||
}
|
||||
|
|
@ -318,18 +320,18 @@ public class FormModel implements Lockable {
|
|||
*/
|
||||
void process(final PageState state, final FormData data)
|
||||
throws FormProcessException {
|
||||
s_log.debug("Processing the form model");
|
||||
LOGGER.debug("Processing the form model");
|
||||
|
||||
final FormSectionEvent e = new FormSectionEvent(this, state, data);
|
||||
|
||||
if (data.isSubmission()) {
|
||||
s_log.debug("The request is a form submission; running " +
|
||||
LOGGER.debug("The request is a form submission; running " +
|
||||
"submission listeners");
|
||||
|
||||
try {
|
||||
fireSubmitted(e);
|
||||
} catch (FormProcessException fpe) {
|
||||
s_log.debug("A FormProcessException was thrown while firing " +
|
||||
LOGGER.debug("A FormProcessException was thrown while firing " +
|
||||
"submit; aborting further processing");
|
||||
return;
|
||||
} finally {
|
||||
|
|
@ -337,39 +339,39 @@ public class FormModel implements Lockable {
|
|||
|
||||
|
||||
try {
|
||||
s_log.debug("Validating parameters");
|
||||
LOGGER.debug("Validating parameters");
|
||||
fireParameterValidation(e);
|
||||
|
||||
s_log.debug("Validating form");
|
||||
LOGGER.debug("Validating form");
|
||||
fireFormValidation(e);
|
||||
} finally {
|
||||
}
|
||||
|
||||
if (data.isValid()) {
|
||||
s_log.debug("The form data is valid; running process " +
|
||||
LOGGER.debug("The form data is valid; running process " +
|
||||
"listeners");
|
||||
|
||||
try {
|
||||
fireFormProcess(e);
|
||||
} 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);
|
||||
|
||||
data.addError("Initialization Aborted: " + fpe.getMessages());
|
||||
} finally {
|
||||
}
|
||||
} 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");
|
||||
}
|
||||
} else {
|
||||
s_log.debug("The request is not a form submission; " +
|
||||
LOGGER.debug("The request is not a form submission; " +
|
||||
"running init listeners");
|
||||
|
||||
try {
|
||||
fireFormInit(e);
|
||||
} 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);
|
||||
|
||||
data.addError("Initialization Aborted: " + fpe.getMessages());
|
||||
|
|
@ -476,13 +478,13 @@ public class FormModel implements Lockable {
|
|||
try {
|
||||
((FormProcessListener) i.next()).process(e);
|
||||
} catch( RedirectSignal signal ) {
|
||||
if( s_log.isDebugEnabled() ) {
|
||||
s_log.debug( "Delaying redirect to " +
|
||||
if( LOGGER.isDebugEnabled() ) {
|
||||
LOGGER.debug( "Delaying redirect to " +
|
||||
signal.getDestinationURL() );
|
||||
}
|
||||
|
||||
if( null != redirect ) {
|
||||
s_log.error( "Non-deterministic redirect. Ignoring earlier occurrence.", redirect );
|
||||
LOGGER.error( "Non-deterministic redirect. Ignoring earlier occurrence.", redirect );
|
||||
}
|
||||
|
||||
redirect = signal;
|
||||
|
|
|
|||
|
|
@ -28,28 +28,29 @@ import com.arsdigita.bebop.event.FormValidationListener;
|
|||
import com.arsdigita.util.Assert;
|
||||
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>
|
||||
* contains other Bebop components, most importantly
|
||||
* <code>Widgets</code> and associated listeners. It serves two purposes:
|
||||
* contains other Bebop components, most importantly <code>Widgets</code> and
|
||||
* associated listeners. It serves two purposes:
|
||||
* <UL>
|
||||
* <LI>Divides a form into visual sections</LI>
|
||||
* <LI>Serves as a container for form fragments that can function by themselves
|
||||
* and can be dropped into other forms</LI>
|
||||
* <LI>Serves as a container for form fragments that can function by themselves
|
||||
* and can be dropped into other forms</LI>
|
||||
* </UL>
|
||||
* <p>Since a <code>FormSection</code> has its own init, validation, and
|
||||
* process listeners, it can do all of its processing without any intervention
|
||||
* from the enclosing form.
|
||||
* <p>
|
||||
* Since a <code>FormSection</code> has its own init, validation, and process
|
||||
* 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
|
||||
* that a <code>Form</code> does, it can only be used if it is added
|
||||
* directly or indirectly to a <code>Form</code>. <code>FormSection</code>s
|
||||
* that are not contained in a <code>Form</code> do not exhibit any useful
|
||||
* behavior.
|
||||
* Although a <code>FormSection</code> contains all the same pieces that a
|
||||
* <code>Form</code> does, it can only be used if it is added directly or
|
||||
* indirectly to a <code>Form</code>. <code>FormSection</code>s that are not
|
||||
* contained in a <code>Form</code> do not exhibit any useful behavior.
|
||||
*
|
||||
* @see Form
|
||||
* @see FormModel
|
||||
|
|
@ -59,34 +60,41 @@ import org.apache.log4j.Logger;
|
|||
* @author Stas Freidin
|
||||
* @author Rory Solomon
|
||||
* @author David Lutterkort
|
||||
*
|
||||
* @version $Id: FormSection.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
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
|
||||
* and set com.arsdigita.subsite.FormSection=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(FormSection.class);
|
||||
/**
|
||||
* Internal logger instance to faciliate debugging. Enable logging output by
|
||||
* editing /WEB-INF/conf/log4j.properties int the runtime environment and
|
||||
* set com.arsdigita.subsite.FormSection=DEBUG by uncommenting or adding the
|
||||
* 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;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Contains all the listeners that were added with the various
|
||||
* addXXXListener methods.
|
||||
* We maintain our own list of listeners, so that we can re-send the
|
||||
* events the FormModel generates, but with us as the source, not the
|
||||
* FormModel. */
|
||||
/**
|
||||
* Contains all the listeners that were added with the various
|
||||
* addXXXListener methods. We maintain our own list of listeners, so that we
|
||||
* can re-send the events the FormModel generates, but with us as the
|
||||
* source, not the FormModel.
|
||||
*/
|
||||
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 FormInitListener m_forwardInit;
|
||||
|
|
@ -94,10 +102,11 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
private FormProcessListener m_forwardProcess;
|
||||
|
||||
/**
|
||||
* Constructs a new form section. Sets the implicit layout Container of
|
||||
* this <code>FormSection</code> to two column <code>ColumnPanel</code>
|
||||
* by calling the 1-argument constructor.
|
||||
**/
|
||||
* Constructs a new form section. Sets the implicit layout Container of this
|
||||
* <code>FormSection</code> to two column <code>ColumnPanel</code> by
|
||||
* calling the 1-argument constructor.
|
||||
*
|
||||
*/
|
||||
public FormSection() {
|
||||
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
|
||||
* <code>FormSection</code> to a new, anonymous FormModel.
|
||||
*
|
||||
*
|
||||
* @param panel
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public FormSection(Container panel) {
|
||||
this(panel, new FormModel("anonymous"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new form section. Sets the implicit layout Container of
|
||||
* this <code>FormSection</code> to <code>panel</code>. Sets the form
|
||||
* model of this <code>FormSection</code> to <code>model</code>.
|
||||
* Constructs a new form section. Sets the implicit layout Container of this
|
||||
* <code>FormSection</code> to <code>panel</code>. Sets the form model of
|
||||
* this <code>FormSection</code> to <code>model</code>.
|
||||
*
|
||||
* @param panel the container within this form section that holds the
|
||||
* components that are added to the form section with calls to the
|
||||
* <code>add</code> methods
|
||||
* components that are added to the form section with calls to
|
||||
* the <code>add</code> methods
|
||||
*
|
||||
* @param model the form model for this form section
|
||||
**/
|
||||
*
|
||||
*/
|
||||
protected FormSection(Container panel, FormModel model) {
|
||||
super();
|
||||
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,
|
||||
* validation, or process listeners are run. The listener's
|
||||
* <code>submitted</code> method may throw a
|
||||
* <code>FormProcessException</code> to signal that any further
|
||||
* processing of the form should be aborted.
|
||||
* <code>FormProcessException</code> to signal that any further processing
|
||||
* of the form should be aborted.
|
||||
*
|
||||
* @param listener a submission listener to run every time the form is
|
||||
* submitted
|
||||
* submitted
|
||||
*
|
||||
* @see FormModel#addSubmissionListener
|
||||
* @pre listener != null
|
||||
*/
|
||||
public void addSubmissionListener(FormSubmissionListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding submission listener " + listener + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding submission listener " + listener + " to "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "Submission Listener");
|
||||
|
|
@ -155,15 +168,15 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the specified submission listener from the
|
||||
* list of submission listeners (if it had previously been added).
|
||||
* Removes the specified submission listener from the list of submission
|
||||
* listeners (if it had previously been added).
|
||||
*
|
||||
* @param listener the submission listener to remove
|
||||
*/
|
||||
public void removeSubmissionListener(FormSubmissionListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing submission listener " + listener + " from "
|
||||
+ this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing submission listener " + listener + " from "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "Submission Listener");
|
||||
|
|
@ -176,28 +189,29 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* listeners.
|
||||
*
|
||||
* @param e the event to pass to the listeners
|
||||
*
|
||||
* @throws FormProcessException if one of the listeners throws such an
|
||||
* exception.
|
||||
* exception.
|
||||
*/
|
||||
protected void fireSubmitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
Assert.exists(e.getFormData(), "FormData");
|
||||
FormProcessException delayedException = null;
|
||||
|
||||
Iterator i = m_listeners.getListenerIterator(
|
||||
FormSubmissionListener.class);
|
||||
FormSubmissionListener.class);
|
||||
while (i.hasNext()) {
|
||||
final FormSubmissionListener listener = (FormSubmissionListener) i.
|
||||
next();
|
||||
next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing submission listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing submission listener " + listener);
|
||||
}
|
||||
|
||||
try {
|
||||
listener.submitted(e);
|
||||
} catch (FormProcessException ex) {
|
||||
s_log.debug(ex);
|
||||
LOGGER.debug(ex);
|
||||
delayedException = ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -207,7 +221,7 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected void forwardSubmission() {
|
||||
if (m_forwardSubmission == null) {
|
||||
|
|
@ -221,35 +235,36 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* form section.
|
||||
*
|
||||
* @return a submission listener that forwards submission events to this
|
||||
* form section.
|
||||
* form section.
|
||||
*/
|
||||
protected FormSubmissionListener createSubmissionListener() {
|
||||
return new FormSubmissionListener() {
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
fireSubmitted(new FormSectionEvent(FormSection.this,
|
||||
e.getPageState(),
|
||||
e.getFormData()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener for form initialization events. Initialization
|
||||
* events occur when a form is initially requested by the user, but
|
||||
* not when the form is subsequently submitted. They typically
|
||||
* perform actions such as querying the database for existing values
|
||||
* to set up an edit form, or obtaining a sequence value to set up a
|
||||
* create form.
|
||||
* Adds a listener for form initialization events. Initialization events
|
||||
* occur when a form is initially requested by the user, but not when the
|
||||
* form is subsequently submitted. They typically perform actions such as
|
||||
* querying the database for existing values to set up an edit form, or
|
||||
* obtaining a sequence value to set up a create form.
|
||||
*
|
||||
* @param listener an instance of a class that implements the
|
||||
* <code>FormInitListener</code> interface
|
||||
* */
|
||||
* <code>FormInitListener</code> interface
|
||||
*
|
||||
*/
|
||||
public void addInitListener(FormInitListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding init listener " + listener + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding init listener " + listener + " to " + this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "FormInitListener");
|
||||
|
|
@ -259,14 +274,14 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the specified init listener from the
|
||||
* list of init listeners (if it had previously been added).
|
||||
* Removes the specified init listener from the list of init listeners (if
|
||||
* it had previously been added).
|
||||
*
|
||||
* @param listener the init listener to remove
|
||||
*/
|
||||
public void removeInitListener(FormInitListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing init listener " + listener + " from " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing init listener " + listener + " from " + this);
|
||||
}
|
||||
|
||||
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
|
||||
* listeners.
|
||||
* Calls the <code>init</code> method on all registered init listeners.
|
||||
*
|
||||
* @param e the event to pass to the listeners
|
||||
*
|
||||
* @throws FormProcessException if one of the listeners throws such an
|
||||
* exception.
|
||||
* exception.
|
||||
*/
|
||||
protected void fireInit(FormSectionEvent e) throws FormProcessException {
|
||||
Assert.exists(e.getFormData(), "FormData");
|
||||
|
|
@ -289,8 +304,8 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
while (i.hasNext()) {
|
||||
final FormInitListener listener = (FormInitListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing init listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing init listener " + listener);
|
||||
}
|
||||
|
||||
listener.init(e);
|
||||
|
|
@ -298,7 +313,7 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected void forwardInit() {
|
||||
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
|
||||
* section.
|
||||
* Creates the init listener that forwards init events to this form section.
|
||||
*
|
||||
* @return an init listener that forwards init events to this
|
||||
* form section.
|
||||
* @return an init listener that forwards init events to this form section.
|
||||
*/
|
||||
protected FormInitListener createInitListener() {
|
||||
return new FormInitListener() {
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
fireInit(new FormSectionEvent(FormSection.this,
|
||||
e.getPageState(),
|
||||
e.getFormData()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -342,20 +356,23 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
e.getPageState(),
|
||||
e.getFormData()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a validation listener, implementing a custom validation
|
||||
* check that applies to the form as a whole. Useful for checks
|
||||
* that require examination of the values of more than one parameter.
|
||||
* Adds a validation listener, implementing a custom validation check that
|
||||
* applies to the form as a whole. Useful for checks that require
|
||||
* examination of the values of more than one parameter.
|
||||
*
|
||||
* @param listener an instance of a class that implements the
|
||||
* <code>FormValidationListener</code> interface
|
||||
* */
|
||||
* <code>FormValidationListener</code> interface
|
||||
*
|
||||
*/
|
||||
public void addValidationListener(FormValidationListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding validation listener " + listener + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding validation listener " + listener + " to "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "FormValidationListener");
|
||||
|
|
@ -365,15 +382,15 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the specified validation listener from the
|
||||
* list of validation listeners (if it had previously been added).
|
||||
* Removes the specified validation listener from the list of validation
|
||||
* listeners (if it had previously been added).
|
||||
*
|
||||
* @param listener a validation listener
|
||||
*/
|
||||
public void removeValidationListener(FormValidationListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing validation listener " + listener + " from "
|
||||
+ this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing validation listener " + listener + " from "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "Validation Listener");
|
||||
|
|
@ -391,19 +408,19 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
FormData data = e.getFormData();
|
||||
Assert.exists(data, "FormData");
|
||||
Iterator i = m_listeners.getListenerIterator(
|
||||
FormValidationListener.class);
|
||||
FormValidationListener.class);
|
||||
while (i.hasNext()) {
|
||||
try {
|
||||
final FormValidationListener listener =
|
||||
(FormValidationListener) i.next();
|
||||
final FormValidationListener listener
|
||||
= (FormValidationListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing validation listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing validation listener " + listener);
|
||||
}
|
||||
|
||||
listener.validate(e);
|
||||
} catch (FormProcessException fpe) {
|
||||
s_log.debug(fpe);
|
||||
LOGGER.debug(fpe);
|
||||
data.addError(fpe.getGlobalizedMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -421,7 +438,7 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* form section.
|
||||
*
|
||||
* @return a validation listener that forwards validation events to this
|
||||
* form section.
|
||||
* form section.
|
||||
*/
|
||||
protected FormValidationListener createValidationListener() {
|
||||
return new FormValidationListener() {
|
||||
|
|
@ -432,23 +449,26 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
e.getPageState(),
|
||||
e.getFormData()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener for form processing events. <p>Process events
|
||||
* only occur after a form submission has been successfully
|
||||
* validated. They are typically used to perform a database
|
||||
* transaction or other operation based on the submitted data.
|
||||
* <p>Process listeners are executed in the order in which
|
||||
* they are added.
|
||||
* Adds a listener for form processing events.
|
||||
* <p>
|
||||
* Process events only occur after a form submission has been successfully
|
||||
* validated. They are typically used to perform a database transaction or
|
||||
* other operation based on the submitted data.
|
||||
* <p>
|
||||
* Process listeners are executed in the order in which they are added.
|
||||
*
|
||||
* @param listener an instance of a class that implements the
|
||||
* <code>FormProcessListener</code> interface
|
||||
* */
|
||||
* <code>FormProcessListener</code> interface
|
||||
*
|
||||
*/
|
||||
public void addProcessListener(final FormProcessListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding process listener " + listener + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding process listener " + listener + " to " + this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "FormProcessListener");
|
||||
|
|
@ -459,15 +479,15 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the specified process listener from the
|
||||
* list of process listeners (if it had previously been added).
|
||||
* Removes the specified process listener from the list of process listeners
|
||||
* (if it had previously been added).
|
||||
*
|
||||
* @param listener the process listener to remove
|
||||
*/
|
||||
public void removeProcessListener(FormProcessListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing process listener " + listener + " from "
|
||||
+ this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing process listener " + listener + " from "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "Process Listener");
|
||||
|
|
@ -488,11 +508,12 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
|
||||
@Override
|
||||
public void process(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
fireProcess(new FormSectionEvent(FormSection.this,
|
||||
e.getPageState(),
|
||||
e.getFormData()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -501,18 +522,19 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* listeners.
|
||||
*
|
||||
* @param e the event to pass to the listeners
|
||||
*
|
||||
* @throws FormProcessException if one of the listeners throws such an
|
||||
* exception.
|
||||
* exception.
|
||||
*/
|
||||
protected void fireProcess(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
Assert.exists(e.getFormData(), "FormData");
|
||||
Iterator i = m_listeners.getListenerIterator(FormProcessListener.class);
|
||||
while (i.hasNext()) {
|
||||
final FormProcessListener listener = (FormProcessListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing process listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing process listener " + listener);
|
||||
}
|
||||
|
||||
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.
|
||||
* (Processing of form sections is done by the form in which the
|
||||
* section is contained.)
|
||||
* (Processing of form sections is done by the form in which the section is
|
||||
* contained.)
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
* @throws javax.servlet.ServletException because processing a form section
|
||||
* is not meaningful.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws javax.servlet.ServletException because processing a form section
|
||||
* is not meaningful.
|
||||
*/
|
||||
public FormData process(PageState data)
|
||||
throws javax.servlet.ServletException {
|
||||
throws javax.servlet.ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener for form cancellation events. Cancellation
|
||||
* listeners are typically used to clean-up page state and
|
||||
* potentially intermediate changes to the database.
|
||||
* Adds a listener for form cancellation events. Cancellation listeners are
|
||||
* typically used to clean-up page state and potentially intermediate
|
||||
* changes to the database.
|
||||
*
|
||||
* @param listener an instance of a class that implements the
|
||||
* <code>FormCancelListener</code> interface
|
||||
* */
|
||||
* <code>FormCancelListener</code> interface
|
||||
*
|
||||
*/
|
||||
public void addCancelListener(FormCancelListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding cancel listener " + listener + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding cancel listener " + listener + " to " + this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "FormCancelListener");
|
||||
|
|
@ -553,14 +578,15 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the specified cancellation listener from the
|
||||
* list of cancellation listeners (if it had previously been added).
|
||||
* Removes the specified cancellation listener from the list of cancellation
|
||||
* listeners (if it had previously been added).
|
||||
*
|
||||
* @param listener the cancellation listener to remove
|
||||
*/
|
||||
public void removeCancelListener(FormCancelListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing cancel listener " + listener + " from " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing cancel listener " + listener + " from "
|
||||
+ this);
|
||||
}
|
||||
|
||||
Assert.exists(listener, "Cancel Listener");
|
||||
|
|
@ -573,18 +599,19 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* listeners.
|
||||
*
|
||||
* @param e the event to pass to the listeners
|
||||
*
|
||||
* @throws FormProcessException if one of the listeners throws such an
|
||||
* exception.
|
||||
* exception.
|
||||
*/
|
||||
protected void fireCancel(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
Assert.exists(e.getFormData(), "FormData");
|
||||
Iterator i = m_listeners.getListenerIterator(FormCancelListener.class);
|
||||
while (i.hasNext()) {
|
||||
final FormCancelListener listener = (FormCancelListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing cancel listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing cancel listener " + listener);
|
||||
}
|
||||
|
||||
listener.cancel(e);
|
||||
|
|
@ -592,15 +619,15 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
}
|
||||
|
||||
/**
|
||||
* Traverses the children this FormSection, collecting parameter models
|
||||
* and listeners into the supplied FormModel. Sets implicit pointers
|
||||
* of widgets in this FormSection to the supplied Form.
|
||||
* Traverses the children this FormSection, collecting parameter models and
|
||||
* listeners into the supplied FormModel. Sets implicit pointers of widgets
|
||||
* in this FormSection to the supplied Form.
|
||||
*
|
||||
* @param f pointer to the form that is set inside Widgets within this
|
||||
* FormSection
|
||||
* @param m the FormModel in which to merge ParameterModels and
|
||||
* Listeners
|
||||
* */
|
||||
* @param m the FormModel in which to merge ParameterModels and Listeners
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void register(Form f, FormModel m) {
|
||||
m.mergeModel(getModel());
|
||||
|
|
@ -610,14 +637,16 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* Accessor method for this form's FormModel.
|
||||
*
|
||||
* @return FormModel The model of this form.
|
||||
* */
|
||||
*
|
||||
*/
|
||||
protected final FormModel getModel() {
|
||||
return m_formModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks this FormSection, its FormModel, and the implicit Container.
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void 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.
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public Container getPanel() {
|
||||
return m_panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator over the children of this component. If the
|
||||
* component has no children, returns an empty iterator (not
|
||||
* <code>null</code> !).
|
||||
* Returns an iterator over the children of this component. If the component
|
||||
* has no children, returns an empty iterator (not <code>null</code> !).
|
||||
*
|
||||
* @post return != null
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Iterator 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>state</code>.</p>
|
||||
*
|
||||
* <p> This method generates DOM to be used with the XSLT template
|
||||
* to produce the appropriate output.</p>
|
||||
* <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 parent the node that will be used to write to
|
||||
* */
|
||||
* @param parent the node that will be used to write to
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void generateXML(PageState pageState, Element parent) {
|
||||
if (isVisible(pageState)) {
|
||||
|
|
@ -677,20 +708,21 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* Adds a component to this container.
|
||||
*
|
||||
* @param pc the component to add to this container
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void add(Component pc) {
|
||||
m_panel.add(pc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a component with the specified layout constraints to this
|
||||
* container. Layout constraints are defined in each layout container as
|
||||
* static ints. Use a bitwise OR to specify multiple constraints.
|
||||
* Adds a component with the specified layout constraints to this container.
|
||||
* Layout constraints are defined in each layout container as static ints.
|
||||
* Use a bitwise OR to specify multiple constraints.
|
||||
*
|
||||
* @param pc the component to add to this container
|
||||
* @param constraints layout constraints (a bitwise OR of static ints in
|
||||
* the particular layout)
|
||||
* @param pc the component to add to this container
|
||||
* @param constraints layout constraints (a bitwise OR of static ints in the
|
||||
* particular layout)
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
* specified element. More
|
||||
* formally, returns true if and only if this list contains at least
|
||||
* Returns <code>true</code> if this list contains the specified element.
|
||||
* More formally, returns true if and only if this list contains at least
|
||||
* one element e such that (o==null ? e==null : o.equals(e)).
|
||||
*
|
||||
* This method returns <code>true</code> only if the component has
|
||||
* been directly
|
||||
* added to this container. If this container contains another
|
||||
* This method returns <code>true</code> only if the component has been
|
||||
* directly added to this container. If this container contains another
|
||||
* container that contains this component, this method returns
|
||||
* <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
|
||||
* specified component directly; <code>false</code> otherwise.
|
||||
* @return <code>true</code> if this Container contains the specified
|
||||
* component directly; <code>false</code> otherwise.
|
||||
*
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return m_panel.contains(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the
|
||||
* Component at the specified position. Each call to add()
|
||||
* increments the index. This method should be used in conjunction
|
||||
* with indexOf
|
||||
* Returns the Component at the specified position. Each call to add()
|
||||
* increments the index. This method should be used in conjunction with
|
||||
* indexOf
|
||||
*
|
||||
* @param index The index of the item to be retrieved from this
|
||||
* Container. Since the user has no control over the index of added
|
||||
* components (other than counting each call to add), this method
|
||||
* should be used in conjunction with indexOf.
|
||||
* @param index The index of the item to be retrieved from this Container.
|
||||
* Since the user has no control over the index of added
|
||||
* components (other than counting each call to add), this
|
||||
* method should be used in conjunction with indexOf.
|
||||
*
|
||||
* @return the component at the specified position in this container
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Component get(int index) {
|
||||
return (Component) m_panel.get(index);
|
||||
|
|
@ -744,10 +775,10 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
*
|
||||
* @param pc component to search for
|
||||
*
|
||||
* @return the index in this list of the first occurrence of
|
||||
* the specified element, or -1 if this list does not contain this
|
||||
* element.
|
||||
* */
|
||||
* @return the index in this list of the first occurrence of the specified
|
||||
* element, or -1 if this list does not contain this element.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int indexOf(Component pc) {
|
||||
return m_panel.indexOf(pc);
|
||||
|
|
@ -757,8 +788,9 @@ public class FormSection extends DescriptiveComponent implements Container {
|
|||
* Determines whether the container contains any components.
|
||||
*
|
||||
* @return <code>true</code> if this container contains no components
|
||||
* <code>false</code> otherwise.
|
||||
* */
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean 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.
|
||||
*
|
||||
* @return the number of components directly in this container.
|
||||
* */
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return m_panel.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.bebop;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
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.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
|
||||
* 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
|
||||
* process, validate, and submission listeners are then fired on every
|
||||
* submission following the one in which the init listeners were fired. This
|
||||
* behavior is useful when used in conjunction with {@link MultiStepForm} or
|
||||
* its subclasses to provide initialization in later steps of a multi step
|
||||
* form that depends on the values entered in earlier steps.
|
||||
* behavior is useful when used in conjunction with {@link MultiStepForm} or its
|
||||
* subclasses to provide initialization in later steps of a multi step form that
|
||||
* depends on the values entered in earlier steps.
|
||||
*
|
||||
* updated chris.gilbert@westsussex.gov.uk - support for session based wizards
|
||||
* (which enable use of actionlinks in wizard)
|
||||
|
||||
*
|
||||
* @see Wizard
|
||||
* @see MultiStepForm
|
||||
*
|
||||
* @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 {
|
||||
private final static Logger s_log = Logger.getLogger(FormStep.class);
|
||||
|
||||
private final static Logger LOGGER = LogManager.getLogger(FormStep.class);
|
||||
|
||||
private Form m_form = null;
|
||||
|
||||
// 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
|
||||
// private Hidden m_initialized;
|
||||
|
||||
private BooleanParameter m_initialized;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* enclosing Form.
|
||||
**/
|
||||
|
||||
*
|
||||
*/
|
||||
public FormStep(String name) {
|
||||
addInitialized(name);
|
||||
}
|
||||
|
|
@ -76,11 +75,11 @@ public class FormStep extends FormSection {
|
|||
* Constructs a new FormStep with the given name. The name must uniquely
|
||||
* identify this FormStep within it's enclosing Form.
|
||||
*
|
||||
* @param name A name that uniquely identifies this FormStep within it's
|
||||
* enclosing Form.
|
||||
* @param name A name that uniquely identifies this FormStep within it's
|
||||
* enclosing Form.
|
||||
* @param panel The container used to back this FormStep.
|
||||
**/
|
||||
|
||||
*
|
||||
*/
|
||||
public FormStep(String name, Container panel) {
|
||||
super(panel);
|
||||
addInitialized(name);
|
||||
|
|
@ -93,14 +92,16 @@ public class FormStep extends FormSection {
|
|||
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
p.addComponentStateParam(this, m_initialized);
|
||||
Traversal trav = new Traversal () {
|
||||
protected void act(Component c) {
|
||||
if (c instanceof Widget) {
|
||||
((Widget) c).setValidateInvisible(false);
|
||||
}
|
||||
p.addComponentStateParam(this, m_initialized);
|
||||
Traversal trav = new Traversal() {
|
||||
|
||||
protected void act(Component c) {
|
||||
if (c instanceof Widget) {
|
||||
((Widget) c).setValidateInvisible(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
trav.preorder(this);
|
||||
}
|
||||
|
|
@ -111,17 +112,18 @@ public class FormStep extends FormSection {
|
|||
}
|
||||
|
||||
private void addInitialized(String name) {
|
||||
// m_initialized = new Hidden(new BooleanParameter(name));
|
||||
// add(m_initialized);
|
||||
m_initialized = new BooleanParameter(name);
|
||||
// m_initialized = new Hidden(new BooleanParameter(name));
|
||||
// add(m_initialized);
|
||||
m_initialized = new BooleanParameter(name);
|
||||
m_initialized.setDefaultValue(Boolean.FALSE);
|
||||
}
|
||||
|
||||
public boolean isInitialized(PageState ps) {
|
||||
// Object init = m_initialized.getValue(ps);
|
||||
Boolean init = (Boolean)ps.getValue(m_initialized);
|
||||
Boolean init = (Boolean) ps.getValue(m_initialized);
|
||||
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 -
|
||||
// form containing this step clears session
|
||||
// info when processed, but fireProcess invoked
|
||||
|
|
@ -142,8 +144,11 @@ public class FormStep extends FormSection {
|
|||
// Turn off forwarding of init events.
|
||||
protected FormInitListener createInitListener() {
|
||||
return new FormInitListener() {
|
||||
public void init(FormSectionEvent evt) { }
|
||||
};
|
||||
|
||||
public void init(FormSectionEvent evt) {
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected void fireSubmitted(FormSectionEvent evt)
|
||||
|
|
@ -161,11 +166,11 @@ public class FormStep extends FormSection {
|
|||
|
||||
protected void fireProcess(FormSectionEvent evt)
|
||||
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())) {
|
||||
super.fireProcess(evt);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +181,7 @@ public class FormStep extends FormSection {
|
|||
fireInit(new FormSectionEvent(this, ps, fd));
|
||||
setInitialized(ps);
|
||||
} catch (FormProcessException ex) {
|
||||
s_log.debug("initialization aborted", ex);
|
||||
LOGGER.debug("initialization aborted", ex);
|
||||
fd.addError("Initialization Aborted: " + ex.getMessages());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,19 +20,23 @@ package com.arsdigita.bebop;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.arsdigita.xml.Element;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.URL;
|
||||
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 Link is a BaseLink that manages URL variables.
|
||||
* A URL on a page. May contain a label, an image, or any other component. A
|
||||
* Link is a BaseLink that manages URL variables.
|
||||
*
|
||||
* <p> <b>Example:</b> The common usage for a Link component is
|
||||
* illustrated in the code fragment below:
|
||||
* <p>
|
||||
* <b>Example:</b> The common usage for a Link component is illustrated in the
|
||||
* code fragment below:
|
||||
*
|
||||
* <pre>
|
||||
* Page p = new Page("Link Example");
|
||||
|
|
@ -41,16 +45,16 @@ import org.apache.log4j.Logger;
|
|||
* p.add(link);
|
||||
* </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>
|
||||
* If either the link text or the URL needs to be changed for a link
|
||||
* within a locked page, a {@link PrintListener} should be used.
|
||||
*
|
||||
* @version $Id$
|
||||
* If either the link text or the URL needs to be changed for a link within a
|
||||
* locked page, a {@link PrintListener} should be used.
|
||||
*/
|
||||
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";
|
||||
|
||||
|
|
@ -63,29 +67,33 @@ public class Link extends BaseLink {
|
|||
protected final String TYPE_LINK = "link";
|
||||
|
||||
/**
|
||||
* <p>Passing this value to {@link #setTargetFrame setTargetFrame} will
|
||||
* create a link that opens a new browser window whenever it is clicked.
|
||||
*</p>
|
||||
* <p>
|
||||
* Passing this value to {@link #setTargetFrame setTargetFrame} will create
|
||||
* a link that opens a new browser window whenever it is clicked.
|
||||
* </p>
|
||||
*
|
||||
* @see #setTargetFrame
|
||||
*/
|
||||
public static final String NEW_FRAME = "_blank";
|
||||
|
||||
/** initialization steps common to all constructors */
|
||||
/**
|
||||
* initialization steps common to all constructors
|
||||
*/
|
||||
private void init() {
|
||||
setTypeAttr(TYPE_LINK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor creates a link taking url as the target and display it to
|
||||
* the user at the same time. It is the only allowed way to present the
|
||||
* user with a not globlized information. The implementation currently
|
||||
* miss-uses the Label component to display just a not globalized String
|
||||
* which is deprecated.
|
||||
* Constructor creates a link taking url as the target and display it to the
|
||||
* user at the same time. It is the only allowed way to present the user
|
||||
* with a not globlized information. The implementation currently miss-uses
|
||||
* the Label component to display just a not globalized String which is
|
||||
* deprecated.
|
||||
*
|
||||
* @param url
|
||||
*
|
||||
* @deprecated use BaseLink(Component,url) instead with a Label using a
|
||||
* GlobalizedMessage instead
|
||||
* GlobalizedMessage instead
|
||||
*/
|
||||
public Link(final String 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.
|
||||
*
|
||||
* @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
|
||||
* the dispatcher. Code that does not should use the
|
||||
* <code>Link</code> constructor taking a <code>URL</code>.
|
||||
* @see #Link(String,URL)
|
||||
* @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 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) {
|
||||
super(child, url);
|
||||
|
|
@ -113,12 +122,11 @@ public class Link extends BaseLink {
|
|||
|
||||
/**
|
||||
* Constructors with <tt>PrintListener</tt> parameters allow for a
|
||||
* {@link PrintListener} to be set for the Link, without the need
|
||||
* to make a separate call to the <tt>addPrintListener</tt> method.
|
||||
* PrintListeners are a convenient way to alter underlying Link
|
||||
* attributes such as Link text or target URL within a locked page
|
||||
* on a per request basis.
|
||||
*
|
||||
* {@link PrintListener} to be set for the Link, without the need to make a
|
||||
* separate call to the <tt>addPrintListener</tt> method. PrintListeners are
|
||||
* a convenient way to alter underlying Link attributes such as Link text or
|
||||
* target URL within a locked page on a per request basis.
|
||||
*
|
||||
* @param child
|
||||
* @param l
|
||||
*/
|
||||
|
|
@ -128,31 +136,29 @@ public class Link extends BaseLink {
|
|||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructors with <tt>PrintListener</tt> parameters allow for a
|
||||
* {@link PrintListener} to be set for the Link, without the need to make a
|
||||
* separate call to the <tt>addPrintListener</tt> method. PrintListeners
|
||||
* are a convenient way to alter underlying Link attributes such as Link
|
||||
* text or target URL within a locked page on a per request basis.
|
||||
*
|
||||
* separate call to the <tt>addPrintListener</tt> method. PrintListeners are
|
||||
* a convenient way to alter underlying Link attributes such as Link text or
|
||||
* target URL within a locked page on a per request basis.
|
||||
*
|
||||
* @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) {
|
||||
super(label,l);
|
||||
super(label, l);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructors with <tt>PrintListener</tt> parameters allow for a
|
||||
* {@link PrintListener} to be set for the Link, without the need to make a
|
||||
* separate call to the <tt>addPrintListener</tt> method. PrintListeners
|
||||
* are a convenient way to alter underlying Link attributes such as Link
|
||||
* text or target URL within a locked page on a per request basis.
|
||||
*
|
||||
* {@link PrintListener} to be set for the Link, without the need to make a
|
||||
* separate call to the <tt>addPrintListener</tt> method. PrintListeners are
|
||||
* a convenient way to alter underlying Link attributes such as Link text or
|
||||
* target URL within a locked page on a per request basis.
|
||||
*
|
||||
* @param listener PrintListener, may be used to change either the Display
|
||||
* 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
|
||||
* for the Link text and the target URL to be set at the same time during
|
||||
* <p>
|
||||
* 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>
|
||||
*
|
||||
* <p>Starting with release 5.2, this method prefixes the
|
||||
* passed-in <code>url</code> 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.</p>
|
||||
* <p>
|
||||
* Starting with release 5.2, this method prefixes the passed-in
|
||||
* <code>url</code> 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.</p>
|
||||
*
|
||||
* <p>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>.</p>
|
||||
* <p>
|
||||
* 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>.</p>
|
||||
*
|
||||
* @see #Link(String,URL)
|
||||
* @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) {
|
||||
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
|
||||
* 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>
|
||||
*
|
||||
* @see com.arsdigita.web.URL
|
||||
* @see com.arsdigita.web.ParameterMap
|
||||
* @param label a <code>String</code> of label text
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
public Link(String label, URL url) {
|
||||
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
|
||||
* have been set previously under the specified name.
|
||||
* Sets a query variable and its value. Overwrites any values that may have
|
||||
* been set previously under the specified name.
|
||||
* <p>
|
||||
* All the variables set with this method are appended to the
|
||||
* query string in the URL that is output for this <code>Link</code>.
|
||||
* All the variables set with this method are appended to the query string
|
||||
* 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
|
||||
*
|
||||
* @pre name != null
|
||||
*/
|
||||
public void setVar(String name, String value) {
|
||||
|
|
@ -242,38 +253,36 @@ public class Link extends BaseLink {
|
|||
// public void addURLVars(String name, String value) {
|
||||
// setVar(name, value);
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* may be this method should be deprecated as well as addURLVars?
|
||||
*
|
||||
* @return may be this method should be deprecated as well as addURLVars?
|
||||
*/
|
||||
public String getURLVarString() {
|
||||
return m_params.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Get the "target" attribute of the link, which determines
|
||||
* which browser frame will load the new page when this link is
|
||||
* clicked.</p>
|
||||
* <p>
|
||||
* Get the "target" attribute of the link, which determines which browser
|
||||
* frame will load the new page when this link is clicked.</p>
|
||||
*/
|
||||
public String getTargetFrame() {
|
||||
return getAttribute(FRAME_TARGET_ATTR);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Set the "target" attribute of the link, which determines
|
||||
* which browser frame will load the new page when this link is
|
||||
* clicked.</p>
|
||||
* <p>
|
||||
* Set the "target" attribute of the link, which determines which browser
|
||||
* frame will load the new page when this link is clicked.</p>
|
||||
*/
|
||||
public void setTargetFrame(String frameName) {
|
||||
setAttribute(FRAME_TARGET_ATTR, frameName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param state
|
||||
* @param parent
|
||||
* @param parent
|
||||
*/
|
||||
protected void generateURL(PageState state, Element parent) {
|
||||
parent.addAttribute("href", prepareURL(state, getTarget()));
|
||||
|
|
@ -302,22 +311,22 @@ public class Link extends BaseLink {
|
|||
|
||||
if (location.indexOf("?") == -1) {
|
||||
// m_params adds the "?" as needed.
|
||||
|
||||
|
||||
return resp.encodeURL(location + m_params);
|
||||
} else {
|
||||
// The location already includes a query string, so
|
||||
// append to it without including a "?".
|
||||
|
||||
|
||||
if (location.endsWith("&")) {
|
||||
return resp.encodeURL(location +
|
||||
m_params.getQueryString());
|
||||
return resp.encodeURL(location + m_params.getQueryString());
|
||||
} else {
|
||||
return resp.encodeURL(location +
|
||||
"&" + m_params.getQueryString());
|
||||
return resp.encodeURL(location + "&" + m_params
|
||||
.getQueryString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return m_webURL.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,30 +21,33 @@ package com.arsdigita.bebop;
|
|||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* sets the appropriate default and PageState-based visibility for its
|
||||
* children.
|
||||
* selected the child with index equal to zero is used. The modal container sets
|
||||
* the appropriate default and PageState-based visibility for its children.
|
||||
*
|
||||
* @author Archit Shah
|
||||
* @version $Id$
|
||||
**/
|
||||
*
|
||||
*/
|
||||
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 ArrayList m_changeListeners = new ArrayList();
|
||||
|
||||
public ModalContainer() {
|
||||
public ModalContainer() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
|
@ -58,12 +61,12 @@ public class ModalContainer extends SimpleContainer implements Resettable {
|
|||
*
|
||||
* Used here to set the visibility of the component.
|
||||
*
|
||||
* The super class' method is empty, so the rule "Always call
|
||||
* <code>super.register</code> when you override <code>register</code>
|
||||
* The super class' method is empty, so the rule "Always call
|
||||
* <code>super.register</code> when you override <code>register</code>
|
||||
* doessn't apply here.
|
||||
*
|
||||
* @pre p != null
|
||||
* @param p
|
||||
* @pre p != null
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
|
|
@ -94,7 +97,7 @@ public class ModalContainer extends SimpleContainer implements Resettable {
|
|||
}
|
||||
|
||||
public void setVisibleComponent(PageState state, Component c) {
|
||||
s_log.debug("changing visibility");
|
||||
LOGGER.debug("changing visibility");
|
||||
|
||||
Component old = getVisibleComponent(state);
|
||||
try {
|
||||
|
|
@ -104,7 +107,7 @@ public class ModalContainer extends SimpleContainer implements Resettable {
|
|||
// visibility of the components. don't have to do anything
|
||||
}
|
||||
c.setVisible(state, true);
|
||||
if (old!=c) {
|
||||
if (old != c) {
|
||||
Iterator listeners = m_changeListeners.iterator();
|
||||
while (listeners.hasNext()) {
|
||||
ChangeListener l = (ChangeListener) listeners.next();
|
||||
|
|
@ -117,7 +120,9 @@ public class ModalContainer extends SimpleContainer implements Resettable {
|
|||
Iterator it = children();
|
||||
while (it.hasNext()) {
|
||||
Component c = (Component) it.next();
|
||||
if (c.isVisible(state)) { return c; }
|
||||
if (c.isVisible(state)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
* other components.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void next(PageState state) {
|
||||
setVisibleComponent(state,
|
||||
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
|
||||
* all other components.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void previous(PageState state) {
|
||||
setVisibleComponent(state,
|
||||
get(indexOf(getVisibleComponent(state)) - 1));
|
||||
|
|
@ -147,33 +154,35 @@ public class ModalContainer extends SimpleContainer implements Resettable {
|
|||
* @param state
|
||||
* @param index 0 based index of component
|
||||
*/
|
||||
public void jumpTo (PageState state, int index) {
|
||||
setVisibleComponent(state, get(index));
|
||||
public void jumpTo(PageState state, int index) {
|
||||
setVisibleComponent(state, get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the specified component visible
|
||||
*
|
||||
*/
|
||||
public void jumpTo (PageState state, Component comp) {
|
||||
setVisibleComponent(state, get(indexOf(comp)));
|
||||
public void jumpTo(PageState state, Component comp) {
|
||||
setVisibleComponent(state, get(indexOf(comp)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the container to display the default component.
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void reset(PageState state) {
|
||||
setVisibleComponent(state, getDefaultComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener that is called whenever this container's mode
|
||||
* (i.e., visible component) is changed using setVisibleComponent().
|
||||
**/
|
||||
* Adds a listener that is called whenever this container's mode (i.e.,
|
||||
* visible component) is changed using setVisibleComponent().
|
||||
*
|
||||
*/
|
||||
public void addModeChangeListener(ChangeListener cl) {
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
m_changeListeners.add(cl);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ import com.arsdigita.util.SystemInformation;
|
|||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
|
|
@ -50,8 +53,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* The top-level container for all Bebop components and containers.
|
||||
*
|
||||
|
|
@ -73,15 +74,13 @@ import org.apache.log4j.Logger;
|
|||
* @author David Lutterkort
|
||||
* @author Stanislav Freidin
|
||||
* @author Uday Mathur
|
||||
*
|
||||
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
|
||||
*/
|
||||
public class Page extends SimpleComponent implements Container {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
@ -104,12 +103,12 @@ public class Page extends SimpleComponent implements Container {
|
|||
static final Collection CONTROL_EVENT_KEYS;
|
||||
|
||||
static {
|
||||
s_log.debug("Static initalizer is starting...");
|
||||
LOGGER.debug("Static initalizer is starting...");
|
||||
CONTROL_EVENT_KEYS = new ArrayList(3);
|
||||
CONTROL_EVENT_KEYS.add(SELECTED);
|
||||
CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
|
||||
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) {
|
||||
s_log.warn("m_panel is null");
|
||||
LOGGER.warn("m_panel is null");
|
||||
}
|
||||
componentRegistrar.preorder(m_panel);
|
||||
if (m_errorDisplay != null) {
|
||||
|
|
@ -872,8 +871,8 @@ public class Page extends SimpleComponent implements Container {
|
|||
|
||||
final ActionListener listener = (ActionListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing action listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing action listener " + listener);
|
||||
}
|
||||
|
||||
listener.actionPerformed(e);
|
||||
|
|
@ -899,8 +898,8 @@ public class Page extends SimpleComponent implements Container {
|
|||
|
||||
final RequestListener listener = (RequestListener) i.next();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Firing request listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Firing request listener " + listener);
|
||||
}
|
||||
|
||||
listener.pageRequested(e);
|
||||
|
|
@ -962,7 +961,7 @@ public class Page extends SimpleComponent implements Container {
|
|||
|
||||
if (!stateContains(c)) {
|
||||
if (c == null) {
|
||||
s_log.error("c is null");
|
||||
LOGGER.error("c is null");
|
||||
} /*else {
|
||||
s_log.error("c: " + c.toString());
|
||||
}*/
|
||||
|
|
@ -1007,7 +1006,7 @@ public class Page extends SimpleComponent implements Container {
|
|||
}
|
||||
if (!m_stateModel.containsFormParam(p)) {
|
||||
String name = parameterName(c, p.getName());
|
||||
s_log.debug(String
|
||||
LOGGER.debug(String
|
||||
.format("Setting name of parameter to add to '%s'",
|
||||
name));
|
||||
p.setName(name);
|
||||
|
|
@ -1334,7 +1333,7 @@ public class Page extends SimpleComponent implements Container {
|
|||
String componentId = (String) it.next();
|
||||
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.
|
||||
getTime()));
|
||||
return hashString.toString();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ import com.arsdigita.web.RedirectSignal;
|
|||
import com.arsdigita.web.URL;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
|
@ -37,11 +41,11 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <p>The request-specific data (state) for a {@link Page}. All
|
||||
|
|
@ -153,12 +157,11 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
* @author David Lutterkort
|
||||
* @author Uday Mathur
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PageState {
|
||||
|
||||
/** 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. */
|
||||
private Page m_page;
|
||||
|
|
@ -501,8 +504,8 @@ public class PageState {
|
|||
return;
|
||||
m_invisible.set(i);
|
||||
}
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Marking visibility parameter as dirty " + m_request + " because of component " + c);
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Marking visibility parameter as dirty " + m_request + " because of component " + c);
|
||||
}
|
||||
// Do this only in toURL since the RLE is expensive
|
||||
//m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible));
|
||||
|
|
@ -884,7 +887,7 @@ public class PageState {
|
|||
|
||||
final ParameterMap params = new ParameterMap();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
dumpVisibility();
|
||||
}
|
||||
|
||||
|
|
@ -917,8 +920,8 @@ public class PageState {
|
|||
|
||||
private void synchronizeVisibility() {
|
||||
if (m_visibilityDirty) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Encoding visibility parameter " + m_request);
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Encoding visibility parameter " + m_request);
|
||||
}
|
||||
m_pageState.put(Page.INVISIBLE, encodeVisibility(m_invisible));
|
||||
m_visibilityDirty = false;
|
||||
|
|
@ -935,30 +938,30 @@ public class PageState {
|
|||
BitSet difference = (BitSet)current.clone();
|
||||
difference.xor(base);
|
||||
|
||||
s_log.debug("Current: " + current.toString());
|
||||
s_log.debug("Default: " + base.toString());
|
||||
s_log.debug("Difference: " + difference.toString());
|
||||
LOGGER.debug("Current: " + current.toString());
|
||||
LOGGER.debug("Default: " + base.toString());
|
||||
LOGGER.debug("Difference: " + difference.toString());
|
||||
|
||||
s_log.debug("Current RAW: " + raw.marshal(current));
|
||||
s_log.debug("Default RAW: " + raw.marshal(base));
|
||||
s_log.debug("Difference RAW: " + raw.marshal(difference));
|
||||
LOGGER.debug("Current RAW: " + raw.marshal(current));
|
||||
LOGGER.debug("Default RAW: " + raw.marshal(base));
|
||||
LOGGER.debug("Difference RAW: " + raw.marshal(difference));
|
||||
|
||||
s_log.debug("Current DGAP: " + dgap.marshal(current));
|
||||
s_log.debug("Default DGAP: " + dgap.marshal(base));
|
||||
s_log.debug("Difference DGAP: " + dgap.marshal(difference));
|
||||
LOGGER.debug("Current DGAP: " + dgap.marshal(current));
|
||||
LOGGER.debug("Default DGAP: " + dgap.marshal(base));
|
||||
LOGGER.debug("Difference DGAP: " + dgap.marshal(difference));
|
||||
|
||||
s_log.debug("Current Result: " + dgap.unmarshal(dgap.marshal(current)));
|
||||
s_log.debug("Default Result: " + dgap.unmarshal(dgap.marshal(base)));
|
||||
s_log.debug("Difference Result: " + dgap.unmarshal(dgap.marshal(difference)));
|
||||
LOGGER.debug("Current Result: " + dgap.unmarshal(dgap.marshal(current)));
|
||||
LOGGER.debug("Default Result: " + dgap.unmarshal(dgap.marshal(base)));
|
||||
LOGGER.debug("Difference Result: " + dgap.unmarshal(dgap.marshal(difference)));
|
||||
|
||||
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)))) {
|
||||
s_log.debug("Broken marshal/unmarshal for default");
|
||||
LOGGER.debug("Broken marshal/unmarshal for default");
|
||||
}
|
||||
if (!difference.equals(dgap.unmarshal(dgap.marshal(difference)))) {
|
||||
s_log.debug("Broken marshal/unmarshal for difference");
|
||||
LOGGER.debug("Broken marshal/unmarshal for difference");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,41 +26,42 @@ import com.arsdigita.bebop.event.ActionEvent;
|
|||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/* FIXME: Add methods for using images in the tab strip */
|
||||
|
||||
/**
|
||||
* A tabbed pane that lets the user switch between components by
|
||||
* clicking on a given title in the tab strip.
|
||||
* A tabbed pane that lets the user switch between components by clicking on a
|
||||
* given title in the tab strip.
|
||||
* <p>
|
||||
* Tabs (components) are added using the {@link #addTab addTab} method. Each
|
||||
* entry consists of a label (which is a string) and the {@link Component}
|
||||
* that is displayed if the user clicks on the label.
|
||||
* entry consists of a label (which is a string) and the {@link Component} that
|
||||
* is displayed if the user clicks on the label.
|
||||
* <p>
|
||||
* There is always exactly one component that is currently visible, the component
|
||||
* that is returned by {@link #getCurrentPane}. Without user interaction,
|
||||
* this is the default pane -- that was set by {@link #setDefaultPane} -- or, if
|
||||
* none has been set, the first component that was added to the <code>TabbedPane</code>.
|
||||
* There is always exactly one component that is currently visible, the
|
||||
* component that is returned by {@link #getCurrentPane}. Without user
|
||||
* interaction, this is the default pane -- that was set by
|
||||
* {@link #setDefaultPane} -- or, if none has been set, the first component that
|
||||
* was added to the <code>TabbedPane</code>.
|
||||
* <p>
|
||||
*
|
||||
* @author David Lutterkort
|
||||
* @author Stanislav Freidin
|
||||
* @author Uday Mathur
|
||||
* @author David Lutterkort
|
||||
* @author Stanislav Freidin
|
||||
* @author Uday Mathur
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TabbedPane extends SimpleContainer {
|
||||
|
||||
private static final String CURRENT_PANE = "pane";
|
||||
/**
|
||||
* The name for the event to change the selected pane.
|
||||
* The value is the index of the pane
|
||||
* The name for the event to change the selected pane. The value is the
|
||||
* index of the pane
|
||||
*/
|
||||
private static final String SELECT_EVENT = "select";
|
||||
|
||||
|
|
@ -68,8 +69,8 @@ public class TabbedPane extends SimpleContainer {
|
|||
private IntegerParameter m_currentPaneParam;
|
||||
private List m_actionListeners;
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(TabbedPane.class.getName());
|
||||
private static final Logger LOGGER = LogManager.getLogger(TabbedPane.class
|
||||
.getName());
|
||||
|
||||
/**
|
||||
* Constructs an empty TabbedPane.
|
||||
|
|
@ -79,9 +80,11 @@ public class TabbedPane extends SimpleContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Registers with the specified root container. Adds a state
|
||||
* parameter to keep track of the visible component to the page.
|
||||
* Registers with the specified root container. Adds a state parameter to
|
||||
* keep track of the visible component to the page.
|
||||
*
|
||||
* @param p the root container to register with
|
||||
*
|
||||
* @pre p != null
|
||||
*/
|
||||
public void register(Page p) {
|
||||
|
|
@ -92,7 +95,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
// in the list
|
||||
Iterator i = children();
|
||||
if (!i.hasNext()) {
|
||||
s_log.warn("TabbedPane registered with no panes");
|
||||
LOGGER.warn("TabbedPane registered with no panes");
|
||||
} else if (m_defaultPane == null) {
|
||||
setDefaultPaneIndex(0);
|
||||
}
|
||||
|
|
@ -104,8 +107,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
/**
|
||||
* Adds a new pane to the dialog. Assigns a rather unhelpful default label
|
||||
* (the pane number) to the component. Use {@link #addTab addTab}
|
||||
* instead.
|
||||
* (the pane number) to the component. Use {@link #addTab addTab} instead.
|
||||
*
|
||||
* @pre pc != null
|
||||
*/
|
||||
|
|
@ -114,21 +116,23 @@ public class TabbedPane extends SimpleContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a new pane with layout constraints to the dialog. Ignores
|
||||
* the constraints. Assigns a rather unhelpful default label
|
||||
* (the pane number) to the component. Use {@link #addTab
|
||||
* Adds a new pane with layout constraints to the dialog. Ignores the
|
||||
* constraints. Assigns a rather unhelpful default label (the pane number)
|
||||
* to the component. Use {@link #addTab
|
||||
* addTab} instead.
|
||||
*
|
||||
* @pre pc != null */
|
||||
* @pre pc != null
|
||||
*/
|
||||
public void add(Component pc, int constraints) {
|
||||
add(pc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tab and its associated component.
|
||||
*
|
||||
* @param label the text to display in the tab strip
|
||||
* @param c the component to display when the user clicks on the
|
||||
* <code>label</code> in the tab strip
|
||||
* @param c the component to display when the user clicks on the
|
||||
* <code>label</code> in the tab strip
|
||||
*
|
||||
* @pre label != null && c != null
|
||||
*/
|
||||
|
|
@ -139,9 +143,10 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
/**
|
||||
* Adds a tab and its associated component.
|
||||
*
|
||||
* @param label the text to display in the tab strip
|
||||
* @param c the component to display when the user clicks on the
|
||||
* <code>label</code> in the tab strip
|
||||
* @param c the component to display when the user clicks on the
|
||||
* <code>label</code> in the tab strip
|
||||
*
|
||||
* @pre label != null && c != null
|
||||
*/
|
||||
|
|
@ -152,6 +157,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
/**
|
||||
* Adds an <code>ActionListener</code>, which is run whenever {@link
|
||||
* #respond respond} is called.
|
||||
*
|
||||
* @param 1 the action listener
|
||||
*
|
||||
* @pre l != null
|
||||
|
|
@ -160,7 +166,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
*/
|
||||
public void addActionListener(ActionListener l) {
|
||||
Assert.isUnlocked(this);
|
||||
if ( m_actionListeners == null ) {
|
||||
if (m_actionListeners == null) {
|
||||
m_actionListeners = new ArrayList();
|
||||
}
|
||||
m_actionListeners.add(l);
|
||||
|
|
@ -168,12 +174,14 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
/**
|
||||
* Removes a previously added <code>ActionListener</code>.
|
||||
*
|
||||
* @param 1 the action listener to remove
|
||||
*
|
||||
* @see #addActionListener addActionListener
|
||||
*/
|
||||
public void removeActionListener(ActionListener l) {
|
||||
Assert.isUnlocked(this);
|
||||
if ( m_actionListeners == null ) {
|
||||
if (m_actionListeners == null) {
|
||||
return;
|
||||
}
|
||||
m_actionListeners.remove(l);
|
||||
|
|
@ -183,7 +191,9 @@ public class TabbedPane extends SimpleContainer {
|
|||
* Fires an <code>ActionEvent</code>. All registered
|
||||
* <code>ActionListener</code>s are run. The source of the event is the
|
||||
* <code>TabbedPane</code>.
|
||||
*
|
||||
* @param state the current page state
|
||||
*
|
||||
* @pre state != null
|
||||
* @see #respond respond
|
||||
*/
|
||||
|
|
@ -192,8 +202,8 @@ public class TabbedPane extends SimpleContainer {
|
|||
if (m_actionListeners == null) {
|
||||
return;
|
||||
}
|
||||
for (Iterator i=m_actionListeners.iterator(); i.hasNext(); ) {
|
||||
if ( e == null ) {
|
||||
for (Iterator i = m_actionListeners.iterator(); i.hasNext();) {
|
||||
if (e == null) {
|
||||
e = new ActionEvent(this, state);
|
||||
}
|
||||
((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
|
||||
* clicks on another label in the tab strip.
|
||||
*
|
||||
* @param i the index of the default pane
|
||||
*/
|
||||
protected void setDefaultPaneIndex(int 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
|
||||
* clicks on another label in the tab strip.
|
||||
* Sets the default pane, which is visible until the user clicks on another
|
||||
* label in the tab strip.
|
||||
*
|
||||
* @param pane the component to display as the default pane
|
||||
*
|
||||
* @pre findPane(pane) != -1
|
||||
|
|
@ -270,15 +282,18 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
/**
|
||||
* Find the pane whose body is the specified component
|
||||
*
|
||||
* @param c the component
|
||||
*
|
||||
* @return the pane index on success, -1 if no such pane exists
|
||||
*/
|
||||
protected int findPane(Component c) {
|
||||
int index = 0;
|
||||
for(Iterator i = children(); i.hasNext(); index++) {
|
||||
Pane p = (Pane)i.next();
|
||||
if(p.getComponent() == c)
|
||||
for (Iterator i = children(); i.hasNext(); index++) {
|
||||
Pane p = (Pane) i.next();
|
||||
if (p.getComponent() == c) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -286,21 +301,19 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
private int findPaneSafe(Component c) {
|
||||
int i = findPane(c);
|
||||
if ( i == -1 ) {
|
||||
throw new IllegalArgumentException
|
||||
("Pane not part of this tabbed dialog");
|
||||
if (i == -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Pane not part of this tabbed dialog");
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the default pane. If no default pane has been set explicitly, the
|
||||
* first pane is returned.
|
||||
*
|
||||
* @return the default pane, or <code>null</code> if there are no
|
||||
* panes.
|
||||
* @return the default pane, or <code>null</code> if there are no panes.
|
||||
*/
|
||||
public Component getDefaultPane() {
|
||||
return m_defaultPane.getComponent();
|
||||
|
|
@ -308,13 +321,14 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
for (Iterator i = children(); i.hasNext();) {
|
||||
Pane p = (Pane) i.next();
|
||||
if ( p.getLabel().equals(label) ) {
|
||||
if (p.getLabel().equals(label)) {
|
||||
return p.getComponent();
|
||||
}
|
||||
}
|
||||
|
|
@ -322,11 +336,12 @@ public class TabbedPane extends SimpleContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the pane with the specified key in its label.
|
||||
* Returns null if a pane with that label does not exist.
|
||||
* This function exists for backward compatibility.
|
||||
* @return the pane with the specified label, or <code>null</code>
|
||||
* if a pane with that label does not exist.
|
||||
* Gets the pane with the specified key in its label. Returns null if a pane
|
||||
* with that label does not exist. This function exists for backward
|
||||
* compatibility.
|
||||
*
|
||||
* @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) {
|
||||
|
||||
|
|
@ -334,7 +349,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
Pane p = (Pane) i.next();
|
||||
Component pLabel = p.getLabel();
|
||||
if (pLabel instanceof Label
|
||||
&& ((Label)pLabel).getLabel().equals(label) ) {
|
||||
&& ((Label) pLabel).getLabel().equals(label)) {
|
||||
return p.getComponent();
|
||||
}
|
||||
}
|
||||
|
|
@ -351,24 +366,24 @@ public class TabbedPane extends SimpleContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the currently visible <code>Pane</code>, the tab label together
|
||||
* with its component.
|
||||
* Get the currently visible <code>Pane</code>, the tab label together with
|
||||
* its component.
|
||||
*/
|
||||
private Pane getCurrent(PageState data) {
|
||||
Integer i = (Integer) data.getValue(m_currentPaneParam);
|
||||
if (i == null) {
|
||||
if (m_defaultPane!=null) {
|
||||
if (m_defaultPane != null) {
|
||||
|
||||
return m_defaultPane;
|
||||
} 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) {
|
||||
if ( index != getSelectedIndex(state) ) {
|
||||
if (index != getSelectedIndex(state)) {
|
||||
getCurrentPane(state).setVisible(state, false);
|
||||
state.setValue(m_currentPaneParam, new Integer(index));
|
||||
getCurrentPane(state).setVisible(state, true);
|
||||
|
|
@ -377,28 +392,31 @@ public class TabbedPane extends SimpleContainer {
|
|||
|
||||
public int getSelectedIndex(PageState state) {
|
||||
Integer current = (Integer) state.getValue(m_currentPaneParam);
|
||||
if ( current == null ) {
|
||||
if (current == null) {
|
||||
return -1;
|
||||
}
|
||||
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) {
|
||||
Element strip = parent.newChildElement("bebop:tabStrip", BEBOP_XML_NS);
|
||||
exportAttributes(strip);
|
||||
|
||||
Pane current = getCurrent(data);
|
||||
strip.addAttribute("selected",current.getComponent().getClass().getName());
|
||||
strip.addAttribute("selected", current.getComponent().getClass()
|
||||
.getName());
|
||||
Iterator tabs;
|
||||
int i;
|
||||
for (tabs = children(), i = 0; tabs.hasNext(); i++) {
|
||||
Pane pane = (Pane)tabs.next();
|
||||
Pane pane = (Pane) tabs.next();
|
||||
// Skip hidden tabs
|
||||
if(!pane.isVisible(data)) continue;
|
||||
if (!pane.isVisible(data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
String key = ((Label) pane.getLabel()).getGlobalizedMessage().getKey();
|
||||
String key = ((Label) pane.getLabel()).getGlobalizedMessage()
|
||||
.getKey();
|
||||
tab.addAttribute("key", key.substring(key.lastIndexOf(".") + 1));
|
||||
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
|
||||
* themselves and then the included page.
|
||||
* <p>Generates a DOM fragment:
|
||||
* <p><code><pre>
|
||||
* Services the request by building a DOM tree with the tabs themselves and
|
||||
* then the included page.
|
||||
* <p>
|
||||
* Generates a DOM fragment:
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* <bebop:tabbedPane>
|
||||
* <bebop:tabStrip>
|
||||
* <bebop:tab [href="..."] [current="t|f"]> .. label .. </bebop:tab>
|
||||
|
|
@ -438,12 +459,14 @@ public class TabbedPane extends SimpleContainer {
|
|||
* </pre></code>
|
||||
*/
|
||||
public void generateXML(PageState state, Element parent) {
|
||||
if ( isVisible(state) && !isEmpty()) {
|
||||
Element tabbed = parent.newChildElement("bebop:tabbedPane", BEBOP_XML_NS);
|
||||
if (isVisible(state) && !isEmpty()) {
|
||||
Element tabbed = parent.newChildElement("bebop:tabbedPane",
|
||||
BEBOP_XML_NS);
|
||||
generateTabs(state, tabbed);
|
||||
exportAttributes(tabbed);
|
||||
|
||||
Element pane = tabbed.newChildElement("bebop:currentPane", BEBOP_XML_NS);
|
||||
Element pane = tabbed.newChildElement("bebop:currentPane",
|
||||
BEBOP_XML_NS);
|
||||
exportAttributes(pane);
|
||||
getCurrentPane(state).generateXML(state, pane);
|
||||
}
|
||||
|
|
@ -460,11 +483,10 @@ public class TabbedPane extends SimpleContainer {
|
|||
* @pre state != null
|
||||
*/
|
||||
public void respond(PageState state)
|
||||
throws ServletException
|
||||
{
|
||||
throws ServletException {
|
||||
String event = state.getControlEventName();
|
||||
|
||||
if ( SELECT_EVENT.equals(event)) {
|
||||
if (SELECT_EVENT.equals(event)) {
|
||||
String value = state.getControlEventValue();
|
||||
setSelectedIndex(state, Integer.parseInt(value));
|
||||
} else {
|
||||
|
|
@ -477,6 +499,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
* Associates a label with the component
|
||||
*/
|
||||
private class Pane extends SimpleContainer {
|
||||
|
||||
private Component m_label;
|
||||
private Component m_component;
|
||||
|
||||
|
|
@ -494,5 +517,7 @@ public class TabbedPane extends SimpleContainer {
|
|||
public final Component getComponent() {
|
||||
return m_component;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,16 +38,16 @@ import com.arsdigita.bebop.table.TableModelBuilder;
|
|||
|
||||
import static com.arsdigita.bebop.util.BebopConstants.*;
|
||||
|
||||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Displays statically or dynamically generated data in tabular form.
|
||||
* The data is retrieved from a <code>TableModel</code>.
|
||||
|
|
@ -97,11 +97,11 @@ import org.apache.log4j.Logger;
|
|||
* @see TableColumnModel
|
||||
*
|
||||
* @author David Lutterkort
|
||||
* @version $Id$
|
||||
*/
|
||||
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
|
||||
private static final String WIDTH = "width";
|
||||
private static final String CELL_SPACING = "cellspacing";
|
||||
|
|
@ -710,7 +710,7 @@ public class Table extends SimpleComponent {
|
|||
final int modelSize = getColumnModel().size();
|
||||
int row = 0;
|
||||
|
||||
logger.debug("Creating table rows...");
|
||||
LOGGER.debug("Creating table rows...");
|
||||
long start = System.currentTimeMillis();
|
||||
do {
|
||||
long rowStart = System.currentTimeMillis();
|
||||
|
|
@ -753,17 +753,17 @@ public class Table extends SimpleComponent {
|
|||
long begin = System.currentTimeMillis();
|
||||
r.getComponent(this, s, value, selected, key, row, i).
|
||||
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()
|
||||
- begin));
|
||||
}
|
||||
}
|
||||
row += 1;
|
||||
logger.debug(
|
||||
LOGGER.debug(
|
||||
String.format("Created row in %d ms",
|
||||
System.currentTimeMillis() - rowStart));
|
||||
} 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));
|
||||
} else if (m_emptyView != null) {
|
||||
m_emptyView.generateXML(s, p);
|
||||
|
|
|
|||
|
|
@ -38,18 +38,18 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Used to print a tree structure. Nodes can be in expanded or
|
||||
* collapsed state. <code>Tree</code> uses the getChildren() and
|
||||
* getRoot() methods from TreeModel and traverses the iterator to get
|
||||
* to all the nodes.
|
||||
* Used to print a tree structure. Nodes can be in expanded or collapsed state.
|
||||
* <code>Tree</code> uses the getChildren() and getRoot() methods from
|
||||
* TreeModel and traverses the iterator to get to all the nodes.
|
||||
*
|
||||
* This class keeps track of which nodes are expanded and collapsed
|
||||
* and the hierarchy of nodes, and displays the tree correspondingly.
|
||||
* This class keeps track of which nodes are expanded and collapsed and the
|
||||
* hierarchy of nodes, and displays the tree correspondingly.
|
||||
*
|
||||
* @author David Lutterkort
|
||||
* @author Stanislav Freidin
|
||||
|
|
@ -58,11 +58,10 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Tree extends SimpleComponent implements Resettable {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(Tree.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(Tree.class);
|
||||
|
||||
private static final boolean s_selectAttributeEnabled =
|
||||
BebopConfig.getConfig().isTreeSelectEnabled();
|
||||
private static final boolean s_selectAttributeEnabled = BebopConfig
|
||||
.getConfig().isTreeSelectEnabled();
|
||||
|
||||
// Any node id in the currentState is equivalent
|
||||
// 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
|
||||
* {@link TreeModelBuilder}. The {@link TreeModelBuilder} will
|
||||
* instantiate a {@link TreeModel} during each request.
|
||||
* {@link TreeModelBuilder}. The {@link TreeModelBuilder} will instantiate a
|
||||
* {@link TreeModel} during each request.
|
||||
*
|
||||
* @param b the {@link TreeModelBuilder}
|
||||
*/
|
||||
|
|
@ -106,31 +105,34 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
m_currentState = new StringParameter(CURRENT_STATE);
|
||||
m_builder = b;
|
||||
m_renderer = new DefaultTreeCellRenderer();
|
||||
m_selection = new ParameterSingleSelectionModel(new StringParameter(SELECT));
|
||||
m_selection = new ParameterSingleSelectionModel(new StringParameter(
|
||||
SELECT));
|
||||
m_listeners = new EventListenerList();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated constructor that takes a default {@link TreeModel}
|
||||
* and wraps it in a dummy TreeModelBuilder.
|
||||
* Deprecated constructor that takes a default {@link TreeModel} and wraps
|
||||
* it in a dummy TreeModelBuilder.
|
||||
*
|
||||
* @param t the TreeModel
|
||||
*
|
||||
* @deprecated This constructor has been deprecated in favor of
|
||||
* <code>Tree(TreeModelBuilder b)</code>. It is not practical
|
||||
* to hardwire the <code>TreeModel</code> into the <code>Tree</code>,
|
||||
* since the model may change during each request. It is possible
|
||||
* to write the model-instantiation code in
|
||||
* {@link TreeModel#getRoot(PageState)}, but the
|
||||
* {@link TreeModelBuilder} fits better into the pattern which has
|
||||
* already been established by {@link List} and {@link Table}
|
||||
* <code>Tree(TreeModelBuilder b)</code>. It is not practical to hardwire
|
||||
* the <code>TreeModel</code> into the <code>Tree</code>, since the model
|
||||
* may change during each request. It is possible to write the
|
||||
* model-instantiation code in {@link TreeModel#getRoot(PageState)}, but the
|
||||
* {@link TreeModelBuilder} fits better into the pattern which has already
|
||||
* been established by {@link List} and {@link Table}
|
||||
*/
|
||||
public Tree(TreeModel t) {
|
||||
this(new WrapperModelBuilder());
|
||||
|
|
@ -160,6 +162,7 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
* Returns the tree model used for this tree.
|
||||
*
|
||||
* @return a <code>TreeModel</code>.
|
||||
*
|
||||
* @see #setTreeModel setTreeModel
|
||||
* @see TreeModel
|
||||
* @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
|
||||
* request.
|
||||
* Returns the {@link TreeModel} used by the tree for the current request.
|
||||
*
|
||||
* @param s the page state
|
||||
*/
|
||||
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
|
||||
* for this tree.
|
||||
* @return the {@link TreeModelBuilder} used to build the tree model for
|
||||
* this tree.
|
||||
*/
|
||||
public final TreeModelBuilder getModelBuilder() {
|
||||
return m_builder;
|
||||
|
|
@ -198,6 +200,7 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
* Sets the tree model used for this tree.
|
||||
*
|
||||
* @return a <code>TreeModel</code>.
|
||||
*
|
||||
* @see #setTreeModel setTreeModel
|
||||
* @see TreeModel
|
||||
*/
|
||||
|
|
@ -207,22 +210,20 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the selection model, which keeps track of which node is
|
||||
* currently selected. It can be used to manipulate the selection
|
||||
* programmatically.
|
||||
* Sets the selection model, which keeps track of which node is currently
|
||||
* selected. It can be used to manipulate the selection programmatically.
|
||||
*
|
||||
* @param m the new selection model
|
||||
*/
|
||||
public void setSelectionModel(SingleSelectionModel m) {
|
||||
Assert.isUnlocked(this);
|
||||
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
|
||||
* currently selected. It can be used to manipulate the selection
|
||||
* programmatically.
|
||||
* Gets the selection model, which keeps track of which node is currently
|
||||
* selected. It can be used to manipulate the selection programmatically.
|
||||
*
|
||||
* @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
|
||||
* if {@link #isSelected isSelected} is <code>true</code>.
|
||||
* Gets the key for the selected node. This will only be a valid key if
|
||||
* {@link #isSelected isSelected} is <code>true</code>.
|
||||
*
|
||||
* @param state represents the state of the current request
|
||||
*
|
||||
* @return the key for the selected node.
|
||||
*
|
||||
* @pre isSelected(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
|
||||
* <code>key</code> was not selected already, fires the {@link
|
||||
* Sets the selection to the one with the specified key. If <code>key</code>
|
||||
* was not selected already, fires the {@link
|
||||
* ChangeEvent}.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param state represents the state of the current request
|
||||
*
|
||||
* @return <code>true</code> if one of the nodes is selected;
|
||||
* <code>false</code> otherwise.
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isSelected(PageState 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>.
|
||||
*
|
||||
* @param state represents the state of the current request
|
||||
*
|
||||
* @post ! isSelected(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
|
||||
* expansion.
|
||||
* Tells whether the tree has state on the request for tree node expansion.
|
||||
*/
|
||||
public final boolean hasExpansionState(final PageState state) {
|
||||
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
|
||||
* the selection model to change listeners registered with the tree. The
|
||||
* returned change listener refires the event with the tree,
|
||||
* rather than the selection model, as source.
|
||||
* returned change listener refires the event with the tree, rather than the
|
||||
* selection model, as source.
|
||||
*
|
||||
* @return the change listener used internally by the tree.
|
||||
*/
|
||||
protected ChangeListener createChangeListener() {
|
||||
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
|
||||
* that listeners receive names the tree as the source.
|
||||
*
|
||||
* @param l the change listener to run when the selected item changes in
|
||||
* a request
|
||||
* @param l the change listener to run when the selected item changes in a
|
||||
* request
|
||||
*
|
||||
* @pre ! isLocked()
|
||||
*/
|
||||
public void addChangeListener(ChangeListener l) {
|
||||
Assert.isUnlocked(this);
|
||||
if ( m_changeListener == null ) {
|
||||
if (m_changeListener == null) {
|
||||
m_changeListener = createChangeListener();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Adding listener " + l + " to " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Adding listener " + l + " to " + this);
|
||||
}
|
||||
|
||||
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
|
||||
* added with {@link #addChangeListener addChangeListener}, although no
|
||||
* error is signalled if the change listener is not found among the
|
||||
* tree's listeners.
|
||||
* Removes a change listener. The listener should have been previously added
|
||||
* with {@link #addChangeListener addChangeListener}, although no error is
|
||||
* signalled if the change listener is not found among the tree's listeners.
|
||||
*
|
||||
* @param l the change listener to remove from the tree
|
||||
*/
|
||||
public void removeChangeListener(ChangeListener l) {
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing listener " + l + " from " + this);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Removing listener " + l + " from " + this);
|
||||
}
|
||||
|
||||
m_listeners.remove(ChangeListener.class, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a change event to signal that the selected list item has changed
|
||||
* in the request represented by <code>state</code>. The source of the
|
||||
* event is the tree.
|
||||
* Fires a change event to signal that the selected list item has changed in
|
||||
* the request represented by <code>state</code>. The source of the event is
|
||||
* the tree.
|
||||
*
|
||||
* @param state represents the state of the current request
|
||||
*/
|
||||
protected void fireStateChanged(PageState state) {
|
||||
Iterator
|
||||
i=m_listeners.getListenerIterator(ChangeListener.class);
|
||||
Iterator i = m_listeners.getListenerIterator(ChangeListener.class);
|
||||
ChangeEvent e = null;
|
||||
|
||||
while (i.hasNext()) {
|
||||
if ( e == null ) {
|
||||
if (e == null) {
|
||||
e = new ChangeEvent(this, state);
|
||||
}
|
||||
((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
|
||||
* of the tree, either to expand or collapse a node, or to select a
|
||||
* node. The listener is run whenever {@link #respond respond} is
|
||||
* called.
|
||||
* Adds a listener that is notified whenever a user clicks on any part of
|
||||
* the tree, either to expand or collapse a node, or to select a node. The
|
||||
* listener is run whenever {@link #respond respond} is called.
|
||||
*
|
||||
* @pre l != null
|
||||
* @pre ! isLocked()
|
||||
|
|
@ -384,6 +389,7 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
|
||||
/**
|
||||
* Removes a previously added <code>ActionListener</code>.
|
||||
*
|
||||
* @see #addActionListener addActionListener
|
||||
*/
|
||||
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
|
||||
* user. The source of the event is the tree.
|
||||
* Notifies listeners that some part of the tree was clicked by the user.
|
||||
* The source of the event is the tree.
|
||||
*
|
||||
* @pre data != null
|
||||
* @see #respond respond
|
||||
*/
|
||||
protected void fireActionEvent(PageState data) {
|
||||
Iterator
|
||||
i=m_listeners.getListenerIterator(ActionListener.class);
|
||||
Iterator i = m_listeners.getListenerIterator(ActionListener.class);
|
||||
ActionEvent e = null;
|
||||
|
||||
while (i.hasNext()) {
|
||||
if ( e == null ) {
|
||||
if (e == null) {
|
||||
e = new ActionEvent(this, data);
|
||||
}
|
||||
((ActionListener) i.next()).actionPerformed(e);
|
||||
|
|
@ -444,12 +449,12 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
* @pre nodeKey != null
|
||||
*/
|
||||
protected void fireTreeExpanded(PageState state, Object nodeKey) {
|
||||
Iterator i =
|
||||
m_listeners.getListenerIterator(TreeExpansionListener.class);
|
||||
Iterator i = m_listeners
|
||||
.getListenerIterator(TreeExpansionListener.class);
|
||||
TreeExpansionEvent e = null;
|
||||
|
||||
while (i.hasNext()) {
|
||||
if ( e == null ) {
|
||||
if (e == null) {
|
||||
e = new TreeExpansionEvent(this, state, nodeKey);
|
||||
}
|
||||
((TreeExpansionListener) i.next()).treeExpanded(e);
|
||||
|
|
@ -465,12 +470,12 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
* @pre nodeKey != null
|
||||
*/
|
||||
protected void fireTreeCollapsed(PageState state, Object nodeKey) {
|
||||
Iterator i =
|
||||
m_listeners.getListenerIterator(TreeExpansionListener.class);
|
||||
Iterator i = m_listeners
|
||||
.getListenerIterator(TreeExpansionListener.class);
|
||||
TreeExpansionEvent e = null;
|
||||
|
||||
while (i.hasNext()) {
|
||||
if ( e == null ) {
|
||||
if (e == null) {
|
||||
e = new TreeExpansionEvent(this, state, nodeKey);
|
||||
}
|
||||
((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.
|
||||
* Changes the currently selected tree component.
|
||||
* Notifies the <code>Tree</code> that a node has been selected. Changes the
|
||||
* currently selected tree component.
|
||||
*/
|
||||
public void respond(PageState data) throws javax.servlet.ServletException {
|
||||
String action = data.getControlEventName();
|
||||
|
|
@ -489,10 +494,11 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
expand(node, data);
|
||||
} else if (COLLAPSE_EVENT.equals(action)) {
|
||||
collapse(node, data);
|
||||
} else if ( SELECT_EVENT.equals(action) ) {
|
||||
} else if (SELECT_EVENT.equals(action)) {
|
||||
setSelectedKey(data, data.getControlEventValue());
|
||||
} else {
|
||||
throw new javax.servlet.ServletException("Unknown event '" + action + "'");
|
||||
throw new javax.servlet.ServletException("Unknown event '" + action
|
||||
+ "'");
|
||||
}
|
||||
fireActionEvent(data);
|
||||
}
|
||||
|
|
@ -500,11 +506,11 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
//////////////////////////////
|
||||
// MANAGE TREE'S NODE STATE //
|
||||
//////////////////////////////
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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.
|
||||
*
|
||||
* @param nodeKey the key that the tree model uses to identify the
|
||||
* node
|
||||
* @param data represents the current request
|
||||
* @param nodeKey the key that the tree model uses to identify the node
|
||||
* @param data represents the current request
|
||||
*
|
||||
* @pre nodeKey != 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
|
||||
if (idIndex != -1) {
|
||||
newCurrentState
|
||||
.append(stateString.substring(0,idIndex))
|
||||
.append(stateString.substring(0, idIndex))
|
||||
.append(" ");
|
||||
if (stateString.length() > (idIndex + idLength)) {
|
||||
newCurrentState.append(stateString.substring(idIndex+idLength));
|
||||
newCurrentState.append(stateString.substring(idIndex
|
||||
+ idLength));
|
||||
}
|
||||
data.setValue(m_currentState, newCurrentState.toString());
|
||||
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.
|
||||
*
|
||||
* @param nodeKey the key that the tree model uses to identify the
|
||||
* node
|
||||
* @param data represents the current request
|
||||
* @param nodeKey the key that the tree model uses to identify the node
|
||||
* @param data represents the current request
|
||||
*
|
||||
* @pre nodeKey != null
|
||||
* @pre data != null
|
||||
|
|
@ -598,7 +603,6 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
/////////////////////////////////////////////
|
||||
// PRINT THE TREE DIRECTLY OR GENERATE DOM //
|
||||
/////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Returns the renderer currently used to render tree nodes.
|
||||
*
|
||||
|
|
@ -619,9 +623,11 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
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();
|
||||
if ( (selKey != null) && (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey)) ) {
|
||||
if ((selKey != null) && (selKey.equals(nodeKey) || selKey.toString()
|
||||
.equals(nodeKey))) {
|
||||
return true;
|
||||
}
|
||||
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).
|
||||
// Since the data query is wrapped within DataQueryIterator, we don't have
|
||||
// access to it directly, so this looks like the only viable option ...
|
||||
while (i.hasNext()) { }
|
||||
while (i.hasNext()) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -643,14 +650,15 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
*
|
||||
*/
|
||||
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);
|
||||
boolean isSelected = (selKey != null)
|
||||
&& (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey));
|
||||
&& (selKey.equals(nodeKey) || selKey.toString()
|
||||
.equals(nodeKey));
|
||||
|
||||
boolean hasChildren = tree.hasChildren(node, data);
|
||||
if (s_selectAttributeEnabled) {
|
||||
|
|
@ -658,36 +666,44 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
if (!isSelected && hasChildren) {
|
||||
hasSelectedChild = hasSelectedChild(tree, node, data, selKey);
|
||||
}
|
||||
t_node.addAttribute("isSelected", String.valueOf(isSelected | hasSelectedChild));
|
||||
t_node.addAttribute("isSelected", String.valueOf(isSelected
|
||||
| hasSelectedChild));
|
||||
}
|
||||
|
||||
if (hasChildren) {
|
||||
boolean collapsed = isCollapsed(nodeKey,data);
|
||||
data.setControlEvent(this, collapsed ? EXPAND_EVENT : COLLAPSE_EVENT, nodeKey);
|
||||
boolean collapsed = isCollapsed(nodeKey, data);
|
||||
data
|
||||
.setControlEvent(this, collapsed ? EXPAND_EVENT : COLLAPSE_EVENT,
|
||||
nodeKey);
|
||||
try {
|
||||
t_node.addAttribute("href", data.stateAsURL());
|
||||
} catch (java.io.IOException ioe) {
|
||||
// TODO: stateAsURL failed
|
||||
}
|
||||
data.clearControlEvent();
|
||||
if ( collapsed ) {
|
||||
if (collapsed) {
|
||||
// Collapsed
|
||||
t_node.addAttribute("collapsed", "t");
|
||||
data.setControlEvent(this, SELECT_EVENT, nodeKey);
|
||||
Component c = getCellRenderer().getComponent(this, data,
|
||||
node.getElement(), isSelected, NOT_EXPANDED, NOT_LEAF,
|
||||
nodeKey);
|
||||
node.getElement(),
|
||||
isSelected,
|
||||
NOT_EXPANDED,
|
||||
NOT_LEAF,
|
||||
nodeKey);
|
||||
c.generateXML(data, t_node);
|
||||
} else {
|
||||
// Expanded
|
||||
t_node.addAttribute("expanded", "t");
|
||||
data.setControlEvent(this, SELECT_EVENT, nodeKey);
|
||||
Component c = getCellRenderer().getComponent(this, data,
|
||||
node.getElement(), isSelected, EXPANDED, NOT_LEAF,
|
||||
nodeKey);
|
||||
node.getElement(),
|
||||
isSelected,
|
||||
EXPANDED, NOT_LEAF,
|
||||
nodeKey);
|
||||
c.generateXML(data, t_node);
|
||||
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);
|
||||
}
|
||||
t_node.addAttribute("indentClose", "t");
|
||||
|
|
@ -697,24 +713,27 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
t_node.addAttribute("childless", "t");
|
||||
data.setControlEvent(this, SELECT_EVENT, nodeKey);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Services the request by building a DOM tree with the nodes
|
||||
* first and then the included page.
|
||||
* Services the request by building a DOM tree with the nodes first and then
|
||||
* the included page.
|
||||
*/
|
||||
public void generateXML(PageState data, Element parent) {
|
||||
|
||||
TreeModel tree = getTreeModel(data);
|
||||
|
||||
if ( ! isVisible(data) ) {
|
||||
if (!isVisible(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
treeElement = parent.newChildElement ("bebop:tree", BEBOP_XML_NS);
|
||||
treeElement = parent.newChildElement("bebop:tree", BEBOP_XML_NS);
|
||||
exportAttributes(treeElement);
|
||||
|
||||
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.
|
||||
*
|
||||
* @deprecated The {@link ParameterSingleSelectionModel} contains
|
||||
* all the functionality of this class
|
||||
* @deprecated The {@link ParameterSingleSelectionModel} contains all the
|
||||
* functionality of this class
|
||||
*/
|
||||
public static class TreeSingleSelectionModel
|
||||
extends ParameterSingleSelectionModel {
|
||||
|
||||
public TreeSingleSelectionModel(ParameterModel 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
|
||||
* deprecated constructor work.
|
||||
* Returns the tree model of the tree. A wrapper class to make deprecated
|
||||
* constructor work.
|
||||
*/
|
||||
private static class WrapperModelBuilder extends LockableImpl
|
||||
implements TreeModelBuilder {
|
||||
|
|
@ -757,6 +778,7 @@ public class Tree extends SimpleComponent implements Resettable {
|
|||
public TreeModel makeModel(Tree t, PageState s) {
|
||||
return t.getTreeModel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import java.util.List;
|
|||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <p>Multiple select widget pair for knowledge types. This FormStep
|
||||
|
|
@ -68,9 +67,6 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class MultipleSelectPairWidget extends FormStep {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(MultipleSelectPairWidget.class);
|
||||
|
||||
private Hidden m_addSelectOptions;
|
||||
private Hidden m_removeSelectOptions;
|
||||
private MultipleSelect m_addSelect;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ import com.arsdigita.bebop.util.BebopConstants;
|
|||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.text.Collator;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -40,7 +43,6 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
|
||||
|
|
@ -51,11 +53,10 @@ import org.libreccm.l10n.GlobalizationHelper;
|
|||
* @author Uday Mathur
|
||||
* @author Rory Solomon
|
||||
* @author Michael Pih
|
||||
* @version $Id$
|
||||
*/
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -36,8 +36,11 @@ import com.arsdigita.bebop.parameters.ParameterData;
|
|||
// in a constant which is used when generating XML
|
||||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.TooManyListenersException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* desire.
|
||||
* <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
|
||||
*
|
||||
* @author Patrick McNeill
|
||||
* @version $Id$
|
||||
* @since 4.5
|
||||
*/
|
||||
public class SearchAndSelect extends FormSection
|
||||
implements BebopConstants, PrintListener {
|
||||
public class SearchAndSelect extends FormSection implements BebopConstants,
|
||||
PrintListener {
|
||||
|
||||
private static final Logger s_cat
|
||||
= Logger.getLogger(SearchAndSelect.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
SearchAndSelect.class);
|
||||
|
||||
protected String m_name;
|
||||
// name of this super-widget
|
||||
|
|
@ -120,7 +122,7 @@ public class SearchAndSelect extends FormSection
|
|||
m_outputSelectWidget = new CheckboxGroup(getName() + ".select");
|
||||
} else {
|
||||
m_outputSelectWidget
|
||||
= new MultipleSelect(getName() + ".select");
|
||||
= new MultipleSelect(getName() + ".select");
|
||||
}
|
||||
} else {
|
||||
m_outputSelectWidget = new SingleSelect(getName() + ".select");
|
||||
|
|
@ -130,15 +132,16 @@ public class SearchAndSelect extends FormSection
|
|||
try {
|
||||
m_outputSelectWidget.addPrintListener(this);
|
||||
} catch (TooManyListenersException e) {
|
||||
s_cat.error("Could not add print listener", e);
|
||||
LOGGER.error("Could not add print listener", 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) {
|
||||
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) {
|
||||
|
|
@ -149,9 +152,9 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
if (m_isSearchLocked
|
||||
|| (((!m_oldValue.equals("")
|
||||
&& m_oldValue.equals(m_value))
|
||||
|| (m_maxViewableResults >= m_results.resultsCount()))
|
||||
&& (m_results.resultsCount() > 0))) {
|
||||
&& m_oldValue.equals(m_value))
|
||||
|| (m_maxViewableResults >= m_results.resultsCount()))
|
||||
&& (m_results.resultsCount() > 0))) {
|
||||
|
||||
OptionGroup outputWidget = (OptionGroup) e.getTarget();
|
||||
outputWidget.clearOptions();
|
||||
|
|
@ -162,9 +165,9 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
for (int i = 0; i < m_results.resultsCount(); i++) {
|
||||
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
|
||||
* SearchAndSelectModel.
|
||||
*
|
||||
* @param name the name of the widget
|
||||
* @param isMultiple whether or not the widget accepts multiple values
|
||||
* @param name the name of the widget
|
||||
* @param isMultiple whether or not the widget accepts multiple values
|
||||
* @param useCheckboxes use checkboxes or a multiselect
|
||||
*/
|
||||
public SearchAndSelect(String name,
|
||||
boolean isMultiple) {
|
||||
boolean isMultiple) {
|
||||
this(name, isMultiple, false);
|
||||
}
|
||||
|
||||
|
|
@ -195,13 +198,13 @@ public class SearchAndSelect extends FormSection
|
|||
* Create a new SearchAndSelect widget with the specified name and
|
||||
* SearchAndSelectModel.
|
||||
*
|
||||
* @param name the name of the widget
|
||||
* @param isMultiple whether or not the widget accepts multiple values
|
||||
* @param name the name of the widget
|
||||
* @param isMultiple whether or not the widget accepts multiple values
|
||||
* @param useCheckboxes use checkboxes or a multiselect
|
||||
*/
|
||||
public SearchAndSelect(String name,
|
||||
boolean isMultiple,
|
||||
boolean useCheckboxes) {
|
||||
boolean isMultiple,
|
||||
boolean useCheckboxes) {
|
||||
|
||||
super(new SimpleContainer());
|
||||
|
||||
|
|
@ -219,12 +222,13 @@ public class SearchAndSelect extends FormSection
|
|||
* user as the error field is also used as a help field.
|
||||
*/
|
||||
super.addValidationListener(new FormValidationListener() {
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) {
|
||||
FormData data = e.getFormData();
|
||||
|
||||
m_results = m_listener.getModel(
|
||||
new PageEvent(m_this, e.getPageState()));
|
||||
new PageEvent(m_this, e.getPageState()));
|
||||
|
||||
if (m_results == null) {
|
||||
return;
|
||||
|
|
@ -244,7 +248,7 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
if (m_isMultiple) {
|
||||
String[] tmpArray = (String[]) data
|
||||
.get(getName() + ".select");
|
||||
.get(getName() + ".select");
|
||||
if (tmpArray == null) {
|
||||
m_value = "";
|
||||
} else {
|
||||
|
|
@ -286,22 +290,22 @@ public class SearchAndSelect extends FormSection
|
|||
if (m_isSearchLocked) {
|
||||
if (!m_isMultiple) {
|
||||
StringParameter param
|
||||
= new StringParameter(getName());
|
||||
= new StringParameter(getName());
|
||||
|
||||
data.setParameter(getName(),
|
||||
new ParameterData(param, m_value));
|
||||
new ParameterData(param, m_value));
|
||||
} else {
|
||||
ArrayParameter param
|
||||
= new ArrayParameter(getName());
|
||||
= new ArrayParameter(getName());
|
||||
String[] tmpArray = (String[]) data
|
||||
.get(getName() + ".select");
|
||||
.get(getName() + ".select");
|
||||
|
||||
if (tmpArray == null) {
|
||||
tmpArray = new String[0];
|
||||
}
|
||||
|
||||
data.setParameter(getName(),
|
||||
new ParameterData(param, tmpArray));
|
||||
new ParameterData(param, tmpArray));
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -311,10 +315,12 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
m_results.setQuery(oldQuery);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public final void setSearchAndSelectListener(SearchAndSelectListener listener) {
|
||||
public final void setSearchAndSelectListener(
|
||||
SearchAndSelectListener listener) {
|
||||
m_listener = listener;
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +412,7 @@ public class SearchAndSelect extends FormSection
|
|||
* textbox, checkbox group, or select, and possibly some number of
|
||||
* formErrors.
|
||||
*
|
||||
* @param state the state of the page
|
||||
* @param state the state of the page
|
||||
* @param parent the parent widget
|
||||
*/
|
||||
public void generateXML(PageState state, Element parent) {
|
||||
|
|
@ -420,9 +426,9 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
if (m_isSearchLocked
|
||||
|| (((!m_oldValue.equals("")
|
||||
&& m_oldValue.equals(m_value))
|
||||
|| (m_maxViewableResults >= m_results.resultsCount()))
|
||||
&& (m_results.resultsCount() > 0))) {
|
||||
&& m_oldValue.equals(m_value))
|
||||
|| (m_maxViewableResults >= m_results.resultsCount()))
|
||||
&& (m_results.resultsCount() > 0))) {
|
||||
m_outputSelectWidget.generateXML(state, parent);
|
||||
} else {
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
protected void generateErrors(PageState state, Element parent) {
|
||||
|
|
@ -453,29 +459,33 @@ public class SearchAndSelect extends FormSection
|
|||
|
||||
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(""))) {
|
||||
error.addAttribute("message",
|
||||
"Please enter a comma-delimited search");
|
||||
"Please enter a comma-delimited search");
|
||||
} else if ((!m_oldValue.equals(curValue))
|
||||
&& !m_isSearchLocked) {
|
||||
&& !m_isSearchLocked) {
|
||||
error.addAttribute("message",
|
||||
"Your search returned "
|
||||
+ m_results.resultsCount() + " matches. "
|
||||
+ "Please refine your search or leave the "
|
||||
+ "search as it is to see all results.");
|
||||
"Your search returned "
|
||||
+ m_results.resultsCount()
|
||||
+ " matches. "
|
||||
+ "Please refine your search or leave the "
|
||||
+ "search as it is to see all results.");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_results.resultsCount() == 0) {
|
||||
if (!curValue.equals("")) {
|
||||
Element error = parent.newChildElement("bebop:formErrors", BEBOP_XML_NS);
|
||||
Element error = parent.newChildElement("bebop:formErrors",
|
||||
BEBOP_XML_NS);
|
||||
error.addAttribute("message",
|
||||
"Your search returned no matches. Please "
|
||||
+ "try again");
|
||||
"Your search returned no matches. Please "
|
||||
+ "try again");
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import java.util.TooManyListenersException;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.bebop.DescriptiveComponent;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
|
|
@ -46,39 +44,33 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
|||
import com.arsdigita.util.Assert;
|
||||
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.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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 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
|
||||
* well as a (localized) hint as a kind of online manual for the user.
|
||||
* </p>
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
* @author Rory Solomon
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class Widget extends DescriptiveComponent
|
||||
implements Cloneable, BebopConstants {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(Widget.class);
|
||||
|
||||
private ParameterModel m_parameterModel;
|
||||
private final EventListenerList m_listeners = new EventListenerList();
|
||||
private ParameterListener m_forwardParameter = null;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ import com.arsdigita.web.TransformationDebugger;
|
|||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Document;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
|
@ -54,7 +57,6 @@ import javax.xml.transform.TransformerException;
|
|||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
|
||||
|
|
@ -70,18 +72,18 @@ import org.libreccm.l10n.GlobalizationHelper;
|
|||
* <em>package</em> mounted on each site node.
|
||||
*
|
||||
* @author Bill Schneider
|
||||
* @version $Id: PageTransformer.java 2071 2010-01-28 18:24:06Z pboy $
|
||||
*/
|
||||
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
|
||||
// stylesheets
|
||||
private static final HashMap s_XSLParameters = new HashMap();
|
||||
|
||||
// load the default xsl parameter generators
|
||||
static {
|
||||
s_log.debug("Static initalizer starting...");
|
||||
LOGGER.debug("Static initalizer starting...");
|
||||
|
||||
registerXSLParameterGenerator("contextPath",
|
||||
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.
|
||||
|
||||
|
|
@ -345,7 +347,7 @@ public class PageTransformer implements PresentationManager {
|
|||
try {
|
||||
return resp.getWriter();
|
||||
} catch (IllegalStateException e) {
|
||||
s_log.warn("Using getOutputStream instead of getWriter");
|
||||
LOGGER.warn("Using getOutputStream instead of getWriter");
|
||||
|
||||
try {
|
||||
return new PrintWriter(new OutputStreamWriter(resp.
|
||||
|
|
@ -402,7 +404,7 @@ public class PageTransformer implements PresentationManager {
|
|||
.getDefaultCharset(DispatcherHelper.getNegotiatedLocale());
|
||||
|
||||
final String output = req.getParameter("output");
|
||||
s_log.info("output=" + output);
|
||||
LOGGER.info("output=" + output);
|
||||
|
||||
if (output == null) {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ package com.arsdigita.bebop.parameters;
|
|||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
* @version $Id$
|
||||
*/
|
||||
public class IntegerParameter extends NumberParameter {
|
||||
|
||||
|
|
@ -32,6 +31,7 @@ public class IntegerParameter extends NumberParameter {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unmarshal(String encoded) {
|
||||
if( encoded == null || encoded.length() == 0 ) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ import java.util.List;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
|
@ -42,13 +40,9 @@ import java.util.Objects;
|
|||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
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
|
||||
* exception if the specified name is null
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.tidy.Tidy;
|
||||
|
||||
/**
|
||||
|
|
@ -76,14 +75,9 @@ import org.w3c.tidy.Tidy;
|
|||
* providing a validation listener based on JTidy. </p>
|
||||
*
|
||||
* @author Vadim Nasardinov (vadimn@redhat.com)
|
||||
* @version $Id$
|
||||
* @since 2002-08-16 21:46:25 -0400
|
||||
**/
|
||||
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 LockableProperties s_tidyProperties;
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ package com.arsdigita.bebop.parameters;
|
|||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
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.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
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)
|
||||
throws FormProcessException {
|
||||
|
|
@ -39,8 +39,8 @@ public class WordValidationListener implements ParameterListener {
|
|||
|
||||
if( null == value ) return;
|
||||
|
||||
if( s_log.isDebugEnabled() ) {
|
||||
s_log.debug( "Name: " + d.getName() + ", Value: " + value );
|
||||
if( LOGGER.isDebugEnabled() ) {
|
||||
LOGGER.debug( "Name: " + d.getName() + ", Value: " + value );
|
||||
}
|
||||
|
||||
Perl5Util re = new Perl5Util();
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@ package com.arsdigita.bebop.util;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <p></p>
|
||||
|
|
@ -34,10 +37,10 @@ import org.apache.log4j.Logger;
|
|||
* This filter may be used to skip only individual components or entire
|
||||
* subtrees. The default filter matches all components.</p>
|
||||
*
|
||||
* @version $Id: Traversal.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
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>,
|
||||
|
|
@ -63,7 +66,7 @@ public abstract class Traversal {
|
|||
private Set m_visiting = null;
|
||||
|
||||
{
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
m_visiting = new HashSet();
|
||||
}
|
||||
}
|
||||
|
|
@ -84,8 +87,8 @@ public abstract class Traversal {
|
|||
*
|
||||
* @param c the component on which to call {@link #act}. */
|
||||
public void preorder(Component c) {
|
||||
if (s_log.isDebugEnabled() && m_visiting.contains(c)) {
|
||||
s_log.debug("Cycle detected at component " + c +
|
||||
if (LOGGER.isDebugEnabled() && m_visiting.contains(c)) {
|
||||
LOGGER.debug("Cycle detected at component " + c +
|
||||
"; visiting nodes: " + m_visiting);
|
||||
throw new IllegalStateException
|
||||
("Component " + c + " is part of a cycle");
|
||||
|
|
@ -100,7 +103,7 @@ public abstract class Traversal {
|
|||
}
|
||||
|
||||
if (flag != SKIP_SUBTREE) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
m_visiting.add(c);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +112,7 @@ public abstract class Traversal {
|
|||
}
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
m_visiting.remove(c);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ import javax.servlet.http.HttpSession;
|
|||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
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.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
|
@ -81,7 +82,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
public abstract class BaseDispatcherServlet extends HttpServlet
|
||||
implements Dispatcher, DispatcherConstants {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
BaseDispatcherServlet.class);
|
||||
private final static int NOT_FOUND = 0;
|
||||
private final static int STATIC_FILE = 1;
|
||||
|
|
@ -99,9 +100,10 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
* list of active requests
|
||||
*/
|
||||
private static Vector s_activeList = new Vector();
|
||||
private static final long serialVersionUID = 7349556332411247334L;
|
||||
|
||||
static {
|
||||
s_log.debug("Static initalizer starting...");
|
||||
LOGGER.debug("Static initalizer starting...");
|
||||
// Add the basic request listeners.
|
||||
|
||||
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();
|
||||
|
|
@ -157,11 +159,11 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
SAXParser parser = spf.newSAXParser();
|
||||
parser.parse(file, new WebXMLReader());
|
||||
} catch (SAXException se) {
|
||||
s_log.error("error in init", se);
|
||||
LOGGER.error("error in init", se);
|
||||
} catch (ParserConfigurationException pce) {
|
||||
s_log.error("error in init", pce);
|
||||
LOGGER.error("error in init", pce);
|
||||
} catch (IOException ioe) {
|
||||
s_log.error("error in init", ioe);
|
||||
LOGGER.error("error in init", ioe);
|
||||
}
|
||||
// default to index.jsp, index.html
|
||||
if (m_welcomeFiles.isEmpty()) {
|
||||
|
|
@ -225,8 +227,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
public void service(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("\n*** *** *** *** *** ***\n"
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("\n*** *** *** *** *** ***\n"
|
||||
+ "Servicing request for URL '" + req
|
||||
.getRequestURI()
|
||||
+ "'\n" + "*** *** *** *** *** ***");
|
||||
|
|
@ -268,7 +270,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
// (defer serving concrete JSPs until after listeners run)
|
||||
int concreteFileType = concreteFileType(req);
|
||||
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.forwardRequestByName("default", req, resp,
|
||||
getServletContext());
|
||||
|
|
@ -294,7 +296,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
StartRequestRecord srr = startRequest(req, resp);
|
||||
reqCtx = srr.m_reqCtx;
|
||||
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) {
|
||||
final String url = re.getRedirectURL();
|
||||
|
||||
|
|
@ -347,7 +349,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
// try to commit
|
||||
finishedNormal = true;
|
||||
} catch (IOException ioe) {
|
||||
s_log.error("error in BaseDispatcherServlet", ioe);
|
||||
LOGGER.error("error in BaseDispatcherServlet", ioe);
|
||||
throw ioe;
|
||||
} catch (ServletException se) {
|
||||
// SDM #140226, improved handling of
|
||||
|
|
@ -368,17 +370,17 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
finishedNormal = true;
|
||||
} else if (rootError != null
|
||||
&& (rootError instanceof RedirectSignal)) {
|
||||
s_log.debug("rethrowing RedirectSignal", rootError);
|
||||
LOGGER.debug("rethrowing RedirectSignal", rootError);
|
||||
throw (RedirectSignal) rootError;
|
||||
} else {
|
||||
s_log.error("error in BaseDispatcherServlet", rootError);
|
||||
LOGGER.error("error in BaseDispatcherServlet", rootError);
|
||||
throw new ServletException(rootError);
|
||||
}
|
||||
} catch (RuntimeException re) {
|
||||
s_log.error("error in BaseDispatcherServlet", re);
|
||||
LOGGER.error("error in BaseDispatcherServlet", re);
|
||||
throw re;
|
||||
} catch (Error error) {
|
||||
s_log.error("error in BaseDispatcherServlet", error);
|
||||
LOGGER.error("error in BaseDispatcherServlet", error);
|
||||
throw error;
|
||||
} finally {
|
||||
if (!reentrant) {
|
||||
|
|
@ -449,7 +451,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
|||
try {
|
||||
((RequestListener) s_listenerList.get(i)).requestFinished(evt);
|
||||
} catch (Exception e) {
|
||||
s_log.error("Error running request finished listener "
|
||||
LOGGER.error("Error running request finished listener "
|
||||
+ s_listenerList.
|
||||
get(i) + " (#" + i + ")", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import com.arsdigita.web.RedirectSignal;
|
|||
import com.arsdigita.web.URL;
|
||||
import com.arsdigita.web.Web;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
|
@ -49,7 +51,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
|
|
@ -59,7 +61,6 @@ import java.net.URLEncoder;
|
|||
*
|
||||
* @author Bill Schneider
|
||||
* @since 4.5
|
||||
* @version $Id$
|
||||
*/
|
||||
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
|
||||
* 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_staticURL;
|
||||
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
|
||||
// party servlet we're screwed
|
||||
req = restoreOriginalRequest(req);
|
||||
s_log.debug("Forwarding the request object " + req);
|
||||
LOGGER.debug("Forwarding the request object " + req);
|
||||
if (attr != null) {
|
||||
rd.include(req, resp);
|
||||
req.setAttribute(INCLUDE_URI, attr);
|
||||
|
|
@ -397,7 +398,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
RequestContext actx)
|
||||
throws RedirectException, DirectoryListingException,
|
||||
java.io.FileNotFoundException {
|
||||
s_log.debug("Resolving abstract file");
|
||||
LOGGER.debug("Resolving abstract file");
|
||||
|
||||
File dirToSearch = null;
|
||||
String fStr = abstractFile.getAbsolutePath();
|
||||
|
|
@ -539,7 +540,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
.restoreRequestWrapper(orig);
|
||||
|
||||
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);
|
||||
|
||||
MultipartHttpServletRequest previousmp
|
||||
|
|
@ -551,9 +552,9 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
DispatcherHelper.saveOriginalRequest(sreq,
|
||||
orig);
|
||||
|
||||
s_log.debug("The main request is now " + sreq);
|
||||
LOGGER.debug("The main request is now " + sreq);
|
||||
} else {
|
||||
s_log.debug(
|
||||
LOGGER.debug(
|
||||
"The request is a new multipart; wrapping the request "
|
||||
+ "object");
|
||||
try {
|
||||
|
|
@ -565,7 +566,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
DispatcherHelper.saveOriginalRequest(sreq, orig);
|
||||
}
|
||||
} else {
|
||||
s_log.debug("The request is not multipart; proceeding "
|
||||
LOGGER.debug("The request is not multipart; proceeding "
|
||||
+ "without wrapping the request");
|
||||
}
|
||||
return sreq;
|
||||
|
|
@ -634,8 +635,8 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
public static void sendExternalRedirect(HttpServletResponse resp,
|
||||
String url)
|
||||
throws IOException {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Redirecting to URL '" + url + "'", new Throwable());
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Redirecting to URL '" + url + "'", new Throwable());
|
||||
}
|
||||
|
||||
if (StringUtils.emptyString(url)) {
|
||||
|
|
@ -670,23 +671,23 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
|
||||
if (sep == -1) {
|
||||
destination = URL.there(req, url);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Setting destination to " + destination);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Setting destination to " + destination);
|
||||
}
|
||||
} else {
|
||||
final ParameterMap params = ParameterMap.fromString(url
|
||||
.substring(sep + 1));
|
||||
|
||||
destination = URL.there(req, url.substring(0, sep), params);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Setting destination with map to "
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Setting destination with map to "
|
||||
+ destination);
|
||||
}
|
||||
}
|
||||
throw new RedirectSignal(destination, true);
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Redirecting to URL without using URL.there. "
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Redirecting to URL without using URL.there. "
|
||||
+ "URL is " + url);
|
||||
}
|
||||
throw new RedirectSignal(url, true);
|
||||
|
|
@ -844,7 +845,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
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 = "";
|
||||
}
|
||||
if (!s_webappCtx.equals(webappCtx)) {
|
||||
s_log.warn(
|
||||
LOGGER.warn(
|
||||
"webappContext changed. Expected='" + s_webappCtx
|
||||
+ "' found='" + webappCtx
|
||||
+ "'.\nPerhaps the enterprise.init "
|
||||
|
|
@ -967,7 +968,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
// XXX Probably need to assert here if isCommitted() returns true.
|
||||
// But first need to figure out what is setting 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);
|
||||
|
|
@ -983,7 +984,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
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!
|
||||
response.setHeader("Pragma", "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"),
|
||||
"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 the original person making the request
|
||||
|
|
@ -1158,7 +1159,7 @@ public final class DispatcherHelper implements DispatcherConstants {
|
|||
Calendar expires = Calendar.getInstance();
|
||||
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("Expires",
|
||||
rfc1123_formatter.format(expires.getTime()));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import java.util.Locale;
|
|||
import java.util.ResourceBundle;
|
||||
import javax.servlet.ServletContext;
|
||||
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
|
||||
|
|
@ -30,12 +31,11 @@ import org.apache.log4j.Logger;
|
|||
* for an incoming request.
|
||||
*
|
||||
* @author Bill Schneider
|
||||
* @version $Id$
|
||||
* @since 4.5
|
||||
*/
|
||||
public class InitialRequestContext implements RequestContext {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
private static final Logger LOGGER = LogManager.getLogger
|
||||
(InitialRequestContext.class);
|
||||
|
||||
private String m_urlSoFar;
|
||||
|
|
@ -105,25 +105,25 @@ public class InitialRequestContext implements RequestContext {
|
|||
*/
|
||||
void initializeURLFromRequest(HttpServletRequest request,
|
||||
boolean preserveOriginalURL) {
|
||||
s_log.debug("Initializing processed and remaining URL parts.");
|
||||
LOGGER.debug("Initializing processed and remaining URL parts.");
|
||||
|
||||
String requestUrl = DispatcherHelper.getCurrentResourcePath(request);
|
||||
m_urlSoFar = request.getContextPath();
|
||||
m_urlRemainder = requestUrl;
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
String contextPath = request.getContextPath();
|
||||
s_log.debug("contextPath: " + contextPath);
|
||||
LOGGER.debug("contextPath: " + contextPath);
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
String servletPath = request.getServletPath();
|
||||
s_log.debug("servletPath: " + servletPath);
|
||||
LOGGER.debug("servletPath: " + servletPath);
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
String pathInfo = request.getPathInfo();
|
||||
s_log.debug("pathInfo: " + pathInfo);
|
||||
LOGGER.debug("pathInfo: " + pathInfo);
|
||||
}
|
||||
|
||||
final String debugURL = "/debug";
|
||||
|
|
@ -147,14 +147,14 @@ public class InitialRequestContext implements RequestContext {
|
|||
m_urlRemainder = m_urlRemainder.substring(debugURLXSL.length());
|
||||
}
|
||||
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");
|
||||
m_originalUrl = m_urlSoFar + m_urlRemainder;
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Set processed URL to '" + m_urlSoFar + "'");
|
||||
s_log.debug("Set remaining URL to '" + m_urlRemainder + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Set processed URL to '" + m_urlSoFar + "'");
|
||||
LOGGER.debug("Set remaining URL to '" + m_urlRemainder + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,14 @@ package com.arsdigita.dispatcher;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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
|
||||
|
|
@ -64,10 +67,11 @@ import org.apache.log4j.Logger;
|
|||
public class JSPApplicationDispatcher extends BaseDispatcherServlet
|
||||
implements Dispatcher {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
private static final Logger LOGGER = LogManager.getLogger
|
||||
(JSPApplicationDispatcher.class);
|
||||
|
||||
private static JSPApplicationDispatcher s_instance = newInstance();
|
||||
private static final long serialVersionUID = 1662461509796743896L;
|
||||
|
||||
/**
|
||||
* Returns a new instance of a JSPApplicationDispatcher.
|
||||
|
|
@ -108,8 +112,8 @@ public class JSPApplicationDispatcher extends BaseDispatcherServlet
|
|||
ServletContext sctx = actx.getServletContext();
|
||||
String remainingURL = actx.getRemainingURLPart();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("I think the remaining URL is '" + remainingURL + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("I think the remaining URL is '" + remainingURL + "'");
|
||||
}
|
||||
|
||||
// This is where we forward a request from /foo1/bar.ext or
|
||||
|
|
@ -120,19 +124,19 @@ public class JSPApplicationDispatcher extends BaseDispatcherServlet
|
|||
actx.getPageBase() +
|
||||
actx.getRemainingURLPart();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Looking for a concrete resource under the web app " +
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Looking for a concrete resource under the web app " +
|
||||
"context at '" + concreteURL + "'");
|
||||
}
|
||||
|
||||
File concreteFile = new File(sctx.getRealPath(concreteURL));
|
||||
|
||||
if (concreteFile.exists()) {
|
||||
s_log.debug("Resource was found; forwarding");
|
||||
LOGGER.debug("Resource was found; forwarding");
|
||||
DispatcherHelper.setRequestContext(req, actx);
|
||||
DispatcherHelper.forwardRequestByPath(concreteURL, req, resp);
|
||||
} else {
|
||||
s_log.debug("Resource not found");
|
||||
LOGGER.debug("Resource not found");
|
||||
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,13 @@ import javax.servlet.http.HttpSession;
|
|||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.log4j.Category;
|
||||
|
||||
import com.arsdigita.globalization.Globalization;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
|
|
@ -68,13 +70,11 @@ import javax.servlet.http.Part;
|
|||
* @author Karl Goldstein
|
||||
* @author Michael Pih
|
||||
* @author Uday Mathur
|
||||
* @version $Id: MultipartHttpServletRequest.java 1512 2007-03-22 02:36:06Z
|
||||
* apevec $
|
||||
* @since 4.5
|
||||
*/
|
||||
public class MultipartHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
private static final Category s_log = Category.getInstance(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
MultipartHttpServletRequest.class);
|
||||
|
||||
private HttpServletRequest m_request;
|
||||
|
|
@ -532,7 +532,7 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void login(final String username,
|
||||
public void login(final String username,
|
||||
final String password) throws ServletException {
|
||||
m_request.login(username, password);
|
||||
}
|
||||
|
|
@ -575,7 +575,7 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
|
||||
@Override
|
||||
public AsyncContext startAsync(final ServletRequest servletRequest,
|
||||
final ServletResponse servletResponse)
|
||||
final ServletResponse servletResponse)
|
||||
throws IllegalStateException {
|
||||
return m_request.startAsync(servletRequest, servletResponse);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,35 +25,35 @@ import com.arsdigita.dispatcher.RequestContext;
|
|||
//import com.arsdigita.persistence.Session;
|
||||
//import com.arsdigita.persistence.SessionManager;
|
||||
//import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Utilities for the globalization process. The methods in this class make
|
||||
* use of the assumption that the ACS handles all locale and resource
|
||||
* negotiation so that the application developer doesn't have to worry about
|
||||
* it.
|
||||
* Utilities for the globalization process. The methods in this class make use
|
||||
* of the assumption that the ACS handles all locale and resource negotiation so
|
||||
* that the application developer doesn't have to worry about it.
|
||||
* </p>
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
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";
|
||||
|
||||
/**
|
||||
* The default encoding for parameterts, as specified by the
|
||||
* servlet spec
|
||||
* The default encoding for parameterts, as specified by the servlet spec
|
||||
*/
|
||||
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";
|
||||
|
||||
// private static Map s_localeToCharsetMap;
|
||||
|
||||
private static String s_defaultCharset = DEFAULT_ENCODING;
|
||||
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
|
||||
static void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
|
|
@ -77,7 +76,6 @@ public class Globalization {
|
|||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
// // Load the Locale to Charset Map from persistent storage.
|
||||
// public static void loadLocaleToCharsetMap() {
|
||||
// // retrieve all Locale objects that have a defaultCharset associated
|
||||
|
|
@ -123,11 +121,10 @@ public class Globalization {
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
static void setDefaultCharset(String encoding) {
|
||||
s_defaultCharset = encoding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the default character set for encoding data
|
||||
*
|
||||
|
|
@ -183,11 +180,11 @@ public class Globalization {
|
|||
// }
|
||||
// return getDefaultCharset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the default character set for the request. First
|
||||
* tries the getCharacterENcoding() method, then falls
|
||||
* back on the DEFAULT_PARAM_ENCODING
|
||||
* Get the default character set for the request. First tries the
|
||||
* getCharacterENcoding() method, then falls back on the
|
||||
* DEFAULT_PARAM_ENCODING
|
||||
*
|
||||
* @return String the character set
|
||||
*/
|
||||
|
|
@ -198,9 +195,9 @@ public class Globalization {
|
|||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the best locale for this request.
|
||||
* Get the best locale for this request.
|
||||
*/
|
||||
private static java.util.Locale getLocale(HttpServletRequest req) {
|
||||
java.util.Locale l = DispatcherHelper.getNegotiatedLocale();
|
||||
|
|
@ -215,57 +212,56 @@ public class Globalization {
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* Decode the value of an HttpServletRequest parameter. The value is
|
||||
* decoded appropriately (lets hope so anyway).
|
||||
* Decode the value of an HttpServletRequest parameter. The value is decoded
|
||||
* appropriately (lets hope so anyway).
|
||||
* </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.
|
||||
*
|
||||
* @return String The decoded value of the parameter.
|
||||
*/
|
||||
public static final String decodeParameter(
|
||||
HttpServletRequest r, String name
|
||||
) {
|
||||
HttpServletRequest r, String name
|
||||
) {
|
||||
String re = r.getParameter(Globalization.ENCODING_PARAM_NAME);
|
||||
String original = r.getParameter(name);
|
||||
String real = null;
|
||||
|
||||
if (re == null ||
|
||||
re.length() == 0) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug(ENCODING_PARAM_NAME + " is not set, using locale " +
|
||||
"default encoding for parameter " + name);
|
||||
if (re == null || re.length() == 0) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(ENCODING_PARAM_NAME + " is not set, using locale "
|
||||
+ "default encoding for parameter " + name);
|
||||
}
|
||||
re = getDefaultCharset(getLocale(r));
|
||||
}
|
||||
|
||||
if (original == null ||
|
||||
original.length() == 0) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " has no value");
|
||||
if (original == null || original.length() == 0) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name + " has no value");
|
||||
}
|
||||
real = original;
|
||||
} else if (getDefaultCharset(r).equals(re)) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " is already in correct encoding");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name
|
||||
+ " is already in correct encoding");
|
||||
}
|
||||
real = original;
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " is being converted from " +
|
||||
getDefaultCharset(r) + " into " + re);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name + " is being converted from "
|
||||
+ getDefaultCharset(r) + " into " + re);
|
||||
}
|
||||
try {
|
||||
real = new String
|
||||
(original.getBytes(getDefaultCharset(r)),
|
||||
re);
|
||||
real = new String(original.getBytes(getDefaultCharset(r)),
|
||||
re);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return real;
|
||||
}
|
||||
|
||||
|
|
@ -278,46 +274,46 @@ public class Globalization {
|
|||
*
|
||||
* @return String[] The decoded parameters.
|
||||
*/
|
||||
public static final String[] decodeParameters
|
||||
(HttpServletRequest r, String name) {
|
||||
public static final String[] decodeParameters(HttpServletRequest r,
|
||||
String name) {
|
||||
String re = r.getParameter(Globalization.ENCODING_PARAM_NAME);
|
||||
String[] originals = r.getParameterValues(name);
|
||||
String[] real = null;
|
||||
|
||||
if (re == null ||
|
||||
re.length() == 0) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug(ENCODING_PARAM_NAME + " is not set, using locale " +
|
||||
"default encoding for parameter " + name);
|
||||
if (re == null || re.length() == 0) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(ENCODING_PARAM_NAME + " is not set, using locale "
|
||||
+ "default encoding for parameter " + name);
|
||||
}
|
||||
re = getDefaultCharset(getLocale(r));
|
||||
}
|
||||
|
||||
if (originals == null ||
|
||||
originals.length == 0) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " has no value");
|
||||
if (originals == null || originals.length == 0) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name + " has no value");
|
||||
}
|
||||
real = originals;
|
||||
} else if (getDefaultCharset(r).equals(re)) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " is already in correct encoding");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name
|
||||
+ " is already in correct encoding");
|
||||
}
|
||||
real = originals;
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Parameter " + name + " is being converted from " +
|
||||
getDefaultCharset(r) + " into " + re);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Parameter " + name + " is being converted from "
|
||||
+ getDefaultCharset(r) + " into " + re);
|
||||
}
|
||||
try {
|
||||
real = new String[originals.length];
|
||||
for (int i = 0; i < originals.length; i++) {
|
||||
real[i] = new String
|
||||
(originals[i].getBytes(getDefaultCharset(r)),
|
||||
re);
|
||||
real[i] = new String(originals[i].getBytes(
|
||||
getDefaultCharset(r)),
|
||||
re);
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -356,13 +352,13 @@ public class Globalization {
|
|||
rb = rc.getResourceBundle();
|
||||
|
||||
if (rb != null) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info(rb.getClass().getName() +
|
||||
" is the chosen ResourceBundle.");
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info(rb.getClass().getName()
|
||||
+ " is the chosen ResourceBundle.");
|
||||
}
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No matching ResourceBundle found");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No matching ResourceBundle found");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -375,7 +371,7 @@ public class Globalization {
|
|||
* appropriate Locale and key.
|
||||
* </p>
|
||||
*
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param key The key used to select the appropriate Object
|
||||
*
|
||||
* @return The localized Object
|
||||
|
|
@ -390,7 +386,6 @@ public class Globalization {
|
|||
// If the key does not contain a '#' character, then use the
|
||||
// HttpServletRequest alone to determine the appropriate
|
||||
// ResourceBundle.
|
||||
|
||||
int separator = key.indexOf('#');
|
||||
if (separator < 0) {
|
||||
rb = getResourceBundle(r);
|
||||
|
|
@ -415,14 +410,14 @@ public class Globalization {
|
|||
if (rb != null) {
|
||||
l7dObject = rb.getObject(key);
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No ResourceBundle available");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No ResourceBundle available");
|
||||
}
|
||||
}
|
||||
} catch (MissingResourceException e) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Key " + key + " was not found in the " +
|
||||
"ResourceBundle");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Key " + key + " was not found in the "
|
||||
+ "ResourceBundle");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -431,11 +426,11 @@ public class Globalization {
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* Get a String from the appropriate ResourceBundle based on the
|
||||
* appropriate Locale and key.
|
||||
* Get a String from the appropriate ResourceBundle based on the appropriate
|
||||
* Locale and key.
|
||||
* </p>
|
||||
*
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param key The key used to select the appropriate String
|
||||
*
|
||||
* @return The localized String
|
||||
|
|
@ -450,12 +445,12 @@ public class Globalization {
|
|||
/**
|
||||
* <p>
|
||||
* Get a parameterized String (for doing MessageFormatting) from the
|
||||
* appropraite ResourceBundle based on the appropriate Locale and key.
|
||||
* Then interpolate the values for the other keys passed.
|
||||
* appropraite ResourceBundle based on the appropriate Locale and key. Then
|
||||
* interpolate the values for the other keys passed.
|
||||
* </p>
|
||||
*
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param key The key used to select the appropriate String
|
||||
* @param r The current HttpServletRequest.
|
||||
* @param key The key used to select the appropriate String
|
||||
* @param arguments A Object[] containing the other keys to localize and
|
||||
* interpolate into the parameterized string. It may also
|
||||
* contain other Objects beside Strings, such as Date
|
||||
|
|
@ -491,26 +486,25 @@ public class Globalization {
|
|||
* default ResourceBundle in another language
|
||||
* </p>
|
||||
*
|
||||
* @param targetBundle The ResourceBundle we are looking for.
|
||||
* @param locale The Locale object representing the language we want.
|
||||
* @param targetBundle The ResourceBundle we are looking for.
|
||||
* @param locale The Locale object representing the language we want.
|
||||
* @param defaultLocale The Locale object representing the default language.
|
||||
*/
|
||||
public static ResourceBundle getBundleNoFallback
|
||||
(String targetBundle, java.util.Locale locale,
|
||||
java.util.Locale defaultLocale) {
|
||||
public static ResourceBundle getBundleNoFallback(String targetBundle,
|
||||
java.util.Locale locale,
|
||||
java.util.Locale defaultLocale) {
|
||||
ResourceBundle bundle = null;
|
||||
|
||||
if (locale == null) {
|
||||
locale =
|
||||
(defaultLocale != null) ?
|
||||
defaultLocale : java.util.Locale.getDefault();
|
||||
locale = (defaultLocale != null) ? defaultLocale : java.util.Locale
|
||||
.getDefault();
|
||||
}
|
||||
|
||||
try {
|
||||
bundle = ResourceBundle.getBundle(targetBundle, locale);
|
||||
} catch (MissingResourceException e) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Didn't find ResourceBundle for " + targetBundle);
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
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
|
||||
// language we were looking for or, by coincidence, the target
|
||||
// language happens to match the default language for the system.
|
||||
if (bundle != null ) {
|
||||
if (
|
||||
targetLanguage.equals(bundle.getLocale().getLanguage()) ||
|
||||
targetLanguage.equals(defaultLocale.getLanguage())
|
||||
) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Found matching ResourceBundle for " +
|
||||
targetBundle);
|
||||
if (bundle != null) {
|
||||
if (targetLanguage.equals(bundle.getLocale().getLanguage())
|
||||
|| targetLanguage.equals(defaultLocale.getLanguage())) {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Found matching ResourceBundle for "
|
||||
+ targetBundle);
|
||||
}
|
||||
} else {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Found non-matching ResourceBundle for " +
|
||||
targetBundle);
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Found non-matching ResourceBundle for "
|
||||
+ targetBundle);
|
||||
}
|
||||
bundle = null;
|
||||
}
|
||||
|
|
@ -539,4 +531,5 @@ public class Globalization {
|
|||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import java.util.ResourceBundle;
|
|||
|
||||
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.l10n.GlobalizationHelper;
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ public class GlobalizedMessage {
|
|||
* /WEB-INF/conf/log4j.properties int hte runtime environment and set
|
||||
* 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_bundleName = "";
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,11 +31,9 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.CcmObjectRepository;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import java.io.File;
|
|||
import java.net.MalformedURLException;
|
||||
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
|
||||
|
|
@ -62,11 +63,10 @@ import org.apache.log4j.Logger;
|
|||
* @author Justin Ross <jross@redhat.com>
|
||||
* rewritten by
|
||||
* @author pboy <pboy@barkhof.uni-bremen.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
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;
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public final class CCMResourceManager {
|
|||
}
|
||||
else {
|
||||
// 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) {
|
||||
|
||||
s_log.debug("storeBaseDir: BaseDir name is given as " + baseDirName );
|
||||
LOGGER.debug("storeBaseDir: BaseDir name is given as " + baseDirName );
|
||||
m_baseDir = new File(baseDirName);
|
||||
|
||||
// eventually: check if dir exists, create it if not.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import com.arsdigita.web.Web;
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +38,8 @@ public class ApplicationPatternGenerator implements PatternGenerator {
|
|||
/**
|
||||
* 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.
|
||||
|
|
@ -51,18 +53,18 @@ public class ApplicationPatternGenerator implements PatternGenerator {
|
|||
public String[] generateValues(String key,
|
||||
HttpServletRequest req) {
|
||||
|
||||
s_log.debug("Processing Application with key: " + key);
|
||||
LOGGER.debug("Processing Application with key: " + key);
|
||||
|
||||
final CcmApplication app = Web.getWebContext().getApplication();
|
||||
if (app != null) {
|
||||
String[] returnValue = {app.getApplicationType()};
|
||||
s_log.debug("Found application >>" + returnValue
|
||||
+ "<< in Application.");
|
||||
LOGGER.debug("Found application >>" + returnValue
|
||||
+ "<< in Application.");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
s_log.debug("ApplicationType for >>" + key
|
||||
+ "<< not found. Trying SiteNodes instead.");
|
||||
LOGGER.debug("ApplicationType for >>" + key
|
||||
+ "<< not found. Trying SiteNodes instead.");
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"No ApplicationType found for type name " + key);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
package com.arsdigita.templating;
|
||||
|
||||
import com.arsdigita.util.servlet.HttpHost;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.web.WebConfig;
|
||||
|
||||
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
|
||||
|
|
@ -39,7 +39,7 @@ public class HostPatternGenerator implements PatternGenerator {
|
|||
* set com.arsdigita.templating.HostPatternGenerator=DEBUG by uncommenting
|
||||
* or adding the line.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
HostPatternGenerator.class);
|
||||
|
||||
/**
|
||||
|
|
@ -61,8 +61,8 @@ public class HostPatternGenerator implements PatternGenerator {
|
|||
WebConfig.getConfig().getHostPort());
|
||||
final String hostName = host.toString();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Generating Values for key: " + key + " ["
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Generating Values for key: " + key + " ["
|
||||
+ "Hostname retrieved: >>" + hostName + "<<]");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import com.arsdigita.web.WebConfig;
|
|||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -43,8 +45,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||
import javax.xml.transform.ErrorListener;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
/**
|
||||
* 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 Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Templating {
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ public class Templating {
|
|||
* set com.arsdigita.templating.Templating=DEBUG by uncommenting it or
|
||||
* 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,
|
||||
|
|
@ -81,7 +82,7 @@ public class Templating {
|
|||
.getConfig();
|
||||
|
||||
static {
|
||||
s_log.debug("Static initalizer starting...");
|
||||
LOGGER.debug("Static initalizer starting...");
|
||||
|
||||
Exceptions.registerUnwrapper(
|
||||
TransformerException.class,
|
||||
|
|
@ -104,7 +105,7 @@ public class Templating {
|
|||
setting = s_config.getStylesheetCacheAge();
|
||||
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 useCache) {
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting template for URL " + source);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Getting template for URL " + source);
|
||||
}
|
||||
|
||||
Assert.exists(source, URL.class);
|
||||
|
|
@ -192,9 +193,9 @@ public class Templating {
|
|||
XSLTemplate template = null;
|
||||
|
||||
if (template == null) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("The template for URL " + source + " is not "
|
||||
+ "cached; creating and caching it now");
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("The template for URL " + source + " is not "
|
||||
+ "cached; creating and caching it now");
|
||||
}
|
||||
|
||||
if (fancyErrors) {
|
||||
|
|
@ -212,9 +213,9 @@ public class Templating {
|
|||
// Debug mode should be captured at a lower level,
|
||||
// probably on UtilConfig.
|
||||
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Template " + template + " has been modified; "
|
||||
+ "recreating it from scratch");
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Template " + template + " has been modified; "
|
||||
+ "recreating it from scratch");
|
||||
}
|
||||
|
||||
if (fancyErrors) {
|
||||
|
|
@ -274,8 +275,8 @@ public class Templating {
|
|||
* @param source the <code>URL</code> to the top-level template resource
|
||||
*/
|
||||
public static synchronized void purgeTemplate(final URL source) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Purging cached template for URL " + source);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Purging cached template for URL " + source);
|
||||
}
|
||||
|
||||
Assert.exists(source, URL.class);
|
||||
|
|
@ -286,8 +287,8 @@ public class Templating {
|
|||
* regenerated on-demand as each gets requested.
|
||||
*/
|
||||
public static synchronized void purgeTemplates() {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Purging all cached templates");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Purging all cached templates");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +313,8 @@ public class Templating {
|
|||
"http://www.w3.org/1999/XSL/Transform");
|
||||
imp.addAttribute("href", path.toString());
|
||||
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Adding import for " + path.toString());
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Adding import for " + path.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -324,8 +325,8 @@ public class Templating {
|
|||
throw new UncheckedWrapperException("cannot build document", ex);
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("XSL is " + doc.toString(true));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("XSL is " + doc.toString(true));
|
||||
}
|
||||
|
||||
return new ByteArrayInputStream(doc.toString(true).getBytes());
|
||||
|
|
@ -379,16 +380,17 @@ public class Templating {
|
|||
// and unrestricted access. The complete code should get refactored to
|
||||
// use ServletContext#getResource(path)
|
||||
String installContext = Web.getWebappContextPath();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Installation context is >" + installContext + "<.");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Installation context is >" + installContext + "<.");
|
||||
}
|
||||
if (!installContext.equals("")) {
|
||||
// CCM is installed into a non-ROOT context
|
||||
if (localPath.startsWith(installContext)) {
|
||||
// remove webapp context part
|
||||
localPath = localPath.substring(installContext.length());
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("WebApp context removed: >>" + localPath + "<<");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER
|
||||
.debug("WebApp context removed: >>" + localPath + "<<");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -401,8 +403,8 @@ public class Templating {
|
|||
// A virtual path to the ResourceServlet
|
||||
localPath = localPath.substring("/resource".length()); //remove virtual part
|
||||
URL newURL = Web.findResource(localPath); //without host part here!
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.
|
||||
debug("Transforming resource " + url + " to "
|
||||
+ newURL);
|
||||
}
|
||||
|
|
@ -415,24 +417,24 @@ public class Templating {
|
|||
if (file.exists()) {
|
||||
try {
|
||||
URL newURL = file.toURL();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Transforming resource " + url + " to "
|
||||
+ newURL);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Transforming resource " + url + " to "
|
||||
+ newURL);
|
||||
}
|
||||
return newURL;
|
||||
} catch (MalformedURLException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
} else if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("File " + filename
|
||||
+ " doesn't exist on disk");
|
||||
} else if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("File " + filename
|
||||
+ " doesn't exist on disk");
|
||||
}
|
||||
}
|
||||
} else // url is not the (local) running CCM host, no transformation
|
||||
// is done
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("URL " + url + " is not local");
|
||||
}
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("URL " + url + " is not local");
|
||||
}
|
||||
|
||||
return url; // returns the original, unmodified url here
|
||||
}
|
||||
|
|
@ -445,9 +447,8 @@ public class Templating {
|
|||
*/
|
||||
class LoggingErrorListener implements ErrorListener {
|
||||
|
||||
private static final Logger s_log
|
||||
= Logger.getLogger(
|
||||
LoggingErrorListener.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
LoggingErrorListener.class);
|
||||
private final ArrayList m_errors;
|
||||
|
||||
LoggingErrorListener() {
|
||||
|
|
@ -474,10 +475,10 @@ class LoggingErrorListener implements ErrorListener {
|
|||
}
|
||||
|
||||
private void log(Level level, TransformerException ex) {
|
||||
s_log.log(level, "Transformer " + level + ": "
|
||||
+ ex.getLocationAsString() + ": " + ex.
|
||||
getMessage(),
|
||||
ex);
|
||||
LOGGER.log(level, "Transformer " + level + ": "
|
||||
+ ex.getLocationAsString() + ": " + ex.
|
||||
getMessage(),
|
||||
ex);
|
||||
m_errors.add(ex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.templating;
|
||||
|
||||
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.StringUtils;
|
||||
|
||||
|
|
@ -26,130 +25,123 @@ import com.arsdigita.web.Web;
|
|||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* extension is stripped; any 'index' is removed, except for the top level.
|
||||
*
|
||||
* So some examples:
|
||||
*
|
||||
*
|
||||
* /content/admin/item.jsp -> { "admin-item", "admin", "index" }
|
||||
* /content/admin/index.jsp -> { "admin", "index" }
|
||||
* /content/admin/ -> { "admin", "index" }
|
||||
* /content/index.jsp -> { "index" }
|
||||
* /content/ -> { "index" }
|
||||
* /content/admin/index.jsp -> { "admin", "index" } /content/admin/ -> {
|
||||
* "admin", "index" } /content/index.jsp -> { "index" } /content/ -> { "index" }
|
||||
*/
|
||||
public class URLPatternGenerator implements PatternGenerator {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(URLPatternGenerator.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
URLPatternGenerator.class);
|
||||
|
||||
private static final String DEFAULT_URL_MATCH = "index";
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* @param req
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] generateValues(String key,
|
||||
HttpServletRequest req) {
|
||||
String path = getPath();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Substituting values for url " + path);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Substituting values for url " + path);
|
||||
}
|
||||
|
||||
|
||||
// Check for a file extension & strip it.
|
||||
int dotIndex = path.lastIndexOf(".");
|
||||
int slashIndex = path.lastIndexOf("/");
|
||||
if (dotIndex > -1
|
||||
&& dotIndex > slashIndex) {
|
||||
&& dotIndex > slashIndex) {
|
||||
path = path.substring(0, dotIndex);
|
||||
}
|
||||
|
||||
|
||||
// Strip '/index' if any
|
||||
if (path != null &&
|
||||
path.endsWith("/" + DEFAULT_URL_MATCH)) {
|
||||
path = path.substring(0, path.length() -
|
||||
DEFAULT_URL_MATCH.length());
|
||||
if (path != null && path.endsWith("/" + DEFAULT_URL_MATCH)) {
|
||||
path = path.substring(0, path.length() - DEFAULT_URL_MATCH.length());
|
||||
}
|
||||
|
||||
|
||||
// Now strip trailing & leading slash
|
||||
if (path != null &&
|
||||
path.startsWith("/")) {
|
||||
if (path != null && path.startsWith("/")) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
if (path != null &&
|
||||
path.endsWith("/")) {
|
||||
path = path.substring(0, path.length()-1);
|
||||
if (path != null && path.endsWith("/")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
|
||||
if (path == null) {
|
||||
path = "";
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Normalized path is '" + path + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Normalized path is '" + path + "'");
|
||||
}
|
||||
String[] bits = StringUtils.split(path, '/');
|
||||
if (s_log.isDebugEnabled()) {
|
||||
for (int i = 0 ; i < bits.length ; i++) {
|
||||
s_log.debug(" -> '" + bits[i] + "'");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
for (int i = 0; i < bits.length; i++) {
|
||||
LOGGER.debug(" -> '" + bits[i] + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we've cut off the file extension, it's time to do the
|
||||
// funky concatenation trick.
|
||||
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
|
||||
// to most general & add in the default 'index' match
|
||||
|
||||
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;
|
||||
String[] reverseBits = new String[bits.length + 1];
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("After concatenation & reversing");
|
||||
for (int i = 0 ; i < reverseBits.length ; i++) {
|
||||
s_log.debug(" -> '" + reverseBits[i] + "'");
|
||||
for (int i = bits.length - 1, j = 0; i > -1; i--, j++) {
|
||||
reverseBits[j] = bits[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;
|
||||
}
|
||||
|
||||
|
||||
private String getPath() {
|
||||
String base = getBasePath();
|
||||
String url = Web.getWebContext().getRequestURL().getPathInfo();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Base is " + base + " url is " + url);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Base is " + base + " url is " + url);
|
||||
}
|
||||
|
||||
Assert.isTrue(url.startsWith(base), "URL " + url + " starts with " + base);
|
||||
|
||||
return url.substring(base.length()-1);
|
||||
|
||||
Assert.isTrue(url.startsWith(base), "URL " + url + " starts with "
|
||||
+ base);
|
||||
|
||||
return url.substring(base.length() - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides the base URL of the application in the current Web request
|
||||
* (i.e. application's PrimaryURL). If no application can be found or
|
||||
no PrimaryURL can be determined ROOT ("/") is returned.
|
||||
|
||||
XXX fix me, why can't we get this from Web.getWebContext().getRequestURL
|
||||
*
|
||||
* Provides the base URL of the application in the current Web request (i.e.
|
||||
* application's PrimaryURL). If no application can be found or no
|
||||
* PrimaryURL can be determined ROOT ("/") is returned. *
|
||||
* XXX fix me, why can't we get this from Web.getWebContext().getRequestURL
|
||||
*
|
||||
* @return primary url of an application or ROOT
|
||||
*/
|
||||
private String getBasePath() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import com.arsdigita.web.Web;
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +38,7 @@ public class WebAppPatternGenerator implements PatternGenerator {
|
|||
* set com.arsdigita.templating.WebAppPatternGenerator=DEBUG by uncommenting
|
||||
* or adding the line.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
WebAppPatternGenerator.class);
|
||||
|
||||
/**
|
||||
|
|
@ -66,8 +67,8 @@ public class WebAppPatternGenerator implements PatternGenerator {
|
|||
ctx = ctx.substring(1);
|
||||
}
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Generating Values key: " + key + " ["
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Generating Values key: " + key + " ["
|
||||
+ "Web.getWebContext(): " + Web.getWebContext() + " ,"
|
||||
+ "Application: " + Web.getWebContext().getApplication()
|
||||
+ "," + "ContextPath: >" + ctx + "<]");
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@ import javax.xml.transform.TransformerFactory;
|
|||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
|
|
@ -54,31 +55,33 @@ import org.w3c.dom.Document;
|
|||
* transformers.
|
||||
*
|
||||
* @author Dan Berrange
|
||||
* @version $Id$
|
||||
*/
|
||||
public final class XSLTemplate {
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.templating.XSLTemplate=DEBUG by uncommenting
|
||||
* or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(XSLTemplate.class);
|
||||
/**
|
||||
* Internal logger instance to faciliate debugging. Enable logging output by
|
||||
* editing /WEB-INF/conf/log4j.properties int hte runtime environment and
|
||||
* set com.arsdigita.templating.XSLTemplate=DEBUG by uncommenting or adding
|
||||
* 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 Templates m_templates;
|
||||
private final List m_dependents;
|
||||
private final Date m_created;
|
||||
|
||||
/**
|
||||
* Creates and loads a new template from <code>source</code>,
|
||||
* using <code>listener</code> to handle any errors.
|
||||
* Creates and loads a new template from <code>source</code>, using
|
||||
* <code>listener</code> to handle any errors.
|
||||
*
|
||||
* @param source A <code>URL</code> pointing to the template
|
||||
* source text
|
||||
* @param listener A <code>ErrorListener</code> to customize
|
||||
* behavior on error
|
||||
* @param source A <code>URL</code> pointing to the template source text
|
||||
* @param listener A <code>ErrorListener</code> to customize behavior on
|
||||
* error
|
||||
*/
|
||||
public XSLTemplate(final URL source,
|
||||
final ErrorListener listener) {
|
||||
|
|
@ -92,17 +95,16 @@ public final class XSLTemplate {
|
|||
final SimpleURIResolver resolver = new SimpleURIResolver();
|
||||
|
||||
try {
|
||||
s_log.debug("Getting new templates object");
|
||||
LOGGER.debug("Getting new templates object");
|
||||
|
||||
final TransformerFactory factory =
|
||||
TransformerFactory.newInstance();
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
factory.setURIResolver(resolver);
|
||||
factory.setErrorListener(listener);
|
||||
|
||||
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) {
|
||||
throw new WrappedTransformerException(ex);
|
||||
} catch (TransformerException ex) {
|
||||
|
|
@ -119,11 +121,10 @@ public final class XSLTemplate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates and loads a new template from <code>source</code> using
|
||||
* the default <code>ErrorListener</code>.
|
||||
* Creates and loads a new template from <code>source</code> using the
|
||||
* default <code>ErrorListener</code>.
|
||||
*
|
||||
* @param source A <code>URL</code> pointing to the template
|
||||
* source text
|
||||
* @param source A <code>URL</code> pointing to the template source text
|
||||
*/
|
||||
public XSLTemplate(final URL source) {
|
||||
this(source, new Log4JErrorListener());
|
||||
|
|
@ -132,8 +133,8 @@ public final class XSLTemplate {
|
|||
/**
|
||||
* Gets the <code>URL</code> of the template source.
|
||||
*
|
||||
* @return The <code>URL</code> location of the template source;
|
||||
* it cannot be null
|
||||
* @return The <code>URL</code> location of the template source; it cannot
|
||||
* be null
|
||||
*/
|
||||
public final URL getSource() {
|
||||
return m_source;
|
||||
|
|
@ -142,8 +143,8 @@ public final class XSLTemplate {
|
|||
/**
|
||||
* Gets a list of all dependent stylesheet files.
|
||||
*
|
||||
* @return A <code>List</code> of <code>URL</code>s to dependent
|
||||
* stylesheet files; it cannot be null
|
||||
* @return A <code>List</code> of <code>URL</code>s to dependent stylesheet
|
||||
* files; it cannot be null
|
||||
*/
|
||||
public final List getDependents() {
|
||||
return m_dependents;
|
||||
|
|
@ -156,7 +157,7 @@ public final class XSLTemplate {
|
|||
* @return The new <code>Transformer</code>; it cannot be null
|
||||
*/
|
||||
public final synchronized Transformer newTransformer() {
|
||||
s_log.debug("Generating new transformer");
|
||||
LOGGER.debug("Generating new transformer");
|
||||
|
||||
try {
|
||||
return m_templates.newTransformer();
|
||||
|
|
@ -167,23 +168,23 @@ public final class XSLTemplate {
|
|||
|
||||
/**
|
||||
* Transforms the <code>source</code> document and sends it to
|
||||
* <code>result</code>. If there are errors,
|
||||
* <code>listener</code> handles them. This method internally
|
||||
* creates and uses a new <code>Transformer</code>.
|
||||
* <code>result</code>. If there are errors, <code>listener</code> handles
|
||||
* them. This method internally creates and uses a new
|
||||
* <code>Transformer</code>.
|
||||
*
|
||||
* @param source The <code>Source</code> to be transformed; it
|
||||
* cannot be null
|
||||
* @param result The <code>Result</code> to capture the
|
||||
* transformed product; it cannot be null
|
||||
* @param listener A <code>ErrorListener</code> to handle
|
||||
* transformation errors; it cannot be null
|
||||
* @param source The <code>Source</code> to be transformed; it cannot be
|
||||
* null
|
||||
* @param result The <code>Result</code> to capture the transformed
|
||||
* product; it cannot be null
|
||||
* @param listener A <code>ErrorListener</code> to handle transformation
|
||||
* errors; it cannot be null
|
||||
*/
|
||||
public final void transform(final Source source,
|
||||
final Result result,
|
||||
final ErrorListener listener) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Transforming " + source + " and sending it to "
|
||||
+ result + " using error listener " + listener);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Transforming " + source + " and sending it to "
|
||||
+ result + " using error listener " + listener);
|
||||
}
|
||||
|
||||
if (Assert.isEnabled()) {
|
||||
|
|
@ -196,11 +197,11 @@ public final class XSLTemplate {
|
|||
final Transformer transformer = newTransformer();
|
||||
transformer.setErrorListener(listener);
|
||||
|
||||
s_log.debug("Transforming the XML source document");
|
||||
|
||||
LOGGER.debug("Transforming the XML source document");
|
||||
|
||||
transformer.transform(source, result);
|
||||
|
||||
s_log.debug("Finished transforming");
|
||||
|
||||
LOGGER.debug("Finished transforming");
|
||||
} catch (TransformerConfigurationException tce) {
|
||||
throw new WrappedTransformerException(tce);
|
||||
} catch (TransformerException te) {
|
||||
|
|
@ -210,13 +211,13 @@ public final class XSLTemplate {
|
|||
|
||||
/**
|
||||
* Transforms the <code>source</code> document and sends it to
|
||||
* <code>result</code>. This method internally creates and uses a
|
||||
* new <code>Transformer</code>.
|
||||
* <code>result</code>. This method internally creates and uses a new
|
||||
* <code>Transformer</code>.
|
||||
*
|
||||
* @param source The <code>Source</code> to be transformed; it
|
||||
* cannot be null
|
||||
* @param result The <code>Result</code> to capture the
|
||||
* transformed product; it cannot be null
|
||||
* @param source The <code>Source</code> to be transformed; it cannot be
|
||||
* null
|
||||
* @param result The <code>Result</code> to capture the transformed product;
|
||||
* it cannot be null
|
||||
*/
|
||||
public final void transform(final Source source,
|
||||
final Result result) {
|
||||
|
|
@ -225,15 +226,14 @@ public final class XSLTemplate {
|
|||
|
||||
/**
|
||||
* Transforms <code>doc</code> and streams the result to
|
||||
* <code>writer</code>. If there are errors,
|
||||
* <code>listener</code> handles them.
|
||||
* <code>writer</code>. If there are errors, <code>listener</code> handles
|
||||
* them.
|
||||
*
|
||||
* @param doc The <code>Document</code> to transform; it cannot be
|
||||
* null
|
||||
* @param writer The <code>PrintWriter</code> to receive the
|
||||
* transformed result; it cannot be null
|
||||
* @param listener A <code>ErrorListener</code> to handle any
|
||||
* errors; it cannot be null
|
||||
* @param doc The <code>Document</code> to transform; it cannot be null
|
||||
* @param writer The <code>PrintWriter</code> to receive the transformed
|
||||
* result; it cannot be null
|
||||
* @param listener A <code>ErrorListener</code> to handle any errors; it
|
||||
* cannot be null
|
||||
*/
|
||||
public final void transform(final Document doc,
|
||||
final PrintWriter writer,
|
||||
|
|
@ -254,10 +254,9 @@ public final class XSLTemplate {
|
|||
* Transforms <code>doc</code> and streams the result to
|
||||
* <code>writer</code>.
|
||||
*
|
||||
* @param doc The <code>Document</code> to transform; it cannot be
|
||||
* null
|
||||
* @param writer The <code>PrintWriter</code> to receive the
|
||||
* transformed result; it cannot be null
|
||||
* @param doc The <code>Document</code> to transform; it cannot be null
|
||||
* @param writer The <code>PrintWriter</code> to receive the transformed
|
||||
* result; it cannot be null
|
||||
*/
|
||||
public final void transform(final Document doc,
|
||||
final PrintWriter writer) {
|
||||
|
|
@ -265,82 +264,81 @@ public final class XSLTemplate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether the XSL files associated with the template have
|
||||
* been modified.
|
||||
* Checks whether the XSL files associated with the template have been
|
||||
* modified.
|
||||
*
|
||||
* @return <code>true</code> if any dependent files have been
|
||||
* modified, otherwise <code>false</code>
|
||||
* @return <code>true</code> if any dependent files have been modified,
|
||||
* otherwise <code>false</code>
|
||||
*/
|
||||
public final boolean isModified() {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Checking if the XSL files for " + this.getSource().toString() + " "
|
||||
+ "have been modified and need to be re-read");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Checking if the XSL files for " + this.getSource()
|
||||
.toString() + " "
|
||||
+ "have been modified and need to be re-read");
|
||||
}
|
||||
|
||||
final Iterator iter = m_dependents.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final URL url = Templating.transformURL((URL) iter.next());
|
||||
final URL url = Templating.transformURL((URL) iter.next());
|
||||
Assert.exists(url, URL.class);
|
||||
|
||||
if (url.getProtocol().equals("file")) {
|
||||
final File file = new File(url.getPath());
|
||||
|
||||
if (file.lastModified() > m_created.getTime()) {
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("File " + file + " was modified " + file.
|
||||
lastModified());
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("File " + file + " was modified " + file.
|
||||
lastModified());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("The URL is not to a file; assuming " + url
|
||||
+ " is not modified");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("The URL is not to a file; assuming " + url
|
||||
+ " is not modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_log.debug("No files were modified");
|
||||
LOGGER.debug("No files were modified");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ZIP file containing this stylesheet and
|
||||
* all dependant's. NB, this method assumes that all
|
||||
* stylesheets live in the same URL protocol. If the
|
||||
* protocol a file is different from the protocol
|
||||
* of the top level, then this file will be excluded
|
||||
* from the ZIP. In practice this limitation is not
|
||||
* critical, because XSL files should always use
|
||||
* relative imports, which implies all imported files
|
||||
* will be in the same URL space.
|
||||
*
|
||||
* @param os the output stream to write the ZIP to
|
||||
* Creates a ZIP file containing this stylesheet and all dependant's. NB,
|
||||
* this method assumes that all stylesheets live in the same URL protocol.
|
||||
* If the protocol a file is different from the protocol of the top level,
|
||||
* then this file will be excluded from the ZIP. In practice this limitation
|
||||
* is not critical, because XSL files should always use relative imports,
|
||||
* which implies all imported files 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
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void toZIP(OutputStream os,
|
||||
String base)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
|
||||
final ZipOutputStream zos = new ZipOutputStream(os);
|
||||
|
||||
URL src = getSource();
|
||||
String srcProto = src.getProtocol();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Outputting files for " + src);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Outputting files for " + src);
|
||||
}
|
||||
|
||||
final Iterator sheets = getDependents().iterator();
|
||||
while (sheets.hasNext()) {
|
||||
URL xsl = (URL) sheets.next();
|
||||
if (xsl.getProtocol().equals(srcProto)) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Outputting file " + xsl);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Outputting file " + xsl);
|
||||
}
|
||||
String path = xsl.getPath();
|
||||
if (path.startsWith("/")) {
|
||||
|
|
@ -351,8 +349,8 @@ public final class XSLTemplate {
|
|||
|
||||
IO.copy(xsl.openStream(), zos);
|
||||
} else {
|
||||
s_log.warn("Not outputting file " + xsl
|
||||
+ " because its not under protocol " + srcProto);
|
||||
LOGGER.warn("Not outputting file " + xsl
|
||||
+ " because its not under protocol " + srcProto);
|
||||
}
|
||||
}
|
||||
zos.finish();
|
||||
|
|
@ -372,14 +370,16 @@ public final class XSLTemplate {
|
|||
|
||||
@Override
|
||||
public void fatalError(TransformerException e) throws
|
||||
TransformerException {
|
||||
TransformerException {
|
||||
log(Level.FATAL, e);
|
||||
}
|
||||
|
||||
private static void log(Level level, TransformerException ex) {
|
||||
s_log.log(level, "Transformer " + level + ": " + ex.
|
||||
getLocationAsString() + ": " + ex.getMessage(),
|
||||
ex);
|
||||
LOGGER.log(level, "Transformer " + level + ": " + ex.
|
||||
getLocationAsString() + ": " + ex.getMessage(),
|
||||
ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,17 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.xml.Element;
|
||||
import java.util.Iterator;
|
||||
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
|
||||
* sections.</p>
|
||||
* A simple layout panel with top, bottom, left, right, and body sections.</p>
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
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 final ArrayList m_actions = new ArrayList();
|
||||
|
|
@ -57,7 +56,7 @@ public class ActionGroup extends ComponentSet {
|
|||
Assert.exists(action, "Component action");
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
m_actions.add(new Object[] {action, clacc});
|
||||
m_actions.add(new Object[]{action, clacc});
|
||||
add(action);
|
||||
}
|
||||
|
||||
|
|
@ -67,24 +66,24 @@ public class ActionGroup extends ComponentSet {
|
|||
|
||||
public final void generateXML(final PageState state, final Element parent) {
|
||||
if (isVisible(state)) {
|
||||
final Element layout = parent.newChildElement
|
||||
("bebop:actionGroup", BEBOP_XML_NS);
|
||||
final Element layout = parent.newChildElement("bebop:actionGroup",
|
||||
BEBOP_XML_NS);
|
||||
|
||||
final Element subject = layout.newChildElement
|
||||
("bebop:subject", BEBOP_XML_NS);
|
||||
final Element subject = layout.newChildElement("bebop:subject",
|
||||
BEBOP_XML_NS);
|
||||
|
||||
if (m_subject != null) {
|
||||
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 Component component = (Component) spec[0];
|
||||
final String clacc = (String) spec[1];
|
||||
|
||||
if (component.isVisible(state)) {
|
||||
final Element action = layout.newChildElement
|
||||
("bebop:action", BEBOP_XML_NS);
|
||||
final Element action = layout
|
||||
.newChildElement("bebop:action", BEBOP_XML_NS);
|
||||
|
||||
if (clacc != null) {
|
||||
action.addAttribute("class", clacc);
|
||||
|
|
@ -95,4 +94,5 @@ public class ActionGroup extends ComponentSet {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,17 +25,18 @@ import com.arsdigita.bebop.SimpleComponent;
|
|||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.SequentialMap;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ public abstract class ComponentMap extends SimpleComponent
|
|||
}
|
||||
|
||||
public void reset(final PageState state) {
|
||||
s_log.debug("Resetting my children");
|
||||
LOGGER.debug("Resetting my children");
|
||||
|
||||
final Iterator iter = children();
|
||||
|
||||
|
|
@ -82,4 +83,5 @@ public abstract class ComponentMap extends SimpleComponent
|
|||
|
||||
public abstract void generateXML(final PageState state,
|
||||
final Element parent);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.xml.Element;
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
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;
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ public class ComponentSet extends SimpleComponent
|
|||
}
|
||||
|
||||
public void reset(final PageState state) {
|
||||
s_log.debug("Resetting children");
|
||||
LOGGER.debug("Resetting children");
|
||||
|
||||
final Iterator iter = children();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,17 @@ import com.arsdigita.bebop.Component;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
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
|
||||
* sections.</p>
|
||||
* A simple layout panel with top, bottom, left, right, and body sections.
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @version $Id$
|
||||
*/
|
||||
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) {
|
||||
put("top", top);
|
||||
|
|
@ -60,8 +59,8 @@ public class LayoutPanel extends ComponentMap {
|
|||
@Override
|
||||
public void generateXML(final PageState state, final Element parent) {
|
||||
if (isVisible(state)) {
|
||||
final Element layout = parent.newChildElement
|
||||
("bebop:layoutPanel", BEBOP_XML_NS);
|
||||
final Element layout = parent.newChildElement("bebop:layoutPanel",
|
||||
BEBOP_XML_NS);
|
||||
|
||||
section(state, layout, "top");
|
||||
section(state, layout, "left");
|
||||
|
|
@ -77,10 +76,11 @@ public class LayoutPanel extends ComponentMap {
|
|||
final Component section = get(key);
|
||||
|
||||
if (section != null) {
|
||||
final Element elem = parent.newChildElement
|
||||
("bebop:" + key, BEBOP_XML_NS);
|
||||
final Element elem = parent.newChildElement("bebop:" + key,
|
||||
BEBOP_XML_NS);
|
||||
|
||||
section.generateXML(state, elem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue