diff --git a/ccm-bundle-devel-wildfly-web/pom.xml b/ccm-bundle-devel-wildfly-web/pom.xml index 99ce7943b..5ed944908 100644 --- a/ccm-bundle-devel-wildfly-web/pom.xml +++ b/ccm-bundle-devel-wildfly-web/pom.xml @@ -55,6 +55,16 @@ + + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-api + + diff --git a/ccm-bundle-devel-wildfly-web/src/main/resources/log4j2.xml b/ccm-bundle-devel-wildfly-web/src/main/resources/log4j2.xml index 78408e294..853a794c1 100644 --- a/ccm-bundle-devel-wildfly-web/src/main/resources/log4j2.xml +++ b/ccm-bundle-devel-wildfly-web/src/main/resources/log4j2.xml @@ -9,6 +9,20 @@ + + + + + + + + + + @@ -52,10 +66,10 @@ level="debug"> + level="debug"> + level="debug"> \ No newline at end of file diff --git a/ccm-bundle-devel-wildfly-web/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml b/ccm-bundle-devel-wildfly-web/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml index 67adce4c2..682849862 100644 --- a/ccm-bundle-devel-wildfly-web/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml +++ b/ccm-bundle-devel-wildfly-web/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml @@ -28,13 +28,16 @@ - + - + - + value="org.hibernate.search.orm:main" /> + + commons-beanutils diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Completable.java b/ccm-core/src/main/java/com/arsdigita/bebop/Completable.java index 5afc2dae3..e4589b816 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Completable.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Completable.java @@ -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 rhs@mit.edu - * @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() { diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/DescriptiveComponent.java b/ccm-core/src/main/java/com/arsdigita/bebop/DescriptiveComponent.java index 9efd421bb..48773a323 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/DescriptiveComponent.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/DescriptiveComponent.java @@ -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"); diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/ElementComponent.java b/ccm-core/src/main/java/com/arsdigita/bebop/ElementComponent.java index 75a939c4e..ac438f6b4 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/ElementComponent.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/ElementComponent.java @@ -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; diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Form.java b/ccm-core/src/main/java/com/arsdigita/bebop/Form.java index 392239323..afc666f42 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Form.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Form.java @@ -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 get submission method for this form. See the Form. A FormSection - * contains other Bebop components, most importantly - * Widgets and associated listeners. It serves two purposes: + * contains other Bebop components, most importantly Widgets and + * associated listeners. It serves two purposes: *
    *
  • Divides a form into visual sections
  • - *
  • Serves as a container for form fragments that can function by themselves - * and can be dropped into other forms
  • + *
  • Serves as a container for form fragments that can function by themselves + * and can be dropped into other forms
  • *
- *

Since a FormSection has its own init, validation, and - * process listeners, it can do all of its processing without any intervention - * from the enclosing form. + *

+ * Since a FormSection has its own init, validation, and process + * listeners, it can do all of its processing without any intervention from the + * enclosing form. * - * Although a FormSection contains all the same pieces - * that a Form does, it can only be used if it is added - * directly or indirectly to a Form. FormSections - * that are not contained in a Form do not exhibit any useful - * behavior. + * Although a FormSection contains all the same pieces that a + * Form does, it can only be used if it is added directly or + * indirectly to a Form. FormSections that are not + * contained in a Form 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 FormModel that stores - * the parameter models for all the widgets in this form section. */ + /** + * Underlying FormModel 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 - * ColumnPanel by default. */ + /** + * The container to which all children are added. A ColumnPanel + * 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 FormSection to two column ColumnPanel - * by calling the 1-argument constructor. - **/ + * Constructs a new form section. Sets the implicit layout Container of this + * FormSection to two column ColumnPanel 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 * FormSection 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 FormSection to panel. Sets the form - * model of this FormSection to model. + * Constructs a new form section. Sets the implicit layout Container of this + * FormSection to panel. Sets the form model of + * this FormSection to model. * * @param panel the container within this form section that holds the - * components that are added to the form section with calls to the - * add methods + * components that are added to the form section with calls to + * the add 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 * submitted method may throw a - * FormProcessException to signal that any further - * processing of the form should be aborted. + * FormProcessException 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 - * FormInitListener interface - * */ + * FormInitListener 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 init method on all registered init - * listeners. + * Calls the init 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 - * FormValidationListener interface - * */ + * FormValidationListener 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.

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. - *

Process listeners are executed in the order in which - * they are added. + * Adds a listener for form processing events. + *

+ * 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. + *

+ * Process listeners are executed in the order in which they are added. * * @param listener an instance of a class that implements the - * FormProcessListener interface - * */ + * FormProcessListener 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 - * FormCancelListener interface - * */ + * FormCancelListener 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 - * null !). + * Returns an iterator over the children of this component. If the component + * has no children, returns an empty iterator (not null !). * * @post return != null - * */ + * + */ @Override public Iterator children() { return m_panel.children(); @@ -659,12 +688,14 @@ public class FormSection extends DescriptiveComponent implements Container { * parent. Uses the request values stored in * state.

* - *

This method generates DOM to be used with the XSLT template - * to produce the appropriate output.

+ *

+ * This method generates DOM to be used with the XSLT template to produce + * the appropriate output.

* * @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 true if this list contains the - * specified element. More - * formally, returns true if and only if this list contains at least + * Returns true 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 true only if the component has - * been directly - * added to this container. If this container contains another + * This method returns true only if the component has been + * directly added to this container. If this container contains another * container that contains this component, this method returns * false. * - * @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 true if this Container contains the - * specified component directly; false otherwise. + * @return true if this Container contains the specified + * component directly; false 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 true if this container contains no components - * false otherwise. - * */ + * false 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(); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/FormStep.java b/ccm-core/src/main/java/com/arsdigita/bebop/FormStep.java index a7dbcad81..957a83d62 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/FormStep.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/FormStep.java @@ -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
rhs@mit.edu - * @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()); } } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Link.java b/ccm-core/src/main/java/com/arsdigita/bebop/Link.java index f2574bd0d..dfb29fe54 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Link.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Link.java @@ -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. * - *

Example: The common usage for a Link component is - * illustrated in the code fragment below: + *

+ * Example: The common usage for a Link component is illustrated in the + * code fragment below: * *

  *  Page p = new Page("Link Example");
@@ -41,16 +45,16 @@ import org.apache.log4j.Logger;
  *  p.add(link);
  * 
* - *

The target of the link above will be rendered in HTML as: + *

+ * The target of the link above will be rendered in HTML as: * href="path/to/target/?foo=1" - * 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"; /** - *

Passing this value to {@link #setTargetFrame setTargetFrame} will - * create a link that opens a new browser window whenever it is clicked. - *

+ *

+ * Passing this value to {@link #setTargetFrame setTargetFrame} will create + * a link that opens a new browser window whenever it is clicked. + *

* * @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 Component 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 url 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 - * Link constructor taking a URL. - * @see #Link(String,URL) + * @param child The Component 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 url + * 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 Link constructor taking a + * URL. + * + * @see #Link(String,URL) */ public Link(Component child, String url) { super(child, url); @@ -113,12 +122,11 @@ public class Link extends BaseLink { /** * Constructors with PrintListener parameters allow for a - * {@link PrintListener} to be set for the Link, without the need - * to make a separate call to the addPrintListener 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 addPrintListener 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 PrintListener parameters allow for a * {@link PrintListener} to be set for the Link, without the need to make a - * separate call to the addPrintListener 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 addPrintListener 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 PrintListener parameters allow for a - * {@link PrintListener} to be set for the Link, without the need to make a - * separate call to the addPrintListener 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 addPrintListener 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 { } /** - *

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 + *

+ * 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.

* - *

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 url - * with the webapp context path or the dispatcher servlet - * path.

+ *

+ * 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 url 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 - * Link constructor taking a URL.

+ *

+ * The vast majority of CCM UI code expects to link through the dispatcher. + * Code that does not should use the Link constructor taking a + * URL.

* * @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 { } /** - *

Constructs a Link using a URL. When this constructor is + *

+ * Constructs a Link using a URL. 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 * ParameterMap argument to URL.

* * @see com.arsdigita.web.URL * @see com.arsdigita.web.ParameterMap * @param label a String of label text - * @param url a URL for the link's target - * @deprecated refactor to use Link(Component,URL) to provide a - * globalized label for the link. + * @param url a URL 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. *

- * All the variables set with this method are appended to the - * query string in the URL that is output for this Link. + * All the variables set with this method are appended to the query string + * in the URL that is output for this Link. * - * @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(); } /** - *

Get the "target" attribute of the link, which determines - * which browser frame will load the new page when this link is - * clicked.

+ *

+ * Get the "target" attribute of the link, which determines which browser + * frame will load the new page when this link is clicked.

*/ public String getTargetFrame() { return getAttribute(FRAME_TARGET_ATTR); } /** - *

Set the "target" attribute of the link, which determines - * which browser frame will load the new page when this link is - * clicked.

+ *

+ * Set the "target" attribute of the link, which determines which browser + * frame will load the new page when this link is clicked.

*/ 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(); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/ModalContainer.java b/ccm-core/src/main/java/com/arsdigita/bebop/ModalContainer.java index 3c7bed343..577ee3301 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/ModalContainer.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/ModalContainer.java @@ -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 - * super.register when you override register + * The super class' method is empty, so the rule "Always call + * super.register when you override register * 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); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Page.java b/ccm-core/src/main/java/com/arsdigita/bebop/Page.java index 6ec4cc0de..f6f2ea14e 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Page.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Page.java @@ -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(); diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/PageState.java b/ccm-core/src/main/java/com/arsdigita/bebop/PageState.java index 137c5d5c4..5b45cd646 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/PageState.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/PageState.java @@ -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; /** *

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"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/TabbedPane.java b/ccm-core/src/main/java/com/arsdigita/bebop/TabbedPane.java index 50b93896d..7e8f0656f 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/TabbedPane.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/TabbedPane.java @@ -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. *

* 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. *

- * 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 TabbedPane. + * 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 TabbedPane. *

* - * @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 - * label in the tab strip + * @param c the component to display when the user clicks on the + * label 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 - * label in the tab strip + * @param c the component to display when the user clicks on the + * label in the tab strip * * @pre label != null && c != null */ @@ -152,6 +157,7 @@ public class TabbedPane extends SimpleContainer { /** * Adds an ActionListener, 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 ActionListener. + * * @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 ActionEvent. All registered * ActionListeners are run. The source of the event is the * TabbedPane. + * * @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 null if there are no - * panes. + * @return the default pane, or null 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 null - * if a pane with that label does not exist. + * + * @return the pane with the specified label, or null 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 null - * 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 null 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 Pane, the tab label together - * with its component. + * Get the currently visible Pane, 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. - *

Generates a DOM fragment: - *

+     * Services the request by building a DOM tree with the tabs themselves and
+     * then the included page.
+     * 

+ * Generates a DOM fragment: + *

+ *

      * <bebop:tabbedPane>
      *  <bebop:tabStrip>
      *   <bebop:tab [href="..."] [current="t|f"]> .. label .. </bebop:tab>
@@ -438,12 +459,14 @@ public class TabbedPane extends SimpleContainer {
      * 
*/ 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; } + } + } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Table.java b/ccm-core/src/main/java/com/arsdigita/bebop/Table.java index d2fde80bf..e19182c84 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Table.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Table.java @@ -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 TableModel. @@ -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); diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/Tree.java b/ccm-core/src/main/java/com/arsdigita/bebop/Tree.java index 5489fa252..21b28a9c5 100644 --- a/ccm-core/src/main/java/com/arsdigita/bebop/Tree.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/Tree.java @@ -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. Tree 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. + * Tree 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 Tree 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 - * Tree(TreeModelBuilder b). It is not practical - * to hardwire the TreeModel into the Tree, - * 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} + * Tree(TreeModelBuilder b). It is not practical to hardwire + * the TreeModel into the Tree, 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 TreeModel. + * * @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 TreeModel. + * * @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 true. + * Gets the key for the selected node. This will only be a valid key if + * {@link #isSelected isSelected} is true. * * @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 - * key was not selected already, fires the {@link + * Sets the selection to the one with the specified key. If key + * 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 true if one of the nodes is currently selected. * * @param state represents the state of the current request + * * @return true if one of the nodes is selected; - * false otherwise. + * false 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 state. * * @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 state. 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 state. 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 ActionListener. + * * @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 Tree that a node has been selected. - * Changes the currently selected tree component. + * Notifies the Tree 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 true if the node at the specified display row is collapsed; - * false otherwise. + * + * @return true if the node at the specified display row is + * collapsed; false 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(); } + } } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/form/MultipleSelectPairWidget.java b/ccm-core/src/main/java/com/arsdigita/bebop/form/MultipleSelectPairWidget.java index e9d8c14f0..638d99194 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/form/MultipleSelectPairWidget.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/form/MultipleSelectPairWidget.java @@ -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; /** *

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; diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/form/OptionGroup.java b/ccm-core/src/main/java/com/arsdigita/bebop/form/OptionGroup.java index f330af602..3c1385139 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/form/OptionGroup.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/form/OptionGroup.java @@ -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. diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/form/SearchAndSelect.java b/ccm-core/src/main/java/com/arsdigita/bebop/form/SearchAndSelect.java index bf2e35415..f9eeb348d 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/form/SearchAndSelect.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/form/SearchAndSelect.java @@ -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. *

- * 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"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/form/Widget.java b/ccm-core/src/main/java/com/arsdigita/bebop/form/Widget.java index 7a872aadb..f27c11f6c 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/form/Widget.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/form/Widget.java @@ -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; + /** - *

* A class representing a widget in the graphical representation of a form. - *

* - *

* 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).

+ * input of month, day and year (and possibly time as well). * - *

* This class and its subclasses provide methods to set all element attributes * except for VALUE, 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 WidgetPeer associated with the widget. - *

- *

+ * * 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. - *

* * @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; diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/page/PageTransformer.java b/ccm-core/src/main/java/com/arsdigita/bebop/page/PageTransformer.java index ed56ff871..985c00fc8 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/page/PageTransformer.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/page/PageTransformer.java @@ -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; * package 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) { diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/IntegerParameter.java b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/IntegerParameter.java index b059aaf7d..12754d149 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/IntegerParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/IntegerParameter.java @@ -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; diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/ParameterModel.java b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/ParameterModel.java index 78adc81a0..77d73b7dd 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/ParameterModel.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/ParameterModel.java @@ -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 diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/TidyHTMLValidationListener.java b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/TidyHTMLValidationListener.java index 3cb4bb950..29c1ea6cc 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/TidyHTMLValidationListener.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/TidyHTMLValidationListener.java @@ -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.

* * @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; diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/WordValidationListener.java b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/WordValidationListener.java index 904923827..11a9a9298 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/parameters/WordValidationListener.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/parameters/WordValidationListener.java @@ -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(); diff --git a/ccm-core/src/main/java/com/arsdigita/bebop/util/Traversal.java b/ccm-core/src/main/java/com/arsdigita/bebop/util/Traversal.java index be55c4130..98132bcba 100755 --- a/ccm-core/src/main/java/com/arsdigita/bebop/util/Traversal.java +++ b/ccm-core/src/main/java/com/arsdigita/bebop/util/Traversal.java @@ -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; /** *

@@ -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.

* - * @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 test returns PERFORM_ACTION, @@ -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); } } diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/BaseDispatcherServlet.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/BaseDispatcherServlet.java index 7ad17531a..9ef505644 100755 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/BaseDispatcherServlet.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/BaseDispatcherServlet.java @@ -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); } diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java index 588516c64..4347f86f4 100644 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java @@ -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())); diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/InitialRequestContext.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/InitialRequestContext.java index dfaf39b19..4f90b1c7d 100644 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/InitialRequestContext.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/InitialRequestContext.java @@ -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 + "'"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/JSPApplicationDispatcher.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/JSPApplicationDispatcher.java index 57522fad2..870f61778 100755 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/JSPApplicationDispatcher.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/JSPApplicationDispatcher.java @@ -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); } } diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/MultipartHttpServletRequest.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/MultipartHttpServletRequest.java index 452661481..9d75f5628 100644 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/MultipartHttpServletRequest.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/MultipartHttpServletRequest.java @@ -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); } diff --git a/ccm-core/src/main/java/com/arsdigita/globalization/Globalization.java b/ccm-core/src/main/java/com/arsdigita/globalization/Globalization.java index c2eb63a21..5612ae720 100644 --- a/ccm-core/src/main/java/com/arsdigita/globalization/Globalization.java +++ b/ccm-core/src/main/java/com/arsdigita/globalization/Globalization.java @@ -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; /** *

- * 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. *

* * @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 { /** *

- * 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). *

* - * @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. *

* - * @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 { /** *

- * 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. *

* - * @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 { /** *

* 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. *

* - * @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 *

* - * @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; } + } diff --git a/ccm-core/src/main/java/com/arsdigita/globalization/GlobalizedMessage.java b/ccm-core/src/main/java/com/arsdigita/globalization/GlobalizedMessage.java index 904a7aad0..434d5112b 100644 --- a/ccm-core/src/main/java/com/arsdigita/globalization/GlobalizedMessage.java +++ b/ccm-core/src/main/java/com/arsdigita/globalization/GlobalizedMessage.java @@ -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 = ""; /** diff --git a/ccm-core/src/main/java/com/arsdigita/kernel/ui/ACSObjectSelectionModel.java b/ccm-core/src/main/java/com/arsdigita/kernel/ui/ACSObjectSelectionModel.java index aca60da8f..6ea6ca9d5 100755 --- a/ccm-core/src/main/java/com/arsdigita/kernel/ui/ACSObjectSelectionModel.java +++ b/ccm-core/src/main/java/com/arsdigita/kernel/ui/ACSObjectSelectionModel.java @@ -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; diff --git a/ccm-core/src/main/java/com/arsdigita/runtime/CCMResourceManager.java b/ccm-core/src/main/java/com/arsdigita/runtime/CCMResourceManager.java index 068bfd553..ed9cebdcd 100644 --- a/ccm-core/src/main/java/com/arsdigita/runtime/CCMResourceManager.java +++ b/ccm-core/src/main/java/com/arsdigita/runtime/CCMResourceManager.java @@ -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; /** *

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. diff --git a/ccm-core/src/main/java/com/arsdigita/templating/ApplicationPatternGenerator.java b/ccm-core/src/main/java/com/arsdigita/templating/ApplicationPatternGenerator.java index 6204b570b..dd9f2ccb5 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/ApplicationPatternGenerator.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/ApplicationPatternGenerator.java @@ -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); diff --git a/ccm-core/src/main/java/com/arsdigita/templating/HostPatternGenerator.java b/ccm-core/src/main/java/com/arsdigita/templating/HostPatternGenerator.java index ab25c9d93..3b51c499c 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/HostPatternGenerator.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/HostPatternGenerator.java @@ -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 + "<<]"); } diff --git a/ccm-core/src/main/java/com/arsdigita/templating/Templating.java b/ccm-core/src/main/java/com/arsdigita/templating/Templating.java index 75f7109c0..ec585ccbd 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/Templating.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/Templating.java @@ -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 URL 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); } diff --git a/ccm-core/src/main/java/com/arsdigita/templating/URLPatternGenerator.java b/ccm-core/src/main/java/com/arsdigita/templating/URLPatternGenerator.java index c45462459..2b8816d77 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/URLPatternGenerator.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/URLPatternGenerator.java @@ -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() { diff --git a/ccm-core/src/main/java/com/arsdigita/templating/WebAppPatternGenerator.java b/ccm-core/src/main/java/com/arsdigita/templating/WebAppPatternGenerator.java index a1edeff9c..468b64714 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/WebAppPatternGenerator.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/WebAppPatternGenerator.java @@ -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 + "<]"); diff --git a/ccm-core/src/main/java/com/arsdigita/templating/XSLTemplate.java b/ccm-core/src/main/java/com/arsdigita/templating/XSLTemplate.java index 0bc7561f6..c9c1113ac 100755 --- a/ccm-core/src/main/java/com/arsdigita/templating/XSLTemplate.java +++ b/ccm-core/src/main/java/com/arsdigita/templating/XSLTemplate.java @@ -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 source, - * using listener to handle any errors. + * Creates and loads a new template from source, using + * listener to handle any errors. * - * @param source A URL pointing to the template - * source text - * @param listener A ErrorListener to customize - * behavior on error + * @param source A URL pointing to the template source text + * @param listener A ErrorListener 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 source using - * the default ErrorListener. + * Creates and loads a new template from source using the + * default ErrorListener. * - * @param source A URL pointing to the template - * source text + * @param source A URL 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 URL of the template source. * - * @return The URL location of the template source; - * it cannot be null + * @return The URL 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 List of URLs to dependent - * stylesheet files; it cannot be null + * @return A List of URLs 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 Transformer; 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 source document and sends it to - * result. If there are errors, - * listener handles them. This method internally - * creates and uses a new Transformer. + * result. If there are errors, listener handles + * them. This method internally creates and uses a new + * Transformer. * - * @param source The Source to be transformed; it - * cannot be null - * @param result The Result to capture the - * transformed product; it cannot be null - * @param listener A ErrorListener to handle - * transformation errors; it cannot be null + * @param source The Source to be transformed; it cannot be + * null + * @param result The Result to capture the transformed + * product; it cannot be null + * @param listener A ErrorListener 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 source document and sends it to - * result. This method internally creates and uses a - * new Transformer. + * result. This method internally creates and uses a new + * Transformer. * - * @param source The Source to be transformed; it - * cannot be null - * @param result The Result to capture the - * transformed product; it cannot be null + * @param source The Source to be transformed; it cannot be + * null + * @param result The Result 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 doc and streams the result to - * writer. If there are errors, - * listener handles them. + * writer. If there are errors, listener handles + * them. * - * @param doc The Document to transform; it cannot be - * null - * @param writer The PrintWriter to receive the - * transformed result; it cannot be null - * @param listener A ErrorListener to handle any - * errors; it cannot be null + * @param doc The Document to transform; it cannot be null + * @param writer The PrintWriter to receive the transformed + * result; it cannot be null + * @param listener A ErrorListener 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 doc and streams the result to * writer. * - * @param doc The Document to transform; it cannot be - * null - * @param writer The PrintWriter to receive the - * transformed result; it cannot be null + * @param doc The Document to transform; it cannot be null + * @param writer The PrintWriter 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 true if any dependent files have been - * modified, otherwise false + * @return true if any dependent files have been modified, + * otherwise false */ 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); } + } + } diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ActionGroup.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ActionGroup.java index 70a610246..6db08359e 100755 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ActionGroup.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ActionGroup.java @@ -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; /** - *

A simple layout panel with top, bottom, left, right, and body - * sections.

+ * A simple layout panel with top, bottom, left, right, and body sections.

* * @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 { } } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentMap.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentMap.java index a253cf964..e3a9f5f07 100644 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentMap.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentMap.java @@ -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); + } diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentSet.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentSet.java index d75d96c7f..368cf8447 100755 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentSet.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ComponentSet.java @@ -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(); diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/LayoutPanel.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/LayoutPanel.java index 6ff00a0cc..83ac34300 100644 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/LayoutPanel.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/LayoutPanel.java @@ -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; /** - *

A simple layout panel with top, bottom, left, right, and body - * sections.

+ * 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); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ModalPanel.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ModalPanel.java index eeae215e1..e658e55ed 100755 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ModalPanel.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/ModalPanel.java @@ -46,14 +46,15 @@ import com.arsdigita.xml.Element; import java.util.Iterator; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * */ public class ModalPanel extends ComponentMap { - private static final Logger s_log = Logger.getLogger(ModalPanel.class); + private static final Logger LOGGER = LogManager.getLogger(ModalPanel.class); private final IndexStack m_stack; private Component m_default; @@ -121,7 +122,7 @@ public class ModalPanel extends ComponentMap { } public final void clear(final PageState state) { - s_log.debug("Clearing the stack"); + LOGGER.debug("Clearing the stack"); m_stack.clear(state); } @@ -137,24 +138,24 @@ public class ModalPanel extends ComponentMap { if (!pushed.equals(top(state))) { m_stack.push(state, state.getPage().stateIndex(pushed)); - if (s_log.isDebugEnabled()) { - s_log.debug("Pushed " + top(state) + " visible"); - s_log.debug("Stack is " + m_stack.toDebugString(state)); - s_log.debug("Here", new Throwable()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Pushed " + top(state) + " visible"); + LOGGER.debug("Stack is " + m_stack.toDebugString(state)); + LOGGER.debug("Here", new Throwable()); } } } public final void pop(final PageState state) { if (m_stack.isEmpty(state)) { - s_log.debug("The stack is empty; nothing was popped"); + LOGGER.debug("The stack is empty; nothing was popped"); } else { m_stack.pop(state); - if (s_log.isDebugEnabled()) { - s_log.debug("Popped " + top(state) + " visible"); - s_log.debug("Stack is " + m_stack.toDebugString(state)); - s_log.debug("Here", new Throwable()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Popped " + top(state) + " visible"); + LOGGER.debug("Stack is " + m_stack.toDebugString(state)); + LOGGER.debug("Here", new Throwable()); } } } @@ -177,7 +178,7 @@ public class ModalPanel extends ComponentMap { m_default = defaalt; - s_log.debug("Default set to " + defaalt); + LOGGER.debug("Default set to " + defaalt); } public final Component getDefault() { @@ -299,8 +300,8 @@ public class ModalPanel extends ComponentMap { } else { push(state, m_target); - if (s_log.isDebugEnabled()) { - s_log.debug("Navigating to " + m_target); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Navigating to " + m_target); } } } @@ -391,7 +392,7 @@ public class ModalPanel extends ComponentMap { } else { m_cancellable = null; - s_log.warn("Form " + form + " does not " + LOGGER.warn("Form " + form + " does not " + "implement Cancellable."); // See note above (import statement)!! // StackTraces.log("The form was created at", form, s_log, "warn"); @@ -413,8 +414,8 @@ public class ModalPanel extends ComponentMap { final PageState state = e.getPageState(); if (m_cancellable != null && m_cancellable.isCancelled(state)) { - if (s_log.isDebugEnabled()) { - s_log.debug("Form processing is cancelled; reverting to " + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Form processing is cancelled; reverting to " + "pre-excursion state"); } @@ -453,8 +454,8 @@ public class ModalPanel extends ComponentMap { public final void process(final FormSectionEvent e) throws FormProcessException { final PageState state = e.getPageState(); - if (s_log.isDebugEnabled()) { - s_log.debug("Form processing went as planned and there is " + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Form processing went as planned and there is " + "no subsequent step; reverting to " + "pre-excursion state"); } @@ -477,8 +478,8 @@ public class ModalPanel extends ComponentMap { public final void process(final FormSectionEvent e) throws FormProcessException { - if (s_log.isDebugEnabled()) { - s_log.debug("Resuming the pre-excursion state"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Resuming the pre-excursion state"); } final PageState state = e.getPageState(); diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/Section.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/Section.java index a246fa70f..99406a827 100755 --- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/Section.java +++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/Section.java @@ -28,21 +28,19 @@ import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.util.Assert; import com.arsdigita.xml.Element; + import java.util.ArrayList; import java.util.Iterator; -import org.apache.log4j.Logger; /** - *

A simple layout panel with top, bottom, left, right, and body - * sections.

+ *

+ * A simple layout panel with top, bottom, left, right, and body sections.

* * @author Justin Ross <jross@redhat.com> * @version $Id$ */ public class Section extends SimpleComponent { - private static final Logger s_log = Logger.getLogger(Section.class); - private final ArrayList m_children; private Component m_heading; private Component m_body; @@ -107,18 +105,19 @@ public class Section extends SimpleComponent { public final void generateXML(final PageState state, final Element parent) { if (isVisible(state)) { - final Element section = parent.newChildElement - ("bebop:section", BEBOP_XML_NS); + final Element section = parent.newChildElement("bebop:section", + BEBOP_XML_NS); - final Element heading = section.newChildElement - ("bebop:heading", BEBOP_XML_NS); + final Element heading = section.newChildElement("bebop:heading", + BEBOP_XML_NS); m_heading.generateXML(state, heading); - final Element body = section.newChildElement - ("bebop:body", BEBOP_XML_NS); + final Element body = section.newChildElement("bebop:body", + BEBOP_XML_NS); m_body.generateXML(state, body); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/CcmObjectSelectionModel.java b/ccm-core/src/main/java/com/arsdigita/ui/CcmObjectSelectionModel.java index d74be2e6e..1ccefb023 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/CcmObjectSelectionModel.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/CcmObjectSelectionModel.java @@ -120,7 +120,7 @@ public class CcmObjectSelectionModel final CcmObjectRepository repository = CdiUtil.createCdiUtil().findBean( CcmObjectRepository.class); @SuppressWarnings("unchecked") - final T object = (T) repository.findById(key).get(); + final T object = (T) repository.findObjectById(key).get(); return object; } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/SimplePage.java b/ccm-core/src/main/java/com/arsdigita/ui/SimplePage.java index 11b89b78b..9ddd51915 100755 --- a/ccm-core/src/main/java/com/arsdigita/ui/SimplePage.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/SimplePage.java @@ -24,7 +24,8 @@ import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; import com.arsdigita.util.Classes; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.HashMap; import java.util.Iterator; @@ -63,10 +64,11 @@ import java.util.Iterator; * */ public class SimplePage extends BasePage { + private static SimplePageLayout s_default = new SimplePageLayout(); private static HashMap s_layouts = new HashMap(); - private static Logger s_log = Logger.getLogger(SimplePage.class); + private static Logger LOGGER = LogManager.getLogger(SimplePage.class); /** * Set the default layout for all applications, which haven't @@ -135,8 +137,8 @@ public class SimplePage extends BasePage { * @param child the component to add to the body */ public void add(Component child) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding component to body " + child.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Adding component to body " + child.getClass()); } super.add(child); @@ -150,8 +152,8 @@ public class SimplePage extends BasePage { */ public void add(Component child, int constraints) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding component to body " + child.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Adding component to body " + child.getClass()); } super.add(child, constraints); @@ -169,8 +171,8 @@ public class SimplePage extends BasePage { while (tags.hasNext()) { String tag = (String)tags.next(); - if (s_log.isDebugEnabled()) { - s_log.debug("Adding component with tag " + tag); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Adding component with tag " + tag); } @@ -180,8 +182,8 @@ public class SimplePage extends BasePage { SimpleComponent child = (SimpleComponent)Classes.newInstance(klass); child.setMetaDataAttribute("tag", tag); - if (s_log.isDebugEnabled()) { - s_log.debug("Adding component " + child.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Adding component " + child.getClass()); } super.add(child); diff --git a/ccm-core/src/main/java/com/arsdigita/ui/UI.java b/ccm-core/src/main/java/com/arsdigita/ui/UI.java index bce3e84ec..0ac4f2f81 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/UI.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/UI.java @@ -22,7 +22,6 @@ import com.arsdigita.ui.login.LoginServlet; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; /** *

@@ -33,11 +32,6 @@ import org.apache.log4j.Logger; */ public abstract class UI { - /** - * Private loggin instance. - */ - private static final Logger s_log = Logger.getLogger(UI.class); - /** * The UI XML namespace. */ diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RolePermissionsTable.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RolePermissionsTable.java index c0b95cc5b..218077ab5 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RolePermissionsTable.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RolePermissionsTable.java @@ -115,7 +115,7 @@ class RolePermissionsTable extends Table { final Role role = roleRepository.findById( Long.parseLong(selectedRoleId.getSelectedKey(state))).get(); final Permission permission = permissionManager - .findById(Long.parseLong(key)); + .findById(Long.parseLong(key)).get(); if (permission.getObject() == null) { permissionManager.revokePrivilege( permission.getGrantedPrivilege(), role); diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/ChangePasswordForm.java b/ccm-core/src/main/java/com/arsdigita/ui/login/ChangePasswordForm.java index f282ff064..18cee2dd6 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/ChangePasswordForm.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/ChangePasswordForm.java @@ -28,7 +28,6 @@ import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.ActionEvent; -import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormValidationListener; @@ -37,21 +36,20 @@ import com.arsdigita.bebop.form.Password; import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.URLParameter; -import com.arsdigita.kernel.KernelConfig; import com.arsdigita.ui.UI; import com.arsdigita.web.URL; import com.arsdigita.web.ReturnSignal; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.security.User; -import org.apache.shiro.subject.Subject; import org.libreccm.security.Shiro; import org.libreccm.security.UserManager; +import java.util.Optional; + /** * A Form that allows a user to change their password by entering their old * password, a new password, and a confirmation of their new password. Requires @@ -69,8 +67,6 @@ public class ChangePasswordForm extends Form implements FormProcessListener, FormValidationListener { - private static final Logger s_log = Logger.getLogger( - ChangePasswordForm.class.getName()); final static String CHANGE_PASSWORD_FORM_NAME = "change-password"; final static String OLD_PASSWORD_PARAM_NAME = "old-password"; final static String NEW_PASSWORD_PARAM_NAME = "new-password"; @@ -119,21 +115,21 @@ public class ChangePasswordForm extends Form final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final Shiro shiro = cdiUtil.findBean(Shiro.class); - final User user = shiro.getUser().get(); + final Optional user = shiro.getUser(); final Label greeting; - if (user == null) { + if (user.isPresent()) { + greeting = new Label(LoginHelper.getMessage( + "login.changePasswordForm.greeting", + new Object[]{String.format("%s %s", + user.get().getGivenName(), + user.get().getFamilyName())})); + } else { greeting = new Label(LoginHelper.getMessage( "login.changePasswordForm.greeting", new Object[]{String.format("%s %s", "", "")})); - } else { - greeting = new Label(LoginHelper.getMessage( - "login.changePasswordForm.greeting", - new Object[]{String.format("%s %s", - user.getGivenName(), - user.getFamilyName())})); } greeting.setFontWeight(Label.BOLD); greeting.setClassAttr("greeting"); diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/EmailInitListener.java b/ccm-core/src/main/java/com/arsdigita/ui/login/EmailInitListener.java index 3a539e2d4..9a2ed9d8e 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/EmailInitListener.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/EmailInitListener.java @@ -23,7 +23,8 @@ import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.parameters.EmailParameter; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.shiro.subject.Subject; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.security.Shiro; @@ -39,7 +40,7 @@ import org.libreccm.security.User; */ public class EmailInitListener implements FormInitListener { - private static final Logger s_log = Logger.getLogger(EmailInitListener.class + private static final Logger LOGGER = LogManager.getLogger(EmailInitListener.class .getName()); private EmailParameter m_param; @@ -51,26 +52,26 @@ public class EmailInitListener implements FormInitListener { public void init(FormSectionEvent event) { FormData data = event.getFormData(); - s_log.debug("START"); + LOGGER.debug("START"); final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final Subject subject = cdiUtil.findBean(Subject.class); final Shiro shiro = cdiUtil.findBean(Shiro.class); if (!subject.isAuthenticated()) { - s_log.debug("FAILURE not logged in"); + LOGGER.debug("FAILURE not logged in"); return; } final User user = shiro.getUser().get(); if (user == null) { - s_log.debug("FAILURE no such user"); + LOGGER.debug("FAILURE no such user"); return; } if (user.getPrimaryEmailAddress() == null) { - s_log.debug("FAILURE null primary email"); + LOGGER.debug("FAILURE null primary email"); return; } @@ -78,7 +79,7 @@ public class EmailInitListener implements FormInitListener { data.put(m_param.getName(), user.getPrimaryEmailAddress().getAddress()); - s_log.debug("SUCCESS"); + LOGGER.debug("SUCCESS"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginHelper.java b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginHelper.java index e4763b26c..39a6a7f1b 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginHelper.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginHelper.java @@ -22,8 +22,12 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.web.ReturnSignal; + +import org.apache.logging.log4j.LogManager; + import java.io.IOException; -import org.apache.log4j.Logger; + +import org.apache.logging.log4j.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -32,11 +36,10 @@ import javax.servlet.http.HttpServletResponse; * Provides helper functions for the login UI. * * @author Sameer Ajmani - * @version $Id$ */ public class LoginHelper { - private static final Logger s_log = Logger.getLogger(LoginHelper.class); + private static final Logger LOGGER = LogManager.getLogger(LoginHelper.class); public static final String RETURN_URL_PARAM_NAME = "return_url"; @@ -129,12 +132,12 @@ public class LoginHelper { throws IOException { if (!response.isCommitted()) { - s_log.debug("Redirecting to: "+url); + LOGGER.debug("Redirecting to: "+url); DispatcherHelper.sendRedirect(request, response, url); response.flushBuffer(); DispatcherHelper.abortRequest(); } else { - s_log.debug("Redirect failed because " + LOGGER.debug("Redirect failed because " +"response already committed"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java index f0f9bdb4c..56473882b 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/LoginServlet.java @@ -34,7 +34,8 @@ import com.arsdigita.ui.UI; import com.arsdigita.web.ReturnSignal; import com.arsdigita.web.URL; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.libreccm.configuration.ConfigurationManager; import org.libreccm.security.UserRepository; @@ -68,7 +69,7 @@ public class LoginServlet extends BebopApplicationServlet { /** * Logger instance for debugging */ - private static final Logger s_log = Logger.getLogger(LoginServlet.class); + private static final Logger LOGGER = LogManager.getLogger(LoginServlet.class); // //////////////////////////////////////////////////////////////////////// // Define various URLs to subpages of Login to manage administrative tasks. @@ -297,7 +298,7 @@ public class LoginServlet extends BebopApplicationServlet { Class c = Class.forName(pageClass); p = (Page) c.newInstance(); } catch (Exception e) { - s_log.error( + LOGGER.error( "Unable to instantiate waf.dispatcher.default_page_class", e); } } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/ScreenNameInitListener.java b/ccm-core/src/main/java/com/arsdigita/ui/login/ScreenNameInitListener.java index 58eab0853..fe9645d6c 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/ScreenNameInitListener.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/ScreenNameInitListener.java @@ -24,7 +24,8 @@ import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.parameters.StringParameter; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.shiro.subject.Subject; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.security.Shiro; @@ -42,8 +43,8 @@ import org.libreccm.security.User; */ public class ScreenNameInitListener implements FormInitListener { - private static Logger s_log = Logger.getLogger(ScreenNameInitListener.class - .getName()); + private static Logger LOGGER = LogManager.getLogger( + ScreenNameInitListener.class); private StringParameter m_param; /** @@ -61,25 +62,25 @@ public class ScreenNameInitListener implements FormInitListener { public void init(FormSectionEvent event) { PageState state = event.getPageState(); FormData data = event.getFormData(); - s_log.debug("START"); + LOGGER.debug("START"); final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final Subject subject = cdiUtil.findBean(Subject.class); final Shiro shiro = cdiUtil.findBean(Shiro.class); if (!subject.isAuthenticated()) { - s_log.debug("FAILURE not logged in"); + LOGGER.debug("FAILURE not logged in"); return; } final User user = shiro.getUser().get(); if (user.getName() == null) { - s_log.debug("FAILURE null screen name"); + LOGGER.debug("FAILURE null screen name"); return; } data.put(m_param.getName(), user.getName()); - s_log.debug("SUCCESS"); + LOGGER.debug("SUCCESS"); } } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/UserAuthenticationListener.java b/ccm-core/src/main/java/com/arsdigita/ui/login/UserAuthenticationListener.java index 75d79b47c..85dd0bf61 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/UserAuthenticationListener.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/UserAuthenticationListener.java @@ -26,7 +26,8 @@ import com.arsdigita.kernel.security.Util; import com.arsdigita.web.Web; import com.arsdigita.web.LoginSignal; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.libreccm.cdi.utils.CdiUtil; import javax.servlet.http.HttpServletRequest; @@ -43,13 +44,10 @@ import org.apache.shiro.subject.Subject; * * @author Phong Nguyen * @author Sameer Ajmani - * @version 1.0 - * @version $Id: UserAuthenticationListener.java 287 2005-02-22 00:29:02Z - * sskracic $ */ public class UserAuthenticationListener implements RequestListener { - private static final Logger s_log = Logger.getLogger( + private static final Logger LOGGER = LogManager.getLogger( UserAuthenticationListener.class); /** @@ -94,7 +92,7 @@ public class UserAuthenticationListener implements RequestListener { PageState state = event.getPageState(); if (!isLoggedIn(state)) { - s_log.debug("User is not logged in"); + LOGGER.debug("User is not logged in"); redirectToLoginPage(state); } @@ -112,7 +110,7 @@ public class UserAuthenticationListener implements RequestListener { // first make sure we're not already looking at the login // page -- if we are, don't redirect! if (urlBase.equals(Web.getWebContext().getRequestURL().getRequestURI())) { - s_log.debug("preventing cyclic redirect to: " + urlBase); + LOGGER.debug("preventing cyclic redirect to: " + urlBase); // return without redirect return; } diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/UserForm.java b/ccm-core/src/main/java/com/arsdigita/ui/login/UserForm.java index 14f9051f3..38e55c2ce 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/UserForm.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/UserForm.java @@ -38,7 +38,6 @@ import com.arsdigita.bebop.parameters.StringLengthValidationListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.kernel.KernelConfig; -import org.apache.log4j.Logger; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.security.User; import org.libreccm.security.UserRepository; @@ -55,9 +54,6 @@ import java.util.Optional; public abstract class UserForm extends Form implements LoginConstants, FormInitListener, FormValidationListener { - private static final Logger LOGGER = Logger.getLogger(UserForm.class - .getName()); - private final boolean m_newUser; protected TextField m_firstName; diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/UserInfo.java b/ccm-core/src/main/java/com/arsdigita/ui/login/UserInfo.java index f291ffd1a..5e91960d6 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/UserInfo.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/UserInfo.java @@ -30,7 +30,8 @@ import com.arsdigita.xml.Element; import java.util.ArrayList; import java.util.List; -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.security.Shiro; import org.libreccm.security.User; @@ -48,17 +49,14 @@ import org.libreccm.web.CcmApplication; * @author Sameer Ajmani * @author Peter Boy (refactored to eliminate old type kernel.Package* / * SiteNode) - * @since 2001-06-01 - * @version 1.0 - * @version $Id$ + */ public class UserInfo extends SimpleContainer { /** * Logger instance for debugging support */ - private static final Logger s_log = Logger.getLogger(UserInfo.class - .getName()); + private static final Logger LOGGER = LogManager.getLogger(UserInfo.class); /** * Holds a list of content centers (Application instances) that exist on @@ -90,7 +88,7 @@ public class UserInfo extends SimpleContainer { @Override public void generateXML(PageState state, Element parent) { if (!isLoggedIn(state)) { - s_log.debug("user is not logged in, so no XML generated"); + LOGGER.debug("user is not logged in, so no XML generated"); return; } final User user = getUser(state); diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/UserLogoutListener.java b/ccm-core/src/main/java/com/arsdigita/ui/login/UserLogoutListener.java index 7a03a0c04..48a89bc5a 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/login/UserLogoutListener.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/login/UserLogoutListener.java @@ -21,7 +21,6 @@ package com.arsdigita.ui.login; import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionListener; -import org.apache.log4j.Logger; import org.apache.shiro.subject.Subject; import org.libreccm.cdi.utils.CdiUtil; @@ -33,9 +32,6 @@ import org.libreccm.cdi.utils.CdiUtil; */ public class UserLogoutListener implements ActionListener { - private static final Logger s_log = Logger.getLogger( - UserLogoutListener.class); - /** * Logs out the user. * diff --git a/ccm-core/src/main/java/com/arsdigita/util/Assert.java b/ccm-core/src/main/java/com/arsdigita/util/Assert.java index 874a51b23..528b4cccc 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/Assert.java +++ b/ccm-core/src/main/java/com/arsdigita/util/Assert.java @@ -18,7 +18,8 @@ */ package com.arsdigita.util; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Utility functions for assertions. @@ -33,12 +34,11 @@ import org.apache.log4j.Logger; * @author David Lutterkort <dlutter@redhat.com> * @author Uday Mathur * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class Assert { /** Class specific logger instance. */ - private static final Logger s_log = Logger.getLogger(Assert.class); + private static final Logger LOGGER = LogManager.getLogger(Assert.class); private static final String DEFAULT_MESSAGE = "Assertion failure"; @@ -400,7 +400,7 @@ public class Assert { private static void error(final String message) { // Log the stack trace too, since we still have code that // manages to hide exceptions. - s_log.error(message, new AssertionError(message)); + LOGGER.error(message, new AssertionError(message)); } /////////////////////////////////////////////////////////////////////////// diff --git a/ccm-core/src/main/java/com/arsdigita/util/Classes.java b/ccm-core/src/main/java/com/arsdigita/util/Classes.java index bd1230241..d206c0dbb 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/Classes.java +++ b/ccm-core/src/main/java/com/arsdigita/util/Classes.java @@ -20,26 +20,21 @@ package com.arsdigita.util; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Constructor; -import org.apache.log4j.Logger; import java.util.Arrays; /** - * A collection of static utility methods for dealing with Java - * classes. + * A collection of static utility methods for dealing with Java classes. * * @author Justin Ross - * @version $Id$ */ public final class Classes { - private static final Logger s_log = Logger.getLogger(Classes.class); - /** * Loads a class from its fully qualified string name. * - * @param clacc A fully qualified String naming - * the class to be loaded + * @param clacc A fully qualified String naming the class to be + * loaded */ public static final Class loadClass(final String clacc) { Assert.exists(clacc, String.class); @@ -52,15 +47,12 @@ public final class Classes { } /** - * Constructs a new instance of a class using the given - * parameters. + * Constructs a new instance of a class using the given parameters. * - * @param clacc The Class of which to make a new - * instance - * @param params A Class[] representing the arguments - * of the desired constructor - * @param values An Object[] of values to fill the - * parameters + * @param clacc The Class of which to make a new instance + * @param params A Class[] representing the arguments of the + * desired constructor + * @param values An Object[] of values to fill the parameters */ public static final Object newInstance(final Class clacc, final Class[] params, @@ -77,25 +69,24 @@ public final class Classes { return constructor.newInstance(values); } catch (NoSuchMethodException ex) { - throw new UncheckedWrapperException - (message(clacc, params, values), ex); + throw new UncheckedWrapperException(message(clacc, params, values), + ex); } catch (IllegalAccessException ex) { - throw new UncheckedWrapperException - (message(clacc, params, values), ex); + throw new UncheckedWrapperException(message(clacc, params, values), + ex); } catch (InvocationTargetException ex) { - throw new UncheckedWrapperException - (message(clacc, params, values), ex); + throw new UncheckedWrapperException(message(clacc, params, values), + ex); } catch (InstantiationException ex) { - throw new UncheckedWrapperException - (message(clacc, params, values), ex); + throw new UncheckedWrapperException(message(clacc, params, values), + ex); } } private static String message(Class klass, Class[] params, Object[] values) { - return "class = " + klass + - ", params = " + message(params) + - ", values = " + message(values); + return "class = " + klass + ", params = " + message(params) + + ", values = " + message(values); } private static String message(Object[] array) { @@ -107,15 +98,13 @@ public final class Classes { } /** - * Constructs a new instance of the class referred to by - * clacc. + * Constructs a new instance of the class referred to by clacc. * - * @param clacc The fully qualified String - * clacc of the object you wish to instantiate - * @param params A Class[] representing the arguments - * of the desired constructor - * @param values An Object[] of values to fill the - * parameters + * @param clacc The fully qualified String clacc of the object + * you wish to instantiate + * @param params A Class[] representing the arguments of the + * desired constructor + * @param values An Object[] of values to fill the parameters */ public static final Object newInstance(final String clacc, final Class[] params, @@ -125,8 +114,8 @@ public final class Classes { /** * Creates a new instance of clacc using its no-args - * constructor. If the class has no such constructor, it throws a - * runtime exception. + * constructor. If the class has no such constructor, it throws a runtime + * exception. * * @param clacc The class of which to create a new instance */ @@ -135,14 +124,14 @@ public final class Classes { } /** - * Creates a new instance of the class represented by - * clacc using its no-args constructor. If the class - * has no such constructor, it throws a runtime exception. + * Creates a new instance of the class represented by clacc + * using its no-args constructor. If the class has no such constructor, it + * throws a runtime exception. * - * @param clacc The fully-qualified String name of - * the class + * @param clacc The fully-qualified String name of the class */ public static final Object newInstance(final String clacc) { return newInstance(loadClass(clacc)); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/Exceptions.java b/ccm-core/src/main/java/com/arsdigita/util/Exceptions.java index c0b3e23f1..3f1506a35 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/Exceptions.java +++ b/ccm-core/src/main/java/com/arsdigita/util/Exceptions.java @@ -18,16 +18,18 @@ */ package com.arsdigita.util; +import org.apache.logging.log4j.LogManager; + import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.ArrayList; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; public class Exceptions { - private static Logger s_log = Logger.getLogger(Exceptions.class); + private static Logger LOGGER = LogManager.getLogger(Exceptions.class); private static Map s_unwrappers = new HashMap(); @@ -38,8 +40,8 @@ public class Exceptions { exceptions.add(t); - if (s_log.isDebugEnabled()) { - s_log.debug("Trying to unwrap " + t.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Trying to unwrap " + t.getClass()); } Throwable current = t; @@ -54,15 +56,15 @@ public class Exceptions { if (inner == null) { Assert.exists(current, Throwable.class); - if (s_log.isDebugEnabled()) { - s_log.debug("Returning exception " + current.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Returning exception " + current.getClass()); } return (Throwable[])exceptions.toArray( new Throwable[exceptions.size()]); } - if (s_log.isDebugEnabled()) { - s_log.debug("Inner exception is " + inner.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Inner exception is " + inner.getClass()); } exceptions.add(inner); @@ -89,23 +91,23 @@ public class Exceptions { } public static ExceptionUnwrapper findUnwrapper(Class exception) { - if (s_log.isDebugEnabled()) { - s_log.debug("Finding unwrapper for " + exception.getName()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Finding unwrapper for " + exception.getName()); } Class current = exception; ExceptionUnwrapper unwrapper = null; while (unwrapper == null && current != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Trying class " + current.getName()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Trying class " + current.getName()); } unwrapper = (ExceptionUnwrapper)s_unwrappers.get(current); current = current.getSuperclass(); } - if (s_log.isDebugEnabled()) { - s_log.debug("Got unwrapper " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got unwrapper " + (unwrapper != null ? unwrapper.getClass() : null)); } return unwrapper; diff --git a/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyReader.java b/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyReader.java index a29379612..3c3e6c9af 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyReader.java +++ b/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyReader.java @@ -24,7 +24,8 @@ import com.arsdigita.util.parameter.ParameterReader; import java.io.IOException; import java.io.InputStream; import java.util.Properties; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * An implementation of ParameterReader that uses @@ -39,7 +40,7 @@ import org.apache.log4j.Logger; */ public class JavaPropertyReader implements ParameterReader { - private static final Logger s_log = Logger.getLogger + private static final Logger LOGGER = LogManager.getLogger (JavaPropertyReader.class); private final Properties m_props; @@ -86,8 +87,8 @@ public class JavaPropertyReader implements ParameterReader { */ @Override public final String read(final Parameter param, final ErrorList errors) { - if (s_log.isDebugEnabled()) { - s_log.debug("Reading " + param + " from " + m_props); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Reading " + param + " from " + m_props); } if (Assert.isEnabled()) { diff --git a/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyWriter.java b/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyWriter.java index 94f116048..d8c77f5de 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyWriter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/JavaPropertyWriter.java @@ -23,7 +23,8 @@ import com.arsdigita.util.parameter.ParameterWriter; import java.io.IOException; import java.io.OutputStream; import java.util.Properties; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * Subject to change. @@ -34,11 +35,10 @@ import org.apache.log4j.Logger; * @see com.arsdigita.util.parameter.ParameterWriter * @see JavaPropertyReader * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class JavaPropertyWriter implements ParameterWriter { - private static final Logger s_log = Logger.getLogger + private static final Logger LOGGER = LogManager.getLogger (JavaPropertyWriter.class); private static final String s_header = @@ -66,8 +66,8 @@ public class JavaPropertyWriter implements ParameterWriter { * parameters to; it cannot be null */ public final void store(final OutputStream out) { - if (s_log.isDebugEnabled()) { - s_log.debug("Storing " + this); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Storing " + this); } Assert.exists(out, OutputStream.class); @@ -89,8 +89,8 @@ public class JavaPropertyWriter implements ParameterWriter { * be null */ public final void write(final Parameter param, final String value) { - if (s_log.isDebugEnabled()) { - s_log.debug("Writing " + param + " with value " + value); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Writing " + param + " with value " + value); } if (Assert.isEnabled()) { diff --git a/ccm-core/src/main/java/com/arsdigita/util/OrderedMap.java b/ccm-core/src/main/java/com/arsdigita/util/OrderedMap.java index 621115a42..e585537d0 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/OrderedMap.java +++ b/ccm-core/src/main/java/com/arsdigita/util/OrderedMap.java @@ -18,10 +18,13 @@ */ package com.arsdigita.util; +import org.apache.logging.log4j.LogManager; + import java.util.TreeMap; import java.util.HashMap; import java.util.Comparator; -import org.apache.log4j.Logger; + +import org.apache.logging.log4j.Logger; /** * An implementation of Map which preserves the order in which you put @@ -29,11 +32,10 @@ import org.apache.log4j.Logger; * * @deprecated use {@link com.arsdigita.util.SequentialMap} instead * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class OrderedMap extends TreeMap { - private static final Logger s_log = Logger.getLogger(OrderedMap.class); + private static final Logger LOGGER = LogManager.getLogger(OrderedMap.class); private OrderingComparator m_comparator; @@ -48,8 +50,8 @@ public class OrderedMap extends TreeMap { * its contents in calls to entrySet().iterator(); */ public Object put(final Object key, final Object value) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding a new map entry: " + key + " => " + value); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Adding a new map entry: " + key + " => " + value); } m_comparator.keep(key); @@ -73,7 +75,7 @@ public class OrderedMap extends TreeMap { } final class OrderingComparator implements Comparator, Cloneable { - private static final Logger s_log = Logger.getLogger + private static final Logger LOGGER = LogManager.getLogger (OrderingComparator.class); private HashMap m_sortKeyMap = new HashMap(); @@ -84,15 +86,15 @@ final class OrderingComparator implements Comparator, Cloneable { Long sk2 = (Long) m_sortKeyMap.get(o2); if (sk1 == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("The sort key of " + o1 + " is null; " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("The sort key of " + o1 + " is null; " + "returning 1"); } return 1; } else if (sk2 == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("The sort key of " + o2 + " is null; " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("The sort key of " + o2 + " is null; " + "returning -1"); } @@ -100,12 +102,12 @@ final class OrderingComparator implements Comparator, Cloneable { } else { final int result = (int) (sk1.longValue() - sk2.longValue()); - if (s_log.isDebugEnabled()) { - s_log.debug("The sort key of " + o1 + " is " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("The sort key of " + o1 + " is " + sk1.longValue()); - s_log.debug("The sort key of " + o2 + " is " + + LOGGER.debug("The sort key of " + o2 + " is " + sk2.longValue()); - s_log.debug("The result is " + result); + LOGGER.debug("The result is " + result); } if (Assert.isEnabled() && result == 0) { diff --git a/ccm-core/src/main/java/com/arsdigita/util/Record.java b/ccm-core/src/main/java/com/arsdigita/util/Record.java index 761dda636..1078e934e 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/Record.java +++ b/ccm-core/src/main/java/com/arsdigita/util/Record.java @@ -18,9 +18,11 @@ */ package com.arsdigita.util; -import java.lang.reflect.Method; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.lang.reflect.InvocationTargetException; -import org.apache.log4j.Logger; +import java.lang.reflect.Method; /** * @author Justin Ross <jross@redhat.com> @@ -28,11 +30,12 @@ import org.apache.log4j.Logger; */ public abstract class Record { - /** Internal logger instance to faciliate debugging. Enable logging output - * by editing /WEB-INF/conf/log4j.properties int the runtime environment - * and set com.arsdigita.util.Record=DEBUG - * by uncommenting or adding the line. */ - private static final Logger s_log = Logger.getLogger(Record.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.util.Record=DEBUG by uncommenting or adding the line. + */ + private static final Logger LOGGER = LogManager.getLogger(Record.class); private Class m_class; private Logger m_log; @@ -85,14 +88,14 @@ public abstract class Record { private Method accessor(final String field) { try { - Method method = m_class.getDeclaredMethod - ("get" + field, new Class[] {}); + Method method = m_class.getDeclaredMethod("get" + field, + new Class[]{}); return method; } catch (NoSuchMethodException nsme) { try { - Method method = m_class.getDeclaredMethod - ("is" + field, new Class[] {}); + Method method = m_class.getDeclaredMethod("is" + field, + new Class[]{}); return method; } catch (NoSuchMethodException me) { @@ -103,7 +106,7 @@ public abstract class Record { private Object value(final Method m) { try { - return m.invoke(this, new Object[] {}); + return m.invoke(this, new Object[]{}); } catch (IllegalAccessException iae) { throw new UncheckedWrapperException(iae); } catch (InvocationTargetException ite) { @@ -134,4 +137,5 @@ public abstract class Record { return info.toString(); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/StringUtils.java b/ccm-core/src/main/java/com/arsdigita/util/StringUtils.java index 593fa342b..1ef508ca2 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/StringUtils.java +++ b/ccm-core/src/main/java/com/arsdigita/util/StringUtils.java @@ -28,7 +28,8 @@ import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * A (static) class of generally-useful string utilities. @@ -39,7 +40,7 @@ import org.apache.log4j.Logger; "PMD.ExcessiveClassLength", "PMD.TooManyMethods", "PMD.CyclomaticComplexity"}) public final class StringUtils { - private static final Logger S_LOG = Logger.getLogger(StringUtils.class); + private static final Logger LOGGER = LogManager.getLogger(StringUtils.class); public static final String NEW_LINE = System.getProperty("line.separator"); //html line break: @@ -260,8 +261,8 @@ public final class StringUtils { * @return */ private static String smartTextInline(final String str) { - if (S_LOG.isDebugEnabled()) { - S_LOG.debug("Input {" + str + "}"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Input {" + str + "}"); } // We're going to use the octal characters \u0001 and \u0002 for @@ -279,8 +280,8 @@ public final class StringUtils { result = result.replaceAll("\\(TM\\)|\\(tm\\)", "TM"); result = result.replaceAll("^\\+", ""); - if (S_LOG.isDebugEnabled()) { - S_LOG.debug("After entities {" + result + "}"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("After entities {" + result + "}"); } // Next lets process italics /italic/ @@ -290,8 +291,8 @@ public final class StringUtils { // Now we're onto the monospace stuff =monospace= result = result.replaceAll("\\=+([a-zA-Z_0-9]+)+\\=", "$1"); - if (S_LOG.isDebugEnabled()) { - S_LOG.debug("After styles {" + result + "}"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("After styles {" + result + "}"); } // untitled mailto @@ -323,8 +324,8 @@ public final class StringUtils { result = result.replaceAll("@(http[s]*://www\\..+\\.[A-Za-z]{2,4})", "$1"); - if (S_LOG.isDebugEnabled()) { - S_LOG.debug("After links {" + result + "}"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("After links {" + result + "}"); } return result; diff --git a/ccm-core/src/main/java/com/arsdigita/util/URLRewriter.java b/ccm-core/src/main/java/com/arsdigita/util/URLRewriter.java index b541f9367..7e0be612b 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/URLRewriter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/URLRewriter.java @@ -27,7 +27,8 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * Re-writes URLs to include additional parameters that come from a @@ -35,12 +36,11 @@ import org.apache.log4j.Logger; * cookieless login possible, by re-writing URLs to include a session * ID parameter. * - * @version $Id$ */ public class URLRewriter { /** Creates a s_logging category with name = to the full name of class */ - private static final Logger s_log = Logger.getLogger(URLRewriter.class); + private static final Logger LOGGER = LogManager.getLogger(URLRewriter.class); /** The parameter providers for the system. Client classes are registered here. */ private static LinkedList s_providers = new LinkedList(); @@ -49,7 +49,7 @@ public class URLRewriter { * Adds a parameter provider. **/ public static void addParameterProvider(ParameterProvider provider) { - s_log.debug("addParameterProvider: " + LOGGER.debug("addParameterProvider: " + provider.getClass().getName()); s_providers.add(provider); } @@ -68,7 +68,7 @@ public class URLRewriter { **/ public static Set getGlobalModels() { if (s_providers.isEmpty()) { - s_log.debug("getGlobalModels: no providers set"); + LOGGER.debug("getGlobalModels: no providers set"); return java.util.Collections.EMPTY_SET; } @@ -87,7 +87,7 @@ public class URLRewriter { **/ public static Set getGlobalParams(HttpServletRequest req) { if (s_providers.isEmpty()) { - s_log.debug("getGlobalParams: no providers set"); + LOGGER.debug("getGlobalParams: no providers set"); return java.util.Collections.EMPTY_SET; } @@ -108,14 +108,14 @@ public class URLRewriter { public static String encodeRedirectURL(HttpServletRequest req, HttpServletResponse resp, String url) { - if (s_log.isDebugEnabled()) { - s_log.debug("encodeRedirectURL: before: " + url); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("encodeRedirectURL: before: " + url); } url = resp.encodeRedirectURL(encodeParams(req, url)); - if (s_log.isDebugEnabled()) { - s_log.debug("encodeRedirectURL: after: " + url); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("encodeRedirectURL: after: " + url); } return url; @@ -144,14 +144,14 @@ public class URLRewriter { public static String encodeURL(HttpServletRequest req, HttpServletResponse resp, String url) { - if (s_log.isDebugEnabled()) { - s_log.debug("encodeURL: before: " + url); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("encodeURL: before: " + url); } url = resp.encodeURL(encodeParams(req, url)); - if (s_log.isDebugEnabled()) { - s_log.debug("encodeURL: after: " + url); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("encodeURL: after: " + url); } return url; @@ -162,7 +162,7 @@ public class URLRewriter { **/ private static String encodeParams(HttpServletRequest req, String url) { if (s_providers.isEmpty()) { - s_log.debug("encodeParams: no providers set"); + LOGGER.debug("encodeParams: no providers set"); return url; } Map params = new java.util.HashMap(); diff --git a/ccm-core/src/main/java/com/arsdigita/util/UncheckedWrapperException.java b/ccm-core/src/main/java/com/arsdigita/util/UncheckedWrapperException.java index 4c5253aba..43ad5b8cb 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/UncheckedWrapperException.java +++ b/ccm-core/src/main/java/com/arsdigita/util/UncheckedWrapperException.java @@ -18,72 +18,68 @@ */ package com.arsdigita.util; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** - * A wrapper exception that can be used to rethrow another - * exception. + * A wrapper exception that can be used to rethrow another exception. * * TODO: This should become a skeleton when/if we switch to Java 1.4. * http://java.sun.com/j2se/1.4/docs/guide/lang/chained-exceptions.html * - * The basic exception methods are overridden with methods that - * combine this wrapper and its root cause, so it can be - * treated just like any normal exception in actual use. + * The basic exception methods are overridden with methods that combine this + * wrapper and its root cause, so it can be treated just like any normal + * exception in actual use. * - * Note that it is not necessary to provide a string along - * with a root cause; in particular, the following usage: + * Note that it is not necessary to provide a string along with a root cause; in + * particular, the following usage: * new UncheckedWrapperException(e); is more correct than * new UncheckedWrapperException(e.getMessage(), e); * * @author David Eison - * @version $Id$ */ public class UncheckedWrapperException extends RuntimeException { - private static final Logger logger = Logger.getLogger( - UncheckedWrapperException.class); + private static final long serialVersionUID = 1473646671430756784L; static { - logger.debug("Static initalizer starting..."); Exceptions.registerUnwrapper( - UncheckedWrapperException.class, - new ExceptionUnwrapper() { + UncheckedWrapperException.class, + new ExceptionUnwrapper() { - public Throwable unwrap(Throwable t) { - UncheckedWrapperException ex = - (UncheckedWrapperException) t; - return ex.getRootCause(); - } - }); - logger.debug("Static initalizer finished."); + public Throwable unwrap(Throwable t) { + UncheckedWrapperException ex = (UncheckedWrapperException) t; + return ex.getRootCause(); + } + + }); } + Throwable m_rootCause; /** * Constructor which only takes a msg, which will cause this - * UncheckedWrapperException to behave like a normal RuntimeException. - * While it doesn't seem to make a lot of sense to have a wrapper - * exception that doesn't wrap anything, this is needed so that it - * can be used as a direct replacement for RuntimeException. + * UncheckedWrapperException to behave like a normal RuntimeException. While + * it doesn't seem to make a lot of sense to have a wrapper exception that + * doesn't wrap anything, this is needed so that it can be used as a direct + * replacement for RuntimeException. */ public UncheckedWrapperException(String msg) { this(msg, null); } /** - * Constructor which takes a root cause - * that this exception will be wrapping. + * Constructor which takes a root cause that this exception will be + * wrapping. */ public UncheckedWrapperException(Throwable rootCause) { this(null, rootCause); } /** - * Constructor which takes a message string and a root cause - * that this exception will be wrapping. The message string - * should be something different than rootCause.getMessage() - * would normally provide. + * Constructor which takes a message string and a root cause that this + * exception will be wrapping. The message string should be something + * different than rootCause.getMessage() would normally provide. */ public UncheckedWrapperException(String s, Throwable rootCause) { super(s); @@ -91,18 +87,19 @@ public class UncheckedWrapperException extends RuntimeException { } /** - * Throws an UncheckedWrapperException, and ensurs that it is logged at ERROR priority. + * Throws an UncheckedWrapperException, and ensurs that it is logged at + * ERROR priority. * - * @param source Class having the error. For Log4J reporting - * @param msg Error message + * @param source Class having the error. For Log4J reporting + * @param msg Error message * @param rootCause The root cause exception * * @throws UncheckedWrapperException */ public static void throwLoggedException(Class source, String msg, Throwable rootCause) throws - UncheckedWrapperException { - Logger log = Logger.getLogger(source); + UncheckedWrapperException { + Logger log = LogManager.getLogger(source); log.error(msg, rootCause); throw new UncheckedWrapperException(msg, rootCause); @@ -135,11 +132,10 @@ public class UncheckedWrapperException extends RuntimeException { /** * Get a string representing this exception and the root cause. * - * Functions like normal toString, except that the name of the - * provided class will be used instead of the name of the - * unchecked wrapper exception. Useful when another exception - * class is using an unchecked wrapper exception to delegate - * to. + * Functions like normal toString, except that the name of the provided + * class will be used instead of the name of the unchecked wrapper + * exception. Useful when another exception class is using an unchecked + * wrapper exception to delegate to. */ public String toString(Class delegatingClass) { // default toString calls getMessage, so we don't want to rely on it @@ -163,7 +159,7 @@ public class UncheckedWrapperException extends RuntimeException { public String getMessage() { if (m_rootCause != null) { return super.getMessage() + " (root cause: " + m_rootCause. - getMessage() + ")"; + getMessage() + ")"; } else { return super.getMessage(); } @@ -204,4 +200,5 @@ public class UncheckedWrapperException extends RuntimeException { m_rootCause.printStackTrace(s); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/AbstractParameterContext.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/AbstractParameterContext.java index 7714d68b3..4dfccbe3f 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/AbstractParameterContext.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/AbstractParameterContext.java @@ -29,7 +29,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + /** * A base implementation of the ParameterContext @@ -39,11 +41,10 @@ import org.apache.log4j.Logger; * * @see com.arsdigita.util.parameter.ParameterContext * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public abstract class AbstractParameterContext implements ParameterContext { - private static final Logger s_log = Logger.getLogger + private static final Logger LOGGER = LogManager.getLogger (AbstractParameterContext.class); private final MapParameter m_param; @@ -66,8 +67,8 @@ public abstract class AbstractParameterContext implements ParameterContext { * cannot be null */ public final void register(final Parameter param) { - if (s_log.isDebugEnabled()) { - s_log.debug("Registering " + param + " on " + this); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Registering " + param + " on " + this); } if (Assert.isEnabled()) { @@ -139,8 +140,8 @@ public abstract class AbstractParameterContext implements ParameterContext { * @see ParameterContext#get(Parameter,Object) */ public void set(final Parameter param, final Object value) { - if (s_log.isDebugEnabled()) { - s_log.debug("Setting " + param + " to " + value); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Setting " + param + " to " + value); } Assert.exists(param, Parameter.class); diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/ClassParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/ClassParameter.java index 1e067a98c..be3b4f1c0 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/ClassParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/ClassParameter.java @@ -19,7 +19,8 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.ClassConverter; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * A parameter representing a Java Class. @@ -29,16 +30,16 @@ import org.apache.log4j.Logger; * @see java.lang.Class * @see Parameter * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class ClassParameter extends AbstractParameter { - private static final Logger logger = Logger.getLogger(ClassParameter.class); + private static final Logger LOGGER = LogManager.getLogger( + ClassParameter.class); static { - logger.debug("Static initalizer starting..."); + LOGGER.debug("Static initalizer starting..."); Converters.set(Class.class, new ClassConverter()); - logger.debug("Static initalizer finished."); + LOGGER.debug("Static initalizer finished."); } public ClassParameter(final String name) { @@ -71,4 +72,5 @@ public class ClassParameter extends AbstractParameter { return theClass.getName(); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/CompoundParameterReader.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/CompoundParameterReader.java index f5789dea6..6fa1ea48f 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/CompoundParameterReader.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/CompoundParameterReader.java @@ -19,10 +19,10 @@ package com.arsdigita.util.parameter; import com.arsdigita.util.Assert; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.log4j.Logger; /** * Aggregates a set of ParameterReaders so they may be @@ -33,13 +33,9 @@ import org.apache.log4j.Logger; * @see ParameterReader * @author Rafael H. Schloming <rhs@mit.edu> * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class CompoundParameterReader implements ParameterReader { - private static final Logger s_log = Logger.getLogger - (CompoundParameterReader.class); - private final List m_readers; /** diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/EnumerationParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/EnumerationParameter.java index 1483a8e0b..a250813b9 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/EnumerationParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/EnumerationParameter.java @@ -19,23 +19,18 @@ package com.arsdigita.util.parameter; import java.util.HashMap; -import org.apache.log4j.Logger; /** * Subject to change. * - * A parameter that maps keys to values and, given a key, marshals or - * unmarshals to the corresponding value. + * A parameter that maps keys to values and, given a key, marshals or unmarshals + * to the corresponding value. * * @see Parameter * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class EnumerationParameter extends AbstractParameter { - private static final Logger s_log = Logger.getLogger - (EnumerationParameter.class); - private final HashMap m_entries; private final HashMap m_reverse; @@ -54,12 +49,12 @@ public class EnumerationParameter extends AbstractParameter { public final void put(final String name, final Object value) { if (m_entries.containsKey(name)) { - throw new IllegalArgumentException - ("name already has a value: " + name); + throw new IllegalArgumentException("name already has a value: " + + name); } if (m_reverse.containsKey(value)) { - throw new IllegalArgumentException - ("value already has a name: " + value); + throw new IllegalArgumentException("value already has a name: " + + value); } m_entries.put(name, value); m_reverse.put(value, name); @@ -69,8 +64,9 @@ public class EnumerationParameter extends AbstractParameter { if (m_entries.containsKey(value)) { return m_entries.get(value); } else { - final ParameterError error = new ParameterError - (this, "The value must be one of " + m_entries.keySet()); + final ParameterError error = new ParameterError(this, + "The value must be one of " + + m_entries.keySet()); errors.add(error); diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/ErrorList.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/ErrorList.java index 923366674..61ca7e67c 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/ErrorList.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/ErrorList.java @@ -26,7 +26,9 @@ import java.io.StringWriter; import java.io.Writer; 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; + /** * Subject to change. @@ -40,11 +42,10 @@ import org.apache.log4j.Logger; * @see ParameterError * @see Parameter * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public final class ErrorList { - private static final Logger s_log = Logger.getLogger(ErrorList.class); + private static final Logger LOGGER = LogManager.getLogger(ErrorList.class); private final ArrayList m_params; @@ -111,7 +112,7 @@ public final class ErrorList { if (!isEmpty()) { final StringWriter writer = new StringWriter(); report(writer); - s_log.error(writer.toString()); + LOGGER.error(writer.toString()); throw new ParameterException ("Errors encountered while reading parameters", this); diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/FileParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/FileParameter.java index 979e2addc..5b9536aa0 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/FileParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/FileParameter.java @@ -20,7 +20,6 @@ package com.arsdigita.util.parameter; import java.io.File; -import org.apache.log4j.Logger; /** * A Parameter representing a File @@ -30,12 +29,12 @@ import org.apache.log4j.Logger; * @author bche */ public class FileParameter extends AbstractParameter { - private static final Logger s_log = Logger.getLogger(FileParameter.class); - + public FileParameter(final String name) { super(name, File.class); } + @Override public Object unmarshal(final String value, final ErrorList errors) { final String sPath = value; File file = new File(sPath); @@ -46,6 +45,7 @@ public class FileParameter extends AbstractParameter { } } + @Override public String marshal(final Object value) { final File file = (File) value; if (file == null) { diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/IntegerParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/IntegerParameter.java index 46a11ff07..5f3f5fe3e 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/IntegerParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/IntegerParameter.java @@ -19,7 +19,8 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.IntegerConverter; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * A parameter representing a Java Integer. @@ -29,16 +30,16 @@ import org.apache.log4j.Logger; * @see java.lang.Integer * @see Parameter * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class IntegerParameter extends AbstractParameter { - private final static Logger logger = Logger.getLogger(IntegerParameter.class); + private final static Logger LOGGER = LogManager.getLogger( + IntegerParameter.class); static { - logger.debug("Static initalizer starting..."); + LOGGER.debug("Static initalizer starting..."); Converters.set(Integer.class, new IntegerConverter()); - logger.debug("Static initalizer finished."); + LOGGER.debug("Static initalizer finished."); } public IntegerParameter(final String name) { @@ -50,4 +51,5 @@ public class IntegerParameter extends AbstractParameter { final Object defaalt) { super(name, multiplicity, defaalt, Integer.class); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/ParameterException.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/ParameterException.java index 651939a2e..e3c0879af 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/ParameterException.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/ParameterException.java @@ -19,8 +19,8 @@ package com.arsdigita.util.parameter; import com.arsdigita.util.Assert; + import java.util.List; -import org.apache.log4j.Logger; /** * Subject to change. @@ -32,12 +32,9 @@ import org.apache.log4j.Logger; * * @see com.arsdigita.util.parameter.ErrorList * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public final class ParameterException extends RuntimeException { - private static final Logger s_log = Logger.getLogger( - ParameterException.class); private static final long serialVersionUID = 1726920836531266365L; private final ErrorList m_errors; diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/ResourceParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/ResourceParameter.java index ebc166975..e353da811 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/ResourceParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/ResourceParameter.java @@ -25,7 +25,8 @@ import java.io.InputStream; import java.net.URL; import java.util.Iterator; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import com.arsdigita.util.UncheckedWrapperException; @@ -45,11 +46,10 @@ import com.arsdigita.util.UncheckedWrapperException; * @author Justin Ross <jross@redhat.com> * @author Brett <bprucha@users.sourceforge net> * @author PBoy <pboy@users.sourceforge net> - * @version $Id$ */ public class ResourceParameter extends AbstractParameter { - private static final Logger s_log = Logger.getLogger(ResourceParameter.class); + private static final Logger LOGGER = LogManager.getLogger(ResourceParameter.class); private Object m_default = null; @@ -129,7 +129,7 @@ public class ResourceParameter extends AbstractParameter { URL url = cload.getResource(value); InputStream stream = cload.getResourceAsStream(value); if (stream == null && isRequired()) { - s_log.error(value + " is not a valid file and is required"); + LOGGER.error(value + " is not a valid file and is required"); final ParameterError error = new ParameterError (this, "Resource not found"); @@ -142,7 +142,7 @@ public class ResourceParameter extends AbstractParameter { } catch (FileNotFoundException ioe) { // we know the file exists so this should not // be an issue - s_log.error(value + " is not a valid file and is required", ioe); + LOGGER.error(value + " is not a valid file and is required", ioe); errors.add(new ParameterError(this, ioe)); diff --git a/ccm-core/src/main/java/com/arsdigita/util/parameter/StringParameter.java b/ccm-core/src/main/java/com/arsdigita/util/parameter/StringParameter.java index 49c7f3f12..fe9ce0830 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/parameter/StringParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/parameter/StringParameter.java @@ -19,7 +19,8 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.StringConverter; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * A parameter representing a Java String. @@ -28,17 +29,17 @@ import org.apache.log4j.Logger; * * @see java.lang.String * @see Parameter - * @author Justin Ross <jross@redhat.com> - * @version $Id$ + * @author Justin Ross <jross@redhat.com> */ public class StringParameter extends AbstractParameter { - private static final Logger logger = Logger.getLogger(StringParameter.class); + private static final Logger LOGGER = LogManager.getLogger( + StringParameter.class); static { - logger.debug("Static initalizer starting..."); + LOGGER.debug("Static initalizer starting..."); Converters.set(String.class, new StringConverter()); - logger.debug("Static initalizer finished."); + LOGGER.debug("Static initalizer finished."); } public StringParameter(final String name, @@ -50,4 +51,5 @@ public class StringParameter extends AbstractParameter { public StringParameter(final String name) { super(name, String.class); } + } diff --git a/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHost.java b/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHost.java index 74396c544..0b9ec0e68 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHost.java +++ b/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHost.java @@ -20,7 +20,8 @@ package com.arsdigita.util.servlet; import com.arsdigita.util.Assert; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * Represents a host computer. The host may in fact be a "virtual" @@ -28,11 +29,10 @@ import org.apache.log4j.Logger; * * @author Dan Berrange * @author Justin Ross <jross@redhat.com> - * @version $Id$ */ public class HttpHost { - private static final Logger s_log = Logger.getLogger(HttpHost.class); + private static final Logger LOGGER = LogManager.getLogger(HttpHost.class); private final String m_name; private final int m_port; @@ -73,8 +73,8 @@ public class HttpHost { final String header = sreq.getHeader("Host"); if (header == null) { - if (s_log.isInfoEnabled()) { - s_log.info("No 'Host:' header present; falling back " + + if (LOGGER.isInfoEnabled()) { + LOGGER.info("No 'Host:' header present; falling back " + "on values from servlet request"); } diff --git a/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHostParameter.java b/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHostParameter.java index 9583b9c56..91d0e0325 100644 --- a/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHostParameter.java +++ b/ccm-core/src/main/java/com/arsdigita/util/servlet/HttpHostParameter.java @@ -21,15 +21,12 @@ package com.arsdigita.util.servlet; import com.arsdigita.util.parameter.ErrorList; import com.arsdigita.util.parameter.ParameterError; import com.arsdigita.util.parameter.StringParameter; -import org.apache.log4j.Logger; /** - * This class represents info about a single host running - * a server in a webapp cluster. + * This class represents info about a single host running a server in a webapp + * cluster. */ public class HttpHostParameter extends StringParameter { - private static final Logger s_log = Logger.getLogger - (HttpHostParameter.class); public HttpHostParameter(final String name) { super(name); @@ -43,22 +40,22 @@ public class HttpHostParameter extends StringParameter { protected Object unmarshal(final String value, final ErrorList errors) { if (value.indexOf("://") != -1) { - final ParameterError error = new ParameterError - (this, "The value must not have a scheme prefix"); + final ParameterError error = new ParameterError(this, + "The value must not have a scheme prefix"); errors.add(error); } if (value.indexOf("/") != -1) { - final ParameterError error = new ParameterError - (this, "The value must not contain slashes"); + final ParameterError error = new ParameterError(this, + "The value must not contain slashes"); errors.add(error); } final int sep = value.indexOf(":"); if (sep == -1) { - final ParameterError error = new ParameterError - (this, "The value must contain a colon"); + final ParameterError error = new ParameterError(this, + "The value must contain a colon"); errors.add(error); } @@ -72,16 +69,16 @@ public class HttpHostParameter extends StringParameter { return new HttpHost(name, Integer.parseInt(port)); } catch (IndexOutOfBoundsException ioobe) { - final ParameterError error = new ParameterError - (this, "The host spec is invalid; it must take the form " + - "hostname:hostport"); + final ParameterError error = new ParameterError(this, + "The host spec is invalid; it must take the form " + + "hostname:hostport"); errors.add(error); return null; } catch (NumberFormatException nfe) { - final ParameterError error = new ParameterError - (this, "The port number must be an integer with no " + - "extraneous spaces or punctuation"); + final ParameterError error = new ParameterError(this, + "The port number must be an integer with no " + + "extraneous spaces or punctuation"); errors.add(error); return null; @@ -96,4 +93,5 @@ public class HttpHostParameter extends StringParameter { return host.getName() + ":" + host.getPort(); } } + } diff --git a/ccm-core/src/main/java/com/arsdigita/web/BaseApplicationServlet.java b/ccm-core/src/main/java/com/arsdigita/web/BaseApplicationServlet.java index cb54295cc..c289a8f2b 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/BaseApplicationServlet.java +++ b/ccm-core/src/main/java/com/arsdigita/web/BaseApplicationServlet.java @@ -22,7 +22,8 @@ import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.InitialRequestContext; import com.arsdigita.dispatcher.RequestContext; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.libreccm.web.ApplicationRepository; import org.libreccm.web.CcmApplication; @@ -64,7 +65,7 @@ public abstract class BaseApplicationServlet extends BaseServlet { private static final long serialVersionUID = 3204787384428680311L; - private static final Logger s_log = Logger.getLogger( + private static final Logger LOGGER = LogManager.getLogger( BaseApplicationServlet.class); /** @@ -160,12 +161,12 @@ public abstract class BaseApplicationServlet extends BaseServlet { * @return */ private CcmApplication getApplication(final HttpServletRequest request) { - s_log.debug("Resolving the application that will handle this request"); + LOGGER.debug("Resolving the application that will handle this request"); Long appId = (Long) request.getAttribute(APPLICATION_ID_ATTRIBUTE); if (appId == null) { - s_log.debug("I didn't receive an application ID with the " + LOGGER.debug("I didn't receive an application ID with the " + "servlet request; trying to get it from the " + "query string"); @@ -181,8 +182,8 @@ public abstract class BaseApplicationServlet extends BaseServlet { } } - if (s_log.isDebugEnabled()) { - s_log.debug("Retrieving application " + appId + " from the " + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Retrieving application " + appId + " from the " + "database"); } diff --git a/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java b/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java index e298320da..608f8ac13 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java +++ b/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java @@ -20,8 +20,8 @@ package com.arsdigita.web; import com.arsdigita.runtime.CCMResourceManager; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; diff --git a/ccm-core/src/main/java/com/arsdigita/web/Debugger.java b/ccm-core/src/main/java/com/arsdigita/web/Debugger.java index cd0949812..6b9e8af85 100755 --- a/ccm-core/src/main/java/com/arsdigita/web/Debugger.java +++ b/ccm-core/src/main/java/com/arsdigita/web/Debugger.java @@ -25,7 +25,8 @@ import java.util.Iterator; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * Debugger contains static methods for registering debuggers. @@ -37,11 +38,10 @@ import org.apache.log4j.Logger; * @see TransformationDebugger * * @author Justin Ross - * @version $Id: Debugger.java 287 2005-02-22 00:29:02Z sskracic $ */ public abstract class Debugger { - private static final Logger s_log = Logger.getLogger(Debugger.class); + private static final Logger LOGGER = LogManager.getLogger(Debugger.class); public static final String DEBUG_PARAMETER = "debug"; public static final ThreadLocal s_debuggers = new DebuggerListLocal(); diff --git a/ccm-core/src/main/java/com/arsdigita/web/DefaultApplicationFileResolver.java b/ccm-core/src/main/java/com/arsdigita/web/DefaultApplicationFileResolver.java index 9941daccd..edfd5f8d6 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/DefaultApplicationFileResolver.java +++ b/ccm-core/src/main/java/com/arsdigita/web/DefaultApplicationFileResolver.java @@ -18,7 +18,8 @@ */ package com.arsdigita.web; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.libreccm.web.CcmApplication; import javax.servlet.RequestDispatcher; @@ -38,7 +39,7 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver { * by editing /WEB-INF/conf/log4j.properties int hte runtime environment * and set com.arsdigita.web.DefaultApplicationFileResolver=DEBUG by * uncommenting or adding the line. */ - private static final Logger s_log = Logger.getLogger + private static final Logger LOGGER = LogManager.getLogger (DefaultApplicationFileResolver.class); /** List of alternative greeting files. Typical vales are index.jsp and @@ -73,8 +74,8 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver { CcmApplication app) { String pathInfo = sreq.getPathInfo(); // effectively provides an url - if (s_log.isDebugEnabled()) { // with application part stripped - s_log.debug("Resolving resource for " + pathInfo); + if (LOGGER.isDebugEnabled()) { // with application part stripped + LOGGER.debug("Resolving resource for " + pathInfo); } // determine the URL the application INSTANCE is really installed at @@ -92,29 +93,29 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver { // probed. if (path.endsWith("/")) { for (String welcomeFile : WELCOME_FILES) { //1.5 enhanced for-loop - if (s_log.isDebugEnabled()) { - s_log.debug("Trying welcome resource " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Trying welcome resource " + path + welcomeFile); } RequestDispatcher rd = Web.findResourceDispatcher( "" + path + welcomeFile); if (rd != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Got dispatcher " + rd); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got dispatcher " + rd); } return rd; } } } else { - if (s_log.isDebugEnabled()) { - s_log.debug("Trying resource " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Trying resource " + path); } RequestDispatcher rd = Web.findResourceDispatcher( "" + path); if (rd != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Got dispatcher " + rd); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got dispatcher " + rd); } return rd; } @@ -133,8 +134,8 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver { } } while (node != null); - if (s_log.isDebugEnabled()) { - s_log.debug("No dispatcher found"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("No dispatcher found"); } // fallthrough, no success - returning null return null; diff --git a/ccm-core/src/main/java/com/arsdigita/web/InternalRequestLocal.java b/ccm-core/src/main/java/com/arsdigita/web/InternalRequestLocal.java index 6e4ff6d45..8c4ca70e5 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/InternalRequestLocal.java +++ b/ccm-core/src/main/java/com/arsdigita/web/InternalRequestLocal.java @@ -18,10 +18,13 @@ */ package com.arsdigita.web; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.util.ArrayList; import java.util.Iterator; + import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; /** * A class that provides request-framed control over a thread-local @@ -75,8 +78,8 @@ import org.apache.log4j.Logger; */ class InternalRequestLocal extends ThreadLocal { - private static final Logger s_log = - Logger.getLogger(InternalRequestLocal.class); + private static final Logger LOGGER = + LogManager.getLogger(InternalRequestLocal.class); private static final ArrayList s_locals = new ArrayList(); @@ -95,8 +98,8 @@ class InternalRequestLocal extends ThreadLocal { * @param sreq */ static void prepareAll(final HttpServletRequest sreq) { - if (s_log.isDebugEnabled()) { - s_log.debug("Initializing all request-local objects; there are " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Initializing all request-local objects; there are " + s_locals.size()); } @@ -113,8 +116,8 @@ class InternalRequestLocal extends ThreadLocal { * */ static void clearAll() { - if (s_log.isDebugEnabled()) { - s_log.debug("Clearing all request-local objects; there are " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Clearing all request-local objects; there are " + s_locals.size()); } diff --git a/ccm-core/src/main/java/com/arsdigita/web/ParameterMap.java b/ccm-core/src/main/java/com/arsdigita/web/ParameterMap.java index 8767ba263..543baffa2 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/ParameterMap.java +++ b/ccm-core/src/main/java/com/arsdigita/web/ParameterMap.java @@ -24,7 +24,8 @@ import com.arsdigita.util.UncheckedWrapperException; import org.apache.commons.codec.net.URLCodec; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; @@ -41,7 +42,7 @@ import java.util.Set; */ public class ParameterMap implements Cloneable { - private static final Logger s_log = Logger.getLogger(ParameterMap.class); + private static final Logger LOGGER = LogManager.getLogger(ParameterMap.class); private static ArrayList s_listeners = new ArrayList(); @@ -101,8 +102,8 @@ public class ParameterMap implements Cloneable { public static final void registerListener (final ParameterListener listener) { - if (s_log.isDebugEnabled()) { - s_log.debug("Registering parameter listener " + listener); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Registering parameter listener " + listener); } s_listeners.add(listener); @@ -168,8 +169,8 @@ public class ParameterMap implements Cloneable { final String value = codec.decode (query.substring(sep + 1, end)); - if (s_log.isDebugEnabled()) { - s_log.debug("Parameter " + name + " = " + value); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Parameter " + name + " = " + value); } final String[] values = getParameterValues(name); diff --git a/ccm-core/src/main/java/com/arsdigita/web/RedirectSignal.java b/ccm-core/src/main/java/com/arsdigita/web/RedirectSignal.java index 71a4020df..cba2ee04b 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/RedirectSignal.java +++ b/ccm-core/src/main/java/com/arsdigita/web/RedirectSignal.java @@ -19,7 +19,9 @@ package com.arsdigita.web; import com.arsdigita.util.Assert; -import org.apache.log4j.Logger; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** *

@@ -59,7 +61,7 @@ public class RedirectSignal extends TransactionSignal { /** * Logger instance for debugging support. */ - private static final Logger s_log = Logger.getLogger(RedirectSignal.class); + private static final Logger LOGGER= LogManager.getLogger(RedirectSignal.class); /** * Destination URL where redirect to @@ -83,8 +85,8 @@ public class RedirectSignal extends TransactionSignal { + "the URL is '" + url + "'"); } - if (s_log.isDebugEnabled()) { - s_log.debug("Request for redirect to URL '" + url + "'", + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Request for redirect to URL '" + url + "'", new Throwable()); } diff --git a/ccm-core/src/main/java/com/arsdigita/web/ReturnSignal.java b/ccm-core/src/main/java/com/arsdigita/web/ReturnSignal.java index 57b8f0b0c..dec22cdb2 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/ReturnSignal.java +++ b/ccm-core/src/main/java/com/arsdigita/web/ReturnSignal.java @@ -19,8 +19,12 @@ package com.arsdigita.web; import com.arsdigita.util.Assert; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; + /** *

A signal that returns the client to a return URL encoded in the @@ -32,7 +36,7 @@ import org.apache.log4j.Logger; */ public class ReturnSignal extends RedirectSignal { - private static final Logger s_log = Logger.getLogger(ReturnSignal.class); + private static final Logger LOGGER = LogManager.getLogger(ReturnSignal.class); private static final long serialVersionUID = -2923355745770322780L; public ReturnSignal(final HttpServletRequest sreq) { @@ -48,14 +52,14 @@ public class ReturnSignal extends RedirectSignal { } private static String getReturnURL(final HttpServletRequest sreq) { - s_log.debug("Fetching the return URL to redirect to"); + LOGGER.debug("Fetching the return URL to redirect to"); final String returnURL = sreq.getParameter("return_url"); Assert.exists(returnURL, "String returnURL"); - if (s_log.isDebugEnabled()) { - s_log.debug("Redirecting to URL '" + returnURL + "'"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Redirecting to URL '" + returnURL + "'"); } return returnURL; @@ -63,22 +67,22 @@ public class ReturnSignal extends RedirectSignal { private static String getReturnURL(final HttpServletRequest sreq, final String fallback) { - s_log.debug("Fetching the return URL to redirect to"); + LOGGER.debug("Fetching the return URL to redirect to"); Assert.exists(fallback, "String fallback"); final String returnURL = sreq.getParameter("return_url"); if (returnURL == null || returnURL.equals("")) { - if (s_log.isDebugEnabled()) { - s_log.debug("Cannot find the return URL parameter; " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Cannot find the return URL parameter; " + "using the fallback URL '" + fallback + "'"); } return fallback; } else { - if (s_log.isDebugEnabled()) { - s_log.debug("Redirecting to the value in the return URL " + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Redirecting to the value in the return URL " + "parameter, '" + returnURL + "'"); } diff --git a/ccm-core/src/main/java/com/arsdigita/web/TransactionSignal.java b/ccm-core/src/main/java/com/arsdigita/web/TransactionSignal.java index 5600170b4..67fa25337 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/TransactionSignal.java +++ b/ccm-core/src/main/java/com/arsdigita/web/TransactionSignal.java @@ -18,7 +18,8 @@ */ package com.arsdigita.web; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** *

@@ -34,15 +35,15 @@ class TransactionSignal extends Error { private static final long serialVersionUID = -6081887476661858043L; - private static final Logger s_log = Logger + private static final Logger LOGGER = LogManager .getLogger(TransactionSignal.class); private final boolean m_isCommitRequested; TransactionSignal(boolean isCommitRequested) { - if (s_log.isDebugEnabled()) { - s_log.debug("Constructing a transaction signal with " + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Constructing a transaction signal with " + "isCommitRequested set " + isCommitRequested); } diff --git a/ccm-core/src/main/java/com/arsdigita/web/TransformationDebugger.java b/ccm-core/src/main/java/com/arsdigita/web/TransformationDebugger.java index 0fd1b7a4e..ae878e1c5 100755 --- a/ccm-core/src/main/java/com/arsdigita/web/TransformationDebugger.java +++ b/ccm-core/src/main/java/com/arsdigita/web/TransformationDebugger.java @@ -35,7 +35,8 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; /** * @@ -54,7 +55,7 @@ import org.apache.log4j.Logger; */ public class TransformationDebugger extends Debugger { - private static final Logger s_log = Logger.getLogger( + private static final Logger LOGGER = LogManager.getLogger( TransformationDebugger.class); // private Document m_original; @@ -145,13 +146,13 @@ public class TransformationDebugger extends Debugger { if (offset != -1) { encoding = contentType.substring(offset + 8).trim(); } - if (s_log.isDebugEnabled()) { - s_log.debug("Received content type " + contentType); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Received content type " + contentType); } InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader(is, encoding); - if (s_log.isDebugEnabled()) { - s_log.debug("Process with character encoding " + isr + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Process with character encoding " + isr .getEncoding()); } BufferedReader input = new BufferedReader(isr); diff --git a/ccm-core/src/main/java/com/arsdigita/web/URL.java b/ccm-core/src/main/java/com/arsdigita/web/URL.java index 58e0a52bd..1d93e2252 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/URL.java +++ b/ccm-core/src/main/java/com/arsdigita/web/URL.java @@ -19,20 +19,17 @@ package com.arsdigita.web; import com.arsdigita.dispatcher.DispatcherHelper; -//import com.arsdigita.kernel.security.Util; import com.arsdigita.util.Assert; import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.servlet.HttpHost; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.libreccm.configuration.ConfigurationManager; import org.libreccm.web.CcmApplication; import java.util.Iterator; +import java.util.Map; import java.util.Set; import javax.enterprise.context.spi.CreationalContext; @@ -40,6 +37,7 @@ import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.BeanManager; import javax.naming.InitialContext; import javax.naming.NamingException; +import javax.servlet.http.HttpServletRequest; /** *

@@ -160,7 +158,7 @@ public class URL { * editing /WEB-INF/conf/log4j.properties int hte runtime environment and * set com.arsdigita.web.URL=DEBUG by uncommenting or adding the line. */ - private static final Logger s_log = Logger.getLogger(URL.class); + private static final Logger LOGGER = LogManager.getLogger(URL.class); public static final String THEMES_DIR = "/themes"; @@ -936,8 +934,8 @@ public class URL { public static URL excursion(final HttpServletRequest sreq, final String path, final ParameterMap params) { - if (s_log.isDebugEnabled()) { - s_log.debug("Creating excursion URL to " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Creating excursion URL to " + path); } final URL url = URL.there(sreq, path, params); diff --git a/ccm-core/src/main/java/com/arsdigita/web/Web.java b/ccm-core/src/main/java/com/arsdigita/web/Web.java index 80777c211..bd3d3d589 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/Web.java +++ b/ccm-core/src/main/java/com/arsdigita/web/Web.java @@ -20,6 +20,9 @@ package com.arsdigita.web; import com.arsdigita.util.Assert; import com.arsdigita.util.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -29,7 +32,6 @@ import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; /** * An entry point for functions of the web package. @@ -45,7 +47,7 @@ public class Web { * editing /WEB-INF/conf/log4j.properties int the runtime environment and * set com.arsdigita.web.Web=DEBUG by uncommenting or adding the line. */ - private static final Logger s_log = Logger.getLogger(Web.class); + private static final Logger LOGGER = LogManager.getLogger(Web.class); // private static final WebConfig s_config = WebConfig.getConfig(); private static final ThreadLocal s_request = new InternalRequestLocal(); @@ -184,8 +186,8 @@ public class Web { public static URL findResource(String resourcePath) { if (resourcePath == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Parameter resource is null. Giving up."); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Parameter resource is null. Giving up."); } return null; } @@ -194,8 +196,8 @@ public class Web { resourcePath = "/" + resourcePath; } if (resourcePath.length() < 2) { - if (s_log.isDebugEnabled()) { - s_log + if (LOGGER.isDebugEnabled()) { + LOGGER .debug("Resource spec is too short: >" + resourcePath + "<"); } return null; @@ -213,14 +215,14 @@ public class Web { try { URL url = myctx.getResource(resourcePath); if (url != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Got URL " + url + " for " + resourcePath); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got URL " + url + " for " + resourcePath); } return url; // Return adjusted resourcePath url } } catch (MalformedURLException ex) { - if (s_log.isDebugEnabled()) { - s_log.debug("Cannot get resource for " + resourcePath); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Cannot get resource for " + resourcePath); } // Try the first part of resourcePath as a webapp context path and // check far a resourcePath there @@ -228,13 +230,13 @@ public class Web { String testPath = resourcePath.substring(1, offset); String path = resourcePath.substring(offset); - if (s_log.isDebugEnabled()) { - s_log.debug("Try to find a context at " + testPath); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Try to find a context at " + testPath); } // Try to achieve a context ServletContext ctx = myctx.getContext(testPath); - if (s_log.isDebugEnabled()) { - s_log + if (LOGGER.isDebugEnabled()) { + LOGGER .debug("Servlet context for " + testPath + " is " + ctx); } if (ctx != null) { @@ -243,16 +245,16 @@ public class Web { try { URL url = ctx.getResource(path); if (url != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Got URL " + url + " for " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got URL " + url + " for " + path); } return url; // Return adjusted resourcePath url - } else if (s_log.isDebugEnabled()) { - s_log.debug("No URL present for " + path); + } else if (LOGGER.isDebugEnabled()) { + LOGGER.debug("No URL present for " + path); } } catch (MalformedURLException exc) { - if (s_log.isDebugEnabled()) { - s_log.debug("cannot get resource for " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("cannot get resource for " + path); } } } @@ -268,8 +270,8 @@ public class Web { String path = resourcePath.substring(offset); String[] webapps = StringUtils.split(webappList, ','); - if (s_log.isDebugEnabled()) { - s_log.debug("Web app list " + webappList + " path " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Web app list " + webappList + " path " + path); } for (int i = (webapps.length - 1); i >= 0; i--) { @@ -284,23 +286,23 @@ public class Web { // } ServletContext ctx = myctx.getContext(ctxPath); - if (s_log.isDebugEnabled()) { - s_log.debug("Servlet context for " + ctxPath + " is " + ctx); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Servlet context for " + ctxPath + " is " + ctx); } if (ctx != null) { try { URL url = ctx.getResource(path); if (url != null) { - if (s_log.isDebugEnabled()) { - s_log.debug("Got URL " + url + " for " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Got URL " + url + " for " + path); } return url; // Return adjusted resourcePath url - } else if (s_log.isDebugEnabled()) { - s_log.debug("No URL present for " + path); + } else if (LOGGER.isDebugEnabled()) { + LOGGER.debug("No URL present for " + path); } } catch (MalformedURLException ex) { - if (s_log.isDebugEnabled()) { - s_log.debug("cannot get resource for " + path); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("cannot get resource for " + path); } } } @@ -383,8 +385,8 @@ public class Web { try { url = ctx.getResource(resourcePath); } catch (MalformedURLException ex) { - if (s_log.isDebugEnabled()) { - s_log.debug("Resource for " + resourcePath + " not found."); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Resource for " + resourcePath + " not found."); } // throw new UncheckedWrapperException( // "No resource at " + resourcePath, ex); diff --git a/ccm-core/src/main/java/com/arsdigita/web/WebContext.java b/ccm-core/src/main/java/com/arsdigita/web/WebContext.java index 82364a7a5..be537f358 100644 --- a/ccm-core/src/main/java/com/arsdigita/web/WebContext.java +++ b/ccm-core/src/main/java/com/arsdigita/web/WebContext.java @@ -18,11 +18,11 @@ */ package com.arsdigita.web; -// import com.arsdigita.web.CcmApplication; import com.arsdigita.util.Assert; import com.arsdigita.util.Record; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.libreccm.web.CcmApplication; /** @@ -47,7 +47,7 @@ public final class WebContext extends Record { * set com.arsdigita.web.WebContext=DEBUG by uncommenting or adding the * line. */ - private static final Logger s_log = Logger.getLogger(WebContext.class); + private static final Logger LOGGER = LogManager.getLogger(WebContext.class); private CcmApplication m_application = null; private URL m_requestURL = null; @@ -65,7 +65,7 @@ public final class WebContext extends Record { * Constructor */ WebContext() { - super(WebContext.class, s_log, s_fields); + super(WebContext.class, LOGGER, s_fields); } /** diff --git a/ccm-core/src/main/java/com/arsdigita/xml/CCMTransformerFactory.java b/ccm-core/src/main/java/com/arsdigita/xml/CCMTransformerFactory.java index 64cdb9cb2..5c11f410d 100644 --- a/ccm-core/src/main/java/com/arsdigita/xml/CCMTransformerFactory.java +++ b/ccm-core/src/main/java/com/arsdigita/xml/CCMTransformerFactory.java @@ -18,6 +18,9 @@ */ package com.arsdigita.xml; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import javax.xml.transform.ErrorListener; import javax.xml.transform.Source; import javax.xml.transform.Templates; @@ -25,7 +28,6 @@ import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; -import org.apache.log4j.Logger; /** * This class acts as a facade for the {@link TransformerFactory} implementation @@ -42,7 +44,7 @@ import org.apache.log4j.Logger; */ public class CCMTransformerFactory extends TransformerFactory { - private static final Logger LOGGER = Logger.getLogger( + private static final Logger LOGGER = LogManager.getLogger( CCMTransformerFactory.class); private final TransformerFactory factory; diff --git a/ccm-core/src/main/java/com/arsdigita/xml/Document.java b/ccm-core/src/main/java/com/arsdigita/xml/Document.java index 8c5fa29a9..e66429e9e 100644 --- a/ccm-core/src/main/java/com/arsdigita/xml/Document.java +++ b/ccm-core/src/main/java/com/arsdigita/xml/Document.java @@ -18,8 +18,12 @@ */ package com.arsdigita.xml; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.ByteArrayOutputStream; import java.io.StringReader; + import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; @@ -28,7 +32,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; -import org.apache.log4j.Logger; + import java.io.UnsupportedEncodingException; /** @@ -53,8 +57,8 @@ import java.io.UnsupportedEncodingException; */ public class Document { - private static final Logger s_log = - Logger.getLogger(Document.class.getName()); + private static final Logger LOGGER = + LogManager.getLogger(Document.class.getName()); /** * this is the identity XSL stylesheet. We need to provide the * identity transform as XSL explicitly because the default @@ -112,7 +116,7 @@ public class Document { // instead to achieve independence from a JVM wide configuration. // Requires additional modifications in c.ad.util.xml.XML static { - s_log.debug("Static initalizer starting..."); + LOGGER.debug("Static initalizer starting..."); s_builder = DocumentBuilderFactory.newInstance(); s_builder.setNamespaceAware(true); s_db = new ThreadLocal() { @@ -126,7 +130,7 @@ public class Document { } } }; - s_log.debug("Static initalized finished."); + LOGGER.debug("Static initalized finished."); } /* Used to build the DOM Documents that this class wraps */ @@ -314,14 +318,14 @@ public class Document { identity.setOutputProperty("encoding", "UTF-8"); identity.transform(new DOMSource(document), new StreamResult(os)); } catch (javax.xml.transform.TransformerException e) { - s_log.error("error in toString", e); + LOGGER.error("error in toString", e); return document.toString(); } try { return os.toString("UTF-8"); } catch (UnsupportedEncodingException ex) { - s_log.error("UTF-8 encoding not supported!!!"); + LOGGER.error("UTF-8 encoding not supported!!!"); return os.toString(); } } diff --git a/ccm-core/src/main/java/com/arsdigita/xml/Element.java b/ccm-core/src/main/java/com/arsdigita/xml/Element.java index 540bbd8fa..5424ce3b1 100644 --- a/ccm-core/src/main/java/com/arsdigita/xml/Element.java +++ b/ccm-core/src/main/java/com/arsdigita/xml/Element.java @@ -20,7 +20,8 @@ package com.arsdigita.xml; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import com.arsdigita.util.Assert; import com.arsdigita.util.UncheckedWrapperException; import java.util.ArrayList; @@ -42,7 +43,7 @@ import org.w3c.dom.Attr; */ public class Element { - private static final Logger s_log = Logger.getLogger(Element.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(Element.class.getName()); protected org.w3c.dom.Element m_element; /* DOM element that is being wrapped */ /** @@ -59,7 +60,7 @@ public class Element { builder.setNamespaceAware(true); return builder.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { - s_log.error(e); + LOGGER.error(e); throw new UncheckedWrapperException( "INTERNAL: Could not create thread local DOM document.", e); @@ -356,7 +357,7 @@ public class Element { } public Element setCDATASection(String cdata) { - s_log.debug("Setting CDATA section to '" + cdata + "'."); + LOGGER.debug("Setting CDATA section to '" + cdata + "'."); if (cdata == null) { cdata = ""; @@ -385,7 +386,7 @@ public class Element { String str = result.toString(); - s_log.debug("Fetched this from CDATA section: " + str); + LOGGER.debug("Fetched this from CDATA section: " + str); return str; } @@ -568,7 +569,7 @@ public class Element { while (xmlFragments.hasNext()) { xml.append(xmlFragments.next()); } - s_log.debug("getXMLHashString: " + xml.toString()); + LOGGER.debug("getXMLHashString: " + xml.toString()); return xml.toString(); } @@ -576,7 +577,7 @@ public class Element { public int hashCode() { Date start = new Date(); String hashString = getXMLHashString(); - s_log.debug( + LOGGER.debug( "hashCode: getXMLString took " + (new Date().getTime() - start.getTime()) + " millisecs"); @@ -587,7 +588,7 @@ public class Element { @Override public boolean equals(Object other) { - s_log.debug("equals invoked"); + LOGGER.debug("equals invoked"); Date start = new Date(); if (other == null) { return false; @@ -598,7 +599,7 @@ public class Element { Element otherElement = (Element) other; String thisXML = getXMLHashString(); String otherXML = otherElement.getXMLHashString(); - s_log.debug( + LOGGER.debug( "Equals: getXMLString twice took " + (new Date().getTime() - start.getTime()) + " millisecs"); diff --git a/ccm-core/src/main/java/com/arsdigita/xml/XML.java b/ccm-core/src/main/java/com/arsdigita/xml/XML.java index 8d049781c..c8e0864ce 100644 --- a/ccm-core/src/main/java/com/arsdigita/xml/XML.java +++ b/ccm-core/src/main/java/com/arsdigita/xml/XML.java @@ -22,6 +22,8 @@ import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.xml.formatters.DateTimeFormatter; +import org.apache.logging.log4j.LogManager; + import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; @@ -39,7 +41,7 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; /** * Provides a set of static helper methods for dealing with XML, @@ -47,15 +49,15 @@ import org.apache.log4j.Logger; */ public class XML { - private static final Logger s_log = Logger.getLogger(XML.class); + private static final Logger LOGGER = LogManager.getLogger(XML.class); // private static XMLConfig s_config; private static final Map s_formatters = new HashMap(); static { - s_log.debug("Static initalizer starting..."); + LOGGER.debug("Static initalizer starting..."); s_formatters.put(Date.class, new DateTimeFormatter()); - s_log.debug("Static initalizer finished."); + LOGGER.debug("Static initalizer finished."); } /** @@ -138,13 +140,13 @@ public class XML { Formatter formatter = findFormatter(value.getClass()); if (formatter == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("No formatter for " + value.getClass()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("No formatter for " + value.getClass()); } return value.toString(); } - if (s_log.isDebugEnabled()) { - s_log.debug("Processing " + value.getClass() + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Processing " + value.getClass() + " with " + formatter.getClass()); } return formatter.format(value); @@ -160,8 +162,8 @@ public class XML { */ public static final void parseResource(String path, DefaultHandler handler) { - if (s_log.isDebugEnabled()) { - s_log.debug("Processing resource " + path + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Processing resource " + path + " with " + handler.getClass()); } @@ -189,8 +191,8 @@ public class XML { */ public static final void parse(InputStream source, DefaultHandler handler) { - if (s_log.isDebugEnabled()) { - s_log.debug("Processing stream " + source + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Processing stream " + source + " with " + handler.getClass()); } diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java index 66ac41678..53fed12a3 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Category.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java @@ -39,6 +39,7 @@ import javax.persistence.AssociationOverride; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToOne; @@ -178,7 +179,7 @@ public class Category extends CcmObject implements Serializable, Portable { * The objects assigned to this category. */ @RecursivePermissions - @OneToMany(mappedBy = "category") + @OneToMany(mappedBy = "category", fetch = FetchType.LAZY) @XmlElementWrapper(name = "objects", namespace = CAT_XML_NS) @JsonManagedReference(value = "category-categorization") private List objects; @@ -187,7 +188,7 @@ public class Category extends CcmObject implements Serializable, Portable { * The sub categories of this category. */ @RecursivePermissions - @OneToMany(mappedBy = "parentCategory") + @OneToMany(mappedBy = "parentCategory", fetch = FetchType.LAZY) @XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS) @XmlElement(name = "category") @JsonManagedReference(value = "subcategory-parentcategory") @@ -197,7 +198,7 @@ public class Category extends CcmObject implements Serializable, Portable { * The parent category category of this category. Despite the root category * of domain every category has a parent category. */ - @ManyToOne + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "PARENT_CATEGORY_ID") @JsonBackReference(value = "subcategory-parentcategory") private Category parentCategory; diff --git a/ccm-core/src/main/java/org/libreccm/cdi/utils/CdiUtil.java b/ccm-core/src/main/java/org/libreccm/cdi/utils/CdiUtil.java index a256e6a68..6d6c40746 100644 --- a/ccm-core/src/main/java/org/libreccm/cdi/utils/CdiUtil.java +++ b/ccm-core/src/main/java/org/libreccm/cdi/utils/CdiUtil.java @@ -18,8 +18,8 @@ */ package org.libreccm.cdi.utils; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import java.util.Iterator; diff --git a/ccm-core/src/main/java/org/libreccm/security/CcmShiroRealmController.java b/ccm-core/src/main/java/org/libreccm/security/CcmShiroRealmController.java index 1b2bdd111..648d96282 100644 --- a/ccm-core/src/main/java/org/libreccm/security/CcmShiroRealmController.java +++ b/ccm-core/src/main/java/org/libreccm/security/CcmShiroRealmController.java @@ -30,6 +30,7 @@ import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; +import javax.persistence.EntityManager; import javax.transaction.Transactional; /** @@ -51,6 +52,9 @@ class CcmShiroRealmController { @Inject private RoleRepository roleRepo; + @Inject + private PermissionManager permissionManager; + @Inject private ConfigurationManager confManager; @@ -99,18 +103,23 @@ class CcmShiroRealmController { final String userIdentifier) { final User user = findUser(userIdentifier); - + // Create a SimpleAuthorizationInfo instance. Contains the information // from the database in the format expected by Shiro. final SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // Get the Roles directly assigned to the user. for (final RoleMembership roleMembership : user.getRoleMemberships()) { // Add the role to the AuthorizationInfo object. - info.addRole(roleMembership.getRole().getName()); + final Role role = roleMembership.getRole(); + info.addRole(role.getName()); - // Add the permissions assigned to the role to the AuthorizatonInfo. - for (final Permission permission : roleMembership.getRole() - .getPermissions()) { + final List permissions = permissionManager + .findPermissionsForRole(role); + + // Add the permissions assigned to the role to the AuthorizatonInfo. ) +// for (final Permission permission : roleMembership.getRole() +// .getPermissions()) { + for (final Permission permission : permissions) { info.addStringPermission(permissionToString(permission)); } } @@ -133,7 +142,7 @@ class CcmShiroRealmController { return info; } - + /** * Helper method for converting a {@link Permission} to the string format * used by Shiro. diff --git a/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java b/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java index 266ee4c46..be6a8111f 100644 --- a/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java +++ b/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java @@ -34,6 +34,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.Collection; +import java.util.Optional; import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; @@ -64,8 +65,42 @@ public class PermissionManager { * * @return The permission identified by the provided {@code permissionId). */ - public Permission findById(final long permissionId) { - return entityManager.find(Permission.class, permissionId); + public Optional findById(final long permissionId) { + return Optional.ofNullable(entityManager.find(Permission.class, + permissionId)); + } + + /** + * Retrieves all permissions granted to a role. + * + * @param role The role + * + * @return A list with all permissions granted to the provided {@code role}. + */ + @Transactional(Transactional.TxType.REQUIRED) + public List findPermissionsForRole(final Role role) { + final TypedQuery query = entityManager.createNamedQuery( + "Permission.findPermissionsForRole", Permission.class); + query.setParameter("grantee", role); + + return query.getResultList(); + } + + /** + * Retrieves all permissions granted on a {@link CcmObject}. + * + * @param object The object + * + * @return A list containing all permissions granted on the provided + * {@code object}. + */ + @Transactional(Transactional.TxType.REQUIRED) + public List findPermissionsForObject(final CcmObject object) { + final TypedQuery query = entityManager.createNamedQuery( + "Permission.findPermissionsForCcmObject", Permission.class); + query.setParameter("object", object); + + return query.getResultList(); } /** @@ -190,11 +225,11 @@ public class PermissionManager { /** * Helper method for granting a recursive permission. - * - * @param privilege The privilege to grant. - * @param grantee The role to which the privilege is granted. - * @param field The current field. - * @param owner The object which own the provided {@code field}. + * + * @param privilege The privilege to grant. + * @param grantee The role to which the privilege is granted. + * @param field The current field. + * @param owner The object which own the provided {@code field}. * @param inheritedFrom The object from which the permission is inherited. */ private void grantRecursive(final String privilege, @@ -265,10 +300,11 @@ public class PermissionManager { /** * Helper method for creating an inherited permission. - * - * @param privilege The privilege to grant. - * @param grantee The role to which {@code privilege} is granted. - * @param object The object on which the {@code privilege} is granted. + * + * @param privilege The privilege to grant. + * @param grantee The role to which {@code privilege} is granted. + * @param object The object on which the {@code privilege} is + * granted. * @param inheritedFrom The object from which the permission is inherited. */ private void grantInherited(final String privilege, diff --git a/ccm-core/src/main/java/org/libreccm/security/Relation.java b/ccm-core/src/main/java/org/libreccm/security/Relation.java index 9b655f3e2..a308a38a5 100644 --- a/ccm-core/src/main/java/org/libreccm/security/Relation.java +++ b/ccm-core/src/main/java/org/libreccm/security/Relation.java @@ -18,8 +18,8 @@ */ package org.libreccm.security; -import org.apache.log4j.Category; import org.libreccm.categorization.Categorization; +import org.libreccm.categorization.Category; import org.libreccm.core.CcmObject; /** diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/AbstractResource.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/AbstractResource.java index 96cec0dcb..492b81519 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/AbstractResource.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/AbstractResource.java @@ -18,7 +18,8 @@ */ package org.libreccm.docrepo; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.hibernate.validator.constraints.NotBlank; import org.libreccm.core.CcmObject; import org.libreccm.portation.Portable; @@ -48,7 +49,7 @@ import java.util.Date; @Table(schema = "CCM_DOCREPO", name = "RESOURCES") public abstract class AbstractResource extends CcmObject implements Portable { - private static final Logger log = Logger.getLogger(AbstractResource.class); + private static final Logger log = LogManager.getLogger(AbstractResource.class); private static final long serialVersionUID = -910317798106611214L; diff --git a/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java b/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java index d50b97ec1..220db2953 100644 --- a/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java +++ b/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java @@ -18,7 +18,8 @@ */ package org.libreccm.docrepo.portation; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.InSequence; @@ -67,7 +68,7 @@ import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies; @Transactional(TransactionMode.COMMIT) @CreateSchema({"create_ccm_docrepo_schema.sql"}) public class FilePortationTest { - private static final Logger log = Logger.getLogger(FilePortationTest.class); + private static final Logger log = LogManager.getLogger(FilePortationTest.class); @Inject private FileRepository fileRepository;