diff --git a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuth.java b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuth.java index b7cb70dfc..7914f746f 100755 --- a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuth.java +++ b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuth.java @@ -22,6 +22,7 @@ import com.arsdigita.web.Application; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.DataObject; import com.arsdigita.domain.DataObjectNotFoundException; +import org.apache.log4j.Logger; /** @@ -31,10 +32,13 @@ import com.arsdigita.domain.DataObjectNotFoundException; */ public class HTTPAuth extends Application { + private static final Logger logger = Logger.getLogger(HTTPAuth.class); private static HTTPAuthConfig s_config = new HTTPAuthConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static HTTPAuthConfig getConfig() { diff --git a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuthConfig.java b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuthConfig.java index 6d3c80b0e..9773d5824 100755 --- a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuthConfig.java +++ b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPAuthConfig.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.auth.http; import com.arsdigita.util.parameter.Converters; @@ -43,29 +42,27 @@ import java.io.InputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.FileNotFoundException; - +import org.apache.log4j.Logger; public class HTTPAuthConfig extends AbstractConfig { - - static { - Converters.set(Inet4AddressRange.class, - new Inet4AddressRangeConvertor()); - } + private static final Logger logger = Logger.getLogger(HTTPAuthConfig.class); + + static { + logger.debug("Static initalizer starting..."); + Converters.set(Inet4AddressRange.class, + new Inet4AddressRangeConvertor()); + logger.debug("Static initalizer finished."); + } private BooleanParameter m_isActive; private BooleanParameter m_isDebugMode; - private IntegerParameter m_nonceTTL; - private StringParameter m_serverName; private IntegerParameter m_serverPort; - private Inet4AddressRangeParameter m_clientIPRange; - private StringParameter m_keyAlias; private StringParameter m_keyCypher; private StringParameter m_keyPassword; - private StringParameter m_keystorePassword; private StringParameter m_keystorePath; @@ -90,11 +87,13 @@ public class HTTPAuthConfig extends AbstractConfig { // XXX bz108251 //Parameter.REQUIRED, null); - m_serverPort = new IntegerParameter("com.arsdigita.auth.http.server_port", + m_serverPort = new IntegerParameter( + "com.arsdigita.auth.http.server_port", Parameter.OPTIONAL, new Integer(80)); - m_clientIPRange = new Inet4AddressRangeParameter("com.arsdigita.auth.http.client_ip_range", + m_clientIPRange = new Inet4AddressRangeParameter( + "com.arsdigita.auth.http.client_ip_range", Parameter.OPTIONAL, // XXX bz108251 //Parameter.REQUIRED, @@ -106,19 +105,22 @@ public class HTTPAuthConfig extends AbstractConfig { m_keyCypher = new StringParameter("com.arsdigita.auth.http.key_cypher", Parameter.OPTIONAL, "RSA"); - m_keyPassword = new StringParameter("com.arsdigita.auth.http.key_password", + m_keyPassword = new StringParameter( + "com.arsdigita.auth.http.key_password", Parameter.OPTIONAL, // XXX bz108251 //Parameter.REQUIRED, null); - m_keystorePassword = new StringParameter("com.arsdigita.auth.http.keystore_password", + m_keystorePassword = new StringParameter( + "com.arsdigita.auth.http.keystore_password", Parameter.OPTIONAL, // XXX bz108251 //Parameter.REQUIRED, null); - m_keystorePath = new StringParameter("com.arsdigita.auth.http.keystore_path", + m_keystorePath = new StringParameter( + "com.arsdigita.auth.http.keystore_path", Parameter.OPTIONAL, // XXX bz108251 //Parameter.REQUIRED, @@ -153,44 +155,43 @@ public class HTTPAuthConfig extends AbstractConfig { } public final int getNonceTTL() { - return ((Integer)get(m_nonceTTL)).intValue(); + return ((Integer) get(m_nonceTTL)).intValue(); } - + public final String getServerName() { - return (String)get(m_serverName); + return (String) get(m_serverName); } public final int getServerPort() { - return ((Integer)get(m_serverPort)).intValue(); + return ((Integer) get(m_serverPort)).intValue(); } public final Inet4AddressRange getClientIPRange() { - return (Inet4AddressRange)get(m_clientIPRange); + return (Inet4AddressRange) get(m_clientIPRange); } public final String getKeyAlias() { - return (String)get(m_keyAlias); + return (String) get(m_keyAlias); } public final String getKeyCypher() { - return (String)get(m_keyCypher); + return (String) get(m_keyCypher); } public final String getKeyPassword() { - return (String)get(m_keyPassword); + return (String) get(m_keyPassword); } public final String getKeyStorePassword() { - return (String)get(m_keystorePassword); + return (String) get(m_keystorePassword); } - + // Package protected, since we won't neccessarily always // store the keystore in a file on disk final String getKeyStorePath() { return (String) get(m_keystorePath); } - public final InputStream getKeyStoreStream() { String file = getKeyStorePath(); @@ -200,12 +201,12 @@ public class HTTPAuthConfig extends AbstractConfig { is = new FileInputStream(file); } catch (FileNotFoundException ex) { throw new UncheckedWrapperException( - "cannot read keystore file " + file, ex); + "cannot read keystore file " + file, ex); } - + return is; } - + public final KeyStore getKeyStore() { InputStream is = getKeyStoreStream(); KeyStore store = null; @@ -215,23 +216,22 @@ public class HTTPAuthConfig extends AbstractConfig { store = KeyStore.getInstance("JKS"); } catch (KeyStoreException ex) { throw new UncheckedWrapperException( - "cannot get keystore instance JKS", ex); + "cannot get keystore instance JKS", ex); } - + try { store.load(is, getKeyStorePassword().toCharArray()); } catch (IOException ex) { throw new UncheckedWrapperException( - "cannot load keystore from " + - getKeyStorePath(), ex); + "cannot load keystore from " + getKeyStorePath(), ex); } catch (CertificateException ex) { throw new UncheckedWrapperException( - "cannot load keystore certificates from " + - getKeyStorePath(), ex); + "cannot load keystore certificates from " + + getKeyStorePath(), ex); } catch (NoSuchAlgorithmException ex) { throw new UncheckedWrapperException( - "cannot check integrity of keystore " + - getKeyStorePath(), ex); + "cannot check integrity of keystore " + getKeyStorePath(), + ex); } return store; } @@ -244,12 +244,12 @@ public class HTTPAuthConfig extends AbstractConfig { cert = keystore.getCertificate(getKeyAlias()); } catch (KeyStoreException ex) { throw new UncheckedWrapperException( - "cannot get public key from keystore " + - getKeyStorePath(), ex); - } + "cannot get public key from keystore " + getKeyStorePath(), + ex); + } Assert.exists(cert, Certificate.class); - + return cert.getPublicKey(); } @@ -258,44 +258,45 @@ public class HTTPAuthConfig extends AbstractConfig { Key key = null; try { - key = keystore.getKey(getKeyAlias(), + key = keystore.getKey(getKeyAlias(), getKeyPassword().toCharArray()); } catch (KeyStoreException ex) { throw new UncheckedWrapperException( - "cannot get private key from keystore " + - getKeyStorePath(), ex); + "cannot get private key from keystore " + getKeyStorePath(), + ex); } catch (NoSuchAlgorithmException ex) { throw new UncheckedWrapperException( - "cannot get private key from keystore " + - getKeyStorePath(), ex); + "cannot get private key from keystore " + getKeyStorePath(), + ex); } catch (UnrecoverableKeyException ex) { throw new UncheckedWrapperException( - "cannot get private key from keystore " + - getKeyStorePath(), ex); - } + "cannot get private key from keystore " + getKeyStorePath(), + ex); + } Assert.exists(key, Key.class); - - return (PrivateKey)key; + + return (PrivateKey) key; } private static class Inet4AddressRangeConvertor implements Converter { + public Object convert(Class type, Object value) { - return Inet4AddressRange.getByName((String)value); + return Inet4AddressRange.getByName((String) value); } } private static class Inet4AddressRangeParameter extends AbstractParameter { + public Inet4AddressRangeParameter(final String name) { super(name, Inet4AddressRange.class); } - + public Inet4AddressRangeParameter(final String name, - final int multiplicity, - final Object defaalt) { + final int multiplicity, + final Object defaalt) { super(name, multiplicity, defaalt, Inet4AddressRange.class); } - } } diff --git a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPLoginModule.java b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPLoginModule.java index ec0586e32..f6347aac4 100755 --- a/ccm-auth-http/src/com/arsdigita/auth/http/HTTPLoginModule.java +++ b/ccm-auth-http/src/com/arsdigita/auth/http/HTTPLoginModule.java @@ -135,6 +135,7 @@ public class HTTPLoginModule extends MappingLoginModule { private static PublicKey s_publicKey = null; static { + s_log.debug("Static initalizer starting..."); if (HTTPAuth.getConfig().isActive()) { if (s_log.isDebugEnabled()) { s_log.debug("Loading public key"); @@ -145,6 +146,7 @@ public class HTTPLoginModule extends MappingLoginModule { s_log.info("HTTP auth is not active"); } } + s_log.debug("Static initalizer finished."); } private static BASE64Decoder s_base64Decoder = new BASE64Decoder(); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java index 955d44831..bba6e0691 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java @@ -50,7 +50,9 @@ public class FileAttachment extends FileAsset { private static final FileAttachmentConfig s_config = new FileAttachmentConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } diff --git a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ItemImageAttachment.java b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ItemImageAttachment.java index c28d574f3..08236efa9 100755 --- a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ItemImageAttachment.java +++ b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ItemImageAttachment.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.cms.contentassets; import com.arsdigita.cms.ContentItem; @@ -42,28 +41,28 @@ import org.apache.log4j.Logger; public class ItemImageAttachment extends ACSObject implements CustomCopy { /** PDL property name for contact details */ - public static final String IMAGE = "image"; - public static final String ITEM = "item"; - public static final String USE_CONTEXT = "useContext"; - public static final String CAPTION = "caption"; - public static final String DESCRIPTION = "description"; - public static final String TITLE = "title"; + public static final String IMAGE = "image"; + public static final String ITEM = "item"; + public static final String USE_CONTEXT = "useContext"; + public static final String CAPTION = "caption"; + public static final String DESCRIPTION = "description"; + public static final String TITLE = "title"; public static final String IMAGE_ATTACHMENTS = "imageAttachments"; - public static final String ITEM_ATTACHMENTS = "itemAttachments"; + public static final String ITEM_ATTACHMENTS = "itemAttachments"; public static final String IMAGE_LINK = "imageLink"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contentassets.ItemImageAttachment"; + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.cms.contentassets.ItemImageAttachment"; + private static final Logger s_log = Logger.getLogger( + ItemImageAttachment.class); + private static final ItemImageAttachmentConfig s_config = + new ItemImageAttachmentConfig(); - private static final Logger s_log - = Logger.getLogger(ItemImageAttachment.class); - - private static final ItemImageAttachmentConfig s_config = new ItemImageAttachmentConfig(); - - static { - s_config.load(); - } + static { + s_log.debug("Static initalizer starting..."); + s_config.load(); + s_log.debug("Static initalizer finished."); + } private ItemImageAttachment() { this(BASE_DATA_OBJECT_TYPE); @@ -81,57 +80,60 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy { return BASE_DATA_OBJECT_TYPE; } - public ItemImageAttachment( ContentItem item, ReusableImageAsset image ) { + public ItemImageAttachment(ContentItem item, ReusableImageAsset image) { this(); - set( ITEM, item ); - set( IMAGE, image ); + set(ITEM, item); + set(IMAGE, image); } - public static ItemImageAttachment retrieve( OID oid ) { - return (ItemImageAttachment) DomainObjectFactory.newInstance( oid ); + public static ItemImageAttachment retrieve(OID oid) { + return (ItemImageAttachment) DomainObjectFactory.newInstance(oid); + } + + public static ItemImageAttachmentConfig getConfig() { + return s_config; } - public static ItemImageAttachmentConfig getConfig() { - return s_config; - } public ReusableImageAsset getImage() { - if( s_log.isDebugEnabled() ) - s_log.debug( "Getting image for " + getOID() ); + if (s_log.isDebugEnabled()) { + s_log.debug("Getting image for " + getOID()); + } - DataObject dobj = (DataObject) get( IMAGE ); - Assert.exists( dobj ); + DataObject dobj = (DataObject) get(IMAGE); + Assert.exists(dobj); - return (ReusableImageAsset) DomainObjectFactory.newInstance( dobj ); + return (ReusableImageAsset) DomainObjectFactory.newInstance(dobj); } - public void setImage( ReusableImageAsset image ) { - Assert.exists( image, ReusableImageAsset.class ); - set( IMAGE, image ); + public void setImage(ReusableImageAsset image) { + Assert.exists(image, ReusableImageAsset.class); + set(IMAGE, image); } public ContentItem getItem() { - DataObject dobj = (DataObject) get( ITEM ); - Assert.exists( dobj ); + DataObject dobj = (DataObject) get(ITEM); + Assert.exists(dobj); - return (ContentItem) DomainObjectFactory.newInstance( dobj ); + return (ContentItem) DomainObjectFactory.newInstance(dobj); } - public void setItem( ContentItem item ) { - Assert.exists( item, ContentItem.class ); - set( ITEM, item ); + public void setItem(ContentItem item) { + Assert.exists(item, ContentItem.class); + set(ITEM, item); } /** Retrieves links for a content item */ - public static DataCollection getImageAttachments( ContentItem item ) { - Assert.exists( item, ContentItem.class ); + public static DataCollection getImageAttachments(ContentItem item) { + Assert.exists(item, ContentItem.class); - if( s_log.isDebugEnabled() ) - s_log.debug("Getting attachments for " + item.getOID() ); + if (s_log.isDebugEnabled()) { + s_log.debug("Getting attachments for " + item.getOID()); + } - DataCollection attachments = SessionManager.getSession().retrieve - ( BASE_DATA_OBJECT_TYPE ); - attachments.addEqualsFilter( ITEM + ".id", item.getID() ); + DataCollection attachments = SessionManager.getSession().retrieve( + BASE_DATA_OBJECT_TYPE); + attachments.addEqualsFilter(ITEM + ".id", item.getID()); return attachments; } @@ -144,52 +146,50 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy { return (String) get(USE_CONTEXT); } - public void setCaption( String caption ) { - set( CAPTION, caption ); + public void setCaption(String caption) { + set(CAPTION, caption); } public String getCaption() { - return (String) get( CAPTION ); + return (String) get(CAPTION); } - public void setTitle( String title ) { - set( TITLE, title ); - } + public void setTitle(String title) { + set(TITLE, title); + } - public String getTitle() { - return (String) get( TITLE ); - } - - public void setDescription( String description) { - set( DESCRIPTION, description ); - } + public String getTitle() { + return (String) get(TITLE); + } - public String getDescription() { - return (String) get( DESCRIPTION ); - } + public void setDescription(String description) { + set(DESCRIPTION, description); + } + public String getDescription() { + return (String) get(DESCRIPTION); + } /** * Automatically publish an unpublished image */ - public boolean copyProperty( final CustomCopy source, - final Property property, - final ItemCopier copier ) { + public boolean copyProperty(final CustomCopy source, + final Property property, + final ItemCopier copier) { String attribute = property.getName(); - if( ItemCopier.VERSION_COPY == copier.getCopyType() && - IMAGE.equals( attribute ) ) - { + if (ItemCopier.VERSION_COPY == copier.getCopyType() && IMAGE.equals( + attribute)) { ItemImageAttachment attachment = (ItemImageAttachment) source; ReusableImageAsset image = attachment.getImage(); ReusableImageAsset liveImage = - (ReusableImageAsset) image.getLiveVersion(); + (ReusableImageAsset) image.getLiveVersion(); - if( null == liveImage ) { + if (null == liveImage) { liveImage = (ReusableImageAsset) image.createLiveVersion(); } - setImage( liveImage ); + setImage(liveImage); return true; } @@ -197,31 +197,30 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy { } // chris gilbert - optional link + public Link getLink() { + Link link = null; + DataObject dobj = (DataObject) get(IMAGE_LINK); + if (dobj != null) { - public Link getLink() { - Link link = null; - DataObject dobj = (DataObject) get( IMAGE_LINK ); - if (dobj != null) { + link = (Link) DomainObjectFactory.newInstance(dobj); + } + return link; + } - link = (Link) DomainObjectFactory.newInstance( dobj ); - } - return link; - } + public void setLink(Link link) { + Assert.exists(link, Link.class); + set(IMAGE_LINK, link); + } - public void setLink( Link link ) { - Assert.exists( link, Link.class ); - set( IMAGE_LINK, link ); - } - - public void removeLink() { - // when we delete the link, the image still references it in DB - // can't make it composite because then image is deleted if we delete - // link. Have to set link to null first (I think) - DomainObject link = DomainObjectFactory.newInstance((DataObject)get(IMAGE_LINK)); - set (IMAGE_LINK, null); - save(); - link.delete(); - - } + public void removeLink() { + // when we delete the link, the image still references it in DB + // can't make it composite because then image is deleted if we delete + // link. Have to set link to null first (I think) + DomainObject link = DomainObjectFactory.newInstance((DataObject) get( + IMAGE_LINK)); + set(IMAGE_LINK, null); + save(); + link.delete(); + } } diff --git a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/Note.java b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/Note.java index 4480796a2..7671dde43 100755 --- a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/Note.java +++ b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/Note.java @@ -45,6 +45,7 @@ public class Note extends ACSObject { private static final Logger s_log = Logger.getLogger( Note.class ); static { + s_log.debug("Static initalizer is starting..."); DomainObjectFactory.registerInstantiator( BASE_DATA_OBJECT_TYPE, new DomainObjectInstantiator() { @@ -58,6 +59,8 @@ public class Note extends ACSObject { } } ); + + s_log.debug("Static initalizer finished."); } public static final String CONTENT = "content"; diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java index 97d038266..53672c017 100755 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java @@ -49,13 +49,9 @@ import com.arsdigita.util.Assert; */ public class RelatedLinkPropertyForm extends LinkPropertyForm { - private static boolean isHideAdditionalResourceFields; + private static boolean isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields(); private String m_linkListName = ""; - - static { - isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields(); - } - + /** * Creates a new form to edit the RelatedLink object specified * by the item selection model passed in. diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/Event.java b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/Event.java index f22de73e5..fafd3ebf5 100755 --- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/Event.java +++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/Event.java @@ -95,7 +95,9 @@ public class Event extends GenericArticle { private static final EventConfig s_config = new EventConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static final EventConfig getConfig() { diff --git a/ccm-cms-types-glossaryitem/src/com/arsdigita/cms/contenttypes/GlossaryItem.java b/ccm-cms-types-glossaryitem/src/com/arsdigita/cms/contenttypes/GlossaryItem.java index 63edb2da3..3bb2507d0 100755 --- a/ccm-cms-types-glossaryitem/src/com/arsdigita/cms/contenttypes/GlossaryItem.java +++ b/ccm-cms-types-glossaryitem/src/com/arsdigita/cms/contenttypes/GlossaryItem.java @@ -24,10 +24,8 @@ import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentPage; import com.arsdigita.util.Assert; - import java.math.BigDecimal; - - +import org.apache.log4j.Logger; /** * This content type represents a GlossaryItem. @@ -36,62 +34,63 @@ import java.math.BigDecimal; */ public class GlossaryItem extends ContentPage { + private static final Logger logger = Logger.getLogger(GlossaryItem.class); /** PDL property name for definition */ public static final String DEFINITION = "definition"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.GlossaryItem"; - + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.cms.contenttypes.GlossaryItem"; private static GlossaryItemConfig config = new GlossaryItemConfig(); + static { - config.load(); + logger.debug("Static initalizer starting..."); + config.load(); + logger.debug("Static initalizer finished."); } + public static GlossaryItemConfig getConfig() { - return config; + return config; } public GlossaryItem() { - this( BASE_DATA_OBJECT_TYPE ); + this(BASE_DATA_OBJECT_TYPE); } - public GlossaryItem( BigDecimal id ) - throws DataObjectNotFoundException { - this( new OID( BASE_DATA_OBJECT_TYPE, id ) ); + public GlossaryItem(BigDecimal id) + throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); } - public GlossaryItem( OID id ) - throws DataObjectNotFoundException { - super( id ); + public GlossaryItem(OID id) + throws DataObjectNotFoundException { + super(id); } - public GlossaryItem( DataObject obj ) { - super( obj ); + public GlossaryItem(DataObject obj) { + super(obj); } - public GlossaryItem( String type ) { - super( type ); + public GlossaryItem(String type) { + super(type); } - public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } /* accessors *****************************************************/ public String getDefinition() { - return (String) get( DEFINITION ); + return (String) get(DEFINITION); } - public void setDefinition( String definition ) { - set( DEFINITION, definition ); + public void setDefinition(String definition) { + set(DEFINITION, definition); } // Search stuff to allow the content type to be searchable public String getSearchSummary() { return getDefinition(); } - } diff --git a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java index 1f78ec9af..d978e2748 100644 --- a/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java +++ b/ccm-cms-types-healthCareFacility/src/com/arsdigita/cms/contenttypes/HealthCareFacility.java @@ -62,7 +62,9 @@ public class HealthCareFacility extends GenericOrganization { * Called when the class is loaded by the Java class loader. */ static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } /** diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java index c623f4b13..5add8f1d0 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java @@ -64,7 +64,9 @@ public class MultiPartArticle extends ContentPage { private static MultiPartArticleConfig s_config = new MultiPartArticleConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static MultiPartArticleConfig getConfig() { diff --git a/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java b/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java index 34c3dafb8..6f2b18a1b 100755 --- a/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java +++ b/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java @@ -28,6 +28,7 @@ import com.arsdigita.util.Assert; import java.math.BigDecimal; import java.text.DateFormat; import java.util.Date; +import org.apache.log4j.Logger; /** *

DomainObject class to represent news item ContentType @@ -57,6 +58,7 @@ import java.util.Date; **/ public class NewsItem extends GenericArticle { + private static final Logger logger = Logger.getLogger(NewsItem.class); /** PDL property name for lead */ public static final String LEAD = "lead"; /** PDL property name for news date */ @@ -69,7 +71,9 @@ public class NewsItem extends GenericArticle { private static final NewsItemConfig s_config = new NewsItemConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static final NewsItemConfig getConfig() { diff --git a/ccm-cms-types-simpleaddress/src/com/arsdigita/cms/contenttypes/SimpleAddress.java b/ccm-cms-types-simpleaddress/src/com/arsdigita/cms/contenttypes/SimpleAddress.java index 502975fe4..d6a805380 100755 --- a/ccm-cms-types-simpleaddress/src/com/arsdigita/cms/contenttypes/SimpleAddress.java +++ b/ccm-cms-types-simpleaddress/src/com/arsdigita/cms/contenttypes/SimpleAddress.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentPage; import com.arsdigita.domain.DataObjectNotFoundException; @@ -42,6 +41,7 @@ import java.math.BigDecimal; **/ public class SimpleAddress extends ContentPage { + private static final Logger logger = Logger.getLogger(SimpleAddress.class); /** PDL property name for address */ public static final String ADDRESS = "address"; /** PDL property name for country iso code */ @@ -60,18 +60,20 @@ public class SimpleAddress extends ContentPage { public static final String NOTES = "notes"; /** PDL property name for URI*/ public static final String URI = "uri"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.Address"; + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.cms.contenttypes.Address"; + private static final SimpleAddressConfig s_config = + new SimpleAddressConfig(); - private static final SimpleAddressConfig s_config = new SimpleAddressConfig(); static { - s_config.load(); + logger.debug("Static initalizer starting..."); + s_config.load(); + logger.debug("Static initalizer finisheds. ."); } - public static final SimpleAddressConfig getConfig() - { - return s_config; + + public static final SimpleAddressConfig getConfig() { + return s_config; } /** @@ -134,97 +136,96 @@ public class SimpleAddress extends ContentPage { */ public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } /* accessors *****************************************************/ - public String getAddress( ) { - return ( String ) get( ADDRESS ); + public String getAddress() { + return (String) get(ADDRESS); } - public void setAddress( String address ) { - set( ADDRESS, address ); + public void setAddress(String address) { + set(ADDRESS, address); } - public String getCountryIsoCode( ) { - DataObject obj = ( DataObject ) get( ISO_COUNTRY_CODE ); - if ( obj != null ) { - IsoCountry country = new IsoCountry( obj ); - return country.getIsoCode( ); + public String getCountryIsoCode() { + DataObject obj = (DataObject) get(ISO_COUNTRY_CODE); + if (obj != null) { + IsoCountry country = new IsoCountry(obj); + return country.getIsoCode(); } return null; } - public void setCountryIsoCode( String isoCode ) { + public void setCountryIsoCode(String isoCode) { IsoCountry assn = null; try { - OID oid = new OID( IsoCountry.BASE_DATA_OBJECT_TYPE ); - oid.set( IsoCountry.ISO_CODE, isoCode ); + OID oid = new OID(IsoCountry.BASE_DATA_OBJECT_TYPE); + oid.set(IsoCountry.ISO_CODE, isoCode); - assn = new IsoCountry( oid ); + assn = new IsoCountry(oid); } catch (DataObjectNotFoundException e) { - assn = new IsoCountry( ); - assn.setIsoCode( isoCode ); + assn = new IsoCountry(); + assn.setIsoCode(isoCode); assn.save(); } - setAssociation( ISO_COUNTRY_CODE, assn ); + setAssociation(ISO_COUNTRY_CODE, assn); } - public String getPostalCode( ) { - return ( String ) get( POSTAL_CODE ); + public String getPostalCode() { + return (String) get(POSTAL_CODE); } - public void setPostalCode( String postalCode ) { - set( POSTAL_CODE, postalCode ); + public void setPostalCode(String postalCode) { + set(POSTAL_CODE, postalCode); } - public String getPhone( ) { - return ( String ) get( PHONE ); + public String getPhone() { + return (String) get(PHONE); } - public void setPhone( String phone ) { - set( PHONE, phone ); + public void setPhone(String phone) { + set(PHONE, phone); } - public String getMobile( ) { - return ( String ) get( MOBILE ); + public String getMobile() { + return (String) get(MOBILE); } - public void setMobile( String mobile ) { - set( MOBILE, mobile ); + public void setMobile(String mobile) { + set(MOBILE, mobile); } - public String getFax( ) { - return ( String ) get( FAX ); + public String getFax() { + return (String) get(FAX); } - public void setFax( String fax ) { - set( FAX, fax ); + public void setFax(String fax) { + set(FAX, fax); } - public String getEmail( ) { - return ( String ) get( EMAIL ); + public String getEmail() { + return (String) get(EMAIL); } - public void setEmail( String email ) { - set( EMAIL, email ); + public void setEmail(String email) { + set(EMAIL, email); } - public String getNotes( ) { - return ( String ) get( NOTES ); + public String getNotes() { + return (String) get(NOTES); } - public void setNotes( String notes ) { - set( NOTES, notes ); + public void setNotes(String notes) { + set(NOTES, notes); } - public void setURI( String uri) { + public void setURI(String uri) { set(URI, uri); } public String getURI() { - return (String)get(URI); + return (String) get(URI); } - } diff --git a/ccm-cms-types-siteproxy/src/com/arsdigita/cms/dispatcher/SiteProxyPanel.java b/ccm-cms-types-siteproxy/src/com/arsdigita/cms/dispatcher/SiteProxyPanel.java index 0fcb47ab4..e2a7fcb88 100755 --- a/ccm-cms-types-siteproxy/src/com/arsdigita/cms/dispatcher/SiteProxyPanel.java +++ b/ccm-cms-types-siteproxy/src/com/arsdigita/cms/dispatcher/SiteProxyPanel.java @@ -62,7 +62,9 @@ public class SiteProxyPanel extends ContentPanel { private static URLPool s_pool = new URLPool(); static { + s_log.debug("Static initalizer starting..."); URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache); + s_log.debug("Static initalizer finished."); }; public SiteProxyPanel() { diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java index 6e9fbbd4d..c25eed738 100755 --- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java +++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java @@ -20,6 +20,7 @@ import com.arsdigita.kernel.User; import com.arsdigita.persistence.metadata.Property; import com.arsdigita.xml.Element; import java.util.Date; +import org.apache.log4j.Logger; /** * A survey content type that represents a survey. This is partially based on @@ -50,9 +51,13 @@ public class Survey extends ContentPage implements XMLGenerator { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Survey"; /* Config */ private static final SurveyConfig s_config = new SurveyConfig(); + /* Logger to debug to static initializer */ + private static final Logger logger = Logger.getLogger(Survey.class); static { + logger.debug("Static initializer starting..."); s_config.load(); + logger.debug("Static initializer finished."); } public static final SurveyConfig getConfig() { diff --git a/ccm-cms/src/com/arsdigita/cms/CMS.java b/ccm-cms/src/com/arsdigita/cms/CMS.java index 1dd164e93..4e7c555a4 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMS.java +++ b/ccm-cms/src/com/arsdigita/cms/CMS.java @@ -60,7 +60,9 @@ public abstract class CMS { }; private static final CMSConfig s_config = new CMSConfig(); static { + s_log.debug("Static initializer starting..."); s_config.load(); + s_log.debug("Static initializer finished."); } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index 2e059cc74..88d0fe0b7 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -125,7 +125,9 @@ public class ContentSection extends Application { private static final CMSConfig s_config = new CMSConfig(); static { + s_log.debug("Static initializer starting..."); s_config.load(); + s_log.debug("Static initializer finished..."); } // Cached properties PageResolver m_pageResolver = null; diff --git a/ccm-cms/src/com/arsdigita/cms/Template.java b/ccm-cms/src/com/arsdigita/cms/Template.java index d320f64dd..ea5056e13 100755 --- a/ccm-cms/src/com/arsdigita/cms/Template.java +++ b/ccm-cms/src/com/arsdigita/cms/Template.java @@ -63,10 +63,12 @@ public class Template extends TextAsset { public static final Map SUPPORTED_MIME_TYPES = new HashMap(); static { + s_log.debug("Static initalizer is starting..."); SUPPORTED_MIME_TYPES.put(JSP_MIME_TYPE, GlobalizationUtil.globalize("mime_type_jsp")); SUPPORTED_MIME_TYPES.put(XSL_MIME_TYPE, GlobalizationUtil.globalize("mime_type_xsl")); + s_log.debug("Static initalizer finished."); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericAddress.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericAddress.java index 5f721e19c..59b647754 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericAddress.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericAddress.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.globalization.LocaleNegotiator; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentPage; @@ -29,6 +28,7 @@ import com.arsdigita.util.Assert; import java.math.BigDecimal; import java.util.Locale; import java.util.TreeMap; +import org.apache.log4j.Logger; /** *

DomainObject class to represent address ContentType @@ -44,6 +44,7 @@ import java.util.TreeMap; **/ public class GenericAddress extends ContentPage { + private static final Logger logger = Logger.getLogger(GenericAddress.class); /** PDL property name for address */ public static final String ADDRESS = "address"; /** PDL property name for postal code */ @@ -54,18 +55,19 @@ public class GenericAddress extends ContentPage { public static final String STATE = "state"; /** PDL property name for country iso code */ public static final String ISO_COUNTRY_CODE = "isoCountryCode"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.GenericAddress"; - + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.cms.contenttypes.GenericAddress"; private static GenericAddressConfig s_config = new GenericAddressConfig(); + static { - s_config.load(); + logger.debug("Static initializer is starting..."); + s_config.load(); + logger.debug("Static initializer finished."); } - public static GenericAddressConfig getConfig() - { - return s_config; + + public static GenericAddressConfig getConfig() { + return s_config; } /** @@ -128,7 +130,7 @@ public class GenericAddress extends ContentPage { */ public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -175,25 +177,29 @@ public class GenericAddress extends ContentPage { // Convert the iso country code to country names using the current locale public static String getCountryNameFromIsoCode(String isoCountryCode) { - - LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", null); + + LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", + null); java.util.Locale locale = new java.util.Locale("", isoCountryCode); return locale.getDisplayCountry(negotiatedLocale.getLocale()); } - + // Get a sorted list auf all countries public static TreeMap getSortedListOfCountries(Locale inLang) { - - LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", null); - String[] countries = Locale.getISOCountries(); - TreeMap countryNames = new TreeMap(); - for(String country : countries) { - if(inLang != null) { - countryNames.put(new java.util.Locale("", country).getDisplayCountry(inLang), country); + LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", + null); + String[] countries = Locale.getISOCountries(); + TreeMap countryNames = new TreeMap(); + + for (String country : countries) { + if (inLang != null) { + countryNames.put(new java.util.Locale("", country). + getDisplayCountry(inLang), country); } else { - countryNames.put(new java.util.Locale("", country).getDisplayCountry(negotiatedLocale.getLocale()), country); + countryNames.put(new java.util.Locale("", country). + getDisplayCountry(negotiatedLocale.getLocale()), country); } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java index 0b946a843..dc2f33c1d 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericContact.java @@ -29,6 +29,7 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.util.Assert; import java.math.BigDecimal; import java.util.StringTokenizer; +import org.apache.log4j.Logger; /** * This content type represents an basic contact @@ -37,6 +38,7 @@ import java.util.StringTokenizer; public class GenericContact extends ContentPage implements RelationAttributeInterface { + private static final Logger logger = Logger.getLogger(GenericContact.class); /** PDL property names */ public static final String PERSON = "person"; // public static final String CONTACT_TYPE = ""; @@ -51,9 +53,11 @@ public class GenericContact extends ContentPage implements new GenericContactConfig(); static { + logger.debug("Static initializer is starting..."); s_config.load(); + logger.debug("Static initializer finished"); } - /** Data object type for tihs domain object */ + /** Data object type for this domain object */ public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericContact"; diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/BaseAsset.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/BaseAsset.java index c2f9d2410..537249ce9 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/BaseAsset.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/BaseAsset.java @@ -50,14 +50,18 @@ class BaseAsset extends ResourceHandlerImpl { private final static String s_defaultName = "File"; - private static final BigDecimalParameter s_assetId; - private static final OIDParameter s_oid; + private static final BigDecimalParameter s_assetId = new BigDecimalParameter(ASSET_ID); + private static final OIDParameter s_oid = new OIDParameter(OID_PARAM); - static { + /* + * jensp 2011-02-11: No need for static initalizer block here. Moved + * to variable declaration (see above). + */ + /*static { s_assetId = new BigDecimalParameter(ASSET_ID); s_oid = new OIDParameter(OID_PARAM); - //s_assetId.addParameterListener(new NotNullValidationListener()); - } + //s_assetId.addParameterListener(new NotNullValidationListener()); + }*/ private final boolean m_download; private String m_disposition; diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java index 5825b69e5..42ff1d95c 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java @@ -53,13 +53,14 @@ import java.util.Iterator; */ public class SimpleXMLGenerator implements XMLGenerator { - private static Logger s_log = + private static final Logger s_log = Logger.getLogger(SimpleXMLGenerator.class); public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class. getName(); // Register general purpose adaptor for all content items static { + s_log.debug("Static initializer starting..."); SimpleDomainObjectTraversalAdapter adapter = new SimpleDomainObjectTraversalAdapter(); adapter.addAssociationProperty("/object/type"); @@ -69,6 +70,7 @@ public class SimpleXMLGenerator implements XMLGenerator { ContentItem.BASE_DATA_OBJECT_TYPE, adapter, ADAPTER_CONTEXT); + s_log.debug("Static initializer finished"); } public SimpleXMLGenerator() { diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/LinkScanner.java b/ccm-cms/src/com/arsdigita/cms/publishToFile/LinkScanner.java index 9265639c9..2a66e81bc 100755 --- a/ccm-cms/src/com/arsdigita/cms/publishToFile/LinkScanner.java +++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/LinkScanner.java @@ -62,220 +62,235 @@ import org.apache.oro.text.regex.Perl5Matcher; */ class LinkScanner { - private static Logger s_log = Logger.getLogger(LinkScanner.class.getName()); - - // Regexp magic. We deliberately don't use the JDK 1.4 regex features, so - // that this class can also be used under JDK 1.3 - - // The option we use for matching - private static final int MATCH_MASK = Perl5Compiler.CASE_INSENSITIVE_MASK - | Perl5Compiler.MULTILINE_MASK; - - // The HTML elements we are interested in. This must match exactly the - // elements listed in TAGS - private static final String ELEMS_RE = "(a|img|link)"; - // Regexp to find a tag - private static final String TAG_RE = "\\<\\s*" + ELEMS_RE + "\\s*([^>]*?)\\s*/?\\>"; - // Regexp to find an attribute/value pair within a tag - private static final String ATTR_RE = "([a-z][a-z0-9]*)\\s*=\\s*([^\\s'\"]+|'[^']*'|\"[^\"]*\")"; - // These two variables will be initialized with precompiled patterns - private static final Pattern TAG_PAT; - private static final Pattern ATTR_PAT; - - // The tags that we are interested in. The regexp ELEMS_RE must match - // exactly these tags. - // REF_ATTR contains for each of the TAGS which of their attribute holds - // the link that we are going to alter. - private static final String [] TAGS = {"img", "link", "a"}; - private static final String [] REF_ATTR = {"src", "href", "href"}; - // The special oid attribute we use to figure out which tags we need to - // futz with. - private static final String OID_ATTR = "oid"; - - // FIXME: These are references to what should be displayed when tag - // rewriting can't find the live target item. These values only work for - // DP. - private static final String [] NOT_FOUND = { "/notfound.jpg", + private static final Logger s_log = Logger.getLogger(LinkScanner.class); + // Regexp magic. We deliberately don't use the JDK 1.4 regex features, so + // that this class can also be used under JDK 1.3 + // The option we use for matching + private static final int MATCH_MASK = Perl5Compiler.CASE_INSENSITIVE_MASK + | Perl5Compiler.MULTILINE_MASK; + // The HTML elements we are interested in. This must match exactly the + // elements listed in TAGS + private static final String ELEMS_RE = "(a|img|link)"; + // Regexp to find a tag + private static final String TAG_RE = "\\<\\s*" + ELEMS_RE + + "\\s*([^>]*?)\\s*/?\\>"; + // Regexp to find an attribute/value pair within a tag + private static final String ATTR_RE = + "([a-z][a-z0-9]*)\\s*=\\s*([^\\s'\"]+|'[^']*'|\"[^\"]*\")"; + // These two variables will be initialized with precompiled patterns + private static final Pattern TAG_PAT; + private static final Pattern ATTR_PAT; + // The tags that we are interested in. The regexp ELEMS_RE must match + // exactly these tags. + // REF_ATTR contains for each of the TAGS which of their attribute holds + // the link that we are going to alter. + private static final String[] TAGS = {"img", "link", "a"}; + private static final String[] REF_ATTR = {"src", "href", "href"}; + // The special oid attribute we use to figure out which tags we need to + // futz with. + private static final String OID_ATTR = "oid"; + // FIXME: These are references to what should be displayed when tag + // rewriting can't find the live target item. These values only work for + // DP. + private static final String[] NOT_FOUND = {"/notfound.jpg", "/notfound.html", - "/notfound.html" }; + "/notfound.html"}; - static { - Perl5Compiler comp = new Perl5Compiler(); - try { - TAG_PAT = comp.compile(TAG_RE, MATCH_MASK); - } catch (MalformedPatternException e) { - throw new RuntimeException("Failed to compile \n'" + TAG_RE +"' " + e.getMessage()); - } - try { - ATTR_PAT = comp.compile(ATTR_RE, MATCH_MASK); - } catch (MalformedPatternException e) { - throw new RuntimeException("Failed to compile \n'" + ATTR_RE +"' " + e.getMessage()); - } - } - - private String m_content; - private TagRef[] m_tags; - - public LinkScanner(String html) { - Assert.exists(html); - m_content = html; - m_tags = parse(); - } - - public void transform(Writer out) - throws IOException { - - if ( m_tags == null || m_tags.length == 0 ) { - // Nothing to do - out.write(m_content); - return; - } - - TagRef ta; - int i = 0; - - out.write(m_content.substring(0, m_tags[0].tagStart)); - for (i = 0; i < m_tags.length; i ++) { - ta = m_tags[i]; - if (i > 0) { - out.write(m_content.substring(m_tags[i - 1].tagEnd, ta.tagStart)); - } - ta.replaceReference(out); - } - out.write( m_content.substring(m_tags[m_tags.length - 1].tagEnd) ); - } - - public int size() { - return (m_tags == null) ? 0 : m_tags.length; - } - - public ContentItem getTarget(int i) { - return m_tags[i].getItem(); - } - - protected BigDecimal getItemOID(int i) { - return m_tags[i].oid; - } - - public void setTargetURL(int i, String url) { - m_tags[i].url = url; - } - - private TagRef[] parse() { - ArrayList foundTags = new ArrayList(); - - PatternMatcherInput body = new PatternMatcherInput(m_content); - PatternMatcherInput tag = new PatternMatcherInput(body.getBuffer()); - PatternMatcher tagMatcher = new Perl5Matcher(); - PatternMatcher attrMatcher = new Perl5Matcher(); - - while ( tagMatcher.contains(body, TAG_PAT) ) { - MatchResult t = tagMatcher.getMatch(); - int tagType = getTagType(t.group(1)); - int tagStart = t.beginOffset(2); - int tagEnd = t.endOffset(2); - tag.setBeginOffset(tagStart); - tag.setEndOffset(tagEnd); - BigDecimal oid = null; - int linkStart = -1; - int linkEnd = -1; - while (attrMatcher.contains(tag, ATTR_PAT)) { - MatchResult a = attrMatcher.getMatch(); - if ( OID_ATTR.equalsIgnoreCase(a.group(1)) ) { - oid = extractOID(a.beginOffset(2), a.endOffset(2)); - } else if ( REF_ATTR[tagType].equalsIgnoreCase(a.group(1)) ) { - linkStart = a.beginOffset(2); - linkEnd = a.endOffset(2); + static { + s_log.debug("Static initializer is starting...s"); + Perl5Compiler comp = new Perl5Compiler(); + try { + TAG_PAT = comp.compile(TAG_RE, MATCH_MASK); + } catch (MalformedPatternException e) { + s_log.error(String.format("Failed to compile regex tag '%s' " + + "with match mask '%s':", + TAG_RE, + MATCH_MASK), + e); + throw new RuntimeException("Failed to compile \n'" + TAG_RE + "' " + e. + getMessage()); } - } - if ( oid != null ) { - TagRef ref = new TagRef(tagType, tagStart, tagEnd, linkStart, linkEnd, - oid); - foundTags.add(ref); - } - } - int size = foundTags.size(); - return ( size > 0 ? (TagRef [])foundTags.toArray(new TagRef[size]) : null); - } - - private BigDecimal extractOID(int begin, int end) { - String val = null; - if ( m_content.charAt(begin) == '"' - || m_content.charAt(begin) == '\'' ) { - val = m_content.substring(begin+1, end-1); - } else { - val = m_content.substring(begin, end); - } - return new BigDecimal(val); - } - - private int getTagType(String tag) { - for (int i=0; i < TAGS.length; i++) { - if (TAGS[i].equalsIgnoreCase(tag)) return i; - } - throw new IllegalStateException("Tag '" + tag + "' found, but no information registered for it in TAGS. This is a programming error."); - } - - /*** - * Class for keeping track of tag references - ***/ - private class TagRef { - - int tagType; - int tagStart; - int tagEnd; - int linkStart; - int linkEnd; - String url; - BigDecimal oid; - - private ContentItem m_item; - - public TagRef(int type, int start, int end, int lstart, int lend, - BigDecimal oid) { - tagType = type; - tagStart= start; - tagEnd = end; - linkStart = lstart; - linkEnd = lend; - this.oid = oid; - } - - public void replaceReference(Writer out) - throws IOException { - String target = (url == null) ? NOT_FOUND[tagType] : url; - - if ( linkStart == -1 ) { - // There was no link attribute on the original tag. Insert one at - // the end. - out.write(m_content.substring(tagStart, tagEnd)); - out.write(" "); - out.write(REF_ATTR[tagType]); - out.write("='"); - out.write(target); - out.write("'"); - } else { - out.write(m_content.substring(tagStart, linkStart)); - out.write('\''); - out.write(target); - out.write("' "); - if ( tagEnd > linkEnd ) { - out.write(m_content.substring(linkEnd+1, tagEnd)); + try { + ATTR_PAT = comp.compile(ATTR_RE, MATCH_MASK); + } catch (MalformedPatternException e) { + s_log.error(String.format("Failed to compile regex tag '%s' " + + "with match mask '%s':", + ATTR_RE, + MATCH_MASK), + e); + throw new RuntimeException("Failed to compile \n'" + ATTR_RE + "' " + e. + getMessage()); } - } + s_log.debug("Static initalizer finshed."); + } + private String m_content; + private TagRef[] m_tags; + + public LinkScanner(String html) { + Assert.exists(html); + m_content = html; + m_tags = parse(); } - public ContentItem getItem() { - if ( m_item == null ) { - m_item = Utilities.getContentItemOrNull( oid ); - // FIXME: The page with editor will contain references to draft - // items. Fixing that requires parsing the HTML of the page - // separately. Here, we just kludge around it by getting the live - // version of referenced items. [lutter] - if ( m_item != null ) m_item = m_item.getLiveVersion(); - } - return m_item; + public void transform(Writer out) + throws IOException { + + if (m_tags == null || m_tags.length == 0) { + // Nothing to do + out.write(m_content); + return; + } + + TagRef ta; + int i = 0; + + out.write(m_content.substring(0, m_tags[0].tagStart)); + for (i = 0; i < m_tags.length; i++) { + ta = m_tags[i]; + if (i > 0) { + out.write(m_content.substring(m_tags[i - 1].tagEnd, ta.tagStart)); + } + ta.replaceReference(out); + } + out.write(m_content.substring(m_tags[m_tags.length - 1].tagEnd)); } - } + public int size() { + return (m_tags == null) ? 0 : m_tags.length; + } + + public ContentItem getTarget(int i) { + return m_tags[i].getItem(); + } + + protected BigDecimal getItemOID(int i) { + return m_tags[i].oid; + } + + public void setTargetURL(int i, String url) { + m_tags[i].url = url; + } + + private TagRef[] parse() { + ArrayList foundTags = new ArrayList(); + + PatternMatcherInput body = new PatternMatcherInput(m_content); + PatternMatcherInput tag = new PatternMatcherInput(body.getBuffer()); + PatternMatcher tagMatcher = new Perl5Matcher(); + PatternMatcher attrMatcher = new Perl5Matcher(); + + while (tagMatcher.contains(body, TAG_PAT)) { + MatchResult t = tagMatcher.getMatch(); + int tagType = getTagType(t.group(1)); + int tagStart = t.beginOffset(2); + int tagEnd = t.endOffset(2); + tag.setBeginOffset(tagStart); + tag.setEndOffset(tagEnd); + BigDecimal oid = null; + int linkStart = -1; + int linkEnd = -1; + while (attrMatcher.contains(tag, ATTR_PAT)) { + MatchResult a = attrMatcher.getMatch(); + if (OID_ATTR.equalsIgnoreCase(a.group(1))) { + oid = extractOID(a.beginOffset(2), a.endOffset(2)); + } else if (REF_ATTR[tagType].equalsIgnoreCase(a.group(1))) { + linkStart = a.beginOffset(2); + linkEnd = a.endOffset(2); + } + } + if (oid != null) { + TagRef ref = new TagRef(tagType, tagStart, tagEnd, linkStart, + linkEnd, + oid); + foundTags.add(ref); + } + } + int size = foundTags.size(); + return (size > 0 ? (TagRef[]) foundTags.toArray(new TagRef[size]) : null); + } + + private BigDecimal extractOID(int begin, int end) { + String val = null; + if (m_content.charAt(begin) == '"' + || m_content.charAt(begin) == '\'') { + val = m_content.substring(begin + 1, end - 1); + } else { + val = m_content.substring(begin, end); + } + return new BigDecimal(val); + } + + private int getTagType(String tag) { + for (int i = 0; i < TAGS.length; i++) { + if (TAGS[i].equalsIgnoreCase(tag)) { + return i; + } + } + throw new IllegalStateException( + "Tag '" + tag + + "' found, but no information registered for it in TAGS. This is a programming error."); + } + + /*** + * Class for keeping track of tag references + ***/ + private class TagRef { + + int tagType; + int tagStart; + int tagEnd; + int linkStart; + int linkEnd; + String url; + BigDecimal oid; + private ContentItem m_item; + + public TagRef(int type, int start, int end, int lstart, int lend, + BigDecimal oid) { + tagType = type; + tagStart = start; + tagEnd = end; + linkStart = lstart; + linkEnd = lend; + this.oid = oid; + } + + public void replaceReference(Writer out) + throws IOException { + String target = (url == null) ? NOT_FOUND[tagType] : url; + + if (linkStart == -1) { + // There was no link attribute on the original tag. Insert one at + // the end. + out.write(m_content.substring(tagStart, tagEnd)); + out.write(" "); + out.write(REF_ATTR[tagType]); + out.write("='"); + out.write(target); + out.write("'"); + } else { + out.write(m_content.substring(tagStart, linkStart)); + out.write('\''); + out.write(target); + out.write("' "); + if (tagEnd > linkEnd) { + out.write(m_content.substring(linkEnd + 1, tagEnd)); + } + } + } + + public ContentItem getItem() { + if (m_item == null) { + m_item = Utilities.getContentItemOrNull(oid); + // FIXME: The page with editor will contain references to draft + // items. Fixing that requires parsing the HTML of the page + // separately. Here, we just kludge around it by getting the live + // version of referenced items. [lutter] + if (m_item != null) { + m_item = m_item.getLiveVersion(); + } + } + return m_item; + } + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextAssetBody.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextAssetBody.java index 7e32cb782..f15703c45 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextAssetBody.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextAssetBody.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.authoring; - import java.io.File; import java.io.FileInputStream; import java.io.UnsupportedEncodingException; @@ -67,7 +66,6 @@ import com.arsdigita.mimetypes.converters.ConvertFormat; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.util.UncheckedWrapperException; - /** * Displays the mime-type and the body of a single {@link TextAsset}. Maintains * a form or uploading files into the text body of the asset, and a form for @@ -88,23 +86,22 @@ import com.arsdigita.util.UncheckedWrapperException; * @version $Id: TextAssetBody.java 1949 2009-06-25 08:30:50Z terry $ */ public abstract class TextAssetBody extends SecurityPropertyEditor - implements Resettable, AuthoringStepComponent, RequestListener { + implements Resettable, AuthoringStepComponent, RequestListener { private static Logger s_log = - Logger.getLogger(TextAssetBody.class); - + Logger.getLogger(TextAssetBody.class); private ItemSelectionModel m_assetModel; - public static final String FILE_UPLOAD = "file"; public static final String TEXT_ENTRY = "text"; - private StringParameter m_streamlinedCreationParam; private static final String STREAMLINED = "_streamlined"; private static final String STREAMLINED_DONE = "1"; - private static final CMSConfig s_config = new CMSConfig(); + static { - s_config.load(); + s_log.debug("Static initializer is starting..."); + s_config.load(); + s_log.debug("Static initializer finished."); } /** @@ -114,8 +111,9 @@ public abstract class TextAssetBody extends SecurityPropertyEditor * be responsible for maintaining the current asset */ public TextAssetBody(ItemSelectionModel assetModel) { - this(assetModel,null); + this(assetModel, null); } + /** * Construct a new GenericArticleBody component * @@ -125,19 +123,20 @@ public abstract class TextAssetBody extends SecurityPropertyEditor * may use the wizard's methods, such as stepForward and stepBack, * in its process listener. */ - public TextAssetBody(ItemSelectionModel assetModel, AuthoringKitWizard parent) { + public TextAssetBody(ItemSelectionModel assetModel, + AuthoringKitWizard parent) { super(); m_assetModel = assetModel; - m_streamlinedCreationParam = - new StringParameter(parent == null ? "item" : - parent.getContentType().getAssociatedObjectType() + "_body_done"); + m_streamlinedCreationParam = + new StringParameter(parent == null ? "item" : parent.getContentType(). + getAssociatedObjectType() + "_body_done"); if (!s_config.getHideTextAssetUploadFile()) { - PageFileForm f = getPageFileForm(); - addFileWidgets(f); - add(FILE_UPLOAD, "Upload a file", f, - f.getSaveCancelSection().getCancelButton()); + PageFileForm f = getPageFileForm(); + addFileWidgets(f); + add(FILE_UPLOAD, "Upload a file", f, + f.getSaveCancelSection().getCancelButton()); } PageTextForm t = new PageTextForm(); @@ -149,7 +148,8 @@ public abstract class TextAssetBody extends SecurityPropertyEditor DomainObjectPropertySheet sheet = getBodyPropertySheet(assetModel); sheet.add("Text Type:", Asset.MIME_TYPE + "." + MimeType.LABEL); - sheet.add((String) GlobalizationUtil.globalize("cms.ui.authoring.body").localize(), TextAsset.CONTENT); + sheet.add((String) GlobalizationUtil.globalize("cms.ui.authoring.body"). + localize(), TextAsset.CONTENT); setDisplayComponent(sheet); @@ -157,7 +157,8 @@ public abstract class TextAssetBody extends SecurityPropertyEditor } - protected DomainObjectPropertySheet getBodyPropertySheet(ItemSelectionModel assetModel) { + protected DomainObjectPropertySheet getBodyPropertySheet( + ItemSelectionModel assetModel) { return new TextAssetBodyPropertySheet(assetModel); } @@ -175,7 +176,7 @@ public abstract class TextAssetBody extends SecurityPropertyEditor * @param state represents the current request */ public TextAsset getTextAsset(PageState state) { - return (TextAsset)m_assetModel.getSelectedObject(state); + return (TextAsset) m_assetModel.getSelectedObject(state); } /** @@ -189,12 +190,12 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // Create a text asset if it does not exist. // This should probably be a method in GenericArticle ? - protected TextAsset createOrGetTextAsset(ItemSelectionModel assetModel, + protected TextAsset createOrGetTextAsset(ItemSelectionModel assetModel, PageState s) { // Get the text asset or create a new one TextAsset t = getTextAsset(s); - if(t == null) { + if (t == null) { t = createTextAsset(s); assetModel.setSelectedObject(s, t); } @@ -238,8 +239,8 @@ public abstract class TextAssetBody extends SecurityPropertyEditor * @param state the PageState */ protected void maybeForwardToNextStep(PageState state) { - if (ContentItemPage.isStreamlinedCreationActive(state) && - !STREAMLINED_DONE.equals(state.getValue(m_streamlinedCreationParam))) { + if (ContentItemPage.isStreamlinedCreationActive(state) && !STREAMLINED_DONE. + equals(state.getValue(m_streamlinedCreationParam))) { state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE); fireCompletionEvent(state); } @@ -257,7 +258,7 @@ public abstract class TextAssetBody extends SecurityPropertyEditor state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE); } } - + /** * Open the edit component if the streamlined * creation parameter is turned on _and_ the streamlined_creation @@ -270,14 +271,14 @@ public abstract class TextAssetBody extends SecurityPropertyEditor //if (getTextAsset(state) != null) { // ComponentAccess ca = (ComponentAccess) getAccessMap().get(TEXT_ENTRY); - if (ContentItemPage.isStreamlinedCreationActive(state) && - !STREAMLINED_DONE.equals(state.getValue(m_streamlinedCreationParam))) { - showComponent(state, TEXT_ENTRY); - } - //} - + if (ContentItemPage.isStreamlinedCreationActive(state) && !STREAMLINED_DONE. + equals(state.getValue(m_streamlinedCreationParam))) { + showComponent(state, TEXT_ENTRY); + } + //} + } - + /** * This is the form that is used to upload files. This method can * be used so that a subclass can use their own subclass of PageFileForm. @@ -291,14 +292,13 @@ public abstract class TextAssetBody extends SecurityPropertyEditor * widget, auto-guesses mime type */ public class PageFileForm extends Form - implements FormProcessListener, FormValidationListener { + implements FormProcessListener, FormValidationListener { private SaveCancelSection m_saveCancelSection; private FileUploadSection m_fileUploadSection; // Variables saved by validate for processing private RequestLocal m_file_upload_content; private RequestLocal m_file_upload_usedINSO; - /** * The text entry widget */ @@ -314,60 +314,59 @@ public abstract class TextAssetBody extends SecurityPropertyEditor } protected String getFileUploadContent(PageState state) { - return (String)m_file_upload_content.get(state); + return (String) m_file_upload_content.get(state); } /** * Make sure that files of this type can be uploaded */ private void validateFileType(MimeType mime, boolean textType) - throws FormProcessException { + throws FormProcessException { - boolean validType = textType || ( - (mime instanceof TextMimeType) && - ((TextMimeType)mime).allowINSOConvert().booleanValue() - ); + boolean validType = textType || ((mime instanceof TextMimeType) && ((TextMimeType) mime). + allowINSOConvert().booleanValue()); if (!validType) { - throw new FormProcessException("Cannot load " + - "files of type " + mime.getMimeType() + " into the article body."); + throw new FormProcessException("Cannot load " + "files of type " + mime. + getMimeType() + " into the article body."); } boolean insoWorks = MimeTypeStatus.getMimeTypeStatus(). - getInsoFilterWorks().intValue() == 1; + getInsoFilterWorks().intValue() == 1; if (!textType && !insoWorks) { // Can't convert. inso filter is not working. Give message. - throw new FormProcessException("Could not convert to html " + - "format because interMedia INSO filter is not installed."); + throw new FormProcessException( + "Could not convert to html " + + "format because interMedia INSO filter is not installed."); } } - /** * read in the content of the file (in bytes). */ private byte[] readFileBytes(File file) throws FormProcessException { - byte [] file_bytes; + byte[] file_bytes; try { FileInputStream fs = new FileInputStream(file); file_bytes = new byte[fs.available()]; fs.read(file_bytes); fs.close(); } catch (Exception e) { - throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.authoring.unable_to_load_file").localize() + e.getMessage()); + throw new FormProcessException((String) GlobalizationUtil. + globalize("cms.ui.authoring.unable_to_load_file"). + localize() + e.getMessage()); } return file_bytes; } - /** * Convert bytes to String, possibly using INSO filter to convert to * HTML type */ - private String convertBytes(byte [] file_bytes, boolean text_type, - boolean [] used_inso) - throws FormProcessException { + private String convertBytes(byte[] file_bytes, boolean text_type, + boolean[] used_inso) + throws FormProcessException { String file_content; // If mime type is not text type, try to convert to html if (!text_type) { @@ -376,40 +375,43 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // Converted successfully, flag type should be html used_inso[0] = true; } else { - throw new FormProcessException("Could not convert to html format. " + - "interMedia INSO filter conversion failed."); + throw new FormProcessException( + "Could not convert to html format. " + + "interMedia INSO filter conversion failed."); } } else { // Text type, no need to convert - String enc = Globalization.getDefaultCharset(Kernel.getContext().getLocale()); + String enc = Globalization.getDefaultCharset(Kernel.getContext(). + getLocale()); try { file_content = new String(file_bytes, enc); } catch (UnsupportedEncodingException ex) { - throw new UncheckedWrapperException("cannot convert to encoding " + enc, ex); + throw new UncheckedWrapperException("cannot convert to encoding " + + enc, ex); } used_inso[0] = false; } return file_content; } - /** * Extract the contents of the html Body tag. * (Done to prevent base and other header tags * from interfering with page display). */ private String extractHTMLBody(String htmlText) - throws FormProcessException { + throws FormProcessException { String lc = htmlText.toLowerCase(); int bodyStart = lc.indexOf("",bodyStart); + int bodyStart_v = lc.indexOf(">", bodyStart); int bodyEnd = lc.indexOf("", bodyStart_v); if (bodyStart == -1 || bodyEnd == -1) { - final String errMsg = "The file (which should be type " - + "HTML) is missing the or tag."; + final String errMsg = + "The file (which should be type " + + "HTML) is missing the or tag."; throw new FormProcessException(errMsg); } - return htmlText.substring(bodyStart_v+1, bodyEnd); + return htmlText.substring(bodyStart_v + 1, bodyEnd); } /** @@ -424,19 +426,19 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // Convert the file to HTML, if possible File file = m_fileUploadSection.getFile(e); - byte [] file_bytes = readFileBytes(file); - boolean [] used_inso = new boolean [1]; + byte[] file_bytes = readFileBytes(file); + boolean[] used_inso = new boolean[1]; String file_content = convertBytes(file_bytes, textType, used_inso); - if (TextMimeType.MIME_TEXT_HTML.equals(mime.getMimeType())) + if (TextMimeType.MIME_TEXT_HTML.equals(mime.getMimeType())) { file_content = extractHTMLBody(file_content); + } PageState state = e.getPageState(); m_file_upload_content.set(state, file_content); m_file_upload_usedINSO.set(state, new Boolean(used_inso[0])); } - /** * Process file upload. Must be validated first. */ @@ -449,14 +451,15 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // Get info created during validation String upload_content = (String) m_file_upload_content.get(state); - boolean usedINSO = ((Boolean) m_file_upload_usedINSO.get(state)) - .booleanValue(); + boolean usedINSO = ((Boolean) m_file_upload_usedINSO.get(state)). + booleanValue(); // Set the mime type MimeType mime = m_fileUploadSection.getMimeType(e); - if (usedINSO) + if (usedINSO) { mime = MimeType.loadMimeType("text/html"); - if(mime != null) { + } + if (mime != null) { t.setMimeType(mime); } @@ -469,7 +472,9 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // Save everything updateTextAsset(state, t); - if(t.isNew() || t.isModified()) t.save(); + if (t.isNew() || t.isModified()) { + t.save(); + } } @@ -486,24 +491,23 @@ public abstract class TextAssetBody extends SecurityPropertyEditor public FileUploadSection getFileUploadSection() { return m_fileUploadSection; } - } /** * A form for editing the body of the text. */ public class PageTextForm extends Form - implements FormInitListener, FormProcessListener, FormSubmissionListener { + implements FormInitListener, FormProcessListener, + FormSubmissionListener { + private SingleSelect m_mimeWidget; private Label m_mimeLabel; private TextArea m_textWidget; private SaveCancelSection m_saveCancelSection; - /** * The text entry widget */ public static final String TEXT_ENTRY = "text_entry"; - /** * The mime type widget */ @@ -523,7 +527,6 @@ public abstract class TextAssetBody extends SecurityPropertyEditor } // These are here so that TemplateBody can set them. - public final void setMimeWidget(final SingleSelect widget) { m_mimeWidget = widget; } @@ -544,20 +547,20 @@ public abstract class TextAssetBody extends SecurityPropertyEditor PageState state = e.getPageState(); - TextAsset t = (TextAsset)m_assetModel.getSelectedObject(state); - if(t != null) { + TextAsset t = (TextAsset) m_assetModel.getSelectedObject(state); + if (t != null) { data.put(TEXT_ENTRY, t.getText()); MimeType m = t.getMimeType(); - if(m != null) { + if (m != null) { data.put(MIME_TYPE, m.getMimeType()); } } } /** Cancels streamlined editing. */ - public void submitted( FormSectionEvent e ) { - if (getSaveCancelSection().getCancelButton() - .isSelected( e.getPageState())) { + public void submitted(FormSectionEvent e) { + if (getSaveCancelSection().getCancelButton().isSelected(e. + getPageState())) { TextAssetBody.this.cancelStreamlinedCreation(e.getPageState()); } } @@ -570,19 +573,23 @@ public abstract class TextAssetBody extends SecurityPropertyEditor TextAsset t = createOrGetTextAsset(m_assetModel, state); // Set the mime type - MimeType m = MimeType.loadMimeType((String)data.get(MIME_TYPE)); + MimeType m = MimeType.loadMimeType((String) data.get(MIME_TYPE)); t.setMimeType(m); // Get the string and normalize it - String text = (String)data.get(TEXT_ENTRY); + String text = (String) data.get(TEXT_ENTRY); - if(text == null) text = ""; + if (text == null) { + text = ""; + } - t.setText((String)data.get(TEXT_ENTRY)); + t.setText((String) data.get(TEXT_ENTRY)); // Save everything updateTextAsset(state, t); - if(t.isNew() || t.isModified()) t.save(); + if (t.isNew() || t.isModified()) { + t.save(); + } TextAssetBody.this.maybeForwardToNextStep(e.getPageState()); } @@ -593,7 +600,6 @@ public abstract class TextAssetBody extends SecurityPropertyEditor public SaveCancelSection getSaveCancelSection() { return m_saveCancelSection; } - } protected String getDefaultMimeType() { @@ -604,11 +610,12 @@ public abstract class TextAssetBody extends SecurityPropertyEditor protected void addFileWidgets(PageFileForm c) { c.m_fileUploadSection = - new FileUploadSection("Text Type:", "text", getDefaultMimeType()); - c.m_fileUploadSection.getFileUploadWidget() - .addValidationListener(new NotNullValidationListener()); + new FileUploadSection("Text Type:", "text", getDefaultMimeType()); + c.m_fileUploadSection.getFileUploadWidget().addValidationListener( + new NotNullValidationListener()); // Default to -guess- because want to use file extension to determine type. - c.m_fileUploadSection.getMimeTypeWidget().setDefaultValue(FileUploadSection.GUESS_MIME); + c.m_fileUploadSection.getMimeTypeWidget().setDefaultValue( + FileUploadSection.GUESS_MIME); c.add(c.m_fileUploadSection); c.m_saveCancelSection = new SaveCancelSection(); @@ -630,20 +637,22 @@ public abstract class TextAssetBody extends SecurityPropertyEditor /* overridable method to put together the PageTextForm Component */ protected void addTextWidgets(PageTextForm c) { - ColumnPanel panel = (ColumnPanel)c.getPanel(); + ColumnPanel panel = (ColumnPanel) c.getPanel(); panel.setBorder(false); panel.setPadColor("#FFFFFF"); panel.setColumnWidth(1, "20%"); panel.setColumnWidth(2, "80%"); panel.setWidth("100%"); - c.add(new Label(GlobalizationUtil.globalize("cms.ui.authoring.text_type"))); + c.add(new Label( + GlobalizationUtil.globalize("cms.ui.authoring.text_type"))); c.m_mimeWidget = new SingleSelect(PageTextForm.MIME_TYPE); c.m_mimeWidget.setClassAttr("displayOneOptionAsLabel"); setMimeTypeOptions(c.m_mimeWidget); c.add(c.m_mimeWidget, ColumnPanel.LEFT); - c.add(new Label(GlobalizationUtil.globalize("cms.ui.authoring.edit_body_text")), + c.add(new Label(GlobalizationUtil.globalize( + "cms.ui.authoring.edit_body_text")), ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH); c.m_textWidget = new CMSDHTMLEditor(PageTextForm.TEXT_ENTRY); @@ -653,18 +662,20 @@ public abstract class TextAssetBody extends SecurityPropertyEditor // width, and similar size as htmlarea. // could be configurable - unset means default 100% x 400px c.m_textWidget.setMetaDataAttribute("width", "575"); - c.m_textWidget.setMetaDataAttribute("height", "500"); + c.m_textWidget.setMetaDataAttribute("height", "500"); c.m_textWidget.setWrap(CMSDHTMLEditor.SOFT); c.add(c.m_textWidget, ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH); c.m_saveCancelSection = new SaveCancelSection(); c.add(c.m_saveCancelSection, ColumnPanel.FULL_WIDTH); - // optionally, we clear the text of MSWord tags every time - // the text is submitted/saved - if (ContentSection.getConfig().getSaveTextCleansWordTags()) { - c.m_saveCancelSection.getSaveButton().setOnClick("wordClean_"+PageTextForm.TEXT_ENTRY+"();"); - } + // optionally, we clear the text of MSWord tags every time + // the text is submitted/saved + if (ContentSection.getConfig().getSaveTextCleansWordTags()) { + c.m_saveCancelSection.getSaveButton().setOnClick("wordClean_" + + PageTextForm.TEXT_ENTRY + + "();"); + } c.addInitListener(c); c.addProcessListener(c); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderBrowser.java b/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderBrowser.java index a94db7224..08814ec13 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderBrowser.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderBrowser.java @@ -189,6 +189,7 @@ public class FolderBrowser extends Table { Assert.exists( m_currentFolder.getStateParameter() ); } + @Override public void register(Page p) { super.register(p); @@ -217,6 +218,7 @@ public class FolderBrowser extends Table { m_deleteColumn.setVisible(state, canDelete); } + @Override public void respond(PageState state) throws ServletException { String key = state.getControlEventName(); String value = state.getControlEventValue(); @@ -407,6 +409,7 @@ public class FolderBrowser extends Table { super(true); } + @Override public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) { @@ -438,12 +441,15 @@ public class FolderBrowser extends Table { private static class ActionCellRenderer implements TableCellRenderer { private static Label s_noAction; private static ControlLink s_link; + private static final Logger logger = Logger.getLogger(ActionCellRenderer.class); static { + logger.debug("Static initializer is starting..."); s_noAction = new Label(" ", false); s_noAction.lock(); s_link = new ControlLink(new Label(globalize("cms.ui.folder.delete"))); s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ? + logger.debug("Static initializer finished."); } public Component getComponent(Table table, PageState state, Object value, diff --git a/ccm-cms/src/com/arsdigita/cms/ui/item/ItemLanguagesTable.java b/ccm-cms/src/com/arsdigita/cms/ui/item/ItemLanguagesTable.java index c62c1a070..a37cb9e48 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/item/ItemLanguagesTable.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/item/ItemLanguagesTable.java @@ -44,6 +44,7 @@ import com.arsdigita.toolbox.ui.DataTable; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** @@ -115,17 +116,20 @@ public class ItemLanguagesTable extends DataTable { * Delete language instance action link. */ private static class ActionCellRenderer implements TableCellRenderer { + private static final Logger logger = Logger.getLogger(ActionCellRenderer.class); private static Label s_noAction; private static Label s_primary; private static ControlLink s_link; static { + logger.debug("Static initializer is starting..."); s_noAction = new Label(" ", false); s_noAction.lock(); s_primary = new Label(GlobalizationUtil.globalize("cms.ui.primary_instance"), false); s_primary.lock(); s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.delete"))); s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ? + logger.debug("Static initalizer finished."); } private ItemSelectionModel m_model; diff --git a/ccm-cms/src/com/arsdigita/cms/ui/templates/ItemTemplatesListing.java b/ccm-cms/src/com/arsdigita/cms/ui/templates/ItemTemplatesListing.java index c1efbb69d..9169eed5e 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/templates/ItemTemplatesListing.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/templates/ItemTemplatesListing.java @@ -56,6 +56,7 @@ import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.toolbox.ui.DataTable; import com.arsdigita.bebop.table.TableModel; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** @@ -171,10 +172,13 @@ public abstract class ItemTemplatesListing extends TemplatesListing { // Static is safe since these components will never ever change private static ControlLink s_link; + private static final Logger logger = Logger.getLogger(AssignCellRenderer.class); static { + logger.debug("Static initializer is starting..."); s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.templates.assign_template"))); s_link.setClassAttr("assignTemplateLink"); + logger.debug("Static initializer finished."); } public AssignCellRenderer() {} diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/TypeElements.java b/ccm-cms/src/com/arsdigita/cms/ui/type/TypeElements.java index 13e24e6c5..e4d9a4fd8 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/TypeElements.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/TypeElements.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.type; - import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.ControlLink; @@ -45,7 +44,6 @@ import org.apache.log4j.Logger; import java.math.BigDecimal; import java.util.Iterator; - /** * This class contains the component to generate a table * of elements for a particular content type @@ -53,8 +51,7 @@ import java.util.Iterator; public class TypeElements extends BoxPanel { private static Logger s_log = - Logger.getLogger(TypeElements.class); - + Logger.getLogger(TypeElements.class); private SingleSelectionModel m_types; private Table m_elementsTable; private TableColumn m_removeColumn; @@ -91,7 +88,9 @@ public class TypeElements extends BoxPanel { try { type = new ContentType(typeId); } catch (DataObjectNotFoundException e) { - UncheckedWrapperException.throwLoggedException(getClass(), "Unable to make content type for id: " + typeId, e); + UncheckedWrapperException.throwLoggedException(getClass(), "Unable to make content type for id: " + + typeId, + e); } return type; } @@ -100,20 +99,25 @@ public class TypeElements extends BoxPanel { * Produce remove links. */ private static class RemoveCellRenderer implements TableCellRenderer { + + private static final Logger logger = Logger.getLogger(RemoveCellRenderer.class); private static Label s_noAction; private static ControlLink s_link; static { + logger.debug("Static initializer is starting..."); s_noAction = new Label(" ", false); s_noAction.lock(); - s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.type.element.delete"))); + s_link = new ControlLink(new Label(GlobalizationUtil.globalize( + "cms.ui.type.element.delete"))); s_link.setConfirmation("Permanently remove this element?"); + logger.debug("Static initalizer finished."); } public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) { - if ( ((Boolean) value).booleanValue() ) { + if (((Boolean) value).booleanValue()) { return s_link; } else { return s_noAction; @@ -123,10 +127,11 @@ public class TypeElements extends BoxPanel { // Removes an element private class ElementRemover extends TableActionAdapter { + public void cellSelected(TableActionEvent e) { int col = e.getColumn().intValue(); - if ( m_removeColumn != m_elementsTable.getColumn(col) ) { + if (m_removeColumn != m_elementsTable.getColumn(col)) { return; } @@ -154,98 +159,101 @@ public class TypeElements extends BoxPanel { */ private Table makeElementsTable() { - final String[] headers = { "Name", "Element Type", "Multiplicity", "Remove" }; + final String[] headers = {"Name", "Element Type", "Multiplicity", + "Remove"}; - TableModelBuilder b = new TableModelBuilder () { - private boolean m_locked; + TableModelBuilder b = new TableModelBuilder() { - public TableModel makeModel(final Table t, final PageState s) { + private boolean m_locked; - return new TableModel() { + public TableModel makeModel(final Table t, final PageState s) { - DynamicObjectType dot = getDynamicObjectType(s); + return new TableModel() { - //NOTE: this only gets the non-inherited properties of - // the object type + DynamicObjectType dot = getDynamicObjectType(s); + //NOTE: this only gets the non-inherited properties of + // the object type + Iterator declaredProperties = dot.getObjectType(). + getDeclaredProperties(); + Property currentProperty = null; - Iterator declaredProperties = dot.getObjectType().getDeclaredProperties(); - Property currentProperty = null; + public int getColumnCount() { + return headers.length; + } - public int getColumnCount() { - return headers.length; - } + public boolean nextRow() { + boolean next = declaredProperties.hasNext(); + if (next) { + currentProperty = + (Property) declaredProperties.next(); + } + return next; + } - public boolean nextRow() { - boolean next = declaredProperties.hasNext(); - if (next) { - currentProperty = (Property) declaredProperties.next(); - } - return next; - } + public Object getElementAt(int columnIndex) { + if (currentProperty == null) { + throw new IllegalArgumentException(); + } - public Object getElementAt(int columnIndex) { - if (currentProperty == null) { - throw new IllegalArgumentException(); - } - - switch (columnIndex) { - case 0: - return currentProperty.getName(); - case 1: - String dataType = currentProperty.getType().getName(); - if (dataType.equals("String")) { - return "text"; - } else if (dataType.equals("BigDecimal")) { - return "number"; - } else if (dataType.equals("Date")) { - return "date"; - } else { - return dataType; - } - case 2: - if (currentProperty.isNullable()) { - return "0 or 1"; - } else if (currentProperty.isRequired()) { - return "1"; - } else if (currentProperty.isCollection()) { - return "0 to n"; - } else { - return new Integer(currentProperty.getMultiplicity()); - } - case 3: - return new Boolean(isRemovable()); - default: - throw new IllegalArgumentException("columnIndex exceeds " + - "number of columns available"); - } - } - - public Object getKeyAt(int columnIndex) { - if (currentProperty == null) { - throw new IllegalArgumentException(); + switch (columnIndex) { + case 0: + return currentProperty.getName(); + case 1: + String dataType = currentProperty.getType(). + getName(); + if (dataType.equals("String")) { + return "text"; + } else if (dataType.equals("BigDecimal")) { + return "number"; + } else if (dataType.equals("Date")) { + return "date"; } else { - //uses the element name as key, unique for each row - return currentProperty.getName(); + return dataType; } - } + case 2: + if (currentProperty.isNullable()) { + return "0 or 1"; + } else if (currentProperty.isRequired()) { + return "1"; + } else if (currentProperty.isCollection()) { + return "0 to n"; + } else { + return new Integer(currentProperty. + getMultiplicity()); + } + case 3: + return new Boolean(isRemovable()); + default: + throw new IllegalArgumentException( + "columnIndex exceeds " + + "number of columns available"); + } + } - private boolean isRemovable() { - return true; - } + public Object getKeyAt(int columnIndex) { + if (currentProperty == null) { + throw new IllegalArgumentException(); + } else { + //uses the element name as key, unique for each row + return currentProperty.getName(); + } + } - }; + private boolean isRemovable() { + return true; + } + }; - } + } - public void lock() { - m_locked = true; - } + public void lock() { + m_locked = true; + } - public boolean isLocked() { - return m_locked; - } - - }; + public boolean isLocked() { + return m_locked; + } + }; Table result = new Table(b, headers); CMSContainer ifemptable = new CMSContainer(); @@ -256,5 +264,4 @@ public class TypeElements extends BoxPanel { return result; } - } diff --git a/ccm-core/src/com/arsdigita/bebop/Page.java b/ccm-core/src/com/arsdigita/bebop/Page.java index 2f19afdef..89393a1eb 100755 --- a/ccm-core/src/com/arsdigita/bebop/Page.java +++ b/ccm-core/src/com/arsdigita/bebop/Page.java @@ -109,10 +109,12 @@ public class Page extends BlockStylable implements Container { static final Collection CONTROL_EVENT_KEYS; static { + s_log.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."); } /** diff --git a/ccm-core/src/com/arsdigita/bebop/demo/workflow/SampleProcesses.java b/ccm-core/src/com/arsdigita/bebop/demo/workflow/SampleProcesses.java index 4dcb0f0ab..a957aeec9 100755 --- a/ccm-core/src/com/arsdigita/bebop/demo/workflow/SampleProcesses.java +++ b/ccm-core/src/com/arsdigita/bebop/demo/workflow/SampleProcesses.java @@ -22,6 +22,7 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.list.ListModel; import java.util.ArrayList; import java.util.NoSuchElementException; +import org.apache.log4j.Logger; /** * A class that provides a sample set of workflows and tasks. The class @@ -37,6 +38,7 @@ import java.util.NoSuchElementException; */ public class SampleProcesses { + private static final Logger logger = Logger.getLogger(SampleProcesses.class); private static SampleProcesses m_instance; /** @@ -51,6 +53,7 @@ public class SampleProcesses { // Set up some default task types static { + logger.debug("Static initalizer starting..."); Task write = new Task("Write"); write.setAssignee("Authors"); Task edit = new Task("Edit"); @@ -68,6 +71,7 @@ public class SampleProcesses { m_allTasks.add(approve); m_allTasks.add(publish); m_allTasks.add(review); + logger.debug("Static initalizer finished..."); } public synchronized static SampleProcesses getInstance() { diff --git a/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java b/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java index 5d3161bd2..d08c65ba4 100755 --- a/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java +++ b/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java @@ -84,89 +84,91 @@ public class PageTransformer implements PresentationManager { // load the default xsl parameter generators static { + s_log.debug("Static initalizer starting..."); registerXSLParameterGenerator("contextPath", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return request.getContextPath(); - } - }); + public String generateValue(HttpServletRequest request) { + return request.getContextPath(); + } + }); registerXSLParameterGenerator("root-context-prefix", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return Web.getConfig().getDispatcherContextPath(); - } - }); + public String generateValue(HttpServletRequest request) { + return Web.getConfig().getDispatcherContextPath(); + } + }); registerXSLParameterGenerator("context-prefix", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return Web.getContext().getRequestURL().getContextPath(); - } - }); + public String generateValue(HttpServletRequest request) { + return Web.getContext().getRequestURL().getContextPath(); + } + }); registerXSLParameterGenerator("static-prefix", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return Web.getContext().getRequestURL().getContextPath() - + com.arsdigita.web.URL.STATIC_DIR; - } - }); + public String generateValue(HttpServletRequest request) { + return Web.getContext().getRequestURL().getContextPath() + + com.arsdigita.web.URL.STATIC_DIR; + } + }); registerXSLParameterGenerator("dispatcher-prefix", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return com.arsdigita.web.URL.getDispatcherPath(); - } - }); + public String generateValue(HttpServletRequest request) { + return com.arsdigita.web.URL.getDispatcherPath(); + } + }); registerXSLParameterGenerator("dcp-on-buttons", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - if (Bebop.getConfig().doubleClickProtectionOnButtons()) { - return "true"; - } else { - return null; - } + public String generateValue(HttpServletRequest request) { + if (Bebop.getConfig().doubleClickProtectionOnButtons()) { + return "true"; + } else { + return null; + } - } - }); + } + }); registerXSLParameterGenerator("dcp-on-links", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - if (Bebop.getConfig().doubleClickProtectionOnLinks()) { - return "true"; - } else { - return null; - } + public String generateValue(HttpServletRequest request) { + if (Bebop.getConfig().doubleClickProtectionOnLinks()) { + return "true"; + } else { + return null; + } - } - }); + } + }); registerXSLParameterGenerator("user-agent", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return request.getHeader("User-Agent"); - } - }); + public String generateValue(HttpServletRequest request) { + return request.getHeader("User-Agent"); + } + }); registerXSLParameterGenerator("negotiated-language", - new XSLParameterGenerator() { + new XSLParameterGenerator() { - public String generateValue(HttpServletRequest request) { - return DispatcherHelper.getNegotiatedLocale().getLanguage(); - } - }); + public String generateValue(HttpServletRequest request) { + return DispatcherHelper.getNegotiatedLocale().getLanguage(); + } + }); + s_log.debug("Static initalizer finished."); } // XXX These need to move somewhere else. /** @@ -216,8 +218,8 @@ public class PageTransformer implements PresentationManager { * Sets the content type of the response and then gets the PrintWriter */ private PrintWriter getWriter(final HttpServletResponse resp, - final String contentType, - final String charset) { + final String contentType, + final String charset) { Assert.exists(contentType); Assert.exists(charset); @@ -229,8 +231,9 @@ public class PageTransformer implements PresentationManager { s_log.warn("Using getOutputStream instead of getWriter"); try { - return new PrintWriter(new OutputStreamWriter(resp.getOutputStream(), - charset)); + return new PrintWriter(new OutputStreamWriter(resp. + getOutputStream(), + charset)); } catch (IOException ex) { throw new UncheckedWrapperException(ex); } @@ -245,8 +248,8 @@ public class PageTransformer implements PresentationManager { * PresentationManager interface. */ public void servePage(final Document doc, - final HttpServletRequest req, - final HttpServletResponse resp) { + final HttpServletRequest req, + final HttpServletResponse resp) { servePage(doc, req, resp, null); } @@ -265,9 +268,9 @@ public class PageTransformer implements PresentationManager { * to the Transformer */ public void servePage(final Document doc, - final HttpServletRequest req, - final HttpServletResponse resp, - final Map params) { + final HttpServletRequest req, + final HttpServletResponse resp, + final Map params) { if (resp.isCommitted()) { return; } @@ -280,7 +283,8 @@ public class PageTransformer implements PresentationManager { Profiler.startOp("XSLT"); try { - final String charset = Globalization.getDefaultCharset(Kernel.getContext().getLocale()); + final String charset = Globalization.getDefaultCharset(Kernel. + getContext().getLocale()); final String output = req.getParameter("output"); s_log.info("output=" + output); @@ -289,12 +293,14 @@ public class PageTransformer implements PresentationManager { DeveloperSupport.startStage("PresMgr get stylesheet"); boolean fancyErrors = Bebop.getConfig().wantFancyXSLErrors() - || Boolean.TRUE.equals(req.getAttribute(FANCY_ERRORS)); + || Boolean.TRUE.equals(req.getAttribute( + FANCY_ERRORS)); // Get the stylesheet transformer object corresponding to the // current request. final XSLTemplate template = Templating.getTemplate(req, - fancyErrors, !Boolean.TRUE.equals(req.getAttribute(CACHE_XSL_NONE))); + fancyErrors, !Boolean.TRUE. + equals(req.getAttribute(CACHE_XSL_NONE))); DeveloperSupport.endStage("PresMgr get stylesheet"); @@ -322,7 +328,8 @@ public class PageTransformer implements PresentationManager { while (entries.hasNext()) { final Map.Entry entry = (Map.Entry) entries.next(); - xf.setParameter((String) entry.getKey(), entry.getValue()); + xf.setParameter((String) entry.getKey(), + entry.getValue()); } } @@ -341,7 +348,7 @@ public class PageTransformer implements PresentationManager { try { xf.transform(new DOMSource(doc.getInternalDocument()), - new StreamResult(writer)); + new StreamResult(writer)); } catch (TransformerException ex) { throw new UncheckedWrapperException( "cannot transform document", ex); @@ -351,8 +358,10 @@ public class PageTransformer implements PresentationManager { // copy and paste from BasePresentationManager if (Kernel.getConfig().isDebugEnabled()) { - Document origDoc = (Document) req.getAttribute("com.arsdigita.xml.Document"); - Debugger.addDebugger(new TransformationDebugger(template.getSource(), template.getDependents())); + Document origDoc = (Document) req.getAttribute( + "com.arsdigita.xml.Document"); + Debugger.addDebugger(new TransformationDebugger(template. + getSource(), template.getDependents())); writer.print(Debugger.getDebugging(req)); } @@ -374,8 +383,10 @@ public class PageTransformer implements PresentationManager { // current request. template = Templating.getTemplate( req, - Boolean.TRUE.equals(req.getAttribute(PageTransformer.FANCY_ERRORS)), - !Boolean.TRUE.equals(req.getAttribute(PageTransformer.CACHE_XSL_NONE))); + Boolean.TRUE.equals(req.getAttribute( + PageTransformer.FANCY_ERRORS)), + !Boolean.TRUE.equals(req.getAttribute( + PageTransformer.CACHE_XSL_NONE))); endTransaction(req); } finally { DeveloperSupport.endStage("PresMgr get stylesheet"); @@ -393,7 +404,7 @@ public class PageTransformer implements PresentationManager { resp.reset(); resp.setContentType("application/zip"); resp.setHeader("Content-Disposition", - "attachment; filename=\"" + prefix + ".zip\""); + "attachment; filename=\"" + prefix + ".zip\""); DispatcherHelper.forceCacheDisable(resp); template.toZIP(os, prefix); @@ -406,7 +417,7 @@ public class PageTransformer implements PresentationManager { } } else { throw new IllegalStateException(output - + " is an unknown output"); + + " is an unknown output"); } } finally { Profiler.stopOp("XSLT"); @@ -435,7 +446,7 @@ public class PageTransformer implements PresentationManager { * only the last registered generator is used. */ public static void registerXSLParameterGenerator(String parameterName, - XSLParameterGenerator parameterGenerator) { + XSLParameterGenerator parameterGenerator) { s_XSLParameters.put(parameterName, parameterGenerator); } @@ -460,9 +471,9 @@ public class PageTransformer implements PresentationManager { * be used in the XSL for the given name */ public static String getXSLParameterValue(String name, - HttpServletRequest request) { + HttpServletRequest request) { XSLParameterGenerator generator = - (XSLParameterGenerator) s_XSLParameters.get(name); + (XSLParameterGenerator) s_XSLParameters.get(name); if (generator != null) { return generator.generateValue(request); } else { @@ -475,13 +486,14 @@ public class PageTransformer implements PresentationManager { * xsl paraemters. */ public static void addXSLParameters(Transformer transformer, - HttpServletRequest request) { + HttpServletRequest request) { final Iterator entries = s_XSLParameters.entrySet().iterator(); while (entries.hasNext()) { final Map.Entry entry = (Map.Entry) entries.next(); - String value = ((XSLParameterGenerator) entry.getValue()).generateValue(request); + String value = ((XSLParameterGenerator) entry.getValue()). + generateValue(request); if (value == null) { // XSL does not like nulls value = ""; diff --git a/ccm-core/src/com/arsdigita/categorization/Category.java b/ccm-core/src/com/arsdigita/categorization/Category.java index f4452d405..177fdee05 100755 --- a/ccm-core/src/com/arsdigita/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/categorization/Category.java @@ -123,7 +123,9 @@ public class Category extends ACSObject { private static CategorizationConfig s_config = new CategorizationConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } // Quasimodo: End public static final String ROOT_CATEGORY = "rootCategory"; diff --git a/ccm-core/src/com/arsdigita/core/LibCheck.java b/ccm-core/src/com/arsdigita/core/LibCheck.java index ddc5fa8a8..021402883 100755 --- a/ccm-core/src/com/arsdigita/core/LibCheck.java +++ b/ccm-core/src/com/arsdigita/core/LibCheck.java @@ -24,6 +24,7 @@ import com.arsdigita.util.Assert; import java.io.InputStream; import java.io.InputStreamReader; +import org.apache.log4j.Logger; /** * LibCheck uses the checklist mechanism to perform additional checks for @@ -37,14 +38,16 @@ import java.io.InputStreamReader; public class LibCheck extends BaseCheck { - + private static final Logger logger = Logger.getLogger(LibCheck.class); // Integrating the packaging.MessageMap service class providing a // package specific message file by overriding the variable in BaseCheck. static { + logger.debug("Static initializer starting..."); final InputStream in = LibCheck.class.getResourceAsStream ("libcheck.messages_linux"); Assert.exists(in, InputStream.class); s_messages.load(new InputStreamReader(in)); + logger.debug("Static initializer finished..."); } private boolean checkJAAS() { diff --git a/ccm-core/src/com/arsdigita/developersupport/Comodifications.java b/ccm-core/src/com/arsdigita/developersupport/Comodifications.java index 31cf85a9c..75f3a93ac 100755 --- a/ccm-core/src/com/arsdigita/developersupport/Comodifications.java +++ b/ccm-core/src/com/arsdigita/developersupport/Comodifications.java @@ -155,9 +155,11 @@ public final class Comodifications { * the Proxy class do most of the work for me. */ private static class ListHandler implements InvocationHandler { + private static final Logger logger = Logger.getLogger(ListHandler.class); private final static Set s_mutators = new HashSet(); static { + logger.debug("Static initalizer starting..."); registerMutator("add", new Class[] {Integer.TYPE, Object.class}); registerMutator("add", new Class[] {Object.class}); registerMutator("addAll", new Class[] {Collection.class}); @@ -169,6 +171,7 @@ public final class Comodifications { registerMutator("removeAll", new Class[] {Collection.class}); registerMutator("retainAll", new Class[] {Collection.class}); registerMutator("set", new Class[] {Integer.TYPE, Object.class}); + logger.debug("Static initalizer finished."); } private final static Method s_iteratorMethod = diff --git a/ccm-core/src/com/arsdigita/developersupport/Counter.java b/ccm-core/src/com/arsdigita/developersupport/Counter.java index b0ab8fa8b..92302e6b0 100755 --- a/ccm-core/src/com/arsdigita/developersupport/Counter.java +++ b/ccm-core/src/com/arsdigita/developersupport/Counter.java @@ -62,8 +62,10 @@ public final class Counter { private final static DecimalFormat DURATION_FMT = new DecimalFormat(); static { + s_log.debug("Static initalizer starting..."); DURATION_FMT.setGroupingSize(3); DURATION_FMT.setGroupingUsed(true); + s_log.debug("Static initalizer finished."); } diff --git a/ccm-core/src/com/arsdigita/developersupport/LoggingProxyFactory.java b/ccm-core/src/com/arsdigita/developersupport/LoggingProxyFactory.java index 0ad5b90d0..aad3071f1 100755 --- a/ccm-core/src/com/arsdigita/developersupport/LoggingProxyFactory.java +++ b/ccm-core/src/com/arsdigita/developersupport/LoggingProxyFactory.java @@ -224,16 +224,20 @@ public final class LoggingProxyFactory implements LoggerConfigurator { } private static class Handler implements InvocationHandler { + private static final Logger logger = Logger.getLogger(Handler.class); private static final Method s_getProxiedObject; static { + logger.debug("Static initalizer starting..."); try { s_getProxiedObject = LoggingProxy.class.getMethod("getProxiedObject", new Class[] {}); } catch (NoSuchMethodException ex) { + logger.error("Statis initalizer failed: ", ex); throw new UncheckedWrapperException("failed", ex); } + logger.debug("Static initalizer finished..."); } private Config m_config; diff --git a/ccm-core/src/com/arsdigita/dispatcher/BaseDispatcherServlet.java b/ccm-core/src/com/arsdigita/dispatcher/BaseDispatcherServlet.java index e06c3c4ff..605f66c36 100755 --- a/ccm-core/src/com/arsdigita/dispatcher/BaseDispatcherServlet.java +++ b/ccm-core/src/com/arsdigita/dispatcher/BaseDispatcherServlet.java @@ -83,58 +83,57 @@ import org.xml.sax.helpers.DefaultHandler; public abstract class BaseDispatcherServlet extends HttpServlet implements Dispatcher, DispatcherConstants { - private static final Logger s_log = Logger.getLogger - (BaseDispatcherServlet.class); - + private static final Logger s_log = Logger.getLogger( + BaseDispatcherServlet.class); private final static int NOT_FOUND = 0; private final static int STATIC_FILE = 1; private final static int JSP_FILE = 2; - private final static String WEB_XML_22_PUBLIC_ID = - "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"; + "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"; private final static String WEB_XML_23_PUBLIC_ID = - "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"; - + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"; /** * We use a Vector here instead of another collection because * Vector is synchronized. */ private static Vector s_listenerList = new Vector(); - /** * list of active requests */ private static Vector s_activeList = new Vector(); static { + s_log.debug("Static initalizer starting..."); // Add the basic request listeners. BaseDispatcherServlet.addRequestListener(new RequestListener() { - public void requestStarted(RequestEvent re) { - DispatcherHelper.setRequest(re.getRequest()); - } - public void requestFinished(RequestEvent re) { - // We could do this: - // DispatcherHelper.setRequest(null); - // but some later RequestListener might want to access - // the request or session. So we'll just let the - // DispatcherHelper hang on to one stale - // HttpServletRequest (per thread). The reference will - // be overwritten on the next request, so we keep only - // a small amount of garbage. - } - }); + public void requestStarted(RequestEvent re) { + DispatcherHelper.setRequest(re.getRequest()); + } + + public void requestFinished(RequestEvent re) { + // We could do this: + // DispatcherHelper.setRequest(null); + // but some later RequestListener might want to access + // the request or session. So we'll just let the + // DispatcherHelper hang on to one stale + // HttpServletRequest (per thread). The reference will + // be overwritten on the next request, so we keep only + // a small amount of garbage. + } + }); BaseDispatcherServlet.addRequestListener(new RequestListener() { - public void requestStarted(RequestEvent re) { - Kernel.getContext().getTransaction().begin(); - } - public void requestFinished(RequestEvent re) { - Kernel.getContext().getTransaction().end(); - } - }); + public void requestStarted(RequestEvent re) { + Kernel.getContext().getTransaction().begin(); + } + + public void requestFinished(RequestEvent re) { + Kernel.getContext().getTransaction().end(); + } + }); //log to DeveloperSupport // BaseDispatcherServlet.addRequestListener(new RequestListener() { @@ -153,19 +152,18 @@ public abstract class BaseDispatcherServlet extends HttpServlet * it depends upon there being at least one DeveloperSupportListener when counting * whether to log queries to webdevsupport. */ - com.arsdigita.developersupport.DeveloperSupport.addListener - (new com.arsdigita.developersupport.DeveloperSupportListener() { - public void requestStart(Object request) { - s_log.debug("DS: requestStart: " + request); - } + com.arsdigita.developersupport.DeveloperSupport.addListener(new com.arsdigita.developersupport.DeveloperSupportListener() { - public void requestEnd(Object request) { - s_log.debug("DS: requestEnd: " + request); - } - } - ); + public void requestStart(Object request) { + s_log.debug("DS: requestStart: " + request); + } + + public void requestEnd(Object request) { + s_log.debug("DS: requestEnd: " + request); + } + }); + s_log.debug("Static initalizer finished."); } - private List m_welcomeFiles = new ArrayList(); /** @@ -177,7 +175,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet super.init(); try { File file = - new File(getServletContext().getRealPath("/WEB-INF/web.xml")); + new File(getServletContext().getRealPath("/WEB-INF/web.xml")); // all we care about is the welcome-file-list element SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setValidating(false); @@ -220,11 +218,10 @@ public abstract class BaseDispatcherServlet extends HttpServlet * @throws com.arsdigita.dispatcher.RedirectException if the dispatcher * should redirect the client to the page contained in the exception **/ - protected abstract RequestContext authenticateUser - (HttpServletRequest req, - HttpServletResponse resp, - RequestContext ctx) - throws RedirectException; + protected abstract RequestContext authenticateUser(HttpServletRequest req, + HttpServletResponse resp, + RequestContext ctx) + throws RedirectException; /** * Called directly by the servlet container when this servlet is invoked @@ -243,18 +240,17 @@ public abstract class BaseDispatcherServlet extends HttpServlet * throws an IOException */ public void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + throws ServletException, IOException { if (s_log.isDebugEnabled()) { - s_log.debug - ("\n*** *** *** *** *** ***\n" + - "Servicing request for URL '" + req.getRequestURI() + "'\n" + - "*** *** *** *** *** ***"); + s_log.debug("\n*** *** *** *** *** ***\n" + + "Servicing request for URL '" + req.getRequestURI() + + "'\n" + "*** *** *** *** *** ***"); } boolean reentrant = true; RequestContext reqCtx = - DispatcherHelper.getRequestContext(req); + DispatcherHelper.getRequestContext(req); boolean finishedNormal = false; // there are two types of re-entrancy we need to consider: @@ -307,8 +303,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet // need an identifier for this particular request String requestId = - Thread.currentThread().getName() + "|" + - System.currentTimeMillis(); + Thread.currentThread().getName() + "|" + System. + currentTimeMillis(); req.setAttribute(REENTRANCE_ATTRIBUTE, requestId); s_activeList.add(requestId); @@ -345,8 +341,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet // whole object since it might actually be a // KernelRequestContext with user / session info if (reqCtx instanceof InitialRequestContext) { - ((InitialRequestContext)reqCtx) - .initializeURLFromRequest(req, true); + ((InitialRequestContext) reqCtx). + initializeURLFromRequest(req, true); } } } @@ -382,7 +378,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet Throwable rootError; do { rootError = t; - t = ((ServletException)t).getRootCause(); + t = ((ServletException) t).getRootCause(); } while (t instanceof ServletException); if (t != null) { rootError = t; @@ -393,9 +389,9 @@ public abstract class BaseDispatcherServlet extends HttpServlet && (rootError instanceof AbortRequestSignal)) { finishedNormal = true; } else if (rootError != null - && (rootError instanceof RedirectSignal)) { + && (rootError instanceof RedirectSignal)) { s_log.debug("rethrowing RedirectSignal", rootError); - throw (RedirectSignal)rootError; + throw (RedirectSignal) rootError; } else { s_log.error("error in BaseDispatcherServlet", rootError); throw new ServletException(rootError); @@ -411,13 +407,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet DeveloperSupport.endStage("BaseDispatcherServlet.service()"); // run the request listener events fireFinishedListener( - new RequestEvent(req, resp, reqCtx, false, finishedNormal)); + new RequestEvent(req, resp, reqCtx, false, + finishedNormal)); // at this point, clear the attribute so // a secondary request will work // and remove the request from the list of currently-active // requests Object requestId = req.getAttribute(REENTRANCE_ATTRIBUTE); - synchronized(s_activeList) { + synchronized (s_activeList) { s_activeList.remove(requestId); s_activeList.notifyAll(); } @@ -438,14 +435,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet **/ private StartRequestRecord startRequest(HttpServletRequest req, HttpServletResponse resp) - throws RedirectException, IOException, ServletException { + throws RedirectException, IOException, ServletException { // turn multipart request into wrapped request // to make up for servlet 2.2 brokenness req = DispatcherHelper.maybeWrapRequest(req); RequestContext reqCtx = - new InitialRequestContext(req, getServletContext()); + new InitialRequestContext(req, getServletContext()); // run the request listener events fireStartListener(new RequestEvent(req, resp, reqCtx, true)); @@ -469,12 +466,12 @@ public abstract class BaseDispatcherServlet extends HttpServlet * listeners */ protected void fireFinishedListener(RequestEvent evt) { - for (int i = 0 ; i < s_listenerList.size(); i++) { + for (int i = 0; i < s_listenerList.size(); i++) { try { - ((RequestListener)s_listenerList.get(i)).requestFinished(evt); + ((RequestListener) s_listenerList.get(i)).requestFinished(evt); } catch (Exception e) { - s_log.error("Error running request finished listener " + - s_listenerList.get(i) + " (#" + i + ")", e); + s_log.error("Error running request finished listener " + s_listenerList. + get(i) + " (#" + i + ")", e); } } } @@ -487,8 +484,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet * listeners */ protected void fireStartListener(RequestEvent evt) { - for (int i = 0 ; i < s_listenerList.size(); i++) { - ((RequestListener)s_listenerList.get(i)).requestStarted(evt); + for (int i = 0; i < s_listenerList.size(); i++) { + ((RequestListener) s_listenerList.get(i)).requestStarted(evt); } } @@ -496,6 +493,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet * Kludge for returning a typed 2-tuple. */ private class StartRequestRecord { + RequestContext m_reqCtx; HttpServletRequest m_req; @@ -517,10 +515,11 @@ public abstract class BaseDispatcherServlet extends HttpServlet if (sema != null) { while (s_activeList.indexOf(sema) != -1) { try { - synchronized(s_activeList) { + synchronized (s_activeList) { s_activeList.wait(); } - } catch (InterruptedException ie) { } + } catch (InterruptedException ie) { + } } sess.removeAttribute(REDIRECT_SEMAPHORE); } @@ -545,15 +544,15 @@ public abstract class BaseDispatcherServlet extends HttpServlet * returns NOT_FOUND otherwise. */ private int concreteFileType(HttpServletRequest req) - throws ServletException, IOException { + throws ServletException, IOException { String path = DispatcherHelper.getCurrentResourcePath(req); ServletContext sctx = this.getServletContext(); File realFile = new File(sctx.getRealPath(path)); - if (realFile.exists() && - (!realFile.isDirectory() || hasWelcomeFile(realFile))) { + if (realFile.exists() && (!realFile.isDirectory() || hasWelcomeFile( + realFile))) { // yup. Go there, bypass the site map. // we have a concrete file so no forwarding to // rewrite the request URL is necessary. @@ -587,7 +586,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet private boolean trailingSlashRedirect(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + throws IOException { String path = DispatcherHelper.getCurrentResourcePath(req); // first, see if we have an extension if (path.lastIndexOf(".") <= path.lastIndexOf("/")) { @@ -612,13 +611,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet * web.xml */ private class WebXMLReader extends DefaultHandler { + StringBuffer m_buffer = new StringBuffer(); public InputSource resolveEntity(String publicId, String systemId) throws SAXException { // we don't want to read the web.xml dtd if (WEB_XML_22_PUBLIC_ID.equals(publicId) - || WEB_XML_23_PUBLIC_ID.equals(publicId)) { + || WEB_XML_23_PUBLIC_ID.equals(publicId)) { StringReader reader = new StringReader(" "); return new InputSource(reader); } else { @@ -645,7 +645,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet String qname) { if (qname.equals("welcome-file-list")) { String[] welcomeFiles = - StringUtils.split(m_buffer.toString(), ','); + StringUtils.split(m_buffer.toString(), ','); for (int i = 0; i < welcomeFiles.length; i++) { m_welcomeFiles.add(welcomeFiles[i].trim()); } diff --git a/ccm-core/src/com/arsdigita/formbuilder/AttributeType.java b/ccm-core/src/com/arsdigita/formbuilder/AttributeType.java index 9cb199de2..47eed8bfe 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/AttributeType.java +++ b/ccm-core/src/com/arsdigita/formbuilder/AttributeType.java @@ -18,13 +18,12 @@ */ package com.arsdigita.formbuilder; - import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.util.UncheckedWrapperException; import java.util.List; - +import org.apache.log4j.Logger; /** * This class contains the attribute data type that are used for form @@ -36,8 +35,8 @@ import java.util.List; */ public class AttributeType { + private static final Logger logger = Logger.getLogger(AttributeType.class); private Class m_parameterModelClass; - private List m_validationListeners; public AttributeType(Class parameterModelClass) { @@ -46,14 +45,12 @@ public class AttributeType { m_validationListeners = new java.util.ArrayList(); } - /** * Standard attribute types */ public static AttributeType INTEGER; public static AttributeType TEXT; public static AttributeType DATE; - // The classes of the standard data types private static Class s_integerClass; private static Class s_textClass; @@ -61,12 +58,15 @@ public class AttributeType { // Initialization of the standard attribute types static { - + logger.debug("Static initalizer starting..."); try { - s_integerClass = Class.forName("com.arsdigita.bebop.parameters.IntegerParameter"); - s_textClass = Class.forName("com.arsdigita.bebop.parameters.StringParameter"); - s_dateClass = Class.forName("com.arsdigita.bebop.parameters.DateParameter"); + s_integerClass = Class.forName( + "com.arsdigita.bebop.parameters.IntegerParameter"); + s_textClass = Class.forName( + "com.arsdigita.bebop.parameters.StringParameter"); + s_dateClass = Class.forName( + "com.arsdigita.bebop.parameters.DateParameter"); } catch (ClassNotFoundException e) { throw new UncheckedWrapperException(e); @@ -75,10 +75,10 @@ public class AttributeType { INTEGER = new AttributeType(s_integerClass); TEXT = new AttributeType(s_textClass); DATE = new AttributeType(s_dateClass); + logger.debug("Static initalizer finished."); } //*** Attribute Methods - public Class getParameterModelClass() { return m_parameterModelClass; } diff --git a/ccm-core/src/com/arsdigita/kernel/security/Crypto.java b/ccm-core/src/com/arsdigita/kernel/security/Crypto.java index 50f8de0f5..8b817f3d4 100755 --- a/ccm-core/src/com/arsdigita/kernel/security/Crypto.java +++ b/ccm-core/src/com/arsdigita/kernel/security/Crypto.java @@ -67,7 +67,9 @@ public class Crypto { public static final String CHARACTER_ENCODING = "UTF-8"; static { + s_log.debug("Static initalizer starting..."); Security.addProvider(new BouncyCastleProvider()); + s_log.debug("Static initalizer finished"); } /** diff --git a/ccm-core/src/com/arsdigita/kernel/security/URLLoginModule.java b/ccm-core/src/com/arsdigita/kernel/security/URLLoginModule.java index 2f49327c4..fb81ed90e 100755 --- a/ccm-core/src/com/arsdigita/kernel/security/URLLoginModule.java +++ b/ccm-core/src/com/arsdigita/kernel/security/URLLoginModule.java @@ -48,8 +48,10 @@ public class URLLoginModule extends UserLoginModule { private static Set s_models = new HashSet(); static { + s_log.debug("Static initalizer starting..."); s_models.add(NORMAL_PARAM); s_models.add(SECURE_PARAM); + s_log.debug("Static initalizer finished..."); } /** diff --git a/ccm-core/src/com/arsdigita/logging/ErrorReport.java b/ccm-core/src/com/arsdigita/logging/ErrorReport.java index 4e38e5cf1..fec82bb10 100755 --- a/ccm-core/src/com/arsdigita/logging/ErrorReport.java +++ b/ccm-core/src/com/arsdigita/logging/ErrorReport.java @@ -63,6 +63,7 @@ public class ErrorReport { private static final Logger s_log = Logger.getLogger(ErrorReport.class); static { + s_log.debug("Static initalizer starting..."); final JavaPropertyReader reader = new JavaPropertyReader (System.getProperties()); @@ -76,6 +77,7 @@ public class ErrorReport { if (dir != null) { ErrorReport.initializeAppender(dir); } + s_log.debug("Static initalizer finished."); } public static void initializeAppender(String directory) { diff --git a/ccm-core/src/com/arsdigita/mail/Mail.java b/ccm-core/src/com/arsdigita/mail/Mail.java index 4f640d34f..891f0e0a0 100755 --- a/ccm-core/src/com/arsdigita/mail/Mail.java +++ b/ccm-core/src/com/arsdigita/mail/Mail.java @@ -69,9 +69,13 @@ import java.util.Set; * @author Ron Henderson * @version $Id: Mail.java 994 2005-11-14 14:29:25Z apevec $ */ - public class Mail implements MessageType { + /** + * Used for logging. + */ + private static final Logger s_log = + Logger.getLogger(Mail.class); private static MailConfig s_config; public static MailConfig getConfig() { @@ -82,118 +86,92 @@ public class Mail implements MessageType { } return s_config; } - private static final InternetAddress[] EMPTY_ADDRESS_LIST = - new InternetAddress[0]; - + new InternetAddress[0]; /** * Table of message headers. */ private Hashtable m_headers; - /** * Email addresses the message is being sent to. */ private InternetAddress[] m_to; - private InternetAddress[] m_filteredTo = EMPTY_ADDRESS_LIST; private InternetAddress[] m_invalidTo = EMPTY_ADDRESS_LIST; private static Set s_invalidDomains = new HashSet(); static { + s_log.debug("Static initalizer starting..."); s_invalidDomains.add("example.com"); + s_log.debug("Static initalizer finished."); } - /** * Email address the message is being sent from. */ private InternetAddress m_from; - /** * Email address used for replies to this message. */ private InternetAddress[] m_replyTo; - /** * Email addresses that the message is being carbon-copied to. */ private InternetAddress[] m_cc; - /** * Email addresses that the message is being blind carbon-copied to. */ private InternetAddress[] m_bcc; - /** * Message subject. */ private String m_subject; - /** * Message body (can be text or HTML). */ private String m_body; - /** * Message body alternate (if the body is HTML) */ private String m_alternate; - /** * Encoding specification for m_body and m_alternate (optional). * Default value (null) implies "us-ascii" encoding. */ private String m_encoding; - /** * Message attachments (optional) */ private MimeMultipart m_attachments; - /** * Unique identifier for each mail send out. */ private String m_messageID; - /** * Session object used to send mail. */ private static Session s_session; - /** * SMTP host to connect to. Only used to override the default for * testing purposes. */ private static String s_host; - /** * SMTP port to connect to. Only used to override the default for * testing purposes. */ private static String s_port; - // Constants used by Mail - final static String CONTENT_TYPE = "Content-Type"; - final static String CONTENT_ID = "Content-ID"; - final static String MIXED = "mixed"; - final static String ALTERNATIVE = "alternative"; - + final static String CONTENT_ID = "Content-ID"; + final static String MIXED = "mixed"; + final static String ALTERNATIVE = "alternative"; /** * Disposition of "inline" */ - public final static String INLINE = javax.mail.Part.INLINE; - + public final static String INLINE = javax.mail.Part.INLINE; /** * Disposition of "attachment" */ - public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT; - - /** - * Used for logging. - */ - - private static final Logger s_log = - Logger.getLogger(Mail.class); + public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT; /** * Default constructor. Must use the setTo, setSubject (and so on) @@ -212,8 +190,7 @@ public class Mail implements MessageType { */ public Mail(String to, String from, - String subject) - { + String subject) { this(to, from, subject, null); } @@ -228,8 +205,7 @@ public class Mail implements MessageType { public Mail(String to, String from, String subject, - String body) - { + String body) { m_to = (to == null ? EMPTY_ADDRESS_LIST : parseAddressField(to)); filterRecipients(); m_from = (from == null ? null : parseAddress(from)); @@ -251,9 +227,8 @@ public class Mail implements MessageType { String from, String subject, String body, - String enc) - { - this(to,from,subject,body); + String enc) { + this(to, from, subject, body); setEncoding(enc); } @@ -265,26 +240,22 @@ public class Mail implements MessageType { * @param subject the subject for the message * @param body the plain text body of the message */ - public static void send(String to, String from, String subject, String body) - throws MessagingException, - SendFailedException - { - Mail msg = new Mail(to,from,subject,body); + throws MessagingException, + SendFailedException { + Mail msg = new Mail(to, from, subject, body); msg.send(); } /** * Sends the message. */ - public void send() - throws MessagingException, - SendFailedException - { + throws MessagingException, + SendFailedException { Transport transport = getSession().getTransport(); transport.connect(); send(transport); @@ -300,11 +271,9 @@ public class Mail implements MessageType { * also such returned from the server. Applications might try * to catch this and re-schedule sending the mail. */ - void send(Transport transport) - throws MessagingException, - SendFailedException - { + throws MessagingException, + SendFailedException { Message msg = null; if (m_filteredTo.length > 0) { msg = getMessage(); @@ -312,12 +281,12 @@ public class Mail implements MessageType { try { transport.sendMessage(msg, msg.getAllRecipients()); } catch (MessagingException mex) { - + // Close the transport agent and rethrow error for // detailed message. - + transport.close(); - + throw new SendFailedException("send failed: ", mex); } } @@ -329,8 +298,8 @@ public class Mail implements MessageType { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); msg.writeTo(os); - s_log.debug("message sent:\n" + os.toString() + - "\n-- EOT --"); + s_log.debug("message sent:\n" + os.toString() + + "\n-- EOT --"); } catch (IOException ex) { s_log.error("unable to log message"); } @@ -338,10 +307,10 @@ public class Mail implements MessageType { s_log.debug("no message sent. No valid recipients:\n"); } } else { - s_log.info("message sent to <" + Arrays.asList(m_filteredTo) + "> from <" + m_from + - "> subject <" + m_subject + ">"); - s_log.info("messages filtered for <" + Arrays.asList(m_invalidTo) + "> from <" + m_from + - "> subject <" + m_subject + ">"); + s_log.info("message sent to <" + Arrays.asList(m_filteredTo) + + "> from <" + m_from + "> subject <" + m_subject + ">"); + s_log.info("messages filtered for <" + Arrays.asList(m_invalidTo) + + "> from <" + m_from + "> subject <" + m_subject + ">"); } } @@ -413,7 +382,7 @@ public class Mail implements MessageType { m_headers = new Hashtable(); } - m_headers.put(name,value); + m_headers.put(name, value); } /** @@ -458,7 +427,6 @@ public class Mail implements MessageType { * * @param enc the requested encoding */ - public void setEncoding(String enc) { m_encoding = enc; } @@ -469,12 +437,10 @@ public class Mail implements MessageType { * * @return the string value of the character encoding being used */ - public String getEncoding() { return m_encoding; } - /** * Adds an attachment to a message. This method is private but * is invoked by all of the other attach methods once they've @@ -482,10 +448,8 @@ public class Mail implements MessageType { * * @param part the message part to attach */ - private void attach(MimeBodyPart part) - throws MessagingException - { + throws MessagingException { if (m_attachments == null) { m_attachments = new MimeMultipart(); } @@ -501,12 +465,10 @@ public class Mail implements MessageType { * @param name the name of the attachment * @param description a description of the attachment */ - public void attach(URL url, String name, String description) - throws MessagingException - { + throws MessagingException { attach(url, name, description, Mail.ATTACHMENT); } @@ -519,13 +481,11 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(URL url, String name, String description, String disposition) - throws MessagingException - { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -546,12 +506,10 @@ public class Mail implements MessageType { * @param name the name of the attachment * @param description a description of the attachment */ - public void attach(File path, String name, String description) - throws MessagingException - { + throws MessagingException { attach(path, name, description, ATTACHMENT); } @@ -565,13 +523,11 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(File path, String name, String description, String disposition) - throws MessagingException - { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -592,13 +548,11 @@ public class Mail implements MessageType { * @param type the MIME type of the attachment * @param name the name of the attachment */ - public void attach(byte[] data, String type, String name) - throws MessagingException - { - attach(data,type,name,null,ATTACHMENT); + throws MessagingException { + attach(data, type, name, null, ATTACHMENT); } /** @@ -611,16 +565,14 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(byte[] data, String type, String name, String description, String disposition) - throws MessagingException - { - ByteArrayDataSource ds = new ByteArrayDataSource(data,type,name); - attach(ds,description,disposition); + throws MessagingException { + ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); + attach(ds, description, disposition); } /** @@ -631,13 +583,11 @@ public class Mail implements MessageType { * @param type the MIME type of the attachment * @param name the name of the attachment */ - public void attach(String data, String type, String name) - throws MessagingException - { - attach(data,type,name,null,ATTACHMENT); + throws MessagingException { + attach(data, type, name, null, ATTACHMENT); } /** @@ -650,16 +600,14 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(String data, String type, String name, String description, String disposition) - throws MessagingException - { - ByteArrayDataSource ds = new ByteArrayDataSource(data,type,name); - attach(ds,description,disposition); + throws MessagingException { + ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); + attach(ds, description, disposition); } /** @@ -671,13 +619,11 @@ public class Mail implements MessageType { * @param type the MIME type of the attachment * @param name the name of the attachment */ - public void attach(ByteArrayInputStream is, String type, String name) - throws MessagingException - { - attach(is,type,name,null,ATTACHMENT); + throws MessagingException { + attach(is, type, name, null, ATTACHMENT); } /** @@ -691,15 +637,13 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(ByteArrayInputStream is, String type, String name, String description, String disposition) - throws MessagingException - { - ByteArrayDataSource ds = new ByteArrayDataSource(is,type,name); + throws MessagingException { + ByteArrayDataSource ds = new ByteArrayDataSource(is, type, name); attach(ds, description, disposition); } @@ -713,12 +657,10 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - protected void attach(ByteArrayDataSource dataSource, String description, String disposition) - throws MessagingException - { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -730,7 +672,6 @@ public class Mail implements MessageType { part.setDisposition(disposition); } - /** * Attaches content to a message by supplying a DataHandler. All * relevant parameters (MIME type, name, ...) are determined @@ -738,14 +679,11 @@ public class Mail implements MessageType { * * @param dh a DataHandler for some piece of content. */ - public void attach(DataHandler dh) - throws MessagingException - { + throws MessagingException { attach(dh, null, ATTACHMENT); } - /** * Attaches content to a message by supplying a DataHandler. Sets * the description and disposition of the content. @@ -754,12 +692,10 @@ public class Mail implements MessageType { * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ - public void attach(DataHandler dh, String description, String disposition) - throws MessagingException - { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -775,7 +711,6 @@ public class Mail implements MessageType { * initializer and any of properties that can be overridden at * the package level. */ - static synchronized Session getSession() { if (s_session == null) { @@ -805,10 +740,8 @@ public class Mail implements MessageType { * example, to queue a number of messages to send all at once rather * than invoke the Mail.send() method for each instance.) */ - private Message getMessage() - throws MessagingException - { + throws MessagingException { // Create the message MimeMessage msg = new MimeMessage(getSession()); @@ -838,7 +771,7 @@ public class Mail implements MessageType { // Encode the subject String enc_subj; try { - enc_subj = MimeUtility.encodeText(m_subject,m_encoding,null); + enc_subj = MimeUtility.encodeText(m_subject, m_encoding, null); } catch (UnsupportedEncodingException uee) { s_log.warn("unable to encode subject: " + uee); enc_subj = m_subject; @@ -849,11 +782,11 @@ public class Mail implements MessageType { if (m_headers != null) { Enumeration e = m_headers.keys(); while (e.hasMoreElements()) { - String name = (String) e.nextElement(); + String name = (String) e.nextElement(); String value = (String) m_headers.get(name); String enc_v; try { - enc_v = MimeUtility.encodeText(value,m_encoding,null); + enc_v = MimeUtility.encodeText(value, m_encoding, null); } catch (UnsupportedEncodingException uee) { s_log.warn("unable to encode header element: " + uee); enc_v = value; @@ -875,7 +808,6 @@ public class Mail implements MessageType { * @param host the SMTP host to connect to * @param port the port number on that host */ - synchronized static void setSmtpServer(String host, String port) { s_host = host; s_port = port; @@ -884,7 +816,6 @@ public class Mail implements MessageType { s_session = null; } - /** * Returns the SMTP mail host for debugging and account information. * @return the SMTP mail host for debugging and account information. @@ -893,17 +824,14 @@ public class Mail implements MessageType { return s_host; } - /** * Writes the content of the message to the given output stream. * Useful for debugging. * * @param os the output stream to write the message to */ - public void writeTo(OutputStream os) - throws MessagingException - { + throws MessagingException { try { getMessage().writeTo(os); } catch (IOException ex) { @@ -919,7 +847,7 @@ public class Mail implements MessageType { if (str.indexOf(",") != -1) { ArrayList a = new ArrayList(); - StringTokenizer st = new StringTokenizer(str,",",false); + StringTokenizer st = new StringTokenizer(str, ",", false); while (st.hasMoreTokens()) { a.add(st.nextToken()); } @@ -950,7 +878,7 @@ public class Mail implements MessageType { * Parses an address. */ private static InternetAddress parseAddress(String str) { - String address = null; + String address = null; String personal = null; InternetAddress addr = null; @@ -960,13 +888,13 @@ public class Mail implements MessageType { if (str.indexOf(" ") == -1) { address = str; } else { - int sp = str.lastIndexOf(" "); - personal = str.substring(0,sp); - address = str.substring(sp+1); + int sp = str.lastIndexOf(" "); + personal = str.substring(0, sp); + address = str.substring(sp + 1); } try { - addr = new InternetAddress(address,personal); + addr = new InternetAddress(address, personal); } catch (UnsupportedEncodingException e) { s_log.error("unable to parse address: " + str); } @@ -1014,20 +942,18 @@ public class Mail implements MessageType { private static void parseHeader(String str, Hashtable headers) { str = str.trim(); - int sp = str.lastIndexOf(":"); - String name = str.substring(0, sp); - String value = (str.substring(sp+1)).trim(); + int sp = str.lastIndexOf(":"); + String name = str.substring(0, sp); + String value = (str.substring(sp + 1)).trim(); - headers.put(name,value); + headers.put(name, value); } /** * Utility function to prepare the content of the message. */ - private Message prepareMessageContent(MimeMessage msg) - throws MessagingException - { + throws MessagingException { if (m_alternate == null && m_attachments == null) { // We have a plain-text message with no attachments. Use @@ -1122,12 +1048,14 @@ public class Mail implements MessageType { filtered.add(m_to[i]); } else { invalid.add(m_to[i]); - s_log.debug("filtering message to non-existent email address " + m_to[i]); + s_log.debug("filtering message to non-existent email address " + + m_to[i]); } } - m_filteredTo = (InternetAddress[]) filtered.toArray(new InternetAddress[filtered.size()]); - m_invalidTo = (InternetAddress[]) invalid.toArray(new InternetAddress[invalid.size()]); + m_filteredTo = (InternetAddress[]) filtered.toArray(new InternetAddress[filtered. + size()]); + m_invalidTo = (InternetAddress[]) invalid.toArray(new InternetAddress[invalid. + size()]); return m_filteredTo; } - } diff --git a/ccm-core/src/com/arsdigita/packaging/BaseCheck.java b/ccm-core/src/com/arsdigita/packaging/BaseCheck.java index 374314411..9ebfe19a6 100755 --- a/ccm-core/src/com/arsdigita/packaging/BaseCheck.java +++ b/ccm-core/src/com/arsdigita/packaging/BaseCheck.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.List; +import org.apache.log4j.Logger; /** * BaseCheck: Extension of the Check abstract class, which can be used as a @@ -45,6 +46,7 @@ import java.util.List; abstract public class BaseCheck extends Check { + private static final Logger logger = Logger.getLogger(BaseCheck.class); public static final String versionId = "$Id: BaseCheck.java 736 2005-09-01 10:46:05Z sskracic $" + " by $Author: sskracic $, " + @@ -53,12 +55,14 @@ abstract public class BaseCheck extends Check { public static final MessageMap s_messages = new MessageMap(); static { + logger.debug("Static initalizer starting..."); final InputStream in = BaseCheck.class.getResourceAsStream ("basecheck.messages_linux"); Assert.exists(in, InputStream.class); s_messages.load(new InputStreamReader(in)); + logger.debug("Static initalizer finished."); } public static String message(final String key) { diff --git a/ccm-core/src/com/arsdigita/packaging/CheckDB.java b/ccm-core/src/com/arsdigita/packaging/CheckDB.java index 4b7ea1ce4..a1c1710b4 100755 --- a/ccm-core/src/com/arsdigita/packaging/CheckDB.java +++ b/ccm-core/src/com/arsdigita/packaging/CheckDB.java @@ -28,6 +28,7 @@ import java.sql.Connection; import java.io.InputStream; import java.io.InputStreamReader; +import org.apache.log4j.Logger; /** @@ -43,6 +44,7 @@ import java.io.InputStreamReader; public class CheckDB extends BaseCheck { + private static final Logger logger = Logger.getLogger(CheckDB.class); public final static String versionId = "$Id: DBCheck.java 736 2005-09-01 10:46:05Z sskracic $" + " by $Author: sskracic $, " + @@ -51,10 +53,12 @@ public class CheckDB extends BaseCheck { // Integration of service class packaging.MessageMap. // Specifies a package specific message file overriding BaseCheck static { + logger.debug("Static initalizer starting..."); final InputStream in = CheckDB.class.getResourceAsStream ("checkdb.messages_linux"); Assert.exists(in, InputStream.class); s_messages.load(new InputStreamReader(in)); + logger.debug("Static initalizer finished."); } diff --git a/ccm-core/src/com/arsdigita/packaging/Get.java b/ccm-core/src/com/arsdigita/packaging/Get.java index 561c5d859..625526da3 100755 --- a/ccm-core/src/com/arsdigita/packaging/Get.java +++ b/ccm-core/src/com/arsdigita/packaging/Get.java @@ -37,6 +37,7 @@ import org.apache.commons.cli.OptionGroup; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.log4j.Logger; /** * Get @@ -49,37 +50,31 @@ import org.apache.commons.cli.PosixParser; * @author Rafael H. Schloming <rhs@mit.edu> * @version $Revision: #6 $ $Date: 2004/08/16 $ **/ - class Get extends Command { - public final static String versionId = - "$Id: Get.java 1324 2006-09-21 22:13:16Z apevec $" + - " by $Author: apevec $, " + - "$DateTime: 2004/08/16 18:10:38 $"; - + public static final Logger logger = Logger.getLogger(Get.class); + public final static String versionId = + "$Id: Get.java 1324 2006-09-21 22:13:16Z apevec $" + + " by $Author: apevec $, " + + "$DateTime: 2004/08/16 18:10:38 $"; private static final Options OPTIONS = getOptions(); static { + logger.debug("Static initalizer starting..."); OptionGroup group = new OptionGroup(); - group.addOption - (OptionBuilder - .hasArg(false) - .withLongOpt("all") - .withDescription("Lists all configuration parameters") - .create("all")); - group.addOption - (OptionBuilder - .hasArg() - .withArgName("PARAMETER") - .withLongOpt("value") - .withDescription("Prints a scalar value without the key") - .create("value")); + group.addOption(OptionBuilder.hasArg(false).withLongOpt("all"). + withDescription("Lists all configuration parameters").create( + "all")); + group.addOption(OptionBuilder.hasArg().withArgName("PARAMETER"). + withLongOpt("value").withDescription( + "Prints a scalar value without the key").create("value")); OPTIONS.addOptionGroup(group); + logger.debug("Static initalizer finished."); } public Get() { - super("get", "Print one or more values from a CCM " + - "configuration database"); + super("get", "Print one or more values from a CCM " + + "configuration database"); } public boolean run(String[] args) { @@ -107,10 +102,9 @@ class Get extends Command { String[] names; if (line.hasOption("value")) { - names = new String[] { line.getOptionValue("value") }; + names = new String[]{line.getOptionValue("value")}; if (line.getArgs().length > 0) { - System.err.println - ("--value option does not allow parameters"); + System.err.println("--value option does not allow parameters"); return false; } } else { @@ -138,10 +132,12 @@ class Get extends Command { parameters.add(param); } } - if (err) { return false; } + if (err) { + return false; + } } - for (Iterator it = parameters.iterator(); it.hasNext(); ) { + for (Iterator it = parameters.iterator(); it.hasNext();) { Parameter param = (Parameter) it.next(); Object value = config.get(param); Properties props = new Properties(); @@ -167,19 +163,20 @@ class Get extends Command { } private void write(Properties properties, PrintStream out) - throws IOException { + throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); properties.store(baos, null); BufferedReader reader = - new BufferedReader(new StringReader(baos.toString())); + new BufferedReader(new StringReader(baos.toString())); while (true) { String line = reader.readLine(); - if (line == null) { return; } + if (line == null) { + return; + } if (line.trim().startsWith("#")) { continue; } out.println(line); } } - } diff --git a/ccm-core/src/com/arsdigita/packaging/HostInit.java b/ccm-core/src/com/arsdigita/packaging/HostInit.java index 7a84210ad..78b702a75 100755 --- a/ccm-core/src/com/arsdigita/packaging/HostInit.java +++ b/ccm-core/src/com/arsdigita/packaging/HostInit.java @@ -82,6 +82,7 @@ public class HostInit { private static final Options OPTIONS = new Options(); static { + s_log.debug("Static initalizer starting..."); OPTIONS.addOption (OptionBuilder .hasArg() @@ -109,6 +110,7 @@ public class HostInit { .withLongOpt("clean") .withDescription("Remove the destination directory before copying files") .create()); + s_log.debug("Static initalizer finsished."); } private static final void err(String msg) { diff --git a/ccm-core/src/com/arsdigita/packaging/Load.java b/ccm-core/src/com/arsdigita/packaging/Load.java index 035fabaa7..ab389ef70 100755 --- a/ccm-core/src/com/arsdigita/packaging/Load.java +++ b/ccm-core/src/com/arsdigita/packaging/Load.java @@ -71,6 +71,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.log4j.Logger; /** * PackageTool worker class, implements the "load" command. @@ -85,9 +86,11 @@ import org.apache.commons.cli.PosixParser; class Load extends Command { + private static final Logger logger = Logger.getLogger(Load.class); private static final Options OPTIONS = getOptions(); static { + logger.debug("Static initalizer starting..."); OPTIONS.addOption (OptionBuilder .hasArg(false) @@ -146,6 +149,7 @@ class Load extends Command { .withDescription("Log parameter values as key-value " + "pairs in FILE") .create());*/ + logger.debug("Static initalizer finished."); } /** diff --git a/ccm-core/src/com/arsdigita/packaging/Set.java b/ccm-core/src/com/arsdigita/packaging/Set.java index f0a08cb12..23ef5c096 100755 --- a/ccm-core/src/com/arsdigita/packaging/Set.java +++ b/ccm-core/src/com/arsdigita/packaging/Set.java @@ -28,6 +28,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.log4j.Logger; /** * Set @@ -43,6 +44,7 @@ import org.apache.commons.cli.PosixParser; class Set extends Command { + private final static Logger logger = Logger.getLogger(Set.class); public final static String versionId = "$Id: Set.java 736 2005-09-01 10:46:05Z sskracic $" + " by $Author: sskracic $, " + @@ -51,12 +53,14 @@ class Set extends Command { private static final Options OPTIONS = getOptions(); static { + logger.debug("Static initalizer starting..."); OPTIONS.addOption (OptionBuilder .hasArg(false) .withLongOpt("interactive") .withDescription("Interactively edit configuration values") .create()); + logger.debug("Static initalizer finished."); } public Set() { diff --git a/ccm-core/src/com/arsdigita/packaging/Unload.java b/ccm-core/src/com/arsdigita/packaging/Unload.java index b221f5d33..1c14ae409 100755 --- a/ccm-core/src/com/arsdigita/packaging/Unload.java +++ b/ccm-core/src/com/arsdigita/packaging/Unload.java @@ -29,6 +29,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.log4j.Logger; /** * Unload @@ -39,6 +40,7 @@ import org.apache.commons.cli.PosixParser; class Unload extends Command { + private static final Logger logger = Logger.getLogger(Unload.class); public final static String versionId = "$Id: Unload.java 736 2005-09-01 10:46:05Z sskracic $" + " by $Author: sskracic $, " + @@ -47,20 +49,24 @@ class Unload extends Command { private static final Options OPTIONS = new Options(); static { + logger.debug("Static initalizer starting..."); OPTIONS.addOption (OptionBuilder .hasArg(false) .withLongOpt("config") .withDescription("Unload configuration") .create()); + logger.debug("Static initalizer finished."); } private static final Set EXCLUDE = new HashSet(); static { + logger.debug("Static initalizer starting..."); EXCLUDE.add("resin.conf"); EXCLUDE.add("resin.pid"); EXCLUDE.add("server.xml"); + logger.debug("Static initalizer finished."); } public Unload() { diff --git a/ccm-core/src/com/arsdigita/packaging/Upgrade.java b/ccm-core/src/com/arsdigita/packaging/Upgrade.java index 513bde261..131826bf6 100755 --- a/ccm-core/src/com/arsdigita/packaging/Upgrade.java +++ b/ccm-core/src/com/arsdigita/packaging/Upgrade.java @@ -41,6 +41,7 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.log4j.Logger; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; @@ -52,6 +53,7 @@ import org.xml.sax.helpers.DefaultHandler; */ class Upgrade extends Command { + private static final Logger logger = Logger.getLogger(Upgrade.class); private static final Options s_options = getOptions(); private String m_from; @@ -59,6 +61,7 @@ class Upgrade extends Command { private final List m_scripts; static { + logger.debug("Static initalizer starting..."); s_options.addOption (OptionBuilder .isRequired() @@ -79,6 +82,7 @@ class Upgrade extends Command { .withLongOpt("parameters") .withDescription("Parameters to pass to upgrade scripts") .create()); + logger.debug("Static initalizer finished."); } public Upgrade() { diff --git a/ccm-core/src/com/arsdigita/persistence/SessionManager.java b/ccm-core/src/com/arsdigita/persistence/SessionManager.java index 394532a96..338fa529f 100755 --- a/ccm-core/src/com/arsdigita/persistence/SessionManager.java +++ b/ccm-core/src/com/arsdigita/persistence/SessionManager.java @@ -55,7 +55,9 @@ public class SessionManager { private static Set s_beforeFlushProcManagers = new HashSet(); static { + s_log.debug("Static initalizer starting..."); addBeforeFlushProcManager(Versions.EPM); + s_log.debug("Static initalizer finished."); } private static Set s_afterFlushProcManagers = new HashSet(); private static Map s_configurations = new HashMap(); diff --git a/ccm-core/src/com/arsdigita/persistence/pdl/PDL.java b/ccm-core/src/com/arsdigita/persistence/pdl/PDL.java index 343d4f998..154e4f980 100755 --- a/ccm-core/src/com/arsdigita/persistence/pdl/PDL.java +++ b/ccm-core/src/com/arsdigita/persistence/pdl/PDL.java @@ -136,6 +136,7 @@ public class PDL { new CommandLine(PDL.class.getName(), null); static { + s_log.debug("Static initalizer starting..."); CMD.addSwitch(new PathSwitch( "-library-path", "PDL files appearing in this path will be searched " + @@ -167,6 +168,7 @@ public class PDL { CMD.addSwitch(new BooleanSwitch("-quiet", "sets logging to ERROR and does not complain if no PDL files are found", Boolean.FALSE)); CMD.addSwitch(new StringSwitch("-testddl", "no clue", null)); + s_log.debug("Static initalizer finished."); } /** diff --git a/ccm-core/src/com/arsdigita/persistence/pdl/SQLRegressionGenerator.java b/ccm-core/src/com/arsdigita/persistence/pdl/SQLRegressionGenerator.java index fc2f24279..cd131eb75 100755 --- a/ccm-core/src/com/arsdigita/persistence/pdl/SQLRegressionGenerator.java +++ b/ccm-core/src/com/arsdigita/persistence/pdl/SQLRegressionGenerator.java @@ -73,10 +73,12 @@ import org.apache.log4j.Logger; */ public class SQLRegressionGenerator { + private static final Logger logger = Logger.getLogger(SQLRegressionGenerator.class); static final CommandLine CMD = new CommandLine(PDL.class.getName(), null); static { + logger.debug("Static initalizer starting..."); CMD.addSwitch(new PathSwitch( "-path", "PDL files appearing in this path will be processed", @@ -95,6 +97,7 @@ public class SQLRegressionGenerator { CMD.addSwitch(new BooleanSwitch("-quiet", "sets logging to ERROR and does not complain if no PDL files are found", Boolean.FALSE)); CMD.addSwitch(new StringSwitch("-database", "target database", null)); + logger.debug("Static initalizer finished."); } /** diff --git a/ccm-core/src/com/arsdigita/profiler/Profiler.java b/ccm-core/src/com/arsdigita/profiler/Profiler.java index b341e3a27..54587825a 100755 --- a/ccm-core/src/com/arsdigita/profiler/Profiler.java +++ b/ccm-core/src/com/arsdigita/profiler/Profiler.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.log4j.Logger; /** * Simple Profiler. @@ -20,16 +21,19 @@ import java.util.Set; * @author Alan Pevec */ public class Profiler { - + + private static final Logger logger = Logger.getLogger(Profiler.class); private static final Set enabledOperations = new HashSet(); // TODO add a configuration page under Developer Support static { + logger.debug("Static initalizer starting..."); enabledOperations.add("APP"); enabledOperations.add("FILT"); enabledOperations.add("CMS"); enabledOperations.add("XML"); enabledOperations.add("DB"); enabledOperations.add("XSLT"); + logger.debug("Static initalizer finished."); } private static ProfilerConfig config = null; diff --git a/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java b/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java index bacc67243..481993818 100755 --- a/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java +++ b/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java @@ -44,9 +44,11 @@ public class QueryEngineRegistry { Logger.getLogger(QueryEngineRegistry.class); static { + s_log.debug("Static initalizer starting..."); registerEngine(IndexerType.NOOP, new FilterType[] {}, new NoopQueryEngine()); + s_log.debug("Static initalizer finished."); } /** diff --git a/ccm-core/src/com/arsdigita/sitenode/ServletErrorReport.java b/ccm-core/src/com/arsdigita/sitenode/ServletErrorReport.java index 273ccd7bf..a1cb41552 100755 --- a/ccm-core/src/com/arsdigita/sitenode/ServletErrorReport.java +++ b/ccm-core/src/com/arsdigita/sitenode/ServletErrorReport.java @@ -35,6 +35,7 @@ import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Party; import com.arsdigita.kernel.User; import com.arsdigita.kernel.PersonName; +import org.apache.log4j.Logger; /** * This is an advanced servlet error report generator @@ -44,6 +45,8 @@ import com.arsdigita.kernel.PersonName; * (guru meditation) code. */ public class ServletErrorReport extends ErrorReport { + + private static final Logger logger = Logger.getLogger(ServletErrorReport.class); /** * The name of the Servlet request attribute which will * contain the guru meditation code @@ -52,16 +55,18 @@ public class ServletErrorReport extends ErrorReport { public static final String GURU_ERROR_REPORT = "guruErrorReport"; static { + logger.debug("Static initalizer starting..."); Exceptions.registerUnwrapper( - ServletException.class, - new ExceptionUnwrapper() { - public Throwable unwrap(Throwable t) { - ServletException ex = (ServletException)t; - return ex.getRootCause(); - } - }); - } + ServletException.class, + new ExceptionUnwrapper() { + public Throwable unwrap(Throwable t) { + ServletException ex = (ServletException) t; + return ex.getRootCause(); + } + }); + logger.debug("Static initalizer finished."); + } private HttpServletRequest m_request; private HttpServletResponse m_response; @@ -72,7 +77,7 @@ public class ServletErrorReport extends ErrorReport { m_request = request; m_response = response; - + // Take great care such that if something goes // wrong while creating the error report, we don't // let the new exception propagate thus loosing the @@ -110,11 +115,11 @@ public class ServletErrorReport extends ErrorReport { private void addRequest() { ArrayList lines = new ArrayList(); - lines.add("Context path: "+ m_request.getContextPath()); - lines.add("Request URI: "+ m_request.getRequestURI()); - lines.add("Query string: "+ m_request.getQueryString()); - lines.add("Method: "+ m_request.getMethod()); - lines.add("Remote user: "+ m_request.getRemoteUser()); + lines.add("Context path: " + m_request.getContextPath()); + lines.add("Request URI: " + m_request.getRequestURI()); + lines.add("Query string: " + m_request.getQueryString()); + lines.add("Method: " + m_request.getMethod()); + lines.add("Remote user: " + m_request.getRemoteUser()); addSection("Request summary", lines); } @@ -127,9 +132,9 @@ public class ServletErrorReport extends ErrorReport { String lines[] = new String[cookies.length]; - for (int i = 0 ; i < lines.length ;i++) { - lines[i] = cookies[i].getName() + ": " + cookies[i].getValue() + - " (expires: " + cookies[i].getMaxAge() + ")"; + for (int i = 0; i < lines.length; i++) { + lines[i] = cookies[i].getName() + ": " + cookies[i].getValue() + + " (expires: " + cookies[i].getMaxAge() + ")"; } addSection("Cookies", lines); @@ -139,14 +144,14 @@ public class ServletErrorReport extends ErrorReport { User user; Party party = Kernel.getContext().getParty(); - if ( party == null ) { + if (party == null) { addSection("CCM User", "Party not logged in"); } else { String lines[] = new String[5]; lines[0] = "Party ID: " + party.getID(); lines[1] = "Email address: " + party.getPrimaryEmail().toString(); - if ( party instanceof User ) { + if (party instanceof User) { user = (User) party; PersonName name = null; @@ -186,9 +191,9 @@ public class ServletErrorReport extends ErrorReport { Enumeration props = m_request.getAttributeNames(); while (props.hasMoreElements()) { - String key = (String)props.nextElement(); - if (GURU_ERROR_REPORT.equals(key) || - GURU_MEDITATION_CODE.equals(key)) { + String key = (String) props.nextElement(); + if (GURU_ERROR_REPORT.equals(key) + || GURU_MEDITATION_CODE.equals(key)) { continue; } Object value = m_request.getAttribute(key); @@ -203,7 +208,7 @@ public class ServletErrorReport extends ErrorReport { Enumeration props = m_request.getHeaderNames(); while (props.hasMoreElements()) { - String key = (String)props.nextElement(); + String key = (String) props.nextElement(); String value = m_request.getHeader(key); data.add(key + ": " + value); } diff --git a/ccm-core/src/com/arsdigita/templating/ApplyTemplates.java b/ccm-core/src/com/arsdigita/templating/ApplyTemplates.java index eefa4be39..75f867636 100755 --- a/ccm-core/src/com/arsdigita/templating/ApplyTemplates.java +++ b/ccm-core/src/com/arsdigita/templating/ApplyTemplates.java @@ -57,6 +57,7 @@ public class ApplyTemplates { "-loop [count] -log [loglevel] -verbose -warmup [count] Stylesheet Input Output " ); static { + s_log.debug("Static initalizer starting..."); s_cmd.addSwitch(new StringSwitch(OPT_LOG, "Log4j debug level", "warn")); @@ -69,6 +70,7 @@ public class ApplyTemplates { s_cmd.addSwitch(new BooleanSwitch(OPT_VERBOSE, "Display progress", Boolean.FALSE)); + s_log.debug("Static initalizer finished."); } public final static void main(String[] args) { diff --git a/ccm-core/src/com/arsdigita/templating/PatternStylesheetResolver.java b/ccm-core/src/com/arsdigita/templating/PatternStylesheetResolver.java index 2c0507aa8..930c6e8ed 100755 --- a/ccm-core/src/com/arsdigita/templating/PatternStylesheetResolver.java +++ b/ccm-core/src/com/arsdigita/templating/PatternStylesheetResolver.java @@ -134,6 +134,7 @@ public class PatternStylesheetResolver implements StylesheetResolver { } static { + s_log.debug("Static initalizer starting..."); registerPatternGenerator ("locale", new LocalePatternGenerator()); registerPatternGenerator @@ -148,6 +149,7 @@ public class PatternStylesheetResolver implements StylesheetResolver { ("webapps", new WebAppPatternGenerator()); registerPatternGenerator ("host", new HostPatternGenerator()); + s_log.debug("Static initalizer finished."); } private String m_path = null; diff --git a/ccm-core/src/com/arsdigita/templating/Templating.java b/ccm-core/src/com/arsdigita/templating/Templating.java index 3883455c0..b9b67e2c7 100755 --- a/ccm-core/src/com/arsdigita/templating/Templating.java +++ b/ccm-core/src/com/arsdigita/templating/Templating.java @@ -17,7 +17,7 @@ */ package com.arsdigita.templating; -import com.arsdigita.bebop.Bebop; +import com.arsdigita.bebop.Bebop; import com.arsdigita.caching.CacheTable; import com.arsdigita.kernel.Kernel; import com.arsdigita.util.Assert; @@ -58,49 +58,47 @@ import org.apache.log4j.Logger; public class Templating { private static final Logger s_log = Logger.getLogger(Templating.class); - // just a tag to assure an implementation exists // public static final Class DEFAULT_PRESENTATION_MANAGER // = SimplePresentationManager.class; - /** * This is the name of the attribute that is set in the request whose * value, if present, is a collection of TransformerExceptions that * can be used to produce a "pretty" error. */ public static final String FANCY_ERROR_COLLECTION = "fancyErrorCollection"; - // this was instantiated with hardcoded values, not anymore private static CacheTable s_templates = null; private static final TemplatingConfig s_config = new TemplatingConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load("ccm-core/templating.properties"); - } - - static { - Exceptions.registerUnwrapper( - TransformerException.class, - new ExceptionUnwrapper() { - public Throwable unwrap(Throwable t) { - TransformerException ex = (TransformerException)t; - return ex.getCause(); - } - }); - } - // now we initiate the CacheTable here - static { + Exceptions.registerUnwrapper( + TransformerException.class, + new ExceptionUnwrapper() { + + public Throwable unwrap(Throwable t) { + TransformerException ex = (TransformerException) t; + return ex.getCause(); + } + }); + + // now we initiate the CacheTable here + // default cache size used to be 50, which is too high I reckon, // each template can eat up to 4 megs Integer setting = s_config.getCacheSize(); int cacheSize = (setting == null ? 10 : setting.intValue()); setting = s_config.getCacheAge(); - int cacheAge = (setting == null ? 60*60*24*3 : setting.intValue()); + int cacheAge = (setting == null ? 60 * 60 * 24 * 3 : setting.intValue()); s_templates = new CacheTable("templating", cacheSize, cacheAge); s_templates.setPurgeAllowed(true); + + s_log.debug("Static initalizer finished..."); } /** @@ -150,7 +148,7 @@ public class Templating { public static synchronized XSLTemplate getTemplate(final URL source) { return getTemplate(source, false, true); } - + /** * Retrieves an XSL template. If the template is already loaded in the * cache, it will be returned. If the template has been modified since @@ -184,8 +182,8 @@ public class Templating { if (template == null) { if (s_log.isInfoEnabled()) { - s_log.info("The template for URL " + source + " is not " + - "cached; creating and caching it now"); + s_log.info("The template for URL " + source + " is not " + + "cached; creating and caching it now"); } if (fancyErrors) { @@ -207,8 +205,8 @@ public class Templating { // probably on UtilConfig. if (s_log.isInfoEnabled()) { - s_log.info("Template " + template + " has been modified; " + - "recreating it from scratch"); + s_log.info("Template " + template + " has been modified; " + + "recreating it from scratch"); } if (fancyErrors) { @@ -304,11 +302,11 @@ public class Templating { root.addAttribute("version", "1.0"); while (paths.hasNext()) { - URL path = (URL)paths.next(); + URL path = (URL) paths.next(); Element imp = root.newChildElement( - "xsl:import", - "http://www.w3.org/1999/XSL/Transform"); + "xsl:import", + "http://www.w3.org/1999/XSL/Transform"); imp.addAttribute("href", path.toString()); if (s_log.isInfoEnabled()) { @@ -338,9 +336,12 @@ public class Templating { HttpHost self = Web.getConfig().getHost(); String path = url.getPath(); - if (self.getName().equals(url.getHost()) && - ((self.getPort() == url.getPort()) || - (url.getPort() == -1 && self.getPort() == 80))) { + if (self.getName().equals(url.getHost()) && ((self.getPort() == url. + getPort()) || (url.getPort() + == -1 + && self. + getPort() + == 80))) { if (path.startsWith("/resource")) { // A virtual path to the servlet @@ -352,14 +353,15 @@ public class Templating { return newURL; } else { // A real path to disk - final String filename = Web.getServletContext().getRealPath(path); + final String filename = + Web.getServletContext().getRealPath(path); File file = new File(filename); if (file.exists()) { try { URL newURL = file.toURL(); if (s_log.isDebugEnabled()) { - s_log.debug("Transforming resource " + - url + " to " + newURL); + s_log.debug("Transforming resource " + url + " to " + + newURL); } return newURL; } catch (MalformedURLException ex) { @@ -367,7 +369,8 @@ public class Templating { } } else { if (s_log.isDebugEnabled()) { - s_log.debug("File " + filename + " doesn't exist on disk"); + s_log.debug("File " + filename + + " doesn't exist on disk"); } } } @@ -382,34 +385,34 @@ public class Templating { } class LoggingErrorListener implements ErrorListener { - private static final Logger s_log = - Logger.getLogger(LoggingErrorListener.class); + private static final Logger s_log = + Logger.getLogger(LoggingErrorListener.class); private ArrayList m_errors; - + LoggingErrorListener() { m_errors = new ArrayList(); } - + public Collection getErrors() { return m_errors; } - + public void warning(TransformerException e) throws TransformerException { log(Level.WARN, e); } - + public void error(TransformerException e) throws TransformerException { log(Level.ERROR, e); } - + public void fatalError(TransformerException e) throws TransformerException { log(Level.FATAL, e); } - + private void log(Level level, TransformerException ex) { - s_log.log(level, "Transformer " + level + ": " + - ex.getLocationAsString() + ": " + ex.getMessage(), + s_log.log(level, "Transformer " + level + ": " + + ex.getLocationAsString() + ": " + ex.getMessage(), ex); m_errors.add(ex); } diff --git a/ccm-core/src/com/arsdigita/templating/html/XHTMLParser.java b/ccm-core/src/com/arsdigita/templating/html/XHTMLParser.java index 199c07adb..c571f527f 100755 --- a/ccm-core/src/com/arsdigita/templating/html/XHTMLParser.java +++ b/ccm-core/src/com/arsdigita/templating/html/XHTMLParser.java @@ -60,8 +60,10 @@ public class XHTMLParser implements HTMLParser { private final static Set s_emptyTags = new HashSet(); static { + s_log.debug("Static initalizer is starting..."); s_emptyTags.add("br"); s_emptyTags.add("hr"); + s_log.debug("Static initalizer finished."); } private final Set m_tags; diff --git a/ccm-core/src/com/arsdigita/toolbox/CharsetEncodingProvider.java b/ccm-core/src/com/arsdigita/toolbox/CharsetEncodingProvider.java index e02e818ca..a60d4da88 100755 --- a/ccm-core/src/com/arsdigita/toolbox/CharsetEncodingProvider.java +++ b/ccm-core/src/com/arsdigita/toolbox/CharsetEncodingProvider.java @@ -29,6 +29,7 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.http.HttpServletRequest; +import org.apache.log4j.Logger; /** *

@@ -40,15 +41,18 @@ import javax.servlet.http.HttpServletRequest; */ public class CharsetEncodingProvider implements ParameterProvider { + private static final Logger logger = Logger.getLogger(CharsetEncodingProvider.class); private static StringParameter s_encodingParam = new StringParameter(Globalization.ENCODING_PARAM_NAME); private static Set s_models = new HashSet(); static { + logger.debug("Static initalizer starting..."); s_encodingParam.setDefaultValue(Globalization.DEFAULT_ENCODING); s_encodingParam.setDefaultOverridesNull(true); s_models.add(s_encodingParam); + logger.debug("Static initalizer finished..."); } public Set getModels() { diff --git a/ccm-core/src/com/arsdigita/util/ConcurrentDict.java b/ccm-core/src/com/arsdigita/util/ConcurrentDict.java index 646a162ed..28159650f 100755 --- a/ccm-core/src/com/arsdigita/util/ConcurrentDict.java +++ b/ccm-core/src/com/arsdigita/util/ConcurrentDict.java @@ -23,6 +23,7 @@ import java.text.NumberFormat; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.apache.log4j.Logger; /** @@ -52,6 +53,7 @@ import java.util.Map; * @version $Revision: #4 $ $DateTime: 2004/08/16 18:10:38 $ **/ public final class ConcurrentDict { + private static final Logger logger = Logger.getLogger(ConcurrentDict.class); // We may want to make it possible to specify the bucket size at // construction time. Hardcoding it is good enough for now. private static final int N_BUCKETS = 64; @@ -59,9 +61,11 @@ public final class ConcurrentDict { private static final Map[] BUCKETS = new Map[N_BUCKETS]; static { + logger.debug("Static initalizer starting..."); for (int ii=0; iiTM"); + s_log.debug("Static initalizer finished."); } private static String smartTextInline(String s) { diff --git a/ccm-core/src/com/arsdigita/util/UncheckedWrapperException.java b/ccm-core/src/com/arsdigita/util/UncheckedWrapperException.java index 51d2da536..7ebd5fe9e 100755 --- a/ccm-core/src/com/arsdigita/util/UncheckedWrapperException.java +++ b/ccm-core/src/com/arsdigita/util/UncheckedWrapperException.java @@ -42,17 +42,23 @@ import org.apache.log4j.Logger; */ public class UncheckedWrapperException extends RuntimeException { - static { - Exceptions.registerUnwrapper( - UncheckedWrapperException.class, - new ExceptionUnwrapper() { - public Throwable unwrap(Throwable t) { - UncheckedWrapperException ex = (UncheckedWrapperException)t; - return ex.getRootCause(); - } - }); - } + private static final Logger logger = Logger.getLogger( + UncheckedWrapperException.class); + static { + logger.debug("Static initalizer starting..."); + Exceptions.registerUnwrapper( + UncheckedWrapperException.class, + new ExceptionUnwrapper() { + + public Throwable unwrap(Throwable t) { + UncheckedWrapperException ex = + (UncheckedWrapperException) t; + return ex.getRootCause(); + } + }); + logger.debug("Static initalizer finished."); + } Throwable m_rootCause; /** @@ -62,7 +68,7 @@ public class UncheckedWrapperException extends RuntimeException { * 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) { + public UncheckedWrapperException(String msg) { this(msg, null); } @@ -74,7 +80,7 @@ public class UncheckedWrapperException extends RuntimeException { * Constructor which takes a root cause * that this exception will be wrapping. */ - public UncheckedWrapperException (Throwable rootCause) { + public UncheckedWrapperException(Throwable rootCause) { this(null, rootCause); } @@ -84,7 +90,7 @@ public class UncheckedWrapperException extends RuntimeException { * should be something different than rootCause.getMessage() * would normally provide. */ - public UncheckedWrapperException (String s, Throwable rootCause) { + public UncheckedWrapperException(String s, Throwable rootCause) { super(s); this.m_rootCause = rootCause; } @@ -98,7 +104,9 @@ public class UncheckedWrapperException extends RuntimeException { * * @throws UncheckedWrapperException */ - public static void throwLoggedException(Class source, String msg, Throwable rootCause) throws UncheckedWrapperException { + public static void throwLoggedException(Class source, String msg, + Throwable rootCause) throws + UncheckedWrapperException { Logger log = Logger.getLogger(source); log.error(msg, rootCause); @@ -121,7 +129,6 @@ public class UncheckedWrapperException extends RuntimeException { // All further methods override normal throwable behavior to // combine information w/ the root cause. - /** * Get a string representing this exception and the root cause. */ @@ -158,7 +165,8 @@ public class UncheckedWrapperException extends RuntimeException { */ public String getMessage() { if (m_rootCause != null) { - return super.getMessage() + " (root cause: " + m_rootCause.getMessage() + ")"; + return super.getMessage() + " (root cause: " + m_rootCause. + getMessage() + ")"; } else { return super.getMessage(); } diff --git a/ccm-core/src/com/arsdigita/util/WrappedError.java b/ccm-core/src/com/arsdigita/util/WrappedError.java index b8fce13f7..b8bd55557 100755 --- a/ccm-core/src/com/arsdigita/util/WrappedError.java +++ b/ccm-core/src/com/arsdigita/util/WrappedError.java @@ -35,7 +35,10 @@ import org.apache.log4j.Logger; */ public class WrappedError extends Error { + private static final Logger logger = Logger.getLogger(WrappedError.class); + static { + logger.debug("Static initalizer starting..."); Exceptions.registerUnwrapper( WrappedError.class, new ExceptionUnwrapper() { @@ -44,6 +47,7 @@ public class WrappedError extends Error { return ex.getRootCause(); } }); + logger.debug("Static initalizer finished."); } Throwable m_rootCause; diff --git a/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java b/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java index 8cc228173..c8ece3839 100755 --- a/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java +++ b/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java @@ -19,6 +19,7 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.ClassConverter; +import org.apache.log4j.Logger; /** * A parameter representing a Java Class. @@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.ClassConverter; */ public class ClassParameter extends AbstractParameter { + private static final Logger logger = Logger.getLogger(ClassParameter.class); + static { + logger.debug("Static initalizer starting..."); Converters.set(Class.class, new ClassConverter()); + logger.debug("Static initalizer finished."); } public ClassParameter(final String name) { diff --git a/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java b/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java index 89597a737..834d30d12 100755 --- a/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java +++ b/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java @@ -19,6 +19,7 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.IntegerConverter; +import org.apache.log4j.Logger; /** * A parameter representing a Java Integer. @@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.IntegerConverter; */ public class IntegerParameter extends AbstractParameter { + private final static Logger logger = Logger.getLogger(IntegerParameter.class); + static { + logger.debug("Static initalizer starting..."); Converters.set(Integer.class, new IntegerConverter()); + logger.debug("Static initalizer finished."); } public IntegerParameter(final String name) { diff --git a/ccm-core/src/com/arsdigita/util/parameter/ParameterPrinter.java b/ccm-core/src/com/arsdigita/util/parameter/ParameterPrinter.java index 7fa95fb1d..baf17dd2c 100755 --- a/ccm-core/src/com/arsdigita/util/parameter/ParameterPrinter.java +++ b/ccm-core/src/com/arsdigita/util/parameter/ParameterPrinter.java @@ -58,6 +58,7 @@ final class ParameterPrinter { private static final Options OPTIONS = new Options(); static { + s_log.debug("Static initalizer starting..."); OPTIONS.addOption (OptionBuilder .hasArg(false) @@ -77,6 +78,7 @@ final class ParameterPrinter { .withArgName("FILE") .withDescription("Use list of additional Config classes from FILE") .create()); + s_log.debug("Static initalizer starting..."); } private static void writeXML(final PrintWriter out) { diff --git a/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java b/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java index df6d7fe94..e0acf0aa1 100755 --- a/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java +++ b/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java @@ -19,6 +19,7 @@ package com.arsdigita.util.parameter; import org.apache.commons.beanutils.converters.StringConverter; +import org.apache.log4j.Logger; /** * A parameter representing a Java String. @@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.StringConverter; */ public class StringParameter extends AbstractParameter { + private static final Logger logger = Logger.getLogger(StringParameter.class); + static { + logger.debug("Static initalizer starting..."); Converters.set(String.class, new StringConverter()); + logger.debug("Static initalizer finished."); } public StringParameter(final String name, diff --git a/ccm-core/src/com/arsdigita/versioning/Adapter.java b/ccm-core/src/com/arsdigita/versioning/Adapter.java index 92723bb48..25282c4a3 100755 --- a/ccm-core/src/com/arsdigita/versioning/Adapter.java +++ b/ccm-core/src/com/arsdigita/versioning/Adapter.java @@ -56,7 +56,9 @@ final class Adapter { private static final Map s_converters = new HashMap(); static { + s_log.debug("Static initalizer starting..."); initializeAdapters(); + s_log.debug("Static initalizer finished."); } private Adapter() {} diff --git a/ccm-core/src/com/arsdigita/versioning/DevSupport.java b/ccm-core/src/com/arsdigita/versioning/DevSupport.java index be7f5bd96..1af155dc2 100755 --- a/ccm-core/src/com/arsdigita/versioning/DevSupport.java +++ b/ccm-core/src/com/arsdigita/versioning/DevSupport.java @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.log4j.Logger; // new versioning @@ -206,6 +207,8 @@ final class DevSupport { private static class DependenceFormatter implements GraphFormatter { + private static final Logger logger = Logger.getLogger(DependenceFormatter.class); + private static final String GRAPH_ATTRS = GRAPH_ATTRS_HEADER + " edge[style=invis];\n" + @@ -229,6 +232,7 @@ final class DevSupport { private static final Map COLORS = new HashMap(); static { + logger.debug("Static initalizer starting..."); COLORS.put(NodeType.VERSIONED_TYPE, "[fillcolor=Tomato,comment=\"versioned type\"]"); COLORS.put(NodeType.COVERSIONED_TYPE, @@ -236,6 +240,7 @@ final class DevSupport { COLORS.put(NodeType.RECOVERABLE, "[fillcolor=LemonChiffon,comment=recoverable]"); COLORS.put(NodeType.UNREACHABLE, "[comment=unreachable]"); + logger.debug("Static initalizer finished."); } public String graphAttributes(Graph graph) { diff --git a/ccm-core/src/com/arsdigita/xml/Document.java b/ccm-core/src/com/arsdigita/xml/Document.java index 8f8f726fc..bca552e3f 100755 --- a/ccm-core/src/com/arsdigita/xml/Document.java +++ b/ccm-core/src/com/arsdigita/xml/Document.java @@ -52,14 +52,13 @@ import java.io.UnsupportedEncodingException; * @since ACS 4.5a */ public class Document { - public static final String versionId = - "$Id: Document.java 287 2005-02-22 00:29:02Z sskracic $" + - " by $Author: sskracic $, " + - "$DateTime: 2004/08/16 18:10:38 $"; + public static final String versionId = + "$Id: Document.java 287 2005-02-22 00:29:02Z sskracic $" + + " by $Author: sskracic $, " + + "$DateTime: 2004/08/16 18:10:38 $"; private static final Logger s_log = - Logger.getLogger(Document.class.getName()); - + Logger.getLogger(Document.class.getName()); /** * this is the identity XSL stylesheet. We need to provide the * identity transform as XSL explicitly because the default @@ -71,43 +70,41 @@ public class Document { // to the output doc with /* private final static String identityXSL = - "\n" - + "\n" - + "\n" - + " " - + "\n\n" - + "\n" - + "\n" - + ""; - */ + "\n" + + "\n" + + "\n" + + " " + + "\n\n" + + "\n" + + "\n" + + ""; + */ // Explicitly create elements & attributes to avoid namespace // problems private final static String identityXSL = - "\n" - + "\n" - + "\n" - + " \n" - + "\n" - + "\n" - + " \n" - + "\n" - + "\n" - + " \n" - + "\n" - + "\n" - + "\n" - + ""; - + "\n" + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + "\n" + + ""; /** * A single DocumentBuilderFactory to use for * creating Documents. */ protected static DocumentBuilderFactory s_builder = null; - /** * A single DocumentBuilder to use for * creating Documents. @@ -119,21 +116,23 @@ 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..."); s_builder = DocumentBuilderFactory.newInstance(); s_builder.setNamespaceAware(true); s_db = new ThreadLocal() { - public Object initialValue() { - try { - return s_builder.newDocumentBuilder(); - } catch (ParserConfigurationException pce) { - return null; - } + + public Object initialValue() { + try { + return s_builder.newDocumentBuilder(); + } catch (ParserConfigurationException pce) { + return null; } - }; + } + }; + s_log.debug("Static initalized finished."); } /* Used to build the DOM Documents that this class wraps */ - /** * The internal DOM document being wrapped. */ @@ -142,11 +141,11 @@ public class Document { /** * Creates a new Document class with no root element. */ - public Document( ) throws ParserConfigurationException { - DocumentBuilder db = (DocumentBuilder)s_db.get(); + public Document() throws ParserConfigurationException { + DocumentBuilder db = (DocumentBuilder) s_db.get(); if (db == null) { - throw new ParserConfigurationException - ("Unable to create a DocumentBuilder"); + throw new ParserConfigurationException( + "Unable to create a DocumentBuilder"); } m_document = db.newDocument(); } @@ -158,7 +157,7 @@ public class Document { * @param doc the org.w3c.dom.Document * */ - public Document( org.w3c.dom.Document doc ) { + public Document(org.w3c.dom.Document doc) { m_document = doc; } @@ -167,11 +166,11 @@ public class Document { * * @param rootNode the element to use as the root node */ - public Document( Element rootNode ) throws ParserConfigurationException { - DocumentBuilder db = (DocumentBuilder)s_db.get(); + public Document(Element rootNode) throws ParserConfigurationException { + DocumentBuilder db = (DocumentBuilder) s_db.get(); if (db == null) { - throw new ParserConfigurationException - ("Unable to create a DocumentBuilder"); + throw new ParserConfigurationException( + "Unable to create a DocumentBuilder"); } m_document = db.newDocument(); @@ -183,24 +182,23 @@ public class Document { * Creates a document from the passed in string that should * be properly formatted XML */ - public Document( String xmlString ) - throws ParserConfigurationException, org.xml.sax.SAXException { - this(new org.xml.sax.InputSource - (new java.io.StringReader(xmlString))); + public Document(String xmlString) + throws ParserConfigurationException, org.xml.sax.SAXException { + this(new org.xml.sax.InputSource(new java.io.StringReader(xmlString))); } - public Document( byte[] xmlBytes ) - throws ParserConfigurationException, org.xml.sax.SAXException { - this(new org.xml.sax.InputSource - (new java.io.ByteArrayInputStream(xmlBytes))); + public Document(byte[] xmlBytes) + throws ParserConfigurationException, org.xml.sax.SAXException { + this(new org.xml.sax.InputSource(new java.io.ByteArrayInputStream( + xmlBytes))); } - private Document(org.xml.sax.InputSource inputSource) - throws ParserConfigurationException, org.xml.sax.SAXException { - DocumentBuilder db = (DocumentBuilder)s_db.get(); + private Document(org.xml.sax.InputSource inputSource) + throws ParserConfigurationException, org.xml.sax.SAXException { + DocumentBuilder db = (DocumentBuilder) s_db.get(); if (db == null) { - throw new ParserConfigurationException - ("Unable to create a DocumentBuilder"); + throw new ParserConfigurationException( + "Unable to create a DocumentBuilder"); } org.w3c.dom.Document domDoc; @@ -218,7 +216,7 @@ public class Document { * @param rootNode the element to use as the root node * @return this document. */ - public Document setRootElement( Element rootNode ) { + public Document setRootElement(Element rootNode) { rootNode.importInto(m_document); m_document.appendChild(rootNode.getInternalElement()); @@ -236,7 +234,7 @@ public class Document { * @param ns the element's namespace URI * @return The newly created root element. */ - public Element createRootElement( String elt, String ns ) { + public Element createRootElement(String elt, String ns) { org.w3c.dom.Element root = m_document.createElementNS(ns, elt); m_document.appendChild(root); Element wrapper = new Element(); @@ -254,7 +252,7 @@ public class Document { * @param elt the element name * @return The newly created root element. */ - public Element createRootElement( String elt ) { + public Element createRootElement(String elt) { org.w3c.dom.Element root = m_document.createElement(elt); m_document.appendChild(root); Element wrapper = new Element(); @@ -273,8 +271,6 @@ public class Document { return root; } - - /** * Not a part of org.jdom.Document, this function returns * the internal DOM representation of this document. This method should @@ -283,7 +279,7 @@ public class Document { * * @return this document. */ - public org.w3c.dom.Document getInternalDocument( ) { + public org.w3c.dom.Document getInternalDocument() { return m_document; } @@ -306,9 +302,9 @@ public class Document { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { StreamSource identitySource = - new StreamSource(new StringReader(identityXSL)); - identity = TransformerFactory.newInstance() - .newTransformer(identitySource); + new StreamSource(new StringReader(identityXSL)); + identity = TransformerFactory.newInstance().newTransformer( + identitySource); identity.setOutputProperty("method", "xml"); identity.setOutputProperty("indent", (indent ? "yes" : "no")); identity.setOutputProperty("encoding", "UTF-8"); diff --git a/ccm-core/src/com/arsdigita/xml/XML.java b/ccm-core/src/com/arsdigita/xml/XML.java index 10bcad536..5e9cb9d99 100755 --- a/ccm-core/src/com/arsdigita/xml/XML.java +++ b/ccm-core/src/com/arsdigita/xml/XML.java @@ -53,7 +53,9 @@ public class XML { private static Map s_formatters = new HashMap(); static { + s_log.debug("Static initalizer starting..."); s_formatters.put(Date.class, new DateTimeFormatter()); + s_log.debug("Static initalizer finished."); } private XML() {} diff --git a/ccm-core/src/com/redhat/persistence/metadata/Column.java b/ccm-core/src/com/redhat/persistence/metadata/Column.java index b6a449da1..04cf7f0d2 100755 --- a/ccm-core/src/com/redhat/persistence/metadata/Column.java +++ b/ccm-core/src/com/redhat/persistence/metadata/Column.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.apache.log4j.Logger; /** * The Column class is used to keep information about the physical schema in @@ -40,6 +41,8 @@ public class Column extends Element { public final static String versionId = "$Id: Column.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $"; + private static final Logger logger = Logger.getLogger(Column.class); + /** * The name of this Column. **/ @@ -353,6 +356,7 @@ public class Column extends Element { private static final Map ORACLE = new HashMap(); static { + logger.debug("Static initalizer starting..."); DEFAULT.put(new Integer(Types.ARRAY), "ARRAY"); DEFAULT.put(new Integer(Types.BIGINT), "BIGINT"); ORACLE.put(new Integer(Types.BIGINT), "integer"); @@ -389,6 +393,7 @@ public class Column extends Element { DEFAULT.put(new Integer(Types.TINYINT), "TINYINT"); DEFAULT.put(new Integer(Types.VARBINARY), "VARBINARY"); DEFAULT.put(new Integer(Types.VARCHAR), "VARCHAR"); + logger.debug("Static initalizer finished."); } private static final String getDatabaseType(int type) { diff --git a/ccm-core/src/com/redhat/persistence/oql/Static.java b/ccm-core/src/com/redhat/persistence/oql/Static.java index d3a5bf45d..f5186c86c 100755 --- a/ccm-core/src/com/redhat/persistence/oql/Static.java +++ b/ccm-core/src/com/redhat/persistence/oql/Static.java @@ -34,6 +34,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import org.apache.log4j.Logger; /** * Static @@ -44,6 +45,8 @@ import java.util.Map; public class Static extends Expression { + private static final Logger logger = Logger.getLogger(Static.class); + public final static String versionId = "$Id: Static.java 1130 2006-04-30 13:40:54Z apevec $ by $Author: apevec $, $DateTime: 2004/08/16 18:10:38 $"; private SQL m_sql; @@ -55,6 +58,7 @@ public class Static extends Expression { private static final Collection s_functions = new HashSet(); static { + logger.debug("Static initalizer starting..."); String[] functions = { /* sql standard functions supported by both oracle and postgres. * there is an added caveat that the function uses normal function @@ -70,6 +74,7 @@ public class Static extends Expression { for (int i = 0; i < functions.length; i++) { s_functions.add(functions[i]); } + logger.debug("Static initalizer finished."); } private static final boolean isAllowedFunction(String s) { diff --git a/ccm-core/src/com/redhat/persistence/profiler/rdbms/SQLSummary.java b/ccm-core/src/com/redhat/persistence/profiler/rdbms/SQLSummary.java index 0ebf28d9c..b4d2d4ef8 100755 --- a/ccm-core/src/com/redhat/persistence/profiler/rdbms/SQLSummary.java +++ b/ccm-core/src/com/redhat/persistence/profiler/rdbms/SQLSummary.java @@ -27,6 +27,7 @@ import com.redhat.persistence.common.SQLParser; import com.redhat.persistence.common.SQLToken; import java.io.StringReader; import java.util.HashMap; +import org.apache.log4j.Logger; /** * SQLSummary @@ -37,6 +38,8 @@ import java.util.HashMap; class SQLSummary { + private static final Logger logger = Logger.getLogger(SQLSummary.class); + private static final HashMap SUMMARIES = new HashMap(); public static SQLSummary get(String text) { @@ -61,10 +64,12 @@ class SQLSummary { private static final HashMap TYPES = new HashMap(); static { + logger.debug("Static initalizer starting..."); TYPES.put("select", new Integer(SELECT)); TYPES.put("insert into", new Integer(INSERT)); TYPES.put("update", new Integer(UPDATE)); TYPES.put("delete from", new Integer(DELETE)); + logger.debug("Static initalizer finished."); } private final int m_type; diff --git a/ccm-core/src/log4j.properties b/ccm-core/src/log4j.properties index f5da30c74..05c91b5b7 100755 --- a/ccm-core/src/log4j.properties +++ b/ccm-core/src/log4j.properties @@ -65,4 +65,122 @@ log4j.logger.com.arsdigita.packaging.Loader=INFO #log4j.logger.com.arsdigita.london.importer=DEBUG #log4j.logger.com.arsdigita.london.terms.importer.TermItemBuilder=DEBUG #log4j.logger.com.arsdigita.categorization.Category=DEBUG -log4j.logger.com.arsdigita.london.util.cmd.BulkPublish=DEBUG \ No newline at end of file + +#For debugging static initalizer blocks (static {}) +#com.arsdigita.auth.http.HTTPAuth=DEBUG +#com.arsdigita.auth.http.HTTPAuthConfig=DEBUG +#com.arsdigita.auth.http.HTTPLoginModule=DEBUG +#com.arsdigita.cms.dispatcher.SimpleXMLGenerator=DEBUG +#com.arsdigita.cms.contenttypes.GenericAddress=DEBUG +#com.arsdigita.cms.contenttypes.GenericContact=DEBUG +#com.arsdigita.cms.publishtofile.LinkScanner=DEBUG +#com.arsdigita.cms.ui.type.TypeElements=DEBUG +#com.arsdigita.cms.ui.item.ItemLanguagesTable=DEBUG +#com.arsdigita.cms.ui.templates.ItemTemplateListing=DEBUG +#com.arsdigita.cms.ui.folder.FolderBrowser=DEBUG +#com.arsdigita.cms.ui.authoring.TextAssetBody=DEBUG +#com.arsdigita.cms.ContentSection=DEBUG +#com.arsdigita.cms.CMS=DEBUG +#com.arsdigita.cms.Loader=DEBUG +#com.arsdigita.cms.Template=DEBUG +#com.arsdigita.cms.Initalizer=DEBUG +#com.arsdigita.cms.contentassets.FileAttachment=DEBUG +#com.arsdigita.cms.contentassets.ItemImageAttachment=DEBUG +#com.arsdigita.cms.contentassets.Note=DEBUG +#com.arsdigita.cms.contentassets.ui=RelatedLinkPropertyForm=DEBUG +#com.arsdigita.cms.contenttypes.Event=DEBUG +#com.arsdigita.cms.contenttypes.GenericOrganization=DEBUG +#com.arsdigita.cms.contenttypes.GlossaryItem=DEBUG +#com.arsdigita.cms.contenttypes.HealthCareFacility=DEBUG +#com.arsdigita.cms.contenttypes.MultiPartArticle=DEBUG +#com.arsdigita.cms.contenttypes.NewsItem=DEBUG +#com.arsdigita.cms.contenttypes.SimpleAddress=DEBUG +#com.arsdigita.cms.dispatcherSiteProxyPanel=DEBUG +#com.arsdigita.cms.contenttypes.Survey=DEBUG +#com.arsdigita.kernel.security.KernelLoginException=DEBUG +#com.arsdigita.kernel.security.URLLoginModule=DEBUG +#com.arsdigita.kernel.security.Crypto=DEBUG +#com.arsdigita.profiler.Profiler=DEBUG +#com.arsdigita.categorization.Category=DEBUG +#com.arsdigita.developersupport.#Comodifications=DEBUG +#com.arsdigita.developersupport.Counter=DEBUG +#com.arsdigita.developersupport.LoggingProxyFactory=DEBUG +#com.arsdigita.persistence.pdl.PDL=DEBUG +#com.arsdigita.persistence.pdl.SQLRegressionGenerator=DEBUG +#com.arsdigita.persistence.SessionManager=DEBUG +#com.arsdigita.packaging.HostInit=DEBUG +#com.arsdigita.packaging.BaseCheck=DEBUG +#com.arsdigita.packaging.Load=DEBUG +#com.arsdigita.packaging.Get=DEBUG +#com.arsdigita.packaging.Unload=DEBUG +#com.arsdigita.packaging.CheckDB=DEBUG +#com.arsdigita.packaging.Upgrade=DEBUG +#com.arsdigita.packaging.Set=DEBUG +#com.arsdigita.toolbox.CharsetEncodingProvider=DEBUG +#com.arsdigita.bebop.demo.workflow.SampleProcess=DEBUG +#com.arsdigita.bebop.page.PageTransformer=DEBUG +#com.arsdigita.bebop.parameters.TidyHTMLValidationListener=DEBUG +#com.arsdigita.bebop.Page=DEBUG +#com.arsdigita.core.LibCheck=DEBUG +#com.arsdigita.templating.html.XHTMLParser=DEBUG +#com.arsdigita.templating.ApplyTemplates=DEBUG +#com.arsdigita.templating.Templating=DEBUG +#com.arsdigita.templating.PatternStylesheetResolver=DEBUG +#com.arsdigita.search.QueryEngineRegistry=DEBUG +#com.arsdigita.formbuilder.AttributeType=DEBUG +#com.arsdigita.mail.Mail=DEBUG +#com.arsdigita.versioning.DevSupport=DEBUG +#com.arsdigita.versioning.Adapter=DEBUG +#com.arsdigita.dispatcher.BaseDispatcherServlet=DEBUG +#com.arsdigita.logging.ErrorReport=DEBUG +#com.arsdigita.xml.XML=DEBUG +#com.arsdigita.xml.Document=DEBUG +#com.arsdigita.sitenode.ServletErrorReport=DEBUG +#com.arsdigita.util.parameter.IntegerParameter=DEBUG +#com.arsdigita.util.parameter.ClassParameter=DEBUG +#com.arsdigita.util.parameter.StringParameter=DEBUG +#com.arsdigita.util.parameter.ParameterPrinter=DEBUG +#com.arsdigita.util.Assert=DEBUG +#com.arsdigita.util.StringUtils=DEBUG +#com.arsdigita.util.UncheckedWrapperException=DEBUG +#com.arsdigita.util.WrappedError=DEBUG +#com.arsdigita.util.ConcurrentDict=DEBUG +#com.redhat.persistence.profiler.rdbms.SQLSummary=DEBUG +#com.redhat.persistence.metadata.Column=DEBUG +#com.redhat.persistence.ogl.Static=DEBUG +#com.arsdigita.cms.docmgr.ui.CreateDocLinkSearchTable=DEBUG +#com.arsdigita.formbuilder.pdf.PDFConfig=DEBUG +#com.arsdigita.ui.TopicsList=DEBUG +#com.arsdigita.forum.ForumPageFactory=DEBUG +#com.arsdigita.forum.Forum=DEBUG +#com.arsdigita.aplaws.ObjectTypeSchemaGenerator=DEBUG +#com.arsdigita.london.atoz.AtoZ=DEBUG +#com.arsdigita.london.cms.dublin.DublinCoreItem=DEBUG +#com.arsdigita.london.exporter.Exporter=DEBUG +#com.arsdigita.london.importer.cms.ItemParser=DEBUG +#com.arsdigita.london.navigation.ui.TemplateURLs=DEBUG +#com.arsdigita.london.navigation.Navigation=DEBUG +#com.arsdigita.london.navigation.ApplicationNavigationModel=DEBUG +#com.arsdigita.london.portal.portlet.RSSFeedPortletHelper=DEBUG +#com.arsdigita.london.portal.ui.admin.GrantsTable=DEBUG +#com.arsdigita.london.portal.ui.Icons=DEBUG +#com.arsdigita.london.Workspace=DEBUG +#com.arsdigita.london.rss.RSS=DEBUG +#com.arsdigita.london.rss.RSSService=DEBUG +#com.arsdigita.london.search.Search=DEBUG +#com.arsdigita.london.shortcuts.Shortcuts=DEBUG +#com.arsdigita.london.subsite.Subsite=DEBUG +#kea.stemmers.LovinsStemmer=DEBUG +#kea.stemmers.StopwordsFrench=DEBUG +#kea.stemmers.StopwordsSpanish=DEBUG +#kea.stemmers.StopwordsEnglish=DEBUG +#kea.stemmers.StopwordsGerman=DEBUG +#com.arsdigita.london.terms.Terms=DEBUG +#com.arsdigita.london.theme.ThemeApplication=DEBUG +#com.arsdigita.cms.contenttypes.ContactInitalizer=DEBUG +#com.arsdigita.cms.contenttypes.SciDepartment=DEBUG +#com.arsdigita.cms.contenttypes.SciOrganization=DEBUG +#com.arsdigita.cms.contenttypes.SciProject=DEBUG +#com.arsdigita.cms.contenttypes.SciMember=DEBUG +#com.arsdigita.cms.webpage.installer.Initializer=DEBUG + diff --git a/ccm-docmgr/src/com/arsdigita/cms/docmgr/ui/CreateDocLinkSearchTable.java b/ccm-docmgr/src/com/arsdigita/cms/docmgr/ui/CreateDocLinkSearchTable.java index 019c37544..0c90fbabe 100755 --- a/ccm-docmgr/src/com/arsdigita/cms/docmgr/ui/CreateDocLinkSearchTable.java +++ b/ccm-docmgr/src/com/arsdigita/cms/docmgr/ui/CreateDocLinkSearchTable.java @@ -204,11 +204,14 @@ public class CreateDocLinkSearchTable extends Table implements DMConstants{ */ private static class ActionCellRenderer implements TableCellRenderer { + private final static Logger logger = Logger.getLogger(ActionCellRenderer.class); private static ControlLink s_link; static { + logger.debug("Static initalizer starting..."); s_link = new ControlLink(new Label(DMConstants.FOLDER_NEW_CREATE_LINK)); - s_link.setConfirmation("Create Link to this Document ?"); + s_link.setConfirmation("Create Link to this Document ?"); + logger.debug("Static initalizer finished."); } public Component getComponent(Table table, PageState state, Object value, diff --git a/ccm-formbuilder-pdf/src/com/arsdigita/formbuilder/pdf/PDFConfig.java b/ccm-formbuilder-pdf/src/com/arsdigita/formbuilder/pdf/PDFConfig.java index 4c7fa8b0e..6f377bd21 100755 --- a/ccm-formbuilder-pdf/src/com/arsdigita/formbuilder/pdf/PDFConfig.java +++ b/ccm-formbuilder-pdf/src/com/arsdigita/formbuilder/pdf/PDFConfig.java @@ -45,12 +45,14 @@ public class PDFConfig extends AbstractConfig { private static final PDFConfig s_config = new PDFConfig(); static { + s_log.debug("Static initalizer starting..."); try { s_config.load(); } catch (java.lang.IllegalArgumentException ex) { s_log.info("Unable to load PDFConfig. This is not a problem " + "during ccm load, but is a problem at all other times"); } + s_log.debug("Static initalizer finished."); } public PDFConfig() { diff --git a/ccm-forum/src/com/arsdigita/forum/Forum.java b/ccm-forum/src/com/arsdigita/forum/Forum.java index 6bcae3f1e..ced7b1af3 100755 --- a/ccm-forum/src/com/arsdigita/forum/Forum.java +++ b/ccm-forum/src/com/arsdigita/forum/Forum.java @@ -80,7 +80,9 @@ public class Forum extends Application { private static final ForumConfig s_config = new ForumConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static ForumConfig getConfig() { diff --git a/ccm-forum/src/com/arsdigita/forum/ForumPageFactory.java b/ccm-forum/src/com/arsdigita/forum/ForumPageFactory.java index 25d60d77d..a29e9c385 100644 --- a/ccm-forum/src/com/arsdigita/forum/ForumPageFactory.java +++ b/ccm-forum/src/com/arsdigita/forum/ForumPageFactory.java @@ -25,6 +25,7 @@ import java.util.Map; import com.arsdigita.bebop.Page; // import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.util.Assert; +import org.apache.log4j.Logger; /** * Factory class that enables projects to provide their own page creators. @@ -35,38 +36,37 @@ import com.arsdigita.util.Assert; */ public class ForumPageFactory { - public static final String THREAD_PAGE = "thread"; - public static final String FORUM_PAGE = "forum"; - - private static Map pageBuilders = new HashMap(); - - static { - // default pageBuilders are those provided with this project - pageBuilders.put(THREAD_PAGE, new ThreadPageBuilder()); - pageBuilders.put(FORUM_PAGE, new ForumPageBuilder()); - } - + private static final Logger logger = Logger.getLogger(ForumPageFactory.class); + public static final String THREAD_PAGE = "thread"; + public static final String FORUM_PAGE = "forum"; + private static Map pageBuilders = new HashMap(); + + static { + logger.debug("Static initalizer starting..."); + // default pageBuilders are those provided with this project + pageBuilders.put(THREAD_PAGE, new ThreadPageBuilder()); + pageBuilders.put(FORUM_PAGE, new ForumPageBuilder()); + logger.debug("Static initalizer finished."); + } + public static Page getPage(String pageType) { Assert.isTrue(pageBuilders.containsKey(pageType), - "Requested page type (" + pageType + - ") does not have a builder registered" ); - PageBuilder builder = (PageBuilder)pageBuilders.get(pageType); - Page page = builder.buildPage(); - page.lock(); - return page; - - - } - - public static Iterator getPages () { - return pageBuilders.keySet().iterator(); - } - - - public static void registerPageBuilder (String pageType, PageBuilder builder) { - pageBuilders.put(pageType, builder); - - } - + "Requested page type (" + pageType + + ") does not have a builder registered"); + PageBuilder builder = (PageBuilder) pageBuilders.get(pageType); + Page page = builder.buildPage(); + page.lock(); + return page; + + } + + public static Iterator getPages() { + return pageBuilders.keySet().iterator(); + } + + public static void registerPageBuilder(String pageType, PageBuilder builder) { + pageBuilders.put(pageType, builder); + + } } diff --git a/ccm-forum/src/com/arsdigita/forum/ui/TopicsList.java b/ccm-forum/src/com/arsdigita/forum/ui/TopicsList.java index a79420dd5..ffd9b6c1c 100755 --- a/ccm-forum/src/com/arsdigita/forum/ui/TopicsList.java +++ b/ccm-forum/src/com/arsdigita/forum/ui/TopicsList.java @@ -31,6 +31,7 @@ import com.arsdigita.forum.ForumContext; import java.util.Set; import java.util.HashSet; import java.util.Iterator; +import org.apache.log4j.Logger; /** @@ -46,14 +47,17 @@ import java.util.Iterator; */ public class TopicsList extends SimpleComponent implements Constants { + private static final Logger logger = Logger.getLogger(TopicsList.class); /** List of properties a topic may have. */ private final static Set s_catProps; static { + logger.debug("Static initalizer starting..."); s_catProps = new HashSet(); s_catProps.add("id"); s_catProps.add("name"); s_catProps.add("numThreads"); s_catProps.add("latestPost"); + logger.debug("Static initalizer finished."); } /** diff --git a/ccm-gen-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java b/ccm-gen-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java index 7d31607f7..56da85a78 100755 --- a/ccm-gen-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java +++ b/ccm-gen-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.aplaws; import com.arsdigita.xml.Element; @@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property; import java.util.HashMap; import java.util.Stack; import java.math.BigDecimal; +import org.apache.log4j.Logger; public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { + private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class); private boolean m_wrapRoot = false; private boolean m_wrapObjects = false; private boolean m_wrapAttributes = false; - - - private Stack m_history = new Stack(); private HashMap m_elements = new HashMap(); - // The xs:element private Element m_element; // The (optional) xs:complexType @@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // The (optional property private Property m_property; private Stack m_properties = new Stack(); - private Element m_root; private String m_rootName; - public static final String SCHEMA_PREFIX = "xs:"; - - public static final String SCHEMA_NS = - "http://www.w3.org/2001/XMLSchema"; - + public static final String SCHEMA_NS = + "http://www.w3.org/2001/XMLSchema"; private static HashMap s_types = new HashMap(); + static { + logger.debug("Static initalizer starting..."); s_types.put(String.class, "xs:string"); s_types.put(Boolean.class, "xs:boolean"); s_types.put(Integer.class, "xs:integer"); s_types.put(BigDecimal.class, "xs:double"); + logger.debug("Static initalizer finished."); } protected static String lookupType(Class klass) { if (s_types.containsKey(klass)) { - return (String)s_types.get(klass); + return (String) s_types.get(klass); } return "xs:string"; } - + public static void registerType(Class klass, String type) { s_types.put(klass, type); } - public ObjectTypeSchemaGenerator(String rootName, String namespace) { m_root = new Element(SCHEMA_PREFIX + "schema", SCHEMA_NS); m_rootName = rootName; - + // Set the namespace for nodes defined by the schema m_root.addAttribute("targetNamespace", namespace); // Set the default namespace for unqualified nodes @@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { return m_root; } - /** * Determines XML output for root object. * If set to true a separate element will @@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); m_sequence = sequence; } - + Element parent; String name; if (m_element == null) { if (m_wrapRoot) { - Element element = m_root.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_root.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", m_rootName); - - Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", + + Element type = element.newChildElement(SCHEMA_PREFIX + + "complexType", SCHEMA_NS); - Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); - + parent = sequence; name = nameFromPath(path); } else { @@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); - + Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute", SCHEMA_NS); oid.addAttribute("name", "oid"); oid.addAttribute("type", "xs:string"); - + // Add to the path -> element map, not that we use this info yet m_elements.put(path, element); // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); + m_history.push(new Element[]{m_element, m_type, m_sequence}); m_element = element; m_type = type; @@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { */ protected void endObject(ObjectType obj, String path) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; @@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapAttributes) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } @@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); element.addAttribute("name", property.getName()); // XXX pdl type -> xs type mapping - element.addAttribute("type",lookupType(property.getJavaClass())); + element.addAttribute("type", lookupType(property.getJavaClass())); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); @@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_sequence.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } else { @@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_type.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } @@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } /** @@ -324,26 +324,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } - } diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java index 7d31607f7..56da85a78 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.aplaws; import com.arsdigita.xml.Element; @@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property; import java.util.HashMap; import java.util.Stack; import java.math.BigDecimal; +import org.apache.log4j.Logger; public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { + private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class); private boolean m_wrapRoot = false; private boolean m_wrapObjects = false; private boolean m_wrapAttributes = false; - - - private Stack m_history = new Stack(); private HashMap m_elements = new HashMap(); - // The xs:element private Element m_element; // The (optional) xs:complexType @@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // The (optional property private Property m_property; private Stack m_properties = new Stack(); - private Element m_root; private String m_rootName; - public static final String SCHEMA_PREFIX = "xs:"; - - public static final String SCHEMA_NS = - "http://www.w3.org/2001/XMLSchema"; - + public static final String SCHEMA_NS = + "http://www.w3.org/2001/XMLSchema"; private static HashMap s_types = new HashMap(); + static { + logger.debug("Static initalizer starting..."); s_types.put(String.class, "xs:string"); s_types.put(Boolean.class, "xs:boolean"); s_types.put(Integer.class, "xs:integer"); s_types.put(BigDecimal.class, "xs:double"); + logger.debug("Static initalizer finished."); } protected static String lookupType(Class klass) { if (s_types.containsKey(klass)) { - return (String)s_types.get(klass); + return (String) s_types.get(klass); } return "xs:string"; } - + public static void registerType(Class klass, String type) { s_types.put(klass, type); } - public ObjectTypeSchemaGenerator(String rootName, String namespace) { m_root = new Element(SCHEMA_PREFIX + "schema", SCHEMA_NS); m_rootName = rootName; - + // Set the namespace for nodes defined by the schema m_root.addAttribute("targetNamespace", namespace); // Set the default namespace for unqualified nodes @@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { return m_root; } - /** * Determines XML output for root object. * If set to true a separate element will @@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); m_sequence = sequence; } - + Element parent; String name; if (m_element == null) { if (m_wrapRoot) { - Element element = m_root.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_root.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", m_rootName); - - Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", + + Element type = element.newChildElement(SCHEMA_PREFIX + + "complexType", SCHEMA_NS); - Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); - + parent = sequence; name = nameFromPath(path); } else { @@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); - + Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute", SCHEMA_NS); oid.addAttribute("name", "oid"); oid.addAttribute("type", "xs:string"); - + // Add to the path -> element map, not that we use this info yet m_elements.put(path, element); // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); + m_history.push(new Element[]{m_element, m_type, m_sequence}); m_element = element; m_type = type; @@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { */ protected void endObject(ObjectType obj, String path) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; @@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapAttributes) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } @@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); element.addAttribute("name", property.getName()); // XXX pdl type -> xs type mapping - element.addAttribute("type",lookupType(property.getJavaClass())); + element.addAttribute("type", lookupType(property.getJavaClass())); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); @@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_sequence.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } else { @@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_type.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } @@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } /** @@ -324,26 +324,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } - } diff --git a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZ.java b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZ.java index a50aad681..ee0fe8b72 100755 --- a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZ.java +++ b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZ.java @@ -33,19 +33,23 @@ import com.arsdigita.util.Assert; import java.util.List; import java.util.ArrayList; +import org.apache.log4j.Logger; /** * Base class of the AtoZ application (module) * */ public class AtoZ extends Application { - + + private static final Logger logger = Logger.getLogger(AtoZ.class); public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.atoz.AtoZ"; private static final AtoZConfig s_config = new AtoZConfig(); static { + logger.debug("Static initializer is starting..."); s_config.load(); + logger.debug("Static initializer is finished."); } public static final AtoZConfig getConfig() { diff --git a/ccm-ldn-dublin/src/com/arsdigita/london/cms/dublin/DublinCoreItem.java b/ccm-ldn-dublin/src/com/arsdigita/london/cms/dublin/DublinCoreItem.java index 4f3ccf1f3..f7eab0e00 100755 --- a/ccm-ldn-dublin/src/com/arsdigita/london/cms/dublin/DublinCoreItem.java +++ b/ccm-ldn-dublin/src/com/arsdigita/london/cms/dublin/DublinCoreItem.java @@ -24,6 +24,7 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.util.Assert; import com.arsdigita.kernel.ACSObject; import java.util.Date; +import org.apache.log4j.Logger; /*** * @@ -61,12 +62,15 @@ import java.util.Date; **/ public class DublinCoreItem extends ContentItem { + private static final Logger logger = Logger.getLogger(DublinCoreItem.class); public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.cms.dublin.DublinCoreItem"; private static final DublinCoreConfig s_config = new DublinCoreConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static final DublinCoreConfig getConfig() { diff --git a/ccm-ldn-exporter/src/com/arsdigita/london/exporter/Exporter.java b/ccm-ldn-exporter/src/com/arsdigita/london/exporter/Exporter.java index 3f20edaf3..00c16b961 100755 --- a/ccm-ldn-exporter/src/com/arsdigita/london/exporter/Exporter.java +++ b/ccm-ldn-exporter/src/com/arsdigita/london/exporter/Exporter.java @@ -18,14 +18,19 @@ package com.arsdigita.london.exporter; +import org.apache.log4j.Logger; + public class Exporter { + private static final Logger logger = Logger.getLogger(Exporter.class); private static ExporterConfig s_config = new ExporterConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static ExporterConfig getConfig() { diff --git a/ccm-ldn-importer/src/com/arsdigita/london/importer/cms/ItemParser.java b/ccm-ldn-importer/src/com/arsdigita/london/importer/cms/ItemParser.java index db9a53dde..29b1a068b 100755 --- a/ccm-ldn-importer/src/com/arsdigita/london/importer/cms/ItemParser.java +++ b/ccm-ldn-importer/src/com/arsdigita/london/importer/cms/ItemParser.java @@ -105,6 +105,7 @@ public class ItemParser extends DomainObjectParser { private Date m_archiveDate; static { + s_log.debug("Static initalizer starting..."); s_ignoredProps = new ArrayList(); s_ignoredProps.add(ID); s_ignoredProps.add(OID_ATTR); @@ -115,6 +116,7 @@ public class ItemParser extends DomainObjectParser { s_ignoredProps.add(ARTICLE_ID); s_ignoredProps.add(DEFAULT_ANCESTORS); s_ignoredProps.add(DO_NOT_SAVE); + s_log.debug("Static initalizer finished."); } public ItemParser(File lobDir, DomainObjectMapper mapper) { diff --git a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ApplicationNavigationModel.java b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ApplicationNavigationModel.java index b928fafdb..d96c1cd36 100755 --- a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ApplicationNavigationModel.java +++ b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ApplicationNavigationModel.java @@ -42,8 +42,10 @@ public class ApplicationNavigationModel implements NavigationModel { new GenericNavigationModel(); static { + s_log.debug("Static initalizer starting..."); register(ContentSection.BASE_DATA_OBJECT_TYPE, new CMSNavigationModel()); register(Navigation.BASE_DATA_OBJECT_TYPE, new DefaultNavigationModel()); + s_log.debug("Static initalizer finished."); } public ACSObject getObject() { diff --git a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/Navigation.java b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/Navigation.java index 1a9b70a43..61d6ef756 100755 --- a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/Navigation.java +++ b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/Navigation.java @@ -27,10 +27,13 @@ import com.arsdigita.web.ParameterMap; import com.arsdigita.web.URL; import com.arsdigita.web.Web; import com.arsdigita.xml.Element; +import org.apache.log4j.Logger; public class Navigation extends Application { + private static final Logger logger = Logger.getLogger(Navigation.class); + public static final String NAV_NS = "http://ccm.redhat.com/london/navigation"; public static final String NAV_PREFIX = "nav"; @@ -42,7 +45,9 @@ public class Navigation extends Application { private static NavigationContext s_context = new NavigationContext(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static NavigationConfig getConfig() { diff --git a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ui/TemplateURLs.java b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ui/TemplateURLs.java index 058dc339f..9a3ef8a8e 100755 --- a/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ui/TemplateURLs.java +++ b/ccm-ldn-navigation/src/com/arsdigita/london/navigation/ui/TemplateURLs.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.london.navigation.ui; import com.arsdigita.london.navigation.NavigationConstants; @@ -30,54 +29,59 @@ import com.arsdigita.xml.Element; import java.util.Iterator; import java.util.LinkedList; +import org.apache.log4j.Logger; public class TemplateURLs extends SimpleComponent { + + private static final Logger logger = Logger.getLogger(TemplateURLs.class); private static final String[] s_contexts; // Pull out and pre-populate the template use contexts. Note that this will // only be done once per server load, but this is ok because there's no UI // for creating contexts. static { + logger.debug("Static initalizer starting..."); TemplateContextCollection templates = TemplateContext.retrieveAll(); LinkedList buffer = new LinkedList(); - while( templates.next() ) { - buffer.add( templates.getTemplateContext().getContext() ); + while (templates.next()) { + buffer.add(templates.getTemplateContext().getContext()); } s_contexts = new String[buffer.size()]; Iterator iter = buffer.iterator(); - for( int i = 0; i < s_contexts.length; i++ ) { + for (int i = 0; i < s_contexts.length; i++) { s_contexts[i] = iter.next().toString(); } + logger.debug("Static initalizer finished."); } public TemplateURLs() { super(); } - public void generateXML( PageState ps, Element p ) { + public void generateXML(PageState ps, Element p) { ContentItem item = CMS.getContext().getContentItem(); - if( null == item ) return; + if (null == item) { + return; + } Element container = p.newChildElement( - NavigationConstants.NAV_PREFIX + ":templateContexts", - NavigationConstants.NAV_NS - ); - container.addAttribute( "type", item.getContentType().getClassName() ); + NavigationConstants.NAV_PREFIX + ":templateContexts", + NavigationConstants.NAV_NS); + container.addAttribute("type", item.getContentType().getClassName()); String sectionPath = item.getContentSection().getPath(); String itemPath = item.getPath(); - for( int i = 0; i < s_contexts.length; i++ ) { + for (int i = 0; i < s_contexts.length; i++) { Element context = container.newChildElement( - NavigationConstants.NAV_PREFIX + ":context", - NavigationConstants.NAV_NS - ); - context.addAttribute( "name", s_contexts[i] ); + NavigationConstants.NAV_PREFIX + ":context", + NavigationConstants.NAV_NS); + context.addAttribute("name", s_contexts[i]); String path = sectionPath + "/tem_" + s_contexts[i] + '/' + itemPath; - context.addAttribute( "path", path ); + context.addAttribute("path", path); } } } diff --git a/ccm-ldn-portal/src/com/arsdigita/london/portal/Workspace.java b/ccm-ldn-portal/src/com/arsdigita/london/portal/Workspace.java index ff4d44e8d..02dd3e22d 100755 --- a/ccm-ldn-portal/src/com/arsdigita/london/portal/Workspace.java +++ b/ccm-ldn-portal/src/com/arsdigita/london/portal/Workspace.java @@ -12,7 +12,6 @@ * rights and limitations under the License. * */ - package com.arsdigita.london.portal; import org.apache.log4j.Logger; @@ -38,7 +37,7 @@ import com.arsdigita.london.portal.ui.WorkspaceTheme; import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQueryDataCollectionAdapter; import com.arsdigita.persistence.Filter; @@ -61,34 +60,29 @@ import java.util.LinkedList; */ public class Workspace extends Application { - private static final Logger s_log = Logger.getLogger(Workspace.class); + private static final Logger s_log = Logger.getLogger(Workspace.class); + private static final WorkspaceConfig s_config = new WorkspaceConfig(); - private static final WorkspaceConfig s_config = new WorkspaceConfig(); - - static { - s_config.load(); - } - - public static WorkspaceConfig getConfig() { - return s_config; - } - - public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.portal.Workspace"; - - public static final String PARTY = "party"; - - public static final String PARTY_ID = PARTY + "." + ACSObject.ID; - - public static final String DEFAULT_LAYOUT = "defaultLayout"; - - public static final String PAGES = "pages"; - - /** - * store this as a static variable as it cannot change during the lifetime - * of the ccm service - */ - private static Workspace defaultHomepageWorkspace = null; + static { + s_log.debug("Static initalizer starting..."); + s_config.load(); + s_log.debug("Static initalizer finished."); + } + public static WorkspaceConfig getConfig() { + return s_config; + } + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.london.portal.Workspace"; + public static final String PARTY = "party"; + public static final String PARTY_ID = PARTY + "." + ACSObject.ID; + public static final String DEFAULT_LAYOUT = "defaultLayout"; + public static final String PAGES = "pages"; + /** + * store this as a static variable as it cannot change during the lifetime + * of the ccm service + */ + private static Workspace defaultHomepageWorkspace = null; /** * Constructor @@ -110,7 +104,6 @@ public class Workspace extends Application { /* * public String getContextPath() { return "ccm-ldn-portal"; } */ - /** * * @return ServletPath (constant) probably should be synchron with web.xml @@ -162,16 +155,17 @@ public class Workspace extends Application { * @return */ public static Workspace createWorkspace(String url, String title, - PageLayout layout, Application parent, + PageLayout layout, + Application parent, boolean isPublic) { if (s_log.isDebugEnabled()) { s_log.debug("Creating group workspace, isPublic:" + isPublic - + " on " + url + " with parent " - + (parent == null ? "none" : parent.getOID().toString())); + + " on " + url + " with parent " + + (parent == null ? "none" : parent.getOID().toString())); } Workspace workspace = (Workspace) Application.createApplication( - BASE_DATA_OBJECT_TYPE, url, title, parent); + BASE_DATA_OBJECT_TYPE, url, title, parent); workspace.setupGroups(title, isPublic); workspace.setDefaultLayout(layout); return workspace; @@ -188,18 +182,19 @@ public class Workspace extends Application { * @return */ public static Workspace createWorkspace(String url, String title, - PageLayout layout, Application parent, User owner) { - if (s_log.isDebugEnabled()) { - s_log.debug("Creating personal workspace for " + owner.getOID() - + " on " + url + " with parent " - + (parent == null ? "none" : parent.getOID().toString())); - } + PageLayout layout, + Application parent, User owner) { + if (s_log.isDebugEnabled()) { + s_log.debug("Creating personal workspace for " + owner.getOID() + + " on " + url + " with parent " + + (parent == null ? "none" : parent.getOID().toString())); + } - Workspace workspace = (Workspace) Application.createApplication( - BASE_DATA_OBJECT_TYPE, url, title, parent); - workspace.setParty(owner); - workspace.setDefaultLayout(layout); - return workspace; + Workspace workspace = (Workspace) Application.createApplication( + BASE_DATA_OBJECT_TYPE, url, title, parent); + workspace.setParty(owner); + workspace.setDefaultLayout(layout); + return workspace; } /** @@ -259,150 +254,149 @@ public class Workspace extends Application { // super.beforeDelete(); // Category.clearRootForObject(this); // } - // This method wouldn't need to exist if permissioning used // the associations rather than direct queries which require // the object to be saved public void afterSave() { - super.afterSave(); + super.afterSave(); - Party party = getParty(); - s_log.debug("Party is " + party.getDisplayName() + " for " - + this.getTitle()); + Party party = getParty(); + s_log.debug("Party is " + party.getDisplayName() + " for " + + this.getTitle()); - if (party instanceof User) { - s_log.debug("Party is a user"); + if (party instanceof User) { + s_log.debug("Party is a user"); - // Personal workspace, so give user full admin - PermissionDescriptor admin = new PermissionDescriptor( - PrivilegeDescriptor.ADMIN, this, party); - PermissionService.grantPermission(admin); + // Personal workspace, so give user full admin + PermissionDescriptor admin = new PermissionDescriptor( + PrivilegeDescriptor.ADMIN, this, party); + PermissionService.grantPermission(admin); - } else if (party instanceof Group) { - s_log.debug("Party is a group"); + } else if (party instanceof Group) { + s_log.debug("Party is a group"); - // Ensure main group has the required permission - PermissionDescriptor pd = new PermissionDescriptor( - getConfig().getWorkspacePartyPrivilege(), this, party); - PermissionService.grantPermission(pd); + // Ensure main group has the required permission + PermissionDescriptor pd = new PermissionDescriptor( + getConfig().getWorkspacePartyPrivilege(), this, party); + PermissionService.grantPermission(pd); - // Now get (or create) the administrators role & grant it admin - Group members = (Group) party; - Role admins = members.getRole("Administrators"); - if (admins == null) { - admins = members.createRole("Administrators"); - admins.save(); - } - admins.grantPermission(this, PrivilegeDescriptor.ADMIN); - } + // Now get (or create) the administrators role & grant it admin + Group members = (Group) party; + Role admins = members.getRole("Administrators"); + if (admins == null) { + admins = members.createRole("Administrators"); + admins.save(); + } + admins.grantPermission(this, PrivilegeDescriptor.ADMIN); + } - // Set permission context for %all pages - WorkspacePageCollection pages = getPages(); - while (pages.next()) { - WorkspacePage page = pages.getPage(); - PermissionService.setContext(page, this); - } + // Set permission context for %all pages + WorkspacePageCollection pages = getPages(); + while (pages.next()) { + WorkspacePage page = pages.getPage(); + PermissionService.setContext(page, this); + } } private void setupGroups(String title, boolean isPublic) { - Group members = new Group(); - members.setName(title); - members.save(); - // set this group as subgroup of workspace application type - // although workspace applications can be nested, place all - // member groups directly under main container (rather than reflecting - // hierarchical structure) because (a) workspace already manages its - // own groups so doesn't need a hierarchy and (b) hierarchy would - // mean for a given workspace, role would be on the same level - // as member groups of sub workspaces - messy & confusing - getApplicationType().getGroup().addSubgroup(members); + Group members = new Group(); + members.setName(title); + members.save(); + // set this group as subgroup of workspace application type + // although workspace applications can be nested, place all + // member groups directly under main container (rather than reflecting + // hierarchical structure) because (a) workspace already manages its + // own groups so doesn't need a hierarchy and (b) hierarchy would + // mean for a given workspace, role would be on the same level + // as member groups of sub workspaces - messy & confusing + getApplicationType().getGroup().addSubgroup(members); - Role admins = members.createRole("Administrators"); - admins.save(); + Role admins = members.createRole("Administrators"); + admins.save(); - if (isPublic) { - Party thePublic; - try { - thePublic = (Party) DomainObjectFactory.newInstance(new OID( - User.BASE_DATA_OBJECT_TYPE, - PermissionManager.VIRTUAL_PUBLIC_ID)); - } catch (DataObjectNotFoundException ex) { - throw new UncheckedWrapperException("cannot find the public", - ex); - } + if (isPublic) { + Party thePublic; + try { + thePublic = (Party) DomainObjectFactory.newInstance(new OID( + User.BASE_DATA_OBJECT_TYPE, + PermissionManager.VIRTUAL_PUBLIC_ID)); + } catch (DataObjectNotFoundException ex) { + throw new UncheckedWrapperException("cannot find the public", + ex); + } - members.addMemberOrSubgroup(thePublic); - members.save(); - } + members.addMemberOrSubgroup(thePublic); + members.save(); + } - setParty(members); + setParty(members); } public static WorkspaceCollection retrieveAll() { return retrieveAll(null); } - public static WorkspaceCollection retrieveAll(Application parent) { - DataCollection wks = SessionManager.getSession().retrieve( - BASE_DATA_OBJECT_TYPE); - if (parent != null) { - wks.addEqualsFilter("parentResource.id", parent.getID()); - } + public static WorkspaceCollection retrieveAll(Application parent) { + DataCollection wks = SessionManager.getSession().retrieve( + BASE_DATA_OBJECT_TYPE); + if (parent != null) { + wks.addEqualsFilter("parentResource.id", parent.getID()); + } - return new WorkspaceCollection(wks); - } + return new WorkspaceCollection(wks); + } - public Workspace retrieveSubworkspaceForParty(Party owner) - throws DataObjectNotFoundException { + public Workspace retrieveSubworkspaceForParty(Party owner) + throws DataObjectNotFoundException { - DataCollection wks = SessionManager.getSession().retrieve( - BASE_DATA_OBJECT_TYPE); + DataCollection wks = SessionManager.getSession().retrieve( + BASE_DATA_OBJECT_TYPE); - wks.addEqualsFilter("parentResource.id", getID()); - wks.addEqualsFilter(PARTY_ID, owner.getID()); + wks.addEqualsFilter("parentResource.id", getID()); + wks.addEqualsFilter(PARTY_ID, owner.getID()); - if (wks.next()) { - Workspace workspace = (Workspace) Application - .retrieveApplication(wks.getDataObject()); + if (wks.next()) { + Workspace workspace = (Workspace) Application.retrieveApplication(wks. + getDataObject()); - wks.close(); + wks.close(); - return workspace; - } + return workspace; + } - throw new DataObjectNotFoundException("cannot find workspace for party"); - } + throw new DataObjectNotFoundException("cannot find workspace for party"); + } - public void delete() { - clearPages(); + public void delete() { + clearPages(); - super.delete(); - } + super.delete(); + } - public void clearPages() { - WorkspacePageCollection pages = getPages(); - while (pages.next()) { - WorkspacePage page = pages.getPage(); - page.delete(); - } - } + public void clearPages() { + WorkspacePageCollection pages = getPages(); + while (pages.next()) { + WorkspacePage page = pages.getPage(); + page.delete(); + } + } - public void setDefaultLayout(PageLayout layout) { - setAssociation(DEFAULT_LAYOUT, layout); - } + public void setDefaultLayout(PageLayout layout) { + setAssociation(DEFAULT_LAYOUT, layout); + } - public PageLayout getDefaultLayout() { - return (PageLayout) DomainObjectFactory - .newInstance((DataObject) get(DEFAULT_LAYOUT)); - } + public PageLayout getDefaultLayout() { + return (PageLayout) DomainObjectFactory.newInstance((DataObject) get( + DEFAULT_LAYOUT)); + } - public void setParty(Party party) { - setAssociation(PARTY, party); - } + public void setParty(Party party) { + setAssociation(PARTY, party); + } - public Party getParty() { - return (Party) DomainObjectFactory.newInstance((DataObject) get(PARTY)); - } + public Party getParty() { + return (Party) DomainObjectFactory.newInstance((DataObject) get(PARTY)); + } public RoleCollection getRoles() { Party party = getParty(); @@ -461,12 +455,12 @@ public class Workspace extends Application { public PartyCollection getNonParticipants() { DataCollection dc = - SessionManager.getSession() - .retrieve("com.arsdigita.kernel.User"); + SessionManager.getSession().retrieve( + "com.arsdigita.kernel.User"); // .retrieve("com.arsdigita.kernel.Party"); - Filter f = dc - .addNotInSubqueryFilter - ("id", "com.arsdigita.london.portal.WorkspaceParticipantIDs"); + Filter f = + dc.addNotInSubqueryFilter("id", + "com.arsdigita.london.portal.WorkspaceParticipantIDs"); f.set("workspaceID", getID()); return new PartyCollection(dc); } @@ -484,8 +478,8 @@ public class Workspace extends Application { * alphabetical order.

**/ public Iterator getParticipantInitials() { - DataQuery query = SessionManager.getSession().retrieveQuery - ("com.arsdigita.london.portal.WorkspaceParticipantInitials"); + DataQuery query = SessionManager.getSession().retrieveQuery( + "com.arsdigita.london.portal.WorkspaceParticipantInitials"); query.setParameter("workspaceID", getID()); LinkedList result = new LinkedList(); @@ -508,7 +502,7 @@ public class Workspace extends Application { Assert.exists(initial); Assert.isTrue(initial.length() == 1, "Initial needs length 1"); Assert.isTrue(initial.equals(initial.toUpperCase()), - "Initial must be uppercase"); + "Initial must be uppercase"); //DataAssociationCursor dac = // ((DataAssociation) get("participants")).cursor(); @@ -516,32 +510,33 @@ public class Workspace extends Application { // ("id", "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial"); DataCollection dc = - SessionManager.getSession() - .retrieve("com.arsdigita.kernel.User"); - Filter f = dc.addInSubqueryFilter - ("id", "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial"); + SessionManager.getSession().retrieve( + "com.arsdigita.kernel.User"); + Filter f = + dc.addInSubqueryFilter("id", + "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial"); f.set("workspaceID", getID()); f.set("nameInitial", initial); return new PartyCollection(dc); } - public WorkspacePageCollection getPages() { - DataAssociation pages = (DataAssociation) get(PAGES); - return new WorkspacePageCollection(pages.cursor()); - } + public WorkspacePageCollection getPages() { + DataAssociation pages = (DataAssociation) get(PAGES); + return new WorkspacePageCollection(pages.cursor()); + } - public void movePageLeft(WorkspacePage workspacePage) { + public void movePageLeft(WorkspacePage workspacePage) { // loop through the pages and look for the previous one - WorkspacePageCollection pages = getPages(); - pages.addOrder(WorkspacePage.SORT_KEY); - int i = 0; + WorkspacePageCollection pages = getPages(); + pages.addOrder(WorkspacePage.SORT_KEY); + int i = 0; WorkspacePage previous = null; WorkspacePage current = null; - while (pages.next()) { - current = pages.getPage(); + while (pages.next()) { + current = pages.getPage(); if (current.equals(workspacePage)) { if (previous == null) { // current is first @@ -555,19 +550,19 @@ public class Workspace extends Application { } previous = current; } - } + } - public void movePageRight(WorkspacePage workspacePage) { + public void movePageRight(WorkspacePage workspacePage) { // loop through the pages and look for the next one - WorkspacePageCollection pages = getPages(); - pages.addOrder(WorkspacePage.SORT_KEY); - int i = 0; + WorkspacePageCollection pages = getPages(); + pages.addOrder(WorkspacePage.SORT_KEY); + int i = 0; WorkspacePage previous = null; WorkspacePage current = null; - while (pages.next()) { - current = pages.getPage(); + while (pages.next()) { + current = pages.getPage(); if (previous != null && previous.equals(workspacePage)) { int currentKey = current.getSortKey(); int previousKey = previous.getSortKey(); @@ -577,73 +572,73 @@ public class Workspace extends Application { } previous = current; } - } + } - public void removePage(WorkspacePage workspacePage) { - WorkspacePageCollection pages = getPages(); - pages.addOrder(WorkspacePage.SORT_KEY); - int i = 0; - while (pages.next()) { - WorkspacePage page = pages.getPage(); - if (page.equals(workspacePage)) { - page.delete(); - } else { - page.setSortKey(i++); - } - } - } + public void removePage(WorkspacePage workspacePage) { + WorkspacePageCollection pages = getPages(); + pages.addOrder(WorkspacePage.SORT_KEY); + int i = 0; + while (pages.next()) { + WorkspacePage page = pages.getPage(); + if (page.equals(workspacePage)) { + page.delete(); + } else { + page.setSortKey(i++); + } + } + } - public WorkspacePage addPage(String title, String description) { - DataAssociationCursor pages = ((DataAssociation) get(PAGES)).cursor(); - pages.addOrder(WorkspacePage.SORT_KEY + " desc"); - int max = -1; - if (pages.next()) { - DataObject dobj = pages.getDataObject(); - Integer tab = (Integer) dobj.get(WorkspacePage.SORT_KEY); - max = tab.intValue(); - pages.close(); - } + public WorkspacePage addPage(String title, String description) { + DataAssociationCursor pages = ((DataAssociation) get(PAGES)).cursor(); + pages.addOrder(WorkspacePage.SORT_KEY + " desc"); + int max = -1; + if (pages.next()) { + DataObject dobj = pages.getDataObject(); + Integer tab = (Integer) dobj.get(WorkspacePage.SORT_KEY); + max = tab.intValue(); + pages.close(); + } - return addPage(title, description, getDefaultLayout(), max + 1); - } + return addPage(title, description, getDefaultLayout(), max + 1); + } - public WorkspacePage addPage(String title, String description, - PageLayout layout, int sortKey) { - return WorkspacePage.create(title, description, layout, this, sortKey); - } + public WorkspacePage addPage(String title, String description, + PageLayout layout, int sortKey) { + return WorkspacePage.create(title, description, layout, this, sortKey); + } - public void setTheme(WorkspaceTheme theme) { - set("theme", theme); - } + public void setTheme(WorkspaceTheme theme) { + set("theme", theme); + } - public WorkspaceTheme getTheme() { - DataObject dobj; + public WorkspaceTheme getTheme() { + DataObject dobj; - dobj = (DataObject) get("theme"); + dobj = (DataObject) get("theme"); - if (dobj == null) - return null; - else { - WorkspaceTheme theme = new WorkspaceTheme(dobj); - return theme; - } - } + if (dobj == null) { + return null; + } else { + WorkspaceTheme theme = new WorkspaceTheme(dobj); + return theme; + } + } + + public static Workspace getCurrentlySelectedWorkspace() { + Application current = Web.getContext().getApplication(); + if (current instanceof Workspace) { + return (Workspace) current; + } + return null; + } - public static Workspace getCurrentlySelectedWorkspace() { - Application current = Web.getContext().getApplication(); - if (current instanceof Workspace) { - return (Workspace) current; - } - return null; - } - public WorkspaceCollection getChildWorkspaces() { - DataQuery query = SessionManager.getSession().retrieveQuery - ("com.arsdigita.london.portal.childWorkspacesForApplicationID"); + DataQuery query = SessionManager.getSession().retrieveQuery( + "com.arsdigita.london.portal.childWorkspacesForApplicationID"); query.setParameter("applicationID", getID()); DataCollection collection = - new DataQueryDataCollectionAdapter(query, "workspace"); + new DataQueryDataCollectionAdapter(query, "workspace"); //collection.addEqualsFilter("isArchived", Boolean.FALSE); query.close(); @@ -670,93 +665,92 @@ public class Workspace extends Application { return applications; } - /** - * Get's the description for a Workspace. - */ + /** + * Get's the description for a Workspace. + */ // public String getDescription() { // return (String) get("description"); // } - - /** - * Set's the description for a Workspace. - */ + /** + * Set's the description for a Workspace. + */ // public void setDescription(String description) { // set("description", description); // } + /** + * Sets the user who owns the workspace + * + * @param user + */ + public void setOwner(User user) { + s_log.debug("setOwner called for " + this.getDisplayName()); + set("owner", user); + } - /** - * Sets the user who owns the workspace - * - * @param user - */ - public void setOwner(User user) { - s_log.debug("setOwner called for " + this.getDisplayName()); - set("owner", user); - } + public User getOwner() { + return (User) get("owner"); + } - public User getOwner() { - return (User) get("owner"); - } + public static Workspace createPersonalWorkspace(final User owner) { - public static Workspace createPersonalWorkspace(final User owner) { + s_log.debug("creating the personal portal for " + + owner.getDisplayName()); - s_log.debug("creating the personal portal for " - + owner.getDisplayName()); + String url = "" + owner.getID(); + String title = "Personal Workspace for " + owner.getDisplayName(); + Application parent = Application.retrieveApplicationForPath( + PersonalPortalPage.PERSONAL_PORTAL_PATH); + final Workspace workspace = createWorkspace(url, title, parent, false); - String url = "" + owner.getID(); - String title = "Personal Workspace for " + owner.getDisplayName(); - Application parent = Application - .retrieveApplicationForPath(PersonalPortalPage.PERSONAL_PORTAL_PATH); - final Workspace workspace = createWorkspace(url, title, parent, false); + // TODO the setOwner method should probably deal with all the + // permissions then later on ownership could be changed + Group group = (Group) workspace.getParty(); + group.addMember(owner); + workspace.setOwner(owner); + new KernelExcursion() { - // TODO the setOwner method should probably deal with all the - // permissions then later on ownership could be changed - Group group = (Group) workspace.getParty(); - group.addMember(owner); - workspace.setOwner(owner); - new KernelExcursion() { - public void excurse() { - setEffectiveParty(Kernel.getSystemParty()); - PermissionDescriptor pd = new PermissionDescriptor( - PrivilegeDescriptor.ADMIN, workspace, owner); - PermissionService.grantPermission(pd); - } - }.run(); - // check that the user is no longer system user - Party party = KernelHelper.getCurrentEffectiveParty(); - s_log.debug("party after excurse is " + party.getDisplayName()); + public void excurse() { + setEffectiveParty(Kernel.getSystemParty()); + PermissionDescriptor pd = new PermissionDescriptor( + PrivilegeDescriptor.ADMIN, workspace, owner); + PermissionService.grantPermission(pd); + } + }.run(); + // check that the user is no longer system user + Party party = KernelHelper.getCurrentEffectiveParty(); + s_log.debug("party after excurse is " + party.getDisplayName()); - Role admins = group.getRole("Administrators"); - if (admins == null) { - admins = group.createRole("Administrators"); - admins.add(owner); - admins.save(); - } + Role admins = group.getRole("Administrators"); + if (admins == null) { + admins = group.createRole("Administrators"); + admins.add(owner); + admins.save(); + } - workspace.setDefaultLayout(PageLayout.getDefaultLayout()); + workspace.setDefaultLayout(PageLayout.getDefaultLayout()); // set the parent app to null // so that the base personal portal doesn't appear anywhere workspace.setParentApplication(null); - return workspace; - } + return workspace; + } - public static Workspace retrievePersonalWorkspace(User owner) { - DataCollection personalWorkspaces = SessionManager.getSession() - .retrieve(BASE_DATA_OBJECT_TYPE); - personalWorkspaces.addEqualsFilter("owner", owner.getID()); + public static Workspace retrievePersonalWorkspace(User owner) { + DataCollection personalWorkspaces = SessionManager.getSession().retrieve( + BASE_DATA_OBJECT_TYPE); + personalWorkspaces.addEqualsFilter("owner", owner.getID()); - if (personalWorkspaces.next()) { - Workspace workspace = (Workspace) Application - .retrieveApplication(personalWorkspaces.getDataObject()); - if (personalWorkspaces.next()) - s_log.error("more than one personal workspaces for this user!!"); - personalWorkspaces.close(); - - return workspace; - } - return null; - } + if (personalWorkspaces.next()) { + Workspace workspace = (Workspace) Application.retrieveApplication(personalWorkspaces. + getDataObject()); + if (personalWorkspaces.next()) { + s_log.error("more than one personal workspaces for this user!!"); + } + personalWorkspaces.close(); + return workspace; + } + return null; + } } diff --git a/ccm-ldn-portal/src/com/arsdigita/london/portal/portlet/RSSFeedPortletHelper.java b/ccm-ldn-portal/src/com/arsdigita/london/portal/portlet/RSSFeedPortletHelper.java index 4558e2404..f666fc593 100755 --- a/ccm-ldn-portal/src/com/arsdigita/london/portal/portlet/RSSFeedPortletHelper.java +++ b/ccm-ldn-portal/src/com/arsdigita/london/portal/portlet/RSSFeedPortletHelper.java @@ -12,7 +12,6 @@ * rights and limitations under the License. * */ - package com.arsdigita.london.portal.portlet; import java.io.IOException; @@ -42,126 +41,121 @@ import com.arsdigita.xml.Element; public class RSSFeedPortletHelper { - private static final Logger s_log = Logger - .getLogger(RSSFeedPortletHelper.class); + private static final Logger s_log = Logger.getLogger( + RSSFeedPortletHelper.class); + private static final String CACHE_SERVICE_KEY = "RSSFeedPortletHelper"; + private static final URLCache cache = new URLCache(1000000, 15 * 60 * 1000); + private static final URLPool pool = new URLPool(); - private static final String CACHE_SERVICE_KEY = "RSSFeedPortletHelper"; + static { + s_log.debug("Static initalizer starting..."); + URLFetcher.registerService(CACHE_SERVICE_KEY, pool, cache); + s_log.debug("Static initalizer finished."); + } - private static final URLCache cache = new URLCache(1000000, 15 * 60 * 1000); + public static Element getRSSElement(String location) { + s_log.debug("getRSSElement from " + location); + try { + URLData data = URLFetcher.fetchURLData(location, CACHE_SERVICE_KEY); + Document doc = new Document(data.getContent()); + return doc.getRootElement(); + } catch (Exception ex) { + // XXX + s_log.warn("Problem with fetching " + location); + return null; + } + } - private static final URLPool pool = new URLPool(); + public static Iterator getACSJHosts() { + return parseRSSFeed(com.arsdigita.web.URL.there( + "/channels/rss/acsj.rss", null).getURL()); + } - static { - URLFetcher.registerService(CACHE_SERVICE_KEY, pool, cache); - }; + public static Iterator getExternalFeeds() { + return parseRSSFeed(com.arsdigita.web.URL.there( + "/channels/rss/external.rss", null).getURL()); + } - public static Element getRSSElement(String location) { - s_log.debug("getRSSElement from " + location); - try { - URLData data = URLFetcher.fetchURLData(location, CACHE_SERVICE_KEY); - Document doc = new Document(data.getContent()); - return doc.getRootElement(); - } catch (Exception ex) { - // XXX - s_log.warn("Problem with fetching " + location); - return null; - } - } + public static Iterator getACSJFeeds(String host) { + return parseRSSFeed(host); + } - public static Iterator getACSJHosts() { - return parseRSSFeed(com.arsdigita.web.URL.there( - "/channels/rss/acsj.rss", null).getURL()); - } + public static Iterator parseRSSFeed(String location) { + List list = new ArrayList(); - public static Iterator getExternalFeeds() { - return parseRSSFeed(com.arsdigita.web.URL.there( - "/channels/rss/external.rss", null).getURL()); - } + try { + URL url = new URL(location); + URLConnection con = url.openConnection(); - public static Iterator getACSJFeeds(String host) { - return parseRSSFeed(host); - } + InputStream is = con.getInputStream(); + try { + SAXParserFactory spf = SAXParserFactory.newInstance(); + SAXParser parser = spf.newSAXParser(); + parser.parse(is, new ItemExtractor(list)); + } catch (ParserConfigurationException e) { + s_log.error("error parsing rss feed", e); + } catch (SAXException e) { + s_log.error("error parsing rss feed", e); + } catch (IOException e) { + s_log.error("error parsing rss feed", e); + } + } catch (MalformedURLException mal) { + mal.printStackTrace(); + // nada + } catch (IOException io) { + io.printStackTrace(); + // nada + } - public static Iterator parseRSSFeed(String location) { - List list = new ArrayList(); + return list.iterator(); + } - try { - URL url = new URL(location); - URLConnection con = url.openConnection(); + protected static class ItemExtractor extends DefaultHandler { - InputStream is = con.getInputStream(); - try { - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser parser = spf.newSAXParser(); - parser.parse(is, new ItemExtractor(list)); - } catch (ParserConfigurationException e) { - s_log.error("error parsing rss feed", e); - } catch (SAXException e) { - s_log.error("error parsing rss feed", e); - } catch (IOException e) { - s_log.error("error parsing rss feed", e); - } - } catch (MalformedURLException mal) { - mal.printStackTrace(); - // nada - } catch (IOException io) { - io.printStackTrace(); - // nada - } + private List m_items; + private boolean m_item; + private String m_url; + private String m_title; + private StringBuffer m_scratch; - return list.iterator(); - } + public ItemExtractor(List items) { + m_items = items; + m_item = false; + m_scratch = new StringBuffer(""); + } - protected static class ItemExtractor extends DefaultHandler { + public void characters(char[] ch, int start, int len) { + for (int i = 0; i < len; i++) { + m_scratch.append(ch[start + i]); + } + } - private List m_items; + public void startElement(String uri, String localName, String qn, + Attributes attrs) { + if (m_item == false) { + if (qn.equals("item")) { + m_item = true; + m_title = null; + m_url = null; + } + } else { + if (qn.equals("title") || qn.equals("link")) { + m_scratch = new StringBuffer(); + } + } + } - private boolean m_item; - - private String m_url; - - private String m_title; - - private StringBuffer m_scratch; - - public ItemExtractor(List items) { - m_items = items; - m_item = false; - m_scratch = new StringBuffer(""); - } - - public void characters(char[] ch, int start, int len) { - for (int i = 0; i < len; i++) { - m_scratch.append(ch[start + i]); - } - } - - public void startElement(String uri, String localName, String qn, - Attributes attrs) { - if (m_item == false) { - if (qn.equals("item")) { - m_item = true; - m_title = null; - m_url = null; - } - } else { - if (qn.equals("title") || qn.equals("link")) { - m_scratch = new StringBuffer(); - } - } - } - - public void endElement(String uri, String localName, String qn) { - if (m_item == true) { - if (qn.equals("title")) { - m_title = m_scratch.toString(); - } else if (qn.equals("link")) { - m_url = m_scratch.toString(); - } else if (qn.equals("item")) { - m_items.add(new String[] { m_url, m_title }); - m_item = false; - } - } - } - } + public void endElement(String uri, String localName, String qn) { + if (m_item == true) { + if (qn.equals("title")) { + m_title = m_scratch.toString(); + } else if (qn.equals("link")) { + m_url = m_scratch.toString(); + } else if (qn.equals("item")) { + m_items.add(new String[]{m_url, m_title}); + m_item = false; + } + } + } + } } diff --git a/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/Icons.java b/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/Icons.java index bd389c50e..b44e856b1 100755 --- a/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/Icons.java +++ b/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/Icons.java @@ -16,6 +16,7 @@ package com.arsdigita.london.portal.ui; import com.arsdigita.bebop.Image; +import org.apache.log4j.Logger; /** * This class contains Images for the various CW icons. These image @@ -25,6 +26,8 @@ import com.arsdigita.bebop.Image; **/ public class Icons { + private static final Logger logger = Logger.getLogger(Icons.class); + public static final Image USER_16; public static final Image GROUP_16; public static final Image LEFT_16; @@ -40,6 +43,7 @@ public class Icons { public static final Image TRASH_16; static { + logger.debug("Static initalizer starting..."); USER_16 = new Image("/packages/workspace/www/assets/User16.gif"); USER_16.setBorder("0"); USER_16.lock(); @@ -97,5 +101,6 @@ public class Icons { TRASH_16 = new Image("/packages/workspace/www/assets/delete.gif"); TRASH_16.setBorder("0"); TRASH_16.lock(); + logger.debug("Static initalizer finished."); } }; diff --git a/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/admin/GrantsTable.java b/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/admin/GrantsTable.java index b280dddf4..dfd91bc80 100755 --- a/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/admin/GrantsTable.java +++ b/ccm-ldn-portal/src/com/arsdigita/london/portal/ui/admin/GrantsTable.java @@ -125,6 +125,7 @@ abstract class GrantsTable extends Table { private static TableCellRenderer[] s_viewCellRenderers; static { + s_log.debug("Static initalizer starting..."); int n = Grant.s_interestingPrivileges.length; s_editCellRenderers = new TableCellRenderer[n]; s_viewCellRenderers = new TableCellRenderer[n]; @@ -134,6 +135,7 @@ abstract class GrantsTable extends Table { s_viewCellRenderers[i] = new ViewPrivilegeCellRenderer(Grant.s_interestingPrivileges[i]); } + s_log.debug("Static initalizer finished."); } // Per-request label for renderer getComponent calls diff --git a/ccm-ldn-rss/src/com/arsdigita/london/rss/RSS.java b/ccm-ldn-rss/src/com/arsdigita/london/rss/RSS.java index 26bcb481e..a2ef1bf55 100755 --- a/ccm-ldn-rss/src/com/arsdigita/london/rss/RSS.java +++ b/ccm-ldn-rss/src/com/arsdigita/london/rss/RSS.java @@ -22,21 +22,25 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.web.Application; +import org.apache.log4j.Logger; /** * Base class of the RSS application (module). * */ public class RSS extends Application { - + + private static final Logger logger = Logger.getLogger(RSS.class); + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.rss.RSS"; - private static final RSSConfig s_config = new RSSConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } /** diff --git a/ccm-ldn-rss/src/com/arsdigita/london/rss/RSSService.java b/ccm-ldn-rss/src/com/arsdigita/london/rss/RSSService.java index f7798a6d5..23a3d2b71 100755 --- a/ccm-ldn-rss/src/com/arsdigita/london/rss/RSSService.java +++ b/ccm-ldn-rss/src/com/arsdigita/london/rss/RSSService.java @@ -69,7 +69,9 @@ public class RSSService { private static final RSSConfig s_config = new RSSConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static RSSConfig getConfig() { diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/Search.java b/ccm-ldn-search/src/com/arsdigita/london/search/Search.java index 4bd0bd264..d7799de7c 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/Search.java +++ b/ccm-ldn-search/src/com/arsdigita/london/search/Search.java @@ -22,20 +22,24 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.web.Application; +import org.apache.log4j.Logger; /** * Base class for the search application (module) * */ public class Search extends Application { - + + private static final Logger logger = Logger.getLogger(Search.class); public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.search.Search"; private static SearchConfig s_config = new SearchConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static SearchConfig getConfig() { diff --git a/ccm-ldn-shortcuts/src/com/arsdigita/london/shortcuts/Shortcuts.java b/ccm-ldn-shortcuts/src/com/arsdigita/london/shortcuts/Shortcuts.java index e663df5af..5ed81e4fc 100755 --- a/ccm-ldn-shortcuts/src/com/arsdigita/london/shortcuts/Shortcuts.java +++ b/ccm-ldn-shortcuts/src/com/arsdigita/london/shortcuts/Shortcuts.java @@ -22,20 +22,25 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.web.Application; +import org.apache.log4j.Logger; /** * Base class of the shortcuts application. * */ public class Shortcuts extends Application { - + + private static final Logger logger = Logger.getLogger(Shortcuts.class); + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.shortcuts.Shortcuts"; private static ShortcutsConfig s_config = new ShortcutsConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public static ShortcutsConfig getConfig() { diff --git a/ccm-ldn-subsite/src/com/arsdigita/london/subsite/Subsite.java b/ccm-ldn-subsite/src/com/arsdigita/london/subsite/Subsite.java index 7c517a8c3..0058da7de 100755 --- a/ccm-ldn-subsite/src/com/arsdigita/london/subsite/Subsite.java +++ b/ccm-ldn-subsite/src/com/arsdigita/london/subsite/Subsite.java @@ -43,7 +43,9 @@ public class Subsite extends Application { private static final SubsiteConfig s_config = new SubsiteConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } private static final SubsiteContext s_context = new SubsiteContext(); diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/Terms.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/Terms.java index 16c0e35a5..f60e748fa 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/Terms.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/Terms.java @@ -15,40 +15,42 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.london.terms; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.web.Application; import com.arsdigita.xml.Element; - +import org.apache.log4j.Logger; /** * Base class of the ccm-ldn-terms application (module) * */ public class Terms extends Application { - - public static final String XML_NS = "http://xmlns.redhat.com/london/terms/1.0"; - public static final String XML_PREFIX = "terms"; + private static final Logger logger = Logger.getLogger(Terms.class); + public static final String XML_NS = + "http://xmlns.redhat.com/london/terms/1.0"; + public static final String XML_PREFIX = "terms"; private static TermsConfig s_config = new TermsConfig(); + static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } - + public static TermsConfig getConfig() { return s_config; } - + public Element newElement(String name) { return new Element(XML_PREFIX + ":" + name, XML_NS); } - - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.london.terms.Terms"; + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.london.terms.Terms"; public Terms(DataObject obj) { super(obj); @@ -65,7 +67,6 @@ public class Terms extends Application { // public String getContextPath() { // return "/ccm-ldn-terms"; // } - /** * Returns the path name of the location of the applications servlet/JSP. * @@ -98,5 +99,4 @@ public class Terms extends Application { // return "/files"; return "/ccm-ldn-terms/files"; } - } diff --git a/ccm-ldn-terms/src/kea/stemmers/LovinsStemmer.java b/ccm-ldn-terms/src/kea/stemmers/LovinsStemmer.java index f38adf10f..2caf95709 100644 --- a/ccm-ldn-terms/src/kea/stemmers/LovinsStemmer.java +++ b/ccm-ldn-terms/src/kea/stemmers/LovinsStemmer.java @@ -1,9 +1,8 @@ package kea.stemmers; - import java.io.Serializable; import java.util.HashMap; - +import org.apache.log4j.Logger; /** * Implements the Lovins stemmer. @@ -13,868 +12,905 @@ import java.util.HashMap; */ public class LovinsStemmer extends Stemmer implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(LovinsStemmer.class); + /** + * + */ + private static final long serialVersionUID = 1L; + /** C version compatibility mode (emulates bugs + in original C implementation) */ + private static boolean m_CompMode = true; + /** The hash tables containing the list of endings. */ + private static HashMap m_l11 = null; + private static HashMap m_l10 = null; + private static HashMap m_l9 = null; + private static HashMap m_l8 = null; + private static HashMap m_l7 = null; + private static HashMap m_l6 = null; + private static HashMap m_l5 = null; + private static HashMap m_l4 = null; + private static HashMap m_l3 = null; + private static HashMap m_l2 = null; + private static HashMap m_l1 = null; -/** C version compatibility mode (emulates bugs - in original C implementation) */ - private static boolean m_CompMode = true; - - /** The hash tables containing the list of endings. */ - private static HashMap m_l11 = null; - private static HashMap m_l10 = null; - private static HashMap m_l9 = null; - private static HashMap m_l8 = null; - private static HashMap m_l7 = null; - private static HashMap m_l6 = null; - private static HashMap m_l5 = null; - private static HashMap m_l4 = null; - private static HashMap m_l3 = null; - private static HashMap m_l2 = null; - private static HashMap m_l1 = null; - - static { - - m_l11 = new HashMap(); - m_l11.put("alistically", "B"); - m_l11.put("arizability", "A"); - m_l11.put("izationally", "B"); - m_l10 = new HashMap(); - m_l10.put("antialness", "A"); - m_l10.put("arisations", "A"); - m_l10.put("arizations", "A"); - m_l10.put("entialness", "A"); - m_l9 = new HashMap(); - m_l9.put("allically", "C"); - m_l9.put("antaneous", "A"); - m_l9.put("antiality", "A"); - m_l9.put("arisation", "A"); - m_l9.put("arization", "A"); - m_l9.put("ationally", "B"); - m_l9.put("ativeness", "A"); - m_l9.put("eableness", "E"); - m_l9.put("entations", "A"); - m_l9.put("entiality", "A"); - m_l9.put("entialize", "A"); - m_l9.put("entiation", "A"); - m_l9.put("ionalness", "A"); - m_l9.put("istically", "A"); - m_l9.put("itousness", "A"); - m_l9.put("izability", "A"); - m_l9.put("izational", "A"); - m_l8 = new HashMap(); - m_l8.put("ableness", "A"); - m_l8.put("arizable", "A"); - m_l8.put("entation", "A"); - m_l8.put("entially", "A"); - m_l8.put("eousness", "A"); - m_l8.put("ibleness", "A"); - m_l8.put("icalness", "A"); - m_l8.put("ionalism", "A"); - m_l8.put("ionality", "A"); - m_l8.put("ionalize", "A"); - m_l8.put("iousness", "A"); - m_l8.put("izations", "A"); - m_l8.put("lessness", "A"); - m_l7 = new HashMap(); - m_l7.put("ability", "A"); - m_l7.put("aically", "A"); - m_l7.put("alistic", "B"); - m_l7.put("alities", "A"); - m_l7.put("ariness", "E"); - m_l7.put("aristic", "A"); - m_l7.put("arizing", "A"); - m_l7.put("ateness", "A"); - m_l7.put("atingly", "A"); - m_l7.put("ational", "B"); - m_l7.put("atively", "A"); - m_l7.put("ativism", "A"); - m_l7.put("elihood", "E"); - m_l7.put("encible", "A"); - m_l7.put("entally", "A"); - m_l7.put("entials", "A"); - m_l7.put("entiate", "A"); - m_l7.put("entness", "A"); - m_l7.put("fulness", "A"); - m_l7.put("ibility", "A"); - m_l7.put("icalism", "A"); - m_l7.put("icalist", "A"); - m_l7.put("icality", "A"); - m_l7.put("icalize", "A"); - m_l7.put("ication", "G"); - m_l7.put("icianry", "A"); - m_l7.put("ination", "A"); - m_l7.put("ingness", "A"); - m_l7.put("ionally", "A"); - m_l7.put("isation", "A"); - m_l7.put("ishness", "A"); - m_l7.put("istical", "A"); - m_l7.put("iteness", "A"); - m_l7.put("iveness", "A"); - m_l7.put("ivistic", "A"); - m_l7.put("ivities", "A"); - m_l7.put("ization", "F"); - m_l7.put("izement", "A"); - m_l7.put("oidally", "A"); - m_l7.put("ousness", "A"); - m_l6 = new HashMap(); - m_l6.put("aceous", "A"); - m_l6.put("acious", "B"); - m_l6.put("action", "G"); - m_l6.put("alness", "A"); - m_l6.put("ancial", "A"); - m_l6.put("ancies", "A"); - m_l6.put("ancing", "B"); - m_l6.put("ariser", "A"); - m_l6.put("arized", "A"); - m_l6.put("arizer", "A"); - m_l6.put("atable", "A"); - m_l6.put("ations", "B"); - m_l6.put("atives", "A"); - m_l6.put("eature", "Z"); - m_l6.put("efully", "A"); - m_l6.put("encies", "A"); - m_l6.put("encing", "A"); - m_l6.put("ential", "A"); - m_l6.put("enting", "C"); - m_l6.put("entist", "A"); - m_l6.put("eously", "A"); - m_l6.put("ialist", "A"); - m_l6.put("iality", "A"); - m_l6.put("ialize", "A"); - m_l6.put("ically", "A"); - m_l6.put("icance", "A"); - m_l6.put("icians", "A"); - m_l6.put("icists", "A"); - m_l6.put("ifully", "A"); - m_l6.put("ionals", "A"); - m_l6.put("ionate", "D"); - m_l6.put("ioning", "A"); - m_l6.put("ionist", "A"); - m_l6.put("iously", "A"); - m_l6.put("istics", "A"); - m_l6.put("izable", "E"); - m_l6.put("lessly", "A"); - m_l6.put("nesses", "A"); - m_l6.put("oidism", "A"); - m_l5 = new HashMap(); - m_l5.put("acies", "A"); - m_l5.put("acity", "A"); - m_l5.put("aging", "B"); - m_l5.put("aical", "A"); - if (!m_CompMode) { - m_l5.put("alist", "A"); - } - m_l5.put("alism", "B"); - m_l5.put("ality", "A"); - m_l5.put("alize", "A"); - m_l5.put("allic", "b"); - m_l5.put("anced", "B"); - m_l5.put("ances", "B"); - m_l5.put("antic", "C"); - m_l5.put("arial", "A"); - m_l5.put("aries", "A"); - m_l5.put("arily", "A"); - m_l5.put("arity", "B"); - m_l5.put("arize", "A"); - m_l5.put("aroid", "A"); - m_l5.put("ately", "A"); - m_l5.put("ating", "I"); - m_l5.put("ation", "B"); - m_l5.put("ative", "A"); - m_l5.put("ators", "A"); - m_l5.put("atory", "A"); - m_l5.put("ature", "E"); - m_l5.put("early", "Y"); - m_l5.put("ehood", "A"); - m_l5.put("eless", "A"); - if (!m_CompMode) { - m_l5.put("elily", "A"); - } else { - m_l5.put("elity", "A"); - } - m_l5.put("ement", "A"); - m_l5.put("enced", "A"); - m_l5.put("ences", "A"); - m_l5.put("eness", "E"); - m_l5.put("ening", "E"); - m_l5.put("ental", "A"); - m_l5.put("ented", "C"); - m_l5.put("ently", "A"); - m_l5.put("fully", "A"); - m_l5.put("ially", "A"); - m_l5.put("icant", "A"); - m_l5.put("ician", "A"); - m_l5.put("icide", "A"); - m_l5.put("icism", "A"); - m_l5.put("icist", "A"); - m_l5.put("icity", "A"); - m_l5.put("idine", "I"); - m_l5.put("iedly", "A"); - m_l5.put("ihood", "A"); - m_l5.put("inate", "A"); - m_l5.put("iness", "A"); - m_l5.put("ingly", "B"); - m_l5.put("inism", "J"); - m_l5.put("inity", "c"); - m_l5.put("ional", "A"); - m_l5.put("ioned", "A"); - m_l5.put("ished", "A"); - m_l5.put("istic", "A"); - m_l5.put("ities", "A"); - m_l5.put("itous", "A"); - m_l5.put("ively", "A"); - m_l5.put("ivity", "A"); - m_l5.put("izers", "F"); - m_l5.put("izing", "F"); - m_l5.put("oidal", "A"); - m_l5.put("oides", "A"); - m_l5.put("otide", "A"); - m_l5.put("ously", "A"); - m_l4 = new HashMap(); - m_l4.put("able", "A"); - m_l4.put("ably", "A"); - m_l4.put("ages", "B"); - m_l4.put("ally", "B"); - m_l4.put("ance", "B"); - m_l4.put("ancy", "B"); - m_l4.put("ants", "B"); - m_l4.put("aric", "A"); - m_l4.put("arly", "K"); - m_l4.put("ated", "I"); - m_l4.put("ates", "A"); - m_l4.put("atic", "B"); - m_l4.put("ator", "A"); - m_l4.put("ealy", "Y"); - m_l4.put("edly", "E"); - m_l4.put("eful", "A"); - m_l4.put("eity", "A"); - m_l4.put("ence", "A"); - m_l4.put("ency", "A"); - m_l4.put("ened", "E"); - m_l4.put("enly", "E"); - m_l4.put("eous", "A"); - m_l4.put("hood", "A"); - m_l4.put("ials", "A"); - m_l4.put("ians", "A"); - m_l4.put("ible", "A"); - m_l4.put("ibly", "A"); - m_l4.put("ical", "A"); - m_l4.put("ides", "L"); - m_l4.put("iers", "A"); - m_l4.put("iful", "A"); - m_l4.put("ines", "M"); - m_l4.put("ings", "N"); - m_l4.put("ions", "B"); - m_l4.put("ious", "A"); - m_l4.put("isms", "B"); - m_l4.put("ists", "A"); - m_l4.put("itic", "H"); - m_l4.put("ized", "F"); - m_l4.put("izer", "F"); - m_l4.put("less", "A"); - m_l4.put("lily", "A"); - m_l4.put("ness", "A"); - m_l4.put("ogen", "A"); - m_l4.put("ward", "A"); - m_l4.put("wise", "A"); - m_l4.put("ying", "B"); - m_l4.put("yish", "A"); - m_l3 = new HashMap(); - m_l3.put("acy", "A"); - m_l3.put("age", "B"); - m_l3.put("aic", "A"); - m_l3.put("als", "b"); - m_l3.put("ant", "B"); - m_l3.put("ars", "O"); - m_l3.put("ary", "F"); - m_l3.put("ata", "A"); - m_l3.put("ate", "A"); - m_l3.put("eal", "Y"); - m_l3.put("ear", "Y"); - m_l3.put("ely", "E"); - m_l3.put("ene", "E"); - m_l3.put("ent", "C"); - m_l3.put("ery", "E"); - m_l3.put("ese", "A"); - m_l3.put("ful", "A"); - m_l3.put("ial", "A"); - m_l3.put("ian", "A"); - m_l3.put("ics", "A"); - m_l3.put("ide", "L"); - m_l3.put("ied", "A"); - m_l3.put("ier", "A"); - m_l3.put("ies", "P"); - m_l3.put("ily", "A"); - m_l3.put("ine", "M"); - m_l3.put("ing", "N"); - m_l3.put("ion", "Q"); - m_l3.put("ish", "C"); - m_l3.put("ism", "B"); - m_l3.put("ist", "A"); - m_l3.put("ite", "a"); - m_l3.put("ity", "A"); - m_l3.put("ium", "A"); - m_l3.put("ive", "A"); - m_l3.put("ize", "F"); - m_l3.put("oid", "A"); - m_l3.put("one", "R"); - m_l3.put("ous", "A"); - m_l2 = new HashMap(); - m_l2.put("ae", "A"); - m_l2.put("al", "b"); - m_l2.put("ar", "X"); - m_l2.put("as", "B"); - m_l2.put("ed", "E"); - m_l2.put("en", "F"); - m_l2.put("es", "E"); - m_l2.put("ia", "A"); - m_l2.put("ic", "A"); - m_l2.put("is", "A"); - m_l2.put("ly", "B"); - m_l2.put("on", "S"); - m_l2.put("or", "T"); - m_l2.put("um", "U"); - m_l2.put("us", "V"); - m_l2.put("yl", "R"); - m_l2.put("s\'", "A"); - m_l2.put("\'s", "A"); - m_l1 = new HashMap(); - m_l1.put("a", "A"); - m_l1.put("e", "A"); - m_l1.put("i", "A"); - m_l1.put("o", "A"); - m_l1.put("s", "W"); - m_l1.put("y", "B"); - } - - /** - * Finds and removes ending from given word. - */ - private String removeEnding(String word) { - - int length = word.length(); - int el = 11; - - while (el > 0) { - if (length - el > 1) { - String ending = word.substring(length - el); - String conditionCode = null; - switch (el) { - case 11: conditionCode = (String)m_l11.get(ending); - break; - case 10: conditionCode = (String)m_l10.get(ending); - break; - case 9: conditionCode = (String)m_l9.get(ending); - break; - case 8: conditionCode = (String)m_l8.get(ending); - break; - case 7: conditionCode = (String)m_l7.get(ending); - break; - case 6: conditionCode = (String)m_l6.get(ending); - break; - case 5: conditionCode = (String)m_l5.get(ending); - break; - case 4: conditionCode = (String)m_l4.get(ending); - break; - case 3: conditionCode = (String)m_l3.get(ending); - break; - case 2: conditionCode = (String)m_l2.get(ending); - break; - case 1: conditionCode = (String)m_l1.get(ending); - break; - default: - } - if (conditionCode != null) { - switch (conditionCode.charAt(0)) { - case 'A': - return word.substring(0, length - el); - case 'B': - if (length - el > 2) { - return word.substring(0, length - el); - } - break; - case 'C': - if (length - el > 3) { - return word.substring(0, length - el); - } - break; - case 'D': - if (length - el > 4) { - return word.substring(0, length - el); - } - break; - case 'E': - if (word.charAt(length - el - 1) != 'e') { - return word.substring(0, length - el); - } - break; - case 'F': - if ((length - el > 2) && - (word.charAt(length - el - 1) != 'e')) { - return word.substring(0, length - el); - } - break; - case 'G': - if ((length - el > 2) && - (word.charAt(length - el - 1) == 'f')) { - return word.substring(0, length - el); - } - break; - case 'H': - if ((word.charAt(length - el - 1) == 't') || - ((word.charAt(length - el - 1) == 'l') && - (word.charAt(length - el - 2) == 'l'))) { - return word.substring(0, length - el); - } - break; - case 'I': - if ((word.charAt(length - el - 1) != 'o') && - (word.charAt(length - el - 1) != 'e')) { - return word.substring(0, length - el); - } - break; - case 'J': - if ((word.charAt(length - el - 1) != 'a') && - (word.charAt(length - el - 1) != 'e')) { - return word.substring(0, length - el); - } - break; - case 'K': - if ((length - el > 2) && - ((word.charAt(length - el - 1) == 'l') || - (word.charAt(length - el - 1) == 'i') || - ((word.charAt(length - el - 1) == 'e') && - (word.charAt(length - el - 3) == 'u')))) { - return word.substring(0, length - el); - } - break; - case 'L': - if ((word.charAt(length - el - 1) != 'u') && - (word.charAt(length - el - 1) != 'x') && - ((word.charAt(length - el - 1) != 's') || - (word.charAt(length - el - 2) == 'o'))) { - return word.substring(0, length - el); - } - break; - case 'M': - if ((word.charAt(length - el - 1) != 'a') && - (word.charAt(length - el - 1) != 'c') && - (word.charAt(length - el - 1) != 'e') && - (word.charAt(length - el - 1) != 'm')) { - return word.substring(0, length - el); - } - break; - case 'N': - if ((length - el > 3) || - ((length - el == 3) && - ((word.charAt(length - el - 3) != 's')))) { - return word.substring(0, length - el); - } - break; - case 'O': - if ((word.charAt(length - el - 1) == 'l') || - (word.charAt(length - el - 1) == 'i')) { - return word.substring(0, length - el); - } - break; - case 'P': - if (word.charAt(length - el - 1) != 'c') { - return word.substring(0, length - el); - } - break; - case 'Q': - if ((length - el > 2) && - (word.charAt(length - el - 1) != 'l') && - (word.charAt(length - el - 1) != 'n')) { - return word.substring(0, length - el); - } - break; - case 'R': - if ((word.charAt(length - el - 1) == 'n') || - (word.charAt(length - el - 1) == 'r')) { - return word.substring(0, length - el); - } - break; - case 'S': - if (((word.charAt(length - el - 1) == 'r') && - (word.charAt(length - el - 2) == 'd')) || - ((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) != 't'))) { - return word.substring(0, length - el); - } - break; - case 'T': - if ((word.charAt(length - el - 1) == 's') || - ((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) != 'o'))) { - return word.substring(0, length - el); - } - break; - case 'U': - if ((word.charAt(length - el - 1) == 'l') || - (word.charAt(length - el - 1) == 'm') || - (word.charAt(length - el - 1) == 'n') || - (word.charAt(length - el - 1) == 'r')) { - return word.substring(0, length - el); - } - break; - case 'V': - if (word.charAt(length - el - 1) == 'c') { - return word.substring(0, length - el); - } - break; - case 'W': - if ((word.charAt(length - el - 1) != 's') && - (word.charAt(length - el - 1) != 'u')) { - return word.substring(0, length - el); - } - break; - case 'X': - if ((word.charAt(length - el - 1) == 'l') || - (word.charAt(length - el - 1) == 'i') || - ((length - el > 2) && - (word.charAt(length - el - 1) == 'e') && - (word.charAt(length - el - 3) == 'u'))) { - return word.substring(0, length - el); - } - break; - case 'Y': - if ((word.charAt(length - el - 1) == 'n') && - (word.charAt(length - el - 2) == 'i')) { - return word.substring(0, length - el); - } - break; - case 'Z': - if (word.charAt(length - el - 1) != 'f') { - return word.substring(0, length - el); - } - break; - case 'a': - if ((word.charAt(length - el - 1) == 'd') || - (word.charAt(length - el - 1) == 'f') || - (((word.charAt(length - el - 1) == 'h') && - (word.charAt(length - el - 2) == 'p'))) || - (((word.charAt(length - el - 1) == 'h') && - (word.charAt(length - el - 2) == 't'))) || - (word.charAt(length - el - 1) == 'l') || - (((word.charAt(length - el - 1) == 'r') && - (word.charAt(length - el - 2) == 'e'))) || - (((word.charAt(length - el - 1) == 'r') && - (word.charAt(length - el - 2) == 'o'))) || - (((word.charAt(length - el - 1) == 's') && - (word.charAt(length - el - 2) == 'e'))) || - (word.charAt(length - el - 1) == 't')) { - return word.substring(0, length - el); - } - break; - case 'b': - if (m_CompMode) { - if (((length - el == 3 ) && - (!((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) == 'e') && - (word.charAt(length - el - 3) == 'm')))) || - ((length - el > 3) && - (!((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) == 's') && - (word.charAt(length - el - 3) == 'y') && - (word.charAt(length - el - 4) == 'r'))))) { - return word.substring(0, length - el); - } - } else { - if ((length - el > 2) && - (!((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) == 'e') && - (word.charAt(length - el - 3) == 'm'))) && - ((length - el < 4) || - (!((word.charAt(length - el - 1) == 't') && - (word.charAt(length - el - 2) == 's') && - (word.charAt(length - el - 3) == 'y') && - (word.charAt(length - el - 4) == 'r'))))) { - return word.substring(0, length - el); - } - } - break; - case 'c': - if (word.charAt(length - el - 1) == 'l') { - return word.substring(0, length - el); - } - break; - default: - throw new IllegalArgumentException("Fatal error."); - } - } - } - el--; - } - return word; - } - - /** - * Recodes ending of given word. - */ - private String recodeEnding(String word) { - - int lastPos = word.length() - 1; - - // Rule 1 - if (word.endsWith("bb") || - word.endsWith("dd") || - word.endsWith("gg") || - word.endsWith("ll") || - word.endsWith("mm") || - word.endsWith("nn") || - word.endsWith("pp") || - word.endsWith("rr") || - word.endsWith("ss") || - word.endsWith("tt")) { - word = word.substring(0, lastPos); - lastPos--; + static { + logger.debug("Static initializer is starting..."); + m_l11 = new HashMap(); + m_l11.put("alistically", "B"); + m_l11.put("arizability", "A"); + m_l11.put("izationally", "B"); + m_l10 = new HashMap(); + m_l10.put("antialness", "A"); + m_l10.put("arisations", "A"); + m_l10.put("arizations", "A"); + m_l10.put("entialness", "A"); + m_l9 = new HashMap(); + m_l9.put("allically", "C"); + m_l9.put("antaneous", "A"); + m_l9.put("antiality", "A"); + m_l9.put("arisation", "A"); + m_l9.put("arization", "A"); + m_l9.put("ationally", "B"); + m_l9.put("ativeness", "A"); + m_l9.put("eableness", "E"); + m_l9.put("entations", "A"); + m_l9.put("entiality", "A"); + m_l9.put("entialize", "A"); + m_l9.put("entiation", "A"); + m_l9.put("ionalness", "A"); + m_l9.put("istically", "A"); + m_l9.put("itousness", "A"); + m_l9.put("izability", "A"); + m_l9.put("izational", "A"); + m_l8 = new HashMap(); + m_l8.put("ableness", "A"); + m_l8.put("arizable", "A"); + m_l8.put("entation", "A"); + m_l8.put("entially", "A"); + m_l8.put("eousness", "A"); + m_l8.put("ibleness", "A"); + m_l8.put("icalness", "A"); + m_l8.put("ionalism", "A"); + m_l8.put("ionality", "A"); + m_l8.put("ionalize", "A"); + m_l8.put("iousness", "A"); + m_l8.put("izations", "A"); + m_l8.put("lessness", "A"); + m_l7 = new HashMap(); + m_l7.put("ability", "A"); + m_l7.put("aically", "A"); + m_l7.put("alistic", "B"); + m_l7.put("alities", "A"); + m_l7.put("ariness", "E"); + m_l7.put("aristic", "A"); + m_l7.put("arizing", "A"); + m_l7.put("ateness", "A"); + m_l7.put("atingly", "A"); + m_l7.put("ational", "B"); + m_l7.put("atively", "A"); + m_l7.put("ativism", "A"); + m_l7.put("elihood", "E"); + m_l7.put("encible", "A"); + m_l7.put("entally", "A"); + m_l7.put("entials", "A"); + m_l7.put("entiate", "A"); + m_l7.put("entness", "A"); + m_l7.put("fulness", "A"); + m_l7.put("ibility", "A"); + m_l7.put("icalism", "A"); + m_l7.put("icalist", "A"); + m_l7.put("icality", "A"); + m_l7.put("icalize", "A"); + m_l7.put("ication", "G"); + m_l7.put("icianry", "A"); + m_l7.put("ination", "A"); + m_l7.put("ingness", "A"); + m_l7.put("ionally", "A"); + m_l7.put("isation", "A"); + m_l7.put("ishness", "A"); + m_l7.put("istical", "A"); + m_l7.put("iteness", "A"); + m_l7.put("iveness", "A"); + m_l7.put("ivistic", "A"); + m_l7.put("ivities", "A"); + m_l7.put("ization", "F"); + m_l7.put("izement", "A"); + m_l7.put("oidally", "A"); + m_l7.put("ousness", "A"); + m_l6 = new HashMap(); + m_l6.put("aceous", "A"); + m_l6.put("acious", "B"); + m_l6.put("action", "G"); + m_l6.put("alness", "A"); + m_l6.put("ancial", "A"); + m_l6.put("ancies", "A"); + m_l6.put("ancing", "B"); + m_l6.put("ariser", "A"); + m_l6.put("arized", "A"); + m_l6.put("arizer", "A"); + m_l6.put("atable", "A"); + m_l6.put("ations", "B"); + m_l6.put("atives", "A"); + m_l6.put("eature", "Z"); + m_l6.put("efully", "A"); + m_l6.put("encies", "A"); + m_l6.put("encing", "A"); + m_l6.put("ential", "A"); + m_l6.put("enting", "C"); + m_l6.put("entist", "A"); + m_l6.put("eously", "A"); + m_l6.put("ialist", "A"); + m_l6.put("iality", "A"); + m_l6.put("ialize", "A"); + m_l6.put("ically", "A"); + m_l6.put("icance", "A"); + m_l6.put("icians", "A"); + m_l6.put("icists", "A"); + m_l6.put("ifully", "A"); + m_l6.put("ionals", "A"); + m_l6.put("ionate", "D"); + m_l6.put("ioning", "A"); + m_l6.put("ionist", "A"); + m_l6.put("iously", "A"); + m_l6.put("istics", "A"); + m_l6.put("izable", "E"); + m_l6.put("lessly", "A"); + m_l6.put("nesses", "A"); + m_l6.put("oidism", "A"); + m_l5 = new HashMap(); + m_l5.put("acies", "A"); + m_l5.put("acity", "A"); + m_l5.put("aging", "B"); + m_l5.put("aical", "A"); + if (!m_CompMode) { + m_l5.put("alist", "A"); + } + m_l5.put("alism", "B"); + m_l5.put("ality", "A"); + m_l5.put("alize", "A"); + m_l5.put("allic", "b"); + m_l5.put("anced", "B"); + m_l5.put("ances", "B"); + m_l5.put("antic", "C"); + m_l5.put("arial", "A"); + m_l5.put("aries", "A"); + m_l5.put("arily", "A"); + m_l5.put("arity", "B"); + m_l5.put("arize", "A"); + m_l5.put("aroid", "A"); + m_l5.put("ately", "A"); + m_l5.put("ating", "I"); + m_l5.put("ation", "B"); + m_l5.put("ative", "A"); + m_l5.put("ators", "A"); + m_l5.put("atory", "A"); + m_l5.put("ature", "E"); + m_l5.put("early", "Y"); + m_l5.put("ehood", "A"); + m_l5.put("eless", "A"); + if (!m_CompMode) { + m_l5.put("elily", "A"); + } else { + m_l5.put("elity", "A"); + } + m_l5.put("ement", "A"); + m_l5.put("enced", "A"); + m_l5.put("ences", "A"); + m_l5.put("eness", "E"); + m_l5.put("ening", "E"); + m_l5.put("ental", "A"); + m_l5.put("ented", "C"); + m_l5.put("ently", "A"); + m_l5.put("fully", "A"); + m_l5.put("ially", "A"); + m_l5.put("icant", "A"); + m_l5.put("ician", "A"); + m_l5.put("icide", "A"); + m_l5.put("icism", "A"); + m_l5.put("icist", "A"); + m_l5.put("icity", "A"); + m_l5.put("idine", "I"); + m_l5.put("iedly", "A"); + m_l5.put("ihood", "A"); + m_l5.put("inate", "A"); + m_l5.put("iness", "A"); + m_l5.put("ingly", "B"); + m_l5.put("inism", "J"); + m_l5.put("inity", "c"); + m_l5.put("ional", "A"); + m_l5.put("ioned", "A"); + m_l5.put("ished", "A"); + m_l5.put("istic", "A"); + m_l5.put("ities", "A"); + m_l5.put("itous", "A"); + m_l5.put("ively", "A"); + m_l5.put("ivity", "A"); + m_l5.put("izers", "F"); + m_l5.put("izing", "F"); + m_l5.put("oidal", "A"); + m_l5.put("oides", "A"); + m_l5.put("otide", "A"); + m_l5.put("ously", "A"); + m_l4 = new HashMap(); + m_l4.put("able", "A"); + m_l4.put("ably", "A"); + m_l4.put("ages", "B"); + m_l4.put("ally", "B"); + m_l4.put("ance", "B"); + m_l4.put("ancy", "B"); + m_l4.put("ants", "B"); + m_l4.put("aric", "A"); + m_l4.put("arly", "K"); + m_l4.put("ated", "I"); + m_l4.put("ates", "A"); + m_l4.put("atic", "B"); + m_l4.put("ator", "A"); + m_l4.put("ealy", "Y"); + m_l4.put("edly", "E"); + m_l4.put("eful", "A"); + m_l4.put("eity", "A"); + m_l4.put("ence", "A"); + m_l4.put("ency", "A"); + m_l4.put("ened", "E"); + m_l4.put("enly", "E"); + m_l4.put("eous", "A"); + m_l4.put("hood", "A"); + m_l4.put("ials", "A"); + m_l4.put("ians", "A"); + m_l4.put("ible", "A"); + m_l4.put("ibly", "A"); + m_l4.put("ical", "A"); + m_l4.put("ides", "L"); + m_l4.put("iers", "A"); + m_l4.put("iful", "A"); + m_l4.put("ines", "M"); + m_l4.put("ings", "N"); + m_l4.put("ions", "B"); + m_l4.put("ious", "A"); + m_l4.put("isms", "B"); + m_l4.put("ists", "A"); + m_l4.put("itic", "H"); + m_l4.put("ized", "F"); + m_l4.put("izer", "F"); + m_l4.put("less", "A"); + m_l4.put("lily", "A"); + m_l4.put("ness", "A"); + m_l4.put("ogen", "A"); + m_l4.put("ward", "A"); + m_l4.put("wise", "A"); + m_l4.put("ying", "B"); + m_l4.put("yish", "A"); + m_l3 = new HashMap(); + m_l3.put("acy", "A"); + m_l3.put("age", "B"); + m_l3.put("aic", "A"); + m_l3.put("als", "b"); + m_l3.put("ant", "B"); + m_l3.put("ars", "O"); + m_l3.put("ary", "F"); + m_l3.put("ata", "A"); + m_l3.put("ate", "A"); + m_l3.put("eal", "Y"); + m_l3.put("ear", "Y"); + m_l3.put("ely", "E"); + m_l3.put("ene", "E"); + m_l3.put("ent", "C"); + m_l3.put("ery", "E"); + m_l3.put("ese", "A"); + m_l3.put("ful", "A"); + m_l3.put("ial", "A"); + m_l3.put("ian", "A"); + m_l3.put("ics", "A"); + m_l3.put("ide", "L"); + m_l3.put("ied", "A"); + m_l3.put("ier", "A"); + m_l3.put("ies", "P"); + m_l3.put("ily", "A"); + m_l3.put("ine", "M"); + m_l3.put("ing", "N"); + m_l3.put("ion", "Q"); + m_l3.put("ish", "C"); + m_l3.put("ism", "B"); + m_l3.put("ist", "A"); + m_l3.put("ite", "a"); + m_l3.put("ity", "A"); + m_l3.put("ium", "A"); + m_l3.put("ive", "A"); + m_l3.put("ize", "F"); + m_l3.put("oid", "A"); + m_l3.put("one", "R"); + m_l3.put("ous", "A"); + m_l2 = new HashMap(); + m_l2.put("ae", "A"); + m_l2.put("al", "b"); + m_l2.put("ar", "X"); + m_l2.put("as", "B"); + m_l2.put("ed", "E"); + m_l2.put("en", "F"); + m_l2.put("es", "E"); + m_l2.put("ia", "A"); + m_l2.put("ic", "A"); + m_l2.put("is", "A"); + m_l2.put("ly", "B"); + m_l2.put("on", "S"); + m_l2.put("or", "T"); + m_l2.put("um", "U"); + m_l2.put("us", "V"); + m_l2.put("yl", "R"); + m_l2.put("s\'", "A"); + m_l2.put("\'s", "A"); + m_l1 = new HashMap(); + m_l1.put("a", "A"); + m_l1.put("e", "A"); + m_l1.put("i", "A"); + m_l1.put("o", "A"); + m_l1.put("s", "W"); + m_l1.put("y", "B"); + logger.debug("Static initalizer finished."); } - // Rule 2 - if (word.endsWith("iev")) { - word = word.substring(0, lastPos - 2).concat("ief"); + /** + * Finds and removes ending from given word. + */ + private String removeEnding(String word) { + + int length = word.length(); + int el = 11; + + while (el > 0) { + if (length - el > 1) { + String ending = word.substring(length - el); + String conditionCode = null; + switch (el) { + case 11: + conditionCode = (String) m_l11.get(ending); + break; + case 10: + conditionCode = (String) m_l10.get(ending); + break; + case 9: + conditionCode = (String) m_l9.get(ending); + break; + case 8: + conditionCode = (String) m_l8.get(ending); + break; + case 7: + conditionCode = (String) m_l7.get(ending); + break; + case 6: + conditionCode = (String) m_l6.get(ending); + break; + case 5: + conditionCode = (String) m_l5.get(ending); + break; + case 4: + conditionCode = (String) m_l4.get(ending); + break; + case 3: + conditionCode = (String) m_l3.get(ending); + break; + case 2: + conditionCode = (String) m_l2.get(ending); + break; + case 1: + conditionCode = (String) m_l1.get(ending); + break; + default: + } + if (conditionCode != null) { + switch (conditionCode.charAt(0)) { + case 'A': + return word.substring(0, length - el); + case 'B': + if (length - el > 2) { + return word.substring(0, length - el); + } + break; + case 'C': + if (length - el > 3) { + return word.substring(0, length - el); + } + break; + case 'D': + if (length - el > 4) { + return word.substring(0, length - el); + } + break; + case 'E': + if (word.charAt(length - el - 1) != 'e') { + return word.substring(0, length - el); + } + break; + case 'F': + if ((length - el > 2) && (word.charAt(length - el + - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'G': + if ((length - el > 2) && (word.charAt(length - el + - 1) == 'f')) { + return word.substring(0, length - el); + } + break; + case 'H': + if ((word.charAt(length - el - 1) == 't') + || ((word.charAt(length - el - 1) == 'l') + && (word.charAt(length - el - 2) == 'l'))) { + return word.substring(0, length - el); + } + break; + case 'I': + if ((word.charAt(length - el - 1) != 'o') + && (word.charAt(length - el - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'J': + if ((word.charAt(length - el - 1) != 'a') + && (word.charAt(length - el - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'K': + if ((length - el > 2) && ((word.charAt(length - el + - 1) == 'l') + || (word.charAt(length + - el - 1) + == 'i') + || ((word.charAt(length + - el - 1) + == 'e') && (word. + charAt( + length + - el - 3) + == 'u')))) { + return word.substring(0, length - el); + } + break; + case 'L': + if ((word.charAt(length - el - 1) != 'u') + && (word.charAt(length - el - 1) != 'x') + && ((word.charAt(length - el - 1) != 's') + || (word.charAt(length - el - 2) == 'o'))) { + return word.substring(0, length - el); + } + break; + case 'M': + if ((word.charAt(length - el - 1) != 'a') + && (word.charAt(length - el - 1) != 'c') + && (word.charAt(length - el - 1) != 'e') + && (word.charAt(length - el - 1) != 'm')) { + return word.substring(0, length - el); + } + break; + case 'N': + if ((length - el > 3) || ((length - el == 3) + && ((word.charAt(length + - el - 3) + != 's')))) { + return word.substring(0, length - el); + } + break; + case 'O': + if ((word.charAt(length - el - 1) == 'l') + || (word.charAt(length - el - 1) == 'i')) { + return word.substring(0, length - el); + } + break; + case 'P': + if (word.charAt(length - el - 1) != 'c') { + return word.substring(0, length - el); + } + break; + case 'Q': + if ((length - el > 2) && (word.charAt(length - el + - 1) != 'l') + && (word.charAt(length - el - 1) != 'n')) { + return word.substring(0, length - el); + } + break; + case 'R': + if ((word.charAt(length - el - 1) == 'n') + || (word.charAt(length - el - 1) == 'r')) { + return word.substring(0, length - el); + } + break; + case 'S': + if (((word.charAt(length - el - 1) == 'r') + && (word.charAt(length - el - 2) == 'd')) + || ((word.charAt(length - el - 1) == 't') + && (word.charAt(length - el - 2) != 't'))) { + return word.substring(0, length - el); + } + break; + case 'T': + if ((word.charAt(length - el - 1) == 's') + || ((word.charAt(length - el - 1) == 't') + && (word.charAt(length - el - 2) != 'o'))) { + return word.substring(0, length - el); + } + break; + case 'U': + if ((word.charAt(length - el - 1) == 'l') + || (word.charAt(length - el - 1) == 'm') + || (word.charAt(length - el - 1) == 'n') + || (word.charAt(length - el - 1) == 'r')) { + return word.substring(0, length - el); + } + break; + case 'V': + if (word.charAt(length - el - 1) == 'c') { + return word.substring(0, length - el); + } + break; + case 'W': + if ((word.charAt(length - el - 1) != 's') + && (word.charAt(length - el - 1) != 'u')) { + return word.substring(0, length - el); + } + break; + case 'X': + if ((word.charAt(length - el - 1) == 'l') + || (word.charAt(length - el - 1) == 'i') + || ((length - el > 2) && (word.charAt(length + - el - 1) + == 'e') && (word. + charAt(length + - el + - 3) + == 'u'))) { + return word.substring(0, length - el); + } + break; + case 'Y': + if ((word.charAt(length - el - 1) == 'n') + && (word.charAt(length - el - 2) == 'i')) { + return word.substring(0, length - el); + } + break; + case 'Z': + if (word.charAt(length - el - 1) != 'f') { + return word.substring(0, length - el); + } + break; + case 'a': + if ((word.charAt(length - el - 1) == 'd') + || (word.charAt(length - el - 1) == 'f') + || (((word.charAt(length - el - 1) == 'h') + && (word.charAt(length - el - 2) == 'p'))) + || (((word.charAt(length - el - 1) == 'h') + && (word.charAt(length - el - 2) == 't'))) + || (word.charAt(length - el - 1) == 'l') + || (((word.charAt(length - el - 1) == 'r') + && (word.charAt(length - el - 2) == 'e'))) + || (((word.charAt(length - el - 1) == 'r') + && (word.charAt(length - el - 2) == 'o'))) + || (((word.charAt(length - el - 1) == 's') + && (word.charAt(length - el - 2) == 'e'))) + || (word.charAt(length - el - 1) == 't')) { + return word.substring(0, length - el); + } + break; + case 'b': + if (m_CompMode) { + if (((length - el == 3) && (!((word.charAt(length + - el + - 1) + == 't') + && (word.charAt( + length - el + - 2) == 'e') + && (word.charAt( + length - el + - 3) == 'm')))) + || ((length - el > 3) + && (!((word.charAt(length - el - 1) + == 't') && (word.charAt(length + - el - 2) + == 's') && (word. + charAt( + length + - el - 3) + == 'y') + && (word.charAt(length - el - 4) + == 'r'))))) { + return word.substring(0, length - el); + } + } else { + if ((length - el > 2) && (!((word.charAt(length + - el + - 1) + == 't') && (word. + charAt( + length + - el + - 2) + == 'e') + && (word.charAt(length + - el + - 3) + == 'm'))) + && ((length - el < 4) + || (!((word.charAt(length - el - 1) + == 't') && (word.charAt(length + - el - 2) + == 's') && (word. + charAt( + length + - el - 3) + == 'y') + && (word.charAt(length - el - 4) + == 'r'))))) { + return word.substring(0, length - el); + } + } + break; + case 'c': + if (word.charAt(length - el - 1) == 'l') { + return word.substring(0, length - el); + } + break; + default: + throw new IllegalArgumentException("Fatal error."); + } + } + } + el--; + } + return word; } - // Rule 3 - if (word.endsWith("uct")) { - word = word.substring(0, lastPos - 2).concat("uc"); - lastPos--; + /** + * Recodes ending of given word. + */ + private String recodeEnding(String word) { + + int lastPos = word.length() - 1; + + // Rule 1 + if (word.endsWith("bb") || word.endsWith("dd") || word.endsWith("gg") || word. + endsWith("ll") || word.endsWith("mm") || word.endsWith("nn") || word. + endsWith("pp") || word.endsWith("rr") || word.endsWith("ss") || word. + endsWith("tt")) { + word = word.substring(0, lastPos); + lastPos--; + } + + // Rule 2 + if (word.endsWith("iev")) { + word = word.substring(0, lastPos - 2).concat("ief"); + } + + // Rule 3 + if (word.endsWith("uct")) { + word = word.substring(0, lastPos - 2).concat("uc"); + lastPos--; + } + + // Rule 4 + if (word.endsWith("umpt")) { + word = word.substring(0, lastPos - 3).concat("um"); + lastPos -= 2; + } + + // Rule 5 + if (word.endsWith("rpt")) { + word = word.substring(0, lastPos - 2).concat("rb"); + lastPos--; + } + + // Rule 6 + if (word.endsWith("urs")) { + word = word.substring(0, lastPos - 2).concat("ur"); + lastPos--; + } + + // Rule 7 + if (word.endsWith("istr")) { + word = word.substring(0, lastPos - 3).concat("ister"); + lastPos++; + } + + // Rule 7a + if (word.endsWith("metr")) { + word = word.substring(0, lastPos - 3).concat("meter"); + lastPos++; + } + + // Rule 8 + if (word.endsWith("olv")) { + word = word.substring(0, lastPos - 2).concat("olut"); + lastPos++; + } + + // Rule 9 + if (word.endsWith("ul")) { + if ((lastPos - 2 < 0) || ((word.charAt(lastPos - 2) != 'a') + && (word.charAt(lastPos - 2) != 'i') + && (word.charAt(lastPos - 2) != 'o'))) { + word = word.substring(0, lastPos - 1).concat("l"); + lastPos--; + } + } + + // Rule 10 + if (word.endsWith("bex")) { + word = word.substring(0, lastPos - 2).concat("bic"); + } + + // Rule 11 + if (word.endsWith("dex")) { + word = word.substring(0, lastPos - 2).concat("dic"); + } + + // Rule 12 + if (word.endsWith("pex")) { + word = word.substring(0, lastPos - 2).concat("pic"); + } + + // Rule 13 + if (word.endsWith("tex")) { + word = word.substring(0, lastPos - 2).concat("tic"); + } + + // Rule 14 + if (word.endsWith("ax")) { + word = word.substring(0, lastPos - 1).concat("ac"); + } + + // Rule 15 + if (word.endsWith("ex")) { + word = word.substring(0, lastPos - 1).concat("ec"); + } + + // Rule 16 + if (word.endsWith("ix")) { + word = word.substring(0, lastPos - 1).concat("ic"); + } + + // Rule 17 + if (word.endsWith("lux")) { + word = word.substring(0, lastPos - 2).concat("luc"); + } + + // Rule 18 + if (word.endsWith("uad")) { + word = word.substring(0, lastPos - 2).concat("uas"); + } + + // Rule 19 + if (word.endsWith("vad")) { + word = word.substring(0, lastPos - 2).concat("vas"); + } + + // Rule 20 + if (word.endsWith("cid")) { + word = word.substring(0, lastPos - 2).concat("cis"); + } + + // Rule 21 + if (word.endsWith("lid")) { + word = word.substring(0, lastPos - 2).concat("lis"); + } + + // Rule 22 + if (word.endsWith("erid")) { + word = word.substring(0, lastPos - 3).concat("eris"); + } + + // Rule 23 + if (word.endsWith("pand")) { + word = word.substring(0, lastPos - 3).concat("pans"); + } + + // Rule 24 + if (word.endsWith("end")) { + if ((lastPos - 3 < 0) || (word.charAt(lastPos - 3) != 's')) { + word = word.substring(0, lastPos - 2).concat("ens"); + } + } + + // Rule 25 + if (word.endsWith("ond")) { + word = word.substring(0, lastPos - 2).concat("ons"); + } + + // Rule 26 + if (word.endsWith("lud")) { + word = word.substring(0, lastPos - 2).concat("lus"); + } + + // Rule 27 + if (word.endsWith("rud")) { + word = word.substring(0, lastPos - 2).concat("rus"); + } + + // Rule 28 + if (word.endsWith("her")) { + if ((lastPos - 3 < 0) || ((word.charAt(lastPos - 3) != 'p') + && (word.charAt(lastPos - 3) != 't'))) { + word = word.substring(0, lastPos - 2).concat("hes"); + } + } + + // Rule 29 + if (word.endsWith("mit")) { + word = word.substring(0, lastPos - 2).concat("mis"); + } + + // Rule 30 + if (word.endsWith("end")) { + if ((lastPos - 3 < 0) || (word.charAt(lastPos - 3) != 'm')) { + word = word.substring(0, lastPos - 2).concat("ens"); + } + } + + // Rule 31 + if (word.endsWith("ert")) { + word = word.substring(0, lastPos - 2).concat("ers"); + } + + // Rule 32 + if (word.endsWith("et")) { + if ((lastPos - 2 < 0) || (word.charAt(lastPos - 2) != 'n')) { + word = word.substring(0, lastPos - 1).concat("es"); + } + } + + // Rule 33 + if (word.endsWith("yt")) { + word = word.substring(0, lastPos - 1).concat("ys"); + } + + // Rule 34 + if (word.endsWith("yz")) { + word = word.substring(0, lastPos - 1).concat("ys"); + } + + return word; } - // Rule 4 - if (word.endsWith("umpt")) { - word = word.substring(0, lastPos - 3).concat("um"); - lastPos -= 2; + /** + * Returns the stemmed version of the given word. + * + * @param word a string consisting of a single word + */ + public String stem(String word) { + + if (word.length() > 2) { + return recodeEnding(removeEnding(word.toLowerCase())); + } else { + return word.toLowerCase(); + } } - // Rule 5 - if (word.endsWith("rpt")) { - word = word.substring(0, lastPos - 2).concat("rb"); - lastPos--; - } + /** + * Stems text coming into stdin and writes it to stdout. + */ + public static void main(String[] ops) { - // Rule 6 - if (word.endsWith("urs")) { - word = word.substring(0, lastPos - 2).concat("ur"); - lastPos--; - } + LovinsStemmer ls = new LovinsStemmer(); - // Rule 7 - if (word.endsWith("istr")) { - word = word.substring(0, lastPos - 3).concat("ister"); - lastPos++; + try { + int num; + StringBuffer wordBuffer = new StringBuffer(); + while ((num = System.in.read()) != -1) { + char c = (char) num; + if (((num >= (int) 'A') && (num <= (int) 'Z')) + || ((num >= (int) 'a') && (num <= (int) 'z'))) { + wordBuffer.append(c); + } else { + if (wordBuffer.length() > 0) { + System.out.print(ls.stem(wordBuffer.toString(). + toLowerCase())); + wordBuffer = new StringBuffer(); + } + System.out.print(c); + } + } + } catch (Exception e) { + e.printStackTrace(); + } } - - // Rule 7a - if (word.endsWith("metr")) { - word = word.substring(0, lastPos - 3).concat("meter"); - lastPos++; - } - - // Rule 8 - if (word.endsWith("olv")) { - word = word.substring(0, lastPos - 2).concat("olut"); - lastPos++; - } - - // Rule 9 - if (word.endsWith("ul")) { - if ((lastPos - 2 < 0) || - ((word.charAt(lastPos - 2) != 'a') && - (word.charAt(lastPos - 2) != 'i') && - (word.charAt(lastPos - 2) != 'o'))) { - word = word.substring(0, lastPos - 1).concat("l"); - lastPos--; - } - } - - // Rule 10 - if (word.endsWith("bex")) { - word = word.substring(0, lastPos - 2).concat("bic"); - } - - // Rule 11 - if (word.endsWith("dex")) { - word = word.substring(0, lastPos - 2).concat("dic"); - } - - // Rule 12 - if (word.endsWith("pex")) { - word = word.substring(0, lastPos - 2).concat("pic"); - } - - // Rule 13 - if (word.endsWith("tex")) { - word = word.substring(0, lastPos - 2).concat("tic"); - } - - // Rule 14 - if (word.endsWith("ax")) { - word = word.substring(0, lastPos - 1).concat("ac"); - } - - // Rule 15 - if (word.endsWith("ex")) { - word = word.substring(0, lastPos - 1).concat("ec"); - } - - // Rule 16 - if (word.endsWith("ix")) { - word = word.substring(0, lastPos - 1).concat("ic"); - } - - // Rule 17 - if (word.endsWith("lux")) { - word = word.substring(0, lastPos - 2).concat("luc"); - } - - // Rule 18 - if (word.endsWith("uad")) { - word = word.substring(0, lastPos - 2).concat("uas"); - } - - // Rule 19 - if (word.endsWith("vad")) { - word = word.substring(0, lastPos - 2).concat("vas"); - } - - // Rule 20 - if (word.endsWith("cid")) { - word = word.substring(0, lastPos - 2).concat("cis"); - } - - // Rule 21 - if (word.endsWith("lid")) { - word = word.substring(0, lastPos - 2).concat("lis"); - } - - // Rule 22 - if (word.endsWith("erid")) { - word = word.substring(0, lastPos - 3).concat("eris"); - } - - // Rule 23 - if (word.endsWith("pand")) { - word = word.substring(0, lastPos - 3).concat("pans"); - } - - // Rule 24 - if (word.endsWith("end")) { - if ((lastPos - 3 < 0) || - (word.charAt(lastPos - 3) != 's')) { - word = word.substring(0, lastPos - 2).concat("ens"); - } - } - - // Rule 25 - if (word.endsWith("ond")) { - word = word.substring(0, lastPos - 2).concat("ons"); - } - - // Rule 26 - if (word.endsWith("lud")) { - word = word.substring(0, lastPos - 2).concat("lus"); - } - - // Rule 27 - if (word.endsWith("rud")) { - word = word.substring(0, lastPos - 2).concat("rus"); - } - - // Rule 28 - if (word.endsWith("her")) { - if ((lastPos - 3 < 0) || - ((word.charAt(lastPos - 3) != 'p') && - (word.charAt(lastPos - 3) != 't'))) { - word = word.substring(0, lastPos - 2).concat("hes"); - } - } - - // Rule 29 - if (word.endsWith("mit")) { - word = word.substring(0, lastPos - 2).concat("mis"); - } - - // Rule 30 - if (word.endsWith("end")) { - if ((lastPos - 3 < 0) || - (word.charAt(lastPos - 3) != 'm')) { - word = word.substring(0, lastPos - 2).concat("ens"); - } - } - - // Rule 31 - if (word.endsWith("ert")) { - word = word.substring(0, lastPos - 2).concat("ers"); - } - - // Rule 32 - if (word.endsWith("et")) { - if ((lastPos - 2 < 0) || - (word.charAt(lastPos - 2) != 'n')) { - word = word.substring(0, lastPos - 1).concat("es"); - } - } - - // Rule 33 - if (word.endsWith("yt")) { - word = word.substring(0, lastPos - 1).concat("ys"); - } - - // Rule 34 - if (word.endsWith("yz")) { - word = word.substring(0, lastPos - 1).concat("ys"); - } - - return word; - } - - /** - * Returns the stemmed version of the given word. - * - * @param word a string consisting of a single word - */ - public String stem(String word) { - - if (word.length() > 2) { - return recodeEnding(removeEnding(word.toLowerCase())); - } else { - return word.toLowerCase(); - } - } - - /** - * Stems text coming into stdin and writes it to stdout. - */ - public static void main(String[] ops) { - - LovinsStemmer ls = new LovinsStemmer(); - - try { - int num; - StringBuffer wordBuffer = new StringBuffer(); - while ((num = System.in.read()) != -1) { - char c = (char)num; - if (((num >= (int)'A') && (num <= (int)'Z')) || - ((num >= (int)'a') && (num <= (int)'z'))) { - wordBuffer.append(c); - } else { - if (wordBuffer.length() > 0) { - System.out.print(ls.stem(wordBuffer.toString(). - toLowerCase())); - wordBuffer = new StringBuffer(); - } - System.out.print(c); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } } - - diff --git a/ccm-ldn-terms/src/kea/stopwords/StopwordsEnglish.java b/ccm-ldn-terms/src/kea/stopwords/StopwordsEnglish.java index 844e1d7ef..e217a6564 100644 --- a/ccm-ldn-terms/src/kea/stopwords/StopwordsEnglish.java +++ b/ccm-ldn-terms/src/kea/stopwords/StopwordsEnglish.java @@ -1,12 +1,11 @@ package kea.stopwords; - - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.Hashtable; +import org.apache.log4j.Logger; /** * Class that can test whether a given string is a stop word. @@ -16,45 +15,43 @@ import java.util.Hashtable; * @version 1.0 */ public class StopwordsEnglish extends Stopwords { - - /** - * - */ - private static final long serialVersionUID = 1L; - - - /** The hashtable containing the list of stopwords */ - private static Hashtable m_Stopwords = null; - - - static { - - if (m_Stopwords == null) { - m_Stopwords = new Hashtable(); - Double dummy = new Double(0); - File txt = new File("data/stopwords/stopwords_en.txt"); - InputStreamReader is; - String sw = null; - try { - is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); - BufferedReader br = new BufferedReader(is); - while ((sw=br.readLine()) != null) { - m_Stopwords.put(sw, dummy); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - } - - /** - * Returns true if the given string is a stop word. - */ - public boolean isStopword(String str) { - - return m_Stopwords.containsKey(str.toLowerCase()); - } + + private static final Logger logger = + Logger.getLogger(StopwordsEnglish.class); + /** + * + */ + private static final long serialVersionUID = 1L; + /** The hashtable containing the list of stopwords */ + private static Hashtable m_Stopwords = null; + + static { + logger.debug("Static initializer is starting..."); + if (m_Stopwords == null) { + m_Stopwords = new Hashtable(); + Double dummy = new Double(0); + File txt = new File("data/stopwords/stopwords_en.txt"); + InputStreamReader is; + String sw = null; + try { + is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); + BufferedReader br = new BufferedReader(is); + while ((sw = br.readLine()) != null) { + m_Stopwords.put(sw, dummy); + } + } catch (Exception e) { + logger.error("Static initalizer failed.", e); + throw new RuntimeException(e); + } + } + logger.debug("Static initalizer is finished."); + } + + /** + * Returns true if the given string is a stop word. + */ + public boolean isStopword(String str) { + + return m_Stopwords.containsKey(str.toLowerCase()); + } } - - diff --git a/ccm-ldn-terms/src/kea/stopwords/StopwordsFrench.java b/ccm-ldn-terms/src/kea/stopwords/StopwordsFrench.java index 71cf66ce1..f260dca7d 100644 --- a/ccm-ldn-terms/src/kea/stopwords/StopwordsFrench.java +++ b/ccm-ldn-terms/src/kea/stopwords/StopwordsFrench.java @@ -1,12 +1,11 @@ package kea.stopwords; - - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.Hashtable; +import org.apache.log4j.Logger; /** * Class that can test whether a given string is a stop word. @@ -16,45 +15,42 @@ import java.util.Hashtable; * @version 1.0 */ public class StopwordsFrench extends Stopwords { - - /** - * - */ - private static final long serialVersionUID = 1L; - - - /** The hashtable containing the list of stopwords */ - private static Hashtable m_Stopwords = null; - - - static { - - if (m_Stopwords == null) { - m_Stopwords = new Hashtable(); - Double dummy = new Double(0); - File txt = new File("data/stopwords/stopwords_fr.txt"); - InputStreamReader is; - String sw = null; - try { - is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); - BufferedReader br = new BufferedReader(is); - while ((sw=br.readLine()) != null) { - m_Stopwords.put(sw, dummy); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - } - - /** - * Returns true if the given string is a stop word. - */ - public boolean isStopword(String str) { - - return m_Stopwords.containsKey(str.toLowerCase()); - } + + private static final Logger logger = Logger.getLogger(StopwordsFrench.class); + /** + * + */ + private static final long serialVersionUID = 1L; + /** The hashtable containing the list of stopwords */ + private static Hashtable m_Stopwords = null; + + static { + logger.debug("Static initializer is starting..."); + if (m_Stopwords == null) { + m_Stopwords = new Hashtable(); + Double dummy = new Double(0); + File txt = new File("data/stopwords/stopwords_fr.txt"); + InputStreamReader is; + String sw = null; + try { + is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); + BufferedReader br = new BufferedReader(is); + while ((sw = br.readLine()) != null) { + m_Stopwords.put(sw, dummy); + } + } catch (Exception e) { + logger.error("Static initalizer failed.", e); + throw new RuntimeException(e); + } + } + logger.debug("Static initalizer is finished."); + } + + /** + * Returns true if the given string is a stop word. + */ + public boolean isStopword(String str) { + + return m_Stopwords.containsKey(str.toLowerCase()); + } } - - diff --git a/ccm-ldn-terms/src/kea/stopwords/StopwordsGerman.java b/ccm-ldn-terms/src/kea/stopwords/StopwordsGerman.java index e7e26cfb8..a676b9638 100644 --- a/ccm-ldn-terms/src/kea/stopwords/StopwordsGerman.java +++ b/ccm-ldn-terms/src/kea/stopwords/StopwordsGerman.java @@ -1,8 +1,7 @@ package kea.stopwords; - - import java.util.Hashtable; +import org.apache.log4j.Logger; /** * Class that can test whether a given string is a stop word. @@ -17,305 +16,303 @@ import java.util.Hashtable; * @version 1.0 */ public class StopwordsGerman extends Stopwords { - - /** - * - */ - private static final long serialVersionUID = 1L; - - -/** The hashtable containing the list of stopwords */ - private static Hashtable m_Stopwords = null; - static { - - if (m_Stopwords == null) { - m_Stopwords = new Hashtable(); - Double dummy = new Double(0); + private static final Logger logger = Logger.getLogger(StopwordsGerman.class); + /** + * + */ + private static final long serialVersionUID = 1L; + /** The hashtable containing the list of stopwords */ + private static Hashtable m_Stopwords = null; - m_Stopwords.put("aber", dummy); + static { + logger.debug("Static initializer is starting..."); + if (m_Stopwords == null) { + m_Stopwords = new Hashtable(); + Double dummy = new Double(0); - m_Stopwords.put("alle", dummy); - m_Stopwords.put("allem", dummy); - m_Stopwords.put("allen", dummy); - m_Stopwords.put("aller", dummy); - m_Stopwords.put("alles", dummy); + m_Stopwords.put("aber", dummy); - m_Stopwords.put("als", dummy); - m_Stopwords.put("also", dummy); - m_Stopwords.put("am", dummy); - m_Stopwords.put("an", dummy); + m_Stopwords.put("alle", dummy); + m_Stopwords.put("allem", dummy); + m_Stopwords.put("allen", dummy); + m_Stopwords.put("aller", dummy); + m_Stopwords.put("alles", dummy); - m_Stopwords.put("ander", dummy); - m_Stopwords.put("andere", dummy); - m_Stopwords.put("anderem", dummy); - m_Stopwords.put("anderen", dummy); - m_Stopwords.put("anderer", dummy); - m_Stopwords.put("anderes", dummy); - m_Stopwords.put("anderm", dummy); - m_Stopwords.put("andern", dummy); - m_Stopwords.put("anders", dummy); + m_Stopwords.put("als", dummy); + m_Stopwords.put("also", dummy); + m_Stopwords.put("am", dummy); + m_Stopwords.put("an", dummy); - m_Stopwords.put("auch", dummy); - m_Stopwords.put("auf", dummy); - m_Stopwords.put("aus", dummy); - m_Stopwords.put("bei", dummy); - m_Stopwords.put("bin", dummy); - m_Stopwords.put("bis", dummy); - m_Stopwords.put("bist", dummy); - m_Stopwords.put("da", dummy); - m_Stopwords.put("damit", dummy); - m_Stopwords.put("dann", dummy); - - m_Stopwords.put("der", dummy); - m_Stopwords.put("den", dummy); - m_Stopwords.put("des", dummy); - m_Stopwords.put("dem", dummy); - m_Stopwords.put("die", dummy); - m_Stopwords.put("das", dummy); + m_Stopwords.put("ander", dummy); + m_Stopwords.put("andere", dummy); + m_Stopwords.put("anderem", dummy); + m_Stopwords.put("anderen", dummy); + m_Stopwords.put("anderer", dummy); + m_Stopwords.put("anderes", dummy); + m_Stopwords.put("anderm", dummy); + m_Stopwords.put("andern", dummy); + m_Stopwords.put("anders", dummy); - m_Stopwords.put("da\u00df", dummy); + m_Stopwords.put("auch", dummy); + m_Stopwords.put("auf", dummy); + m_Stopwords.put("aus", dummy); + m_Stopwords.put("bei", dummy); + m_Stopwords.put("bin", dummy); + m_Stopwords.put("bis", dummy); + m_Stopwords.put("bist", dummy); + m_Stopwords.put("da", dummy); + m_Stopwords.put("damit", dummy); + m_Stopwords.put("dann", dummy); - m_Stopwords.put("derselbe", dummy); - m_Stopwords.put("derselben", dummy); - m_Stopwords.put("denselben", dummy); - m_Stopwords.put("desselben", dummy); - m_Stopwords.put("demselben", dummy); - m_Stopwords.put("dieselbe", dummy); - m_Stopwords.put("dieselben", dummy); - m_Stopwords.put("dasselbe", dummy); + m_Stopwords.put("der", dummy); + m_Stopwords.put("den", dummy); + m_Stopwords.put("des", dummy); + m_Stopwords.put("dem", dummy); + m_Stopwords.put("die", dummy); + m_Stopwords.put("das", dummy); - m_Stopwords.put("dazu", dummy); + m_Stopwords.put("da\u00df", dummy); - m_Stopwords.put("dein", dummy); - m_Stopwords.put("deine", dummy); - m_Stopwords.put("deinem", dummy); - m_Stopwords.put("deinen", dummy); - m_Stopwords.put("deiner", dummy); - m_Stopwords.put("deines", dummy); + m_Stopwords.put("derselbe", dummy); + m_Stopwords.put("derselben", dummy); + m_Stopwords.put("denselben", dummy); + m_Stopwords.put("desselben", dummy); + m_Stopwords.put("demselben", dummy); + m_Stopwords.put("dieselbe", dummy); + m_Stopwords.put("dieselben", dummy); + m_Stopwords.put("dasselbe", dummy); - m_Stopwords.put("denn", dummy); - - m_Stopwords.put("derer", dummy); - m_Stopwords.put("dessen", dummy); - - m_Stopwords.put("dich", dummy); - m_Stopwords.put("dir", dummy); - m_Stopwords.put("du", dummy); + m_Stopwords.put("dazu", dummy); - m_Stopwords.put("dies", dummy); - m_Stopwords.put("diese", dummy); - m_Stopwords.put("diesem", dummy); - m_Stopwords.put("diesen", dummy); - m_Stopwords.put("dieser", dummy); - m_Stopwords.put("dieses", dummy); + m_Stopwords.put("dein", dummy); + m_Stopwords.put("deine", dummy); + m_Stopwords.put("deinem", dummy); + m_Stopwords.put("deinen", dummy); + m_Stopwords.put("deiner", dummy); + m_Stopwords.put("deines", dummy); - m_Stopwords.put("doch", dummy); - m_Stopwords.put("dort", dummy); + m_Stopwords.put("denn", dummy); - m_Stopwords.put("durch", dummy); + m_Stopwords.put("derer", dummy); + m_Stopwords.put("dessen", dummy); - m_Stopwords.put("ein", dummy); - m_Stopwords.put("eine", dummy); - m_Stopwords.put("einem", dummy); - m_Stopwords.put("einen", dummy); - m_Stopwords.put("einer", dummy); - m_Stopwords.put("eines", dummy); + m_Stopwords.put("dich", dummy); + m_Stopwords.put("dir", dummy); + m_Stopwords.put("du", dummy); - m_Stopwords.put("einig", dummy); - m_Stopwords.put("einige", dummy); - m_Stopwords.put("einigem", dummy); - m_Stopwords.put("einigen", dummy); - m_Stopwords.put("einiger", dummy); - m_Stopwords.put("einiges", dummy); + m_Stopwords.put("dies", dummy); + m_Stopwords.put("diese", dummy); + m_Stopwords.put("diesem", dummy); + m_Stopwords.put("diesen", dummy); + m_Stopwords.put("dieser", dummy); + m_Stopwords.put("dieses", dummy); - m_Stopwords.put("einmal", dummy); + m_Stopwords.put("doch", dummy); + m_Stopwords.put("dort", dummy); - m_Stopwords.put("er", dummy); - m_Stopwords.put("ihn", dummy); - m_Stopwords.put("ihm", dummy); + m_Stopwords.put("durch", dummy); - m_Stopwords.put("es", dummy); - m_Stopwords.put("etwas", dummy); + m_Stopwords.put("ein", dummy); + m_Stopwords.put("eine", dummy); + m_Stopwords.put("einem", dummy); + m_Stopwords.put("einen", dummy); + m_Stopwords.put("einer", dummy); + m_Stopwords.put("eines", dummy); - m_Stopwords.put("euer", dummy); - m_Stopwords.put("eure", dummy); - m_Stopwords.put("eurem", dummy); - m_Stopwords.put("euren", dummy); - m_Stopwords.put("eurer", dummy); - m_Stopwords.put("eures", dummy); + m_Stopwords.put("einig", dummy); + m_Stopwords.put("einige", dummy); + m_Stopwords.put("einigem", dummy); + m_Stopwords.put("einigen", dummy); + m_Stopwords.put("einiger", dummy); + m_Stopwords.put("einiges", dummy); - m_Stopwords.put("f\u00fcr", dummy); - m_Stopwords.put("gegen", dummy); - m_Stopwords.put("gewesen", dummy); - m_Stopwords.put("hab", dummy); - m_Stopwords.put("habe", dummy); - m_Stopwords.put("haben", dummy); - m_Stopwords.put("hat", dummy); - m_Stopwords.put("hatte", dummy); - m_Stopwords.put("hatten", dummy); - m_Stopwords.put("hier", dummy); - m_Stopwords.put("hin", dummy); - m_Stopwords.put("hinter", dummy); - - m_Stopwords.put("ich", dummy); - m_Stopwords.put("mich", dummy); - m_Stopwords.put("mir", dummy); + m_Stopwords.put("einmal", dummy); - m_Stopwords.put("ihr", dummy); - m_Stopwords.put("ihre", dummy); - m_Stopwords.put("ihrem", dummy); - m_Stopwords.put("ihren", dummy); - m_Stopwords.put("ihrer", dummy); - m_Stopwords.put("ihres", dummy); - m_Stopwords.put("euch", dummy); + m_Stopwords.put("er", dummy); + m_Stopwords.put("ihn", dummy); + m_Stopwords.put("ihm", dummy); - m_Stopwords.put("im", dummy); - m_Stopwords.put("in", dummy); - m_Stopwords.put("indem", dummy); - m_Stopwords.put("ins", dummy); - m_Stopwords.put("ist", dummy); + m_Stopwords.put("es", dummy); + m_Stopwords.put("etwas", dummy); - m_Stopwords.put("jede", dummy); - m_Stopwords.put("jedem", dummy); - m_Stopwords.put("jeden", dummy); - m_Stopwords.put("jeder", dummy); - m_Stopwords.put("jedes", dummy); + m_Stopwords.put("euer", dummy); + m_Stopwords.put("eure", dummy); + m_Stopwords.put("eurem", dummy); + m_Stopwords.put("euren", dummy); + m_Stopwords.put("eurer", dummy); + m_Stopwords.put("eures", dummy); - m_Stopwords.put("jene", dummy); - m_Stopwords.put("jenem", dummy); - m_Stopwords.put("jenen", dummy); - m_Stopwords.put("jener", dummy); - m_Stopwords.put("jenes", dummy); + m_Stopwords.put("f\u00fcr", dummy); + m_Stopwords.put("gegen", dummy); + m_Stopwords.put("gewesen", dummy); + m_Stopwords.put("hab", dummy); + m_Stopwords.put("habe", dummy); + m_Stopwords.put("haben", dummy); + m_Stopwords.put("hat", dummy); + m_Stopwords.put("hatte", dummy); + m_Stopwords.put("hatten", dummy); + m_Stopwords.put("hier", dummy); + m_Stopwords.put("hin", dummy); + m_Stopwords.put("hinter", dummy); - m_Stopwords.put("jetzt", dummy); - m_Stopwords.put("kann", dummy); + m_Stopwords.put("ich", dummy); + m_Stopwords.put("mich", dummy); + m_Stopwords.put("mir", dummy); - m_Stopwords.put("kein", dummy); - m_Stopwords.put("keine", dummy); - m_Stopwords.put("keinem", dummy); - m_Stopwords.put("keinen", dummy); - m_Stopwords.put("keiner", dummy); - m_Stopwords.put("keines", dummy); + m_Stopwords.put("ihr", dummy); + m_Stopwords.put("ihre", dummy); + m_Stopwords.put("ihrem", dummy); + m_Stopwords.put("ihren", dummy); + m_Stopwords.put("ihrer", dummy); + m_Stopwords.put("ihres", dummy); + m_Stopwords.put("euch", dummy); - m_Stopwords.put("k\u00f6nnen", dummy); - m_Stopwords.put("k\u00f6nnte", dummy); - m_Stopwords.put("machen", dummy); - m_Stopwords.put("man", dummy); + m_Stopwords.put("im", dummy); + m_Stopwords.put("in", dummy); + m_Stopwords.put("indem", dummy); + m_Stopwords.put("ins", dummy); + m_Stopwords.put("ist", dummy); - m_Stopwords.put("manche", dummy); - m_Stopwords.put("manchem", dummy); - m_Stopwords.put("manchen", dummy); - m_Stopwords.put("mancher", dummy); - m_Stopwords.put("manches", dummy); + m_Stopwords.put("jede", dummy); + m_Stopwords.put("jedem", dummy); + m_Stopwords.put("jeden", dummy); + m_Stopwords.put("jeder", dummy); + m_Stopwords.put("jedes", dummy); - m_Stopwords.put("mein", dummy); - m_Stopwords.put("meine", dummy); - m_Stopwords.put("meinem", dummy); - m_Stopwords.put("meinen", dummy); - m_Stopwords.put("meiner", dummy); - m_Stopwords.put("meines", dummy); + m_Stopwords.put("jene", dummy); + m_Stopwords.put("jenem", dummy); + m_Stopwords.put("jenen", dummy); + m_Stopwords.put("jener", dummy); + m_Stopwords.put("jenes", dummy); - m_Stopwords.put("mit", dummy); - m_Stopwords.put("muss", dummy); - m_Stopwords.put("musste", dummy); - m_Stopwords.put("nach", dummy); - m_Stopwords.put("nicht", dummy); - m_Stopwords.put("nichts", dummy); - m_Stopwords.put("noch", dummy); - m_Stopwords.put("nun", dummy); - m_Stopwords.put("nur", dummy); - m_Stopwords.put("ob", dummy); - m_Stopwords.put("oder", dummy); - m_Stopwords.put("ohne", dummy); - m_Stopwords.put("sehr", dummy); + m_Stopwords.put("jetzt", dummy); + m_Stopwords.put("kann", dummy); - m_Stopwords.put("sein", dummy); - m_Stopwords.put("seine", dummy); - m_Stopwords.put("seinem", dummy); - m_Stopwords.put("seinen", dummy); - m_Stopwords.put("seiner", dummy); - m_Stopwords.put("seines", dummy); + m_Stopwords.put("kein", dummy); + m_Stopwords.put("keine", dummy); + m_Stopwords.put("keinem", dummy); + m_Stopwords.put("keinen", dummy); + m_Stopwords.put("keiner", dummy); + m_Stopwords.put("keines", dummy); - m_Stopwords.put("selbst", dummy); - m_Stopwords.put("sich", dummy); - - m_Stopwords.put("sie", dummy); - m_Stopwords.put("ihnen", dummy); + m_Stopwords.put("k\u00f6nnen", dummy); + m_Stopwords.put("k\u00f6nnte", dummy); + m_Stopwords.put("machen", dummy); + m_Stopwords.put("man", dummy); - m_Stopwords.put("sind", dummy); - m_Stopwords.put("so", dummy); + m_Stopwords.put("manche", dummy); + m_Stopwords.put("manchem", dummy); + m_Stopwords.put("manchen", dummy); + m_Stopwords.put("mancher", dummy); + m_Stopwords.put("manches", dummy); - m_Stopwords.put("solche", dummy); - m_Stopwords.put("solchem", dummy); - m_Stopwords.put("solchen", dummy); - m_Stopwords.put("solcher", dummy); - m_Stopwords.put("solches", dummy); + m_Stopwords.put("mein", dummy); + m_Stopwords.put("meine", dummy); + m_Stopwords.put("meinem", dummy); + m_Stopwords.put("meinen", dummy); + m_Stopwords.put("meiner", dummy); + m_Stopwords.put("meines", dummy); - m_Stopwords.put("soll", dummy); - m_Stopwords.put("sollte", dummy); - m_Stopwords.put("sondern", dummy); - m_Stopwords.put("sonst", dummy); - m_Stopwords.put("\00fcber", dummy); - m_Stopwords.put("um", dummy); - m_Stopwords.put("und", dummy); + m_Stopwords.put("mit", dummy); + m_Stopwords.put("muss", dummy); + m_Stopwords.put("musste", dummy); + m_Stopwords.put("nach", dummy); + m_Stopwords.put("nicht", dummy); + m_Stopwords.put("nichts", dummy); + m_Stopwords.put("noch", dummy); + m_Stopwords.put("nun", dummy); + m_Stopwords.put("nur", dummy); + m_Stopwords.put("ob", dummy); + m_Stopwords.put("oder", dummy); + m_Stopwords.put("ohne", dummy); + m_Stopwords.put("sehr", dummy); - m_Stopwords.put("uns", dummy); - m_Stopwords.put("unser", dummy); - m_Stopwords.put("unserem", dummy); - m_Stopwords.put("unseren", dummy); - m_Stopwords.put("unsere", dummy); - m_Stopwords.put("unseres", dummy); + m_Stopwords.put("sein", dummy); + m_Stopwords.put("seine", dummy); + m_Stopwords.put("seinem", dummy); + m_Stopwords.put("seinen", dummy); + m_Stopwords.put("seiner", dummy); + m_Stopwords.put("seines", dummy); - m_Stopwords.put("unter", dummy); - m_Stopwords.put("viel", dummy); - m_Stopwords.put("vom", dummy); - m_Stopwords.put("von", dummy); - m_Stopwords.put("vor", dummy); - m_Stopwords.put("w\u00e4hrend", dummy); - m_Stopwords.put("war", dummy); - m_Stopwords.put("waren", dummy); - m_Stopwords.put("warst", dummy); - m_Stopwords.put("was", dummy); - m_Stopwords.put("weg", dummy); - m_Stopwords.put("weil", dummy); - m_Stopwords.put("weiter", dummy); + m_Stopwords.put("selbst", dummy); + m_Stopwords.put("sich", dummy); - m_Stopwords.put("welche", dummy); - m_Stopwords.put("welchem", dummy); - m_Stopwords.put("welchen", dummy); - m_Stopwords.put("welcher", dummy); - m_Stopwords.put("welches", dummy); + m_Stopwords.put("sie", dummy); + m_Stopwords.put("ihnen", dummy); - m_Stopwords.put("wenn", dummy); - m_Stopwords.put("werde", dummy); - m_Stopwords.put("werden", dummy); - m_Stopwords.put("wie", dummy); - m_Stopwords.put("wieder", dummy); - m_Stopwords.put("will", dummy); - m_Stopwords.put("wir", dummy); - m_Stopwords.put("wird", dummy); - m_Stopwords.put("wirst", dummy); - m_Stopwords.put("wo", dummy); - m_Stopwords.put("wollen", dummy); - m_Stopwords.put("wollte", dummy); - m_Stopwords.put("w\u00fcrde", dummy); - m_Stopwords.put("w\u00fcrden", dummy); - m_Stopwords.put("zu", dummy); - m_Stopwords.put("zum", dummy); - m_Stopwords.put("zur", dummy); - m_Stopwords.put("zwar", dummy); - m_Stopwords.put("zwischen", dummy); + m_Stopwords.put("sind", dummy); + m_Stopwords.put("so", dummy); + + m_Stopwords.put("solche", dummy); + m_Stopwords.put("solchem", dummy); + m_Stopwords.put("solchen", dummy); + m_Stopwords.put("solcher", dummy); + m_Stopwords.put("solches", dummy); + + m_Stopwords.put("soll", dummy); + m_Stopwords.put("sollte", dummy); + m_Stopwords.put("sondern", dummy); + m_Stopwords.put("sonst", dummy); + m_Stopwords.put("\00fcber", dummy); + m_Stopwords.put("um", dummy); + m_Stopwords.put("und", dummy); + + m_Stopwords.put("uns", dummy); + m_Stopwords.put("unser", dummy); + m_Stopwords.put("unserem", dummy); + m_Stopwords.put("unseren", dummy); + m_Stopwords.put("unsere", dummy); + m_Stopwords.put("unseres", dummy); + + m_Stopwords.put("unter", dummy); + m_Stopwords.put("viel", dummy); + m_Stopwords.put("vom", dummy); + m_Stopwords.put("von", dummy); + m_Stopwords.put("vor", dummy); + m_Stopwords.put("w\u00e4hrend", dummy); + m_Stopwords.put("war", dummy); + m_Stopwords.put("waren", dummy); + m_Stopwords.put("warst", dummy); + m_Stopwords.put("was", dummy); + m_Stopwords.put("weg", dummy); + m_Stopwords.put("weil", dummy); + m_Stopwords.put("weiter", dummy); + + m_Stopwords.put("welche", dummy); + m_Stopwords.put("welchem", dummy); + m_Stopwords.put("welchen", dummy); + m_Stopwords.put("welcher", dummy); + m_Stopwords.put("welches", dummy); + + m_Stopwords.put("wenn", dummy); + m_Stopwords.put("werde", dummy); + m_Stopwords.put("werden", dummy); + m_Stopwords.put("wie", dummy); + m_Stopwords.put("wieder", dummy); + m_Stopwords.put("will", dummy); + m_Stopwords.put("wir", dummy); + m_Stopwords.put("wird", dummy); + m_Stopwords.put("wirst", dummy); + m_Stopwords.put("wo", dummy); + m_Stopwords.put("wollen", dummy); + m_Stopwords.put("wollte", dummy); + m_Stopwords.put("w\u00fcrde", dummy); + m_Stopwords.put("w\u00fcrden", dummy); + m_Stopwords.put("zu", dummy); + m_Stopwords.put("zum", dummy); + m_Stopwords.put("zur", dummy); + m_Stopwords.put("zwar", dummy); + m_Stopwords.put("zwischen", dummy); + } + logger.debug("Static initalizer is finished."); } - } - - /** - * Returns true if the given string is a stop word. - */ - public boolean isStopword(String str) { - return m_Stopwords.containsKey(str.toLowerCase()); - } + /** + * Returns true if the given string is a stop word. + */ + public boolean isStopword(String str) { + + return m_Stopwords.containsKey(str.toLowerCase()); + } } - - diff --git a/ccm-ldn-terms/src/kea/stopwords/StopwordsSpanish.java b/ccm-ldn-terms/src/kea/stopwords/StopwordsSpanish.java index 488f87884..f8206339c 100644 --- a/ccm-ldn-terms/src/kea/stopwords/StopwordsSpanish.java +++ b/ccm-ldn-terms/src/kea/stopwords/StopwordsSpanish.java @@ -1,12 +1,11 @@ package kea.stopwords; - - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.Hashtable; +import org.apache.log4j.Logger; /** * Class that can test whether a given string is a stop word. @@ -16,45 +15,44 @@ import java.util.Hashtable; * @version 1.0 */ public class StopwordsSpanish extends Stopwords { - - /** - * - */ - private static final long serialVersionUID = 1L; - - - /** The hashtable containing the list of stopwords */ - private static Hashtable m_Stopwords = null; - - - static { - - if (m_Stopwords == null) { - m_Stopwords = new Hashtable(); - Double dummy = new Double(0); - File txt = new File("data/stopwords/stopwords_es.txt"); - InputStreamReader is; - String sw = null; - try { - is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); - BufferedReader br = new BufferedReader(is); - while ((sw=br.readLine()) != null) { - m_Stopwords.put(sw, dummy); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - } - - /** - * Returns true if the given string is a stop word. - */ - public boolean isStopword(String str) { - - return m_Stopwords.containsKey(str.toLowerCase()); - } + + private static final Logger logger = + Logger.getLogger(StopwordsSpanish.class); + /** + * + */ + private static final long serialVersionUID = 1L; + /** The hashtable containing the list of stopwords */ + private static Hashtable m_Stopwords = null; + + static { + logger.debug("Static initalizer is starting..."); + if (m_Stopwords == null) { + m_Stopwords = new Hashtable(); + Double dummy = new Double(0); + File txt = new File("data/stopwords/stopwords_es.txt"); + InputStreamReader is; + String sw = null; + try { + is = new InputStreamReader(new FileInputStream(txt), "UTF-8"); + BufferedReader br = new BufferedReader(is); + while ((sw = br.readLine()) != null) { + m_Stopwords.put(sw, dummy); + } + } catch (Exception e) { + logger.error("Static initalizer failed: ", e); + throw new RuntimeException(e); + } + + } + logger.debug("Static initalizer is finished."); + } + + /** + * Returns true if the given string is a stop word. + */ + public boolean isStopword(String str) { + + return m_Stopwords.containsKey(str.toLowerCase()); + } } - - diff --git a/ccm-ldn-theme/src/com/arsdigita/london/theme/ThemeApplication.java b/ccm-ldn-theme/src/com/arsdigita/london/theme/ThemeApplication.java index 39d95f339..23b41bae6 100755 --- a/ccm-ldn-theme/src/com/arsdigita/london/theme/ThemeApplication.java +++ b/ccm-ldn-theme/src/com/arsdigita/london/theme/ThemeApplication.java @@ -41,7 +41,9 @@ public class ThemeApplication extends Application { public static ThemeConfig s_config = new ThemeConfig(); static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static ThemeConfig getConfig() { diff --git a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java index 8c90e28da..8a0dcb7e2 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java @@ -27,6 +27,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; // import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.runtime.DomainInitEvent; +import org.apache.log4j.Logger; // import com.arsdigita.runtime.LegacyInitEvent; /** @@ -37,86 +38,91 @@ import com.arsdigita.runtime.DomainInitEvent; */ public class ContactInitializer extends ContentTypeInitializer { - public ContactInitializer() { - super("ccm-ldn-types-contact.pdl.mf", Contact.BASE_DATA_OBJECT_TYPE); - } + private static final Logger logger = Logger.getLogger( + ContactInitializer.class); - public String[] getStylesheets() { - return new String [] { - "/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl", - }; - } - - public String getTraversalXML() { - return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Contact.xml"; - } - - private static ArrayList phoneTypesList = new ArrayList(10); - - static { - phoneTypesList.add("Office"); - phoneTypesList.add("Mobile"); - phoneTypesList.add("Fax"); - phoneTypesList.add("Home"); - phoneTypesList.add("Minicom"); - } - - /** - * Return the statically initialized list of phone types. - */ - public static ArrayList getPhoneTypes(){ - return phoneTypesList; + public ContactInitializer() { + super("ccm-ldn-types-contact.pdl.mf", Contact.BASE_DATA_OBJECT_TYPE); } - + + public String[] getStylesheets() { + return new String[]{ + "/static/content-types/com/arsdigita/cms/contenttypes/Contact.xsl",}; + } + + public String getTraversalXML() { + return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Contact.xml"; + } + private static ArrayList phoneTypesList = new ArrayList(10); + + static { + logger.debug("Static initalizer starting..."); + phoneTypesList.add("Office"); + phoneTypesList.add("Mobile"); + phoneTypesList.add("Fax"); + phoneTypesList.add("Home"); + phoneTypesList.add("Minicom"); + logger.debug("Static initalizer finished."); + } + + /** + * Return the statically initialized list of phone types. + */ + public static ArrayList getPhoneTypes() { + return phoneTypesList; + } + // public void init(LegacyInitEvent evt) { public void init(DomainInitEvent evt) { - super.init(evt); - - if (ContentSection.getConfig().getHasContactsAuthoringStep()) { + super.init(evt); - // Add the "Contact"authoring step - AuthoringKitWizard.registerAssetStep( + if (ContentSection.getConfig().getHasContactsAuthoringStep()) { + + // Add the "Contact"authoring step + AuthoringKitWizard.registerAssetStep( getBaseType(), getAuthoringStep(), getAuthoringStepLabel(), getAuthoringStepDescription(), getAuthoringStepSortKey()); - - // and sort out the display - at the moment this is just the + + // and sort out the display - at the moment this is just the // basic properties, addresses and phones - ContentItemTraversalAdapter associatedContactTraversalAdapter = + ContentItemTraversalAdapter associatedContactTraversalAdapter = new ContentItemTraversalAdapter(); - associatedContactTraversalAdapter.addAssociationProperty("/object/phones"); - associatedContactTraversalAdapter.addAssociationProperty("/object/contactAddress"); - - ContentItemTraversalAdapter.registerAssetAdapter( + associatedContactTraversalAdapter.addAssociationProperty( + "/object/phones"); + associatedContactTraversalAdapter.addAssociationProperty( + "/object/contactAddress"); + + ContentItemTraversalAdapter.registerAssetAdapter( "associatedContactForItem", associatedContactTraversalAdapter, "com.arsdigita.cms.dispatcher.SimpleXMLGenerator"); - } - + } + } - + private int getAuthoringStepSortKey() { - // TODO - workout what this does and possibly make it configurable - return 1; + // TODO - workout what this does and possibly make it configurable + return 1; } - + private GlobalizedMessage getAuthoringStepDescription() { - return new GlobalizedMessage( - "com.arsdigita.cms.contenttypes.contact_authoring_step_description", - "com.arsdigita.cms.contenttypes.ContactResources"); + return new GlobalizedMessage( + "com.arsdigita.cms.contenttypes.contact_authoring_step_description", + "com.arsdigita.cms.contenttypes.ContactResources"); } - + private GlobalizedMessage getAuthoringStepLabel() { - return new GlobalizedMessage( + return new GlobalizedMessage( "com.arsdigita.cms.contenttypes.contact_authoring_step_label", "com.arsdigita.cms.contenttypes.ContactResources"); } - + private Class getAuthoringStep() { - return AddContactPropertiesStep.class; + return AddContactPropertiesStep.class; } - + private String getBaseType() { - return ContentPage.BASE_DATA_OBJECT_TYPE; + return ContentPage.BASE_DATA_OBJECT_TYPE; } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/scipublications/SciPublicationsServlet.java b/ccm-sci-publications/src/com/arsdigita/cms/scipublications/SciPublicationsServlet.java index 140bae10e..ee48dadcd 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/scipublications/SciPublicationsServlet.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/scipublications/SciPublicationsServlet.java @@ -19,6 +19,10 @@ */ package com.arsdigita.cms.scipublications; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Page; +import com.arsdigita.bebop.PageFactory; import com.arsdigita.categorization.CategorizedCollection; import com.arsdigita.categorization.Category; import com.arsdigita.cms.ContentBundle; @@ -29,8 +33,11 @@ import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.ACSObject; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; import com.arsdigita.web.Application; import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; @@ -127,6 +134,25 @@ public class SciPublicationsServlet extends BaseApplicationServlet { response.getWriter().append("Please choose an application."); //ToDo: Show a menu? + } else if ("hellobebop".equals(path)) { + Page page; + Form form; + Label label; + + page = PageFactory.buildPage("SciPublications", + "Hello World with Bebop"); + form = new Form("HelloWorld"); + label = new Label("Hello World! Created with Bebop."); + + form.add(label); + page.add(form); + + page.lock(); + + Document document = page.buildDocument(request, response); + PresentationManager presentationManager = Templating. + getPresentationManager(); + presentationManager.servePage(document, request, response); } else if ("export".equals(path)) { logger.debug("Export a publication"); @@ -413,7 +439,7 @@ public class SciPublicationsServlet extends BaseApplicationServlet { response.setHeader("Content-Disposition", String.format( "attachment; filename=publications.%s", - exporter.getSupportedFormat(). + exporter.getSupportedFormat(). getFileExtension())); } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciDepartment.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciDepartment.java index b2830e351..5744ded2e 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciDepartment.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciDepartment.java @@ -25,6 +25,7 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.util.Assert; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** *

@@ -66,6 +67,7 @@ import java.math.BigDecimal; */ public class SciDepartment extends GenericOrganizationalUnit { + private static final Logger logger = Logger.getLogger(SciDepartment.class); public static final String DEPARTMENT_SHORT_DESCRIPTION = "departmentShortDescription"; public static final String DEPARTMENT_DESCRIPTION = "departmentDescription"; @@ -81,7 +83,9 @@ public class SciDepartment extends GenericOrganizationalUnit { new SciOrganizationConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public SciDepartment() { diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciMember.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciMember.java index 384f1f65b..35411356b 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciMember.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciMember.java @@ -23,6 +23,7 @@ import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** * A concrete class extending {@link GenericPerson}. Does not add any new @@ -32,14 +33,17 @@ import java.math.BigDecimal; * @author Jens Pelzetter */ public class SciMember extends GenericPerson { - + + private static final Logger logger = Logger.getLogger(SciMember.class); public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.SciMember"; private static final SciOrganizationConfig s_config = new SciOrganizationConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer starting..."); } public SciMember() { diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganization.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganization.java index 3aad68a65..a8216abd1 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganization.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganization.java @@ -25,6 +25,7 @@ import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.util.Assert; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** *

@@ -56,10 +57,11 @@ import java.math.BigDecimal; * @author Jens Pelzetter * @see GenericOrganizationalUnit * @see SciDepartment - * @see SciProject^ + * @see SciProject */ public class SciOrganization extends GenericOrganizationalUnit { + private static final Logger logger = Logger.getLogger(SciOrganization.class); public static final String ORGANIZATION_SHORT_DESCRIPTION = "organizationShortDescription"; public static final String ORGANIZATION_DESCRIPTION = @@ -74,7 +76,9 @@ public class SciOrganization extends GenericOrganizationalUnit { new SciOrganizationConfig(); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public SciOrganization() { diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java index 56fe97ba6..e47797d11 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java @@ -84,7 +84,9 @@ public class SciProject extends GenericOrganizationalUnit { private static final Logger logger = Logger.getLogger(SciProject.class); static { + logger.debug("Static initalizer starting..."); s_config.load(); + logger.debug("Static initalizer finished."); } public SciProject() { diff --git a/ccm-shp-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java b/ccm-shp-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java index 7d31607f7..56da85a78 100755 --- a/ccm-shp-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java +++ b/ccm-shp-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.aplaws; import com.arsdigita.xml.Element; @@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property; import java.util.HashMap; import java.util.Stack; import java.math.BigDecimal; +import org.apache.log4j.Logger; public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { + private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class); private boolean m_wrapRoot = false; private boolean m_wrapObjects = false; private boolean m_wrapAttributes = false; - - - private Stack m_history = new Stack(); private HashMap m_elements = new HashMap(); - // The xs:element private Element m_element; // The (optional) xs:complexType @@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // The (optional property private Property m_property; private Stack m_properties = new Stack(); - private Element m_root; private String m_rootName; - public static final String SCHEMA_PREFIX = "xs:"; - - public static final String SCHEMA_NS = - "http://www.w3.org/2001/XMLSchema"; - + public static final String SCHEMA_NS = + "http://www.w3.org/2001/XMLSchema"; private static HashMap s_types = new HashMap(); + static { + logger.debug("Static initalizer starting..."); s_types.put(String.class, "xs:string"); s_types.put(Boolean.class, "xs:boolean"); s_types.put(Integer.class, "xs:integer"); s_types.put(BigDecimal.class, "xs:double"); + logger.debug("Static initalizer finished."); } protected static String lookupType(Class klass) { if (s_types.containsKey(klass)) { - return (String)s_types.get(klass); + return (String) s_types.get(klass); } return "xs:string"; } - + public static void registerType(Class klass, String type) { s_types.put(klass, type); } - public ObjectTypeSchemaGenerator(String rootName, String namespace) { m_root = new Element(SCHEMA_PREFIX + "schema", SCHEMA_NS); m_rootName = rootName; - + // Set the namespace for nodes defined by the schema m_root.addAttribute("targetNamespace", namespace); // Set the default namespace for unqualified nodes @@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { return m_root; } - /** * Determines XML output for root object. * If set to true a separate element will @@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); m_sequence = sequence; } - + Element parent; String name; if (m_element == null) { if (m_wrapRoot) { - Element element = m_root.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_root.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", m_rootName); - - Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", + + Element type = element.newChildElement(SCHEMA_PREFIX + + "complexType", SCHEMA_NS); - Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); - + parent = sequence; name = nameFromPath(path); } else { @@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); - + Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute", SCHEMA_NS); oid.addAttribute("name", "oid"); oid.addAttribute("type", "xs:string"); - + // Add to the path -> element map, not that we use this info yet m_elements.put(path, element); // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); + m_history.push(new Element[]{m_element, m_type, m_sequence}); m_element = element; m_type = type; @@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { */ protected void endObject(ObjectType obj, String path) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; @@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapAttributes) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } @@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); element.addAttribute("name", property.getName()); // XXX pdl type -> xs type mapping - element.addAttribute("type",lookupType(property.getJavaClass())); + element.addAttribute("type", lookupType(property.getJavaClass())); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); @@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_sequence.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } else { @@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_type.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } @@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } /** @@ -324,26 +324,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } - } diff --git a/ccm-webpage/src/com/arsdigita/cms/webpage/installer/Initializer.java b/ccm-webpage/src/com/arsdigita/cms/webpage/installer/Initializer.java index 72083845d..cf3dc3e0e 100755 --- a/ccm-webpage/src/com/arsdigita/cms/webpage/installer/Initializer.java +++ b/ccm-webpage/src/com/arsdigita/cms/webpage/installer/Initializer.java @@ -12,7 +12,6 @@ * rights and limitations under the License. * */ - package com.arsdigita.cms.webpage.installer; import com.arsdigita.cms.webpage.Webpage; @@ -55,17 +54,12 @@ import java.util.List; import com.arsdigita.util.Assert; import com.arsdigita.db.DbHelper; - public class Initializer extends CompoundInitializer { //public static final String CONTENT_SECTION = "contentSection"; - - private static Logger s_log = Logger.getLogger - (Initializer.class.getName()); - + private static Logger s_log = Logger.getLogger(Initializer.class.getName()); //private Configuration m_conf = new Configuration(); - public Initializer() { final String url = RuntimeConfig.getConfig().getJDBCURL(); final int database = DbHelper.getDatabaseFromURL(url); @@ -81,31 +75,29 @@ public class Initializer extends CompoundInitializer { //public Configuration getConfiguration() { // return m_conf; //} - - + @Override public void init(DomainInitEvent e) { super.init(e); - - e.getFactory().registerInstantiator - (Webpage.BASE_DATA_OBJECT_TYPE, - new ACSObjectInstantiator() { - public DomainObject doNewInstance(DataObject dataObject) { - return new Webpage(dataObject); - } - }); - + + e.getFactory().registerInstantiator(Webpage.BASE_DATA_OBJECT_TYPE, + new ACSObjectInstantiator() { + + @Override + public DomainObject doNewInstance(DataObject dataObject) { + return new Webpage(dataObject); + } + }); + startup(); } - - // ============================================================ - - private static final WebpageConfig s_config = new WebpageConfig(); // FR: load the parameter values static { + s_log.debug("Static initalizer starting..."); s_config.load(); + s_log.debug("Static initalizer finished."); } public static WebpageConfig getConfig() { @@ -121,20 +113,19 @@ public class Initializer extends CompoundInitializer { config.setContentSection(section); - TransactionContext txn = SessionManager.getSession() - .getTransactionContext(); + TransactionContext txn = SessionManager.getSession(). + getTransactionContext(); txn.beginTxn(); - + loadWebpagePortlet(); txn.commitTxn(); } - public void shutdown() { /* Empty */ } - + private void loadWebpagePortlet() { PortletSetup setup = new PortletSetup(s_log); setup.setPortletObjectType(WebpagePortlet.BASE_DATA_OBJECT_TYPE); @@ -142,6 +133,7 @@ public class Initializer extends CompoundInitializer { setup.setDescription("Displays a webpage"); setup.setProfile(PortletType.WIDE_PROFILE); setup.setInstantiator(new ACSObjectInstantiator() { + protected DomainObject doNewInstance(DataObject dataObject) { return new WebpagePortlet(dataObject); } @@ -149,23 +141,24 @@ public class Initializer extends CompoundInitializer { setup.run(); new ResourceTypeConfig(WebpagePortlet.BASE_DATA_OBJECT_TYPE) { - public ResourceConfigFormSection getCreateFormSection - (final ResourceType resType, final RequestLocal parentAppRL) { + + public ResourceConfigFormSection getCreateFormSection( + final ResourceType resType, final RequestLocal parentAppRL) { final ResourceConfigFormSection config = - new WebpagePortletEditor(resType, parentAppRL); - + new WebpagePortletEditor(resType, + parentAppRL); + return config; } - - public ResourceConfigFormSection getModifyFormSection - (final RequestLocal application) { + + public ResourceConfigFormSection getModifyFormSection( + final RequestLocal application) { final WebpagePortletEditor config = - new WebpagePortletEditor(application); - + new WebpagePortletEditor(application); + return config; } }; } - } diff --git a/ccm-zes-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java b/ccm-zes-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java index 7d31607f7..56da85a78 100644 --- a/ccm-zes-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java +++ b/ccm-zes-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java @@ -15,7 +15,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.aplaws; import com.arsdigita.xml.Element; @@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property; import java.util.HashMap; import java.util.Stack; import java.math.BigDecimal; +import org.apache.log4j.Logger; public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { + private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class); private boolean m_wrapRoot = false; private boolean m_wrapObjects = false; private boolean m_wrapAttributes = false; - - - private Stack m_history = new Stack(); private HashMap m_elements = new HashMap(); - // The xs:element private Element m_element; // The (optional) xs:complexType @@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // The (optional property private Property m_property; private Stack m_properties = new Stack(); - private Element m_root; private String m_rootName; - public static final String SCHEMA_PREFIX = "xs:"; - - public static final String SCHEMA_NS = - "http://www.w3.org/2001/XMLSchema"; - + public static final String SCHEMA_NS = + "http://www.w3.org/2001/XMLSchema"; private static HashMap s_types = new HashMap(); + static { + logger.debug("Static initalizer starting..."); s_types.put(String.class, "xs:string"); s_types.put(Boolean.class, "xs:boolean"); s_types.put(Integer.class, "xs:integer"); s_types.put(BigDecimal.class, "xs:double"); + logger.debug("Static initalizer finished."); } protected static String lookupType(Class klass) { if (s_types.containsKey(klass)) { - return (String)s_types.get(klass); + return (String) s_types.get(klass); } return "xs:string"; } - + public static void registerType(Class klass, String type) { s_types.put(klass, type); } - public ObjectTypeSchemaGenerator(String rootName, String namespace) { m_root = new Element(SCHEMA_PREFIX + "schema", SCHEMA_NS); m_rootName = rootName; - + // Set the namespace for nodes defined by the schema m_root.addAttribute("targetNamespace", namespace); // Set the default namespace for unqualified nodes @@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { return m_root; } - /** * Determines XML output for root object. * If set to true a separate element will @@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); m_sequence = sequence; } - + Element parent; String name; if (m_element == null) { if (m_wrapRoot) { - Element element = m_root.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_root.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", m_rootName); - - Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", + + Element type = element.newChildElement(SCHEMA_PREFIX + + "complexType", SCHEMA_NS); - Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); - + parent = sequence; name = nameFromPath(path); } else { @@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); - + Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute", SCHEMA_NS); oid.addAttribute("name", "oid"); oid.addAttribute("type", "xs:string"); - + // Add to the path -> element map, not that we use this info yet m_elements.put(path, element); // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); + m_history.push(new Element[]{m_element, m_type, m_sequence}); m_element = element; m_type = type; @@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { */ protected void endObject(ObjectType obj, String path) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; @@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapAttributes) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } @@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { SCHEMA_NS); element.addAttribute("name", property.getName()); // XXX pdl type -> xs type mapping - element.addAttribute("type",lookupType(property.getJavaClass())); + element.addAttribute("type", lookupType(property.getJavaClass())); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); @@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_sequence.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } else { @@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { // Add to element m_type.addContent(element); - + // Add to the path -> element map m_elements.put(path, element); } @@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } /** @@ -324,26 +324,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { Property property) { if (m_wrapObjects) { if (m_sequence == null) { - Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence", + Element sequence = m_type.newChildElement(SCHEMA_PREFIX + + "sequence", SCHEMA_NS); m_sequence = sequence; } - Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element", + Element element = m_sequence.newChildElement(SCHEMA_PREFIX + + "element", SCHEMA_NS); element.addAttribute("name", property.getName()); if (property.isNullable()) { element.addAttribute("minOccurs", "0"); } - + Element type = element.newChildElement(SCHEMA_PREFIX + "complexType", SCHEMA_NS); Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence", SCHEMA_NS); - + // Preserve context - m_history.push(new Element[] { m_element, m_type, m_sequence }); - + m_history.push(new Element[]{m_element, m_type, m_sequence}); + m_element = element; m_type = type; m_sequence = sequence; @@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal { String path, Property property) { if (m_wrapObjects) { - Element[] saved = (Element[])m_history.pop(); + Element[] saved = (Element[]) m_history.pop(); m_element = saved[0]; m_type = saved[1]; m_sequence = saved[2]; } - m_property = (Property)m_properties.pop(); + m_property = (Property) m_properties.pop(); } - }