- Einige static initalizer (static {...} Blöcke in ccm-cms::com.arsdigita.cms.dispatcher.BaseAsset und ccm-cms-assets-relatedlink::com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm entfernt
- Alle anderen static initalizers haben jetzt am Anfang und Ende eine Log-Ausgabe (Level debug), in Klassen die bisher keinen Logger hatten wurde ein Logger eingebaut - log4j.properties in ccm-core enthält jetzt vorbereitetet, auskommentierte Zeilen für alle Klassen mit static Blöcken git-svn-id: https://svn.libreccm.org/ccm/trunk@748 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
0a96c0fed6
commit
32aec3251d
|
|
@ -22,6 +22,7 @@ import com.arsdigita.web.Application;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,10 +32,13 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
*/
|
*/
|
||||||
public class HTTPAuth extends Application {
|
public class HTTPAuth extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(HTTPAuth.class);
|
||||||
private static HTTPAuthConfig s_config = new HTTPAuthConfig();
|
private static HTTPAuthConfig s_config = new HTTPAuthConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HTTPAuthConfig getConfig() {
|
public static HTTPAuthConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.auth.http;
|
package com.arsdigita.auth.http;
|
||||||
|
|
||||||
import com.arsdigita.util.parameter.Converters;
|
import com.arsdigita.util.parameter.Converters;
|
||||||
|
|
@ -43,29 +42,27 @@ import java.io.InputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class HTTPAuthConfig extends AbstractConfig {
|
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_isActive;
|
||||||
private BooleanParameter m_isDebugMode;
|
private BooleanParameter m_isDebugMode;
|
||||||
|
|
||||||
private IntegerParameter m_nonceTTL;
|
private IntegerParameter m_nonceTTL;
|
||||||
|
|
||||||
private StringParameter m_serverName;
|
private StringParameter m_serverName;
|
||||||
private IntegerParameter m_serverPort;
|
private IntegerParameter m_serverPort;
|
||||||
|
|
||||||
private Inet4AddressRangeParameter m_clientIPRange;
|
private Inet4AddressRangeParameter m_clientIPRange;
|
||||||
|
|
||||||
private StringParameter m_keyAlias;
|
private StringParameter m_keyAlias;
|
||||||
private StringParameter m_keyCypher;
|
private StringParameter m_keyCypher;
|
||||||
private StringParameter m_keyPassword;
|
private StringParameter m_keyPassword;
|
||||||
|
|
||||||
private StringParameter m_keystorePassword;
|
private StringParameter m_keystorePassword;
|
||||||
private StringParameter m_keystorePath;
|
private StringParameter m_keystorePath;
|
||||||
|
|
||||||
|
|
@ -90,11 +87,13 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
// XXX bz108251
|
// XXX bz108251
|
||||||
//Parameter.REQUIRED,
|
//Parameter.REQUIRED,
|
||||||
null);
|
null);
|
||||||
m_serverPort = new IntegerParameter("com.arsdigita.auth.http.server_port",
|
m_serverPort = new IntegerParameter(
|
||||||
|
"com.arsdigita.auth.http.server_port",
|
||||||
Parameter.OPTIONAL,
|
Parameter.OPTIONAL,
|
||||||
new Integer(80));
|
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,
|
Parameter.OPTIONAL,
|
||||||
// XXX bz108251
|
// XXX bz108251
|
||||||
//Parameter.REQUIRED,
|
//Parameter.REQUIRED,
|
||||||
|
|
@ -106,19 +105,22 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
m_keyCypher = new StringParameter("com.arsdigita.auth.http.key_cypher",
|
m_keyCypher = new StringParameter("com.arsdigita.auth.http.key_cypher",
|
||||||
Parameter.OPTIONAL,
|
Parameter.OPTIONAL,
|
||||||
"RSA");
|
"RSA");
|
||||||
m_keyPassword = new StringParameter("com.arsdigita.auth.http.key_password",
|
m_keyPassword = new StringParameter(
|
||||||
|
"com.arsdigita.auth.http.key_password",
|
||||||
Parameter.OPTIONAL,
|
Parameter.OPTIONAL,
|
||||||
// XXX bz108251
|
// XXX bz108251
|
||||||
//Parameter.REQUIRED,
|
//Parameter.REQUIRED,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
|
||||||
m_keystorePassword = new StringParameter("com.arsdigita.auth.http.keystore_password",
|
m_keystorePassword = new StringParameter(
|
||||||
|
"com.arsdigita.auth.http.keystore_password",
|
||||||
Parameter.OPTIONAL,
|
Parameter.OPTIONAL,
|
||||||
// XXX bz108251
|
// XXX bz108251
|
||||||
//Parameter.REQUIRED,
|
//Parameter.REQUIRED,
|
||||||
null);
|
null);
|
||||||
m_keystorePath = new StringParameter("com.arsdigita.auth.http.keystore_path",
|
m_keystorePath = new StringParameter(
|
||||||
|
"com.arsdigita.auth.http.keystore_path",
|
||||||
Parameter.OPTIONAL,
|
Parameter.OPTIONAL,
|
||||||
// XXX bz108251
|
// XXX bz108251
|
||||||
//Parameter.REQUIRED,
|
//Parameter.REQUIRED,
|
||||||
|
|
@ -153,44 +155,43 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getNonceTTL() {
|
public final int getNonceTTL() {
|
||||||
return ((Integer)get(m_nonceTTL)).intValue();
|
return ((Integer) get(m_nonceTTL)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getServerName() {
|
public final String getServerName() {
|
||||||
return (String)get(m_serverName);
|
return (String) get(m_serverName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getServerPort() {
|
public final int getServerPort() {
|
||||||
return ((Integer)get(m_serverPort)).intValue();
|
return ((Integer) get(m_serverPort)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Inet4AddressRange getClientIPRange() {
|
public final Inet4AddressRange getClientIPRange() {
|
||||||
return (Inet4AddressRange)get(m_clientIPRange);
|
return (Inet4AddressRange) get(m_clientIPRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getKeyAlias() {
|
public final String getKeyAlias() {
|
||||||
return (String)get(m_keyAlias);
|
return (String) get(m_keyAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getKeyCypher() {
|
public final String getKeyCypher() {
|
||||||
return (String)get(m_keyCypher);
|
return (String) get(m_keyCypher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getKeyPassword() {
|
public final String getKeyPassword() {
|
||||||
return (String)get(m_keyPassword);
|
return (String) get(m_keyPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getKeyStorePassword() {
|
public final String getKeyStorePassword() {
|
||||||
return (String)get(m_keystorePassword);
|
return (String) get(m_keystorePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package protected, since we won't neccessarily always
|
// Package protected, since we won't neccessarily always
|
||||||
// store the keystore in a file on disk
|
// store the keystore in a file on disk
|
||||||
final String getKeyStorePath() {
|
final String getKeyStorePath() {
|
||||||
return (String) get(m_keystorePath);
|
return (String) get(m_keystorePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final InputStream getKeyStoreStream() {
|
public final InputStream getKeyStoreStream() {
|
||||||
String file = getKeyStorePath();
|
String file = getKeyStorePath();
|
||||||
|
|
||||||
|
|
@ -200,12 +201,12 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
is = new FileInputStream(file);
|
is = new FileInputStream(file);
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot read keystore file " + file, ex);
|
"cannot read keystore file " + file, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final KeyStore getKeyStore() {
|
public final KeyStore getKeyStore() {
|
||||||
InputStream is = getKeyStoreStream();
|
InputStream is = getKeyStoreStream();
|
||||||
KeyStore store = null;
|
KeyStore store = null;
|
||||||
|
|
@ -215,23 +216,22 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
store = KeyStore.getInstance("JKS");
|
store = KeyStore.getInstance("JKS");
|
||||||
} catch (KeyStoreException ex) {
|
} catch (KeyStoreException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot get keystore instance JKS", ex);
|
"cannot get keystore instance JKS", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
store.load(is, getKeyStorePassword().toCharArray());
|
store.load(is, getKeyStorePassword().toCharArray());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot load keystore from " +
|
"cannot load keystore from " + getKeyStorePath(), ex);
|
||||||
getKeyStorePath(), ex);
|
|
||||||
} catch (CertificateException ex) {
|
} catch (CertificateException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot load keystore certificates from " +
|
"cannot load keystore certificates from "
|
||||||
getKeyStorePath(), ex);
|
+ getKeyStorePath(), ex);
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot check integrity of keystore " +
|
"cannot check integrity of keystore " + getKeyStorePath(),
|
||||||
getKeyStorePath(), ex);
|
ex);
|
||||||
}
|
}
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
@ -244,12 +244,12 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
cert = keystore.getCertificate(getKeyAlias());
|
cert = keystore.getCertificate(getKeyAlias());
|
||||||
} catch (KeyStoreException ex) {
|
} catch (KeyStoreException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot get public key from keystore " +
|
"cannot get public key from keystore " + getKeyStorePath(),
|
||||||
getKeyStorePath(), ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.exists(cert, Certificate.class);
|
Assert.exists(cert, Certificate.class);
|
||||||
|
|
||||||
return cert.getPublicKey();
|
return cert.getPublicKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,44 +258,45 @@ public class HTTPAuthConfig extends AbstractConfig {
|
||||||
|
|
||||||
Key key = null;
|
Key key = null;
|
||||||
try {
|
try {
|
||||||
key = keystore.getKey(getKeyAlias(),
|
key = keystore.getKey(getKeyAlias(),
|
||||||
getKeyPassword().toCharArray());
|
getKeyPassword().toCharArray());
|
||||||
} catch (KeyStoreException ex) {
|
} catch (KeyStoreException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot get private key from keystore " +
|
"cannot get private key from keystore " + getKeyStorePath(),
|
||||||
getKeyStorePath(), ex);
|
ex);
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot get private key from keystore " +
|
"cannot get private key from keystore " + getKeyStorePath(),
|
||||||
getKeyStorePath(), ex);
|
ex);
|
||||||
} catch (UnrecoverableKeyException ex) {
|
} catch (UnrecoverableKeyException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot get private key from keystore " +
|
"cannot get private key from keystore " + getKeyStorePath(),
|
||||||
getKeyStorePath(), ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.exists(key, Key.class);
|
Assert.exists(key, Key.class);
|
||||||
|
|
||||||
return (PrivateKey)key;
|
return (PrivateKey) key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Inet4AddressRangeConvertor implements Converter {
|
private static class Inet4AddressRangeConvertor implements Converter {
|
||||||
|
|
||||||
public Object convert(Class type,
|
public Object convert(Class type,
|
||||||
Object value) {
|
Object value) {
|
||||||
return Inet4AddressRange.getByName((String)value);
|
return Inet4AddressRange.getByName((String) value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Inet4AddressRangeParameter extends AbstractParameter {
|
private static class Inet4AddressRangeParameter extends AbstractParameter {
|
||||||
|
|
||||||
public Inet4AddressRangeParameter(final String name) {
|
public Inet4AddressRangeParameter(final String name) {
|
||||||
super(name, Inet4AddressRange.class);
|
super(name, Inet4AddressRange.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inet4AddressRangeParameter(final String name,
|
public Inet4AddressRangeParameter(final String name,
|
||||||
final int multiplicity,
|
final int multiplicity,
|
||||||
final Object defaalt) {
|
final Object defaalt) {
|
||||||
super(name, multiplicity, defaalt, Inet4AddressRange.class);
|
super(name, multiplicity, defaalt, Inet4AddressRange.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ public class HTTPLoginModule extends MappingLoginModule {
|
||||||
|
|
||||||
private static PublicKey s_publicKey = null;
|
private static PublicKey s_publicKey = null;
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
if (HTTPAuth.getConfig().isActive()) {
|
if (HTTPAuth.getConfig().isActive()) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Loading public key");
|
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.info("HTTP auth is not active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BASE64Decoder s_base64Decoder = new BASE64Decoder();
|
private static BASE64Decoder s_base64Decoder = new BASE64Decoder();
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,9 @@ public class FileAttachment extends FileAsset {
|
||||||
private static final FileAttachmentConfig s_config = new FileAttachmentConfig();
|
private static final FileAttachmentConfig s_config = new FileAttachmentConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.cms.contentassets;
|
package com.arsdigita.cms.contentassets;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
|
@ -42,28 +41,28 @@ import org.apache.log4j.Logger;
|
||||||
public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
||||||
|
|
||||||
/** PDL property name for contact details */
|
/** PDL property name for contact details */
|
||||||
public static final String IMAGE = "image";
|
public static final String IMAGE = "image";
|
||||||
public static final String ITEM = "item";
|
public static final String ITEM = "item";
|
||||||
public static final String USE_CONTEXT = "useContext";
|
public static final String USE_CONTEXT = "useContext";
|
||||||
public static final String CAPTION = "caption";
|
public static final String CAPTION = "caption";
|
||||||
public static final String DESCRIPTION = "description";
|
public static final String DESCRIPTION = "description";
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String IMAGE_ATTACHMENTS = "imageAttachments";
|
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";
|
public static final String IMAGE_LINK = "imageLink";
|
||||||
|
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
= "com.arsdigita.cms.contentassets.ItemImageAttachment";
|
"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
|
static {
|
||||||
= Logger.getLogger(ItemImageAttachment.class);
|
s_log.debug("Static initalizer starting...");
|
||||||
|
s_config.load();
|
||||||
private static final ItemImageAttachmentConfig s_config = new ItemImageAttachmentConfig();
|
s_log.debug("Static initalizer finished.");
|
||||||
|
}
|
||||||
static {
|
|
||||||
s_config.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemImageAttachment() {
|
private ItemImageAttachment() {
|
||||||
this(BASE_DATA_OBJECT_TYPE);
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
@ -81,57 +80,60 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemImageAttachment( ContentItem item, ReusableImageAsset image ) {
|
public ItemImageAttachment(ContentItem item, ReusableImageAsset image) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
set( ITEM, item );
|
set(ITEM, item);
|
||||||
set( IMAGE, image );
|
set(IMAGE, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemImageAttachment retrieve( OID oid ) {
|
public static ItemImageAttachment retrieve(OID oid) {
|
||||||
return (ItemImageAttachment) DomainObjectFactory.newInstance( oid );
|
return (ItemImageAttachment) DomainObjectFactory.newInstance(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemImageAttachmentConfig getConfig() {
|
||||||
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemImageAttachmentConfig getConfig() {
|
|
||||||
return s_config;
|
|
||||||
}
|
|
||||||
public ReusableImageAsset getImage() {
|
public ReusableImageAsset getImage() {
|
||||||
if( s_log.isDebugEnabled() )
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug( "Getting image for " + getOID() );
|
s_log.debug("Getting image for " + getOID());
|
||||||
|
}
|
||||||
|
|
||||||
DataObject dobj = (DataObject) get( IMAGE );
|
DataObject dobj = (DataObject) get(IMAGE);
|
||||||
Assert.exists( dobj );
|
Assert.exists(dobj);
|
||||||
|
|
||||||
return (ReusableImageAsset) DomainObjectFactory.newInstance( dobj );
|
return (ReusableImageAsset) DomainObjectFactory.newInstance(dobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImage( ReusableImageAsset image ) {
|
public void setImage(ReusableImageAsset image) {
|
||||||
Assert.exists( image, ReusableImageAsset.class );
|
Assert.exists(image, ReusableImageAsset.class);
|
||||||
set( IMAGE, image );
|
set(IMAGE, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentItem getItem() {
|
public ContentItem getItem() {
|
||||||
DataObject dobj = (DataObject) get( ITEM );
|
DataObject dobj = (DataObject) get(ITEM);
|
||||||
Assert.exists( dobj );
|
Assert.exists(dobj);
|
||||||
|
|
||||||
return (ContentItem) DomainObjectFactory.newInstance( dobj );
|
return (ContentItem) DomainObjectFactory.newInstance(dobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem( ContentItem item ) {
|
public void setItem(ContentItem item) {
|
||||||
Assert.exists( item, ContentItem.class );
|
Assert.exists(item, ContentItem.class);
|
||||||
set( ITEM, item );
|
set(ITEM, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retrieves links for a content item */
|
/** Retrieves links for a content item */
|
||||||
public static DataCollection getImageAttachments( ContentItem item ) {
|
public static DataCollection getImageAttachments(ContentItem item) {
|
||||||
Assert.exists( item, ContentItem.class );
|
Assert.exists(item, ContentItem.class);
|
||||||
|
|
||||||
if( s_log.isDebugEnabled() )
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Getting attachments for " + item.getOID() );
|
s_log.debug("Getting attachments for " + item.getOID());
|
||||||
|
}
|
||||||
|
|
||||||
DataCollection attachments = SessionManager.getSession().retrieve
|
DataCollection attachments = SessionManager.getSession().retrieve(
|
||||||
( BASE_DATA_OBJECT_TYPE );
|
BASE_DATA_OBJECT_TYPE);
|
||||||
attachments.addEqualsFilter( ITEM + ".id", item.getID() );
|
attachments.addEqualsFilter(ITEM + ".id", item.getID());
|
||||||
|
|
||||||
return attachments;
|
return attachments;
|
||||||
}
|
}
|
||||||
|
|
@ -144,52 +146,50 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
||||||
return (String) get(USE_CONTEXT);
|
return (String) get(USE_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCaption( String caption ) {
|
public void setCaption(String caption) {
|
||||||
set( CAPTION, caption );
|
set(CAPTION, caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCaption() {
|
public String getCaption() {
|
||||||
return (String) get( CAPTION );
|
return (String) get(CAPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle( String title ) {
|
public void setTitle(String title) {
|
||||||
set( TITLE, title );
|
set(TITLE, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return (String) get( TITLE );
|
return (String) get(TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription( String description) {
|
|
||||||
set( DESCRIPTION, description );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public void setDescription(String description) {
|
||||||
return (String) get( DESCRIPTION );
|
set(DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return (String) get(DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically publish an unpublished image
|
* Automatically publish an unpublished image
|
||||||
*/
|
*/
|
||||||
public boolean copyProperty( final CustomCopy source,
|
public boolean copyProperty(final CustomCopy source,
|
||||||
final Property property,
|
final Property property,
|
||||||
final ItemCopier copier ) {
|
final ItemCopier copier) {
|
||||||
String attribute = property.getName();
|
String attribute = property.getName();
|
||||||
if( ItemCopier.VERSION_COPY == copier.getCopyType() &&
|
if (ItemCopier.VERSION_COPY == copier.getCopyType() && IMAGE.equals(
|
||||||
IMAGE.equals( attribute ) )
|
attribute)) {
|
||||||
{
|
|
||||||
ItemImageAttachment attachment = (ItemImageAttachment) source;
|
ItemImageAttachment attachment = (ItemImageAttachment) source;
|
||||||
ReusableImageAsset image = attachment.getImage();
|
ReusableImageAsset image = attachment.getImage();
|
||||||
|
|
||||||
ReusableImageAsset liveImage =
|
ReusableImageAsset liveImage =
|
||||||
(ReusableImageAsset) image.getLiveVersion();
|
(ReusableImageAsset) image.getLiveVersion();
|
||||||
|
|
||||||
if( null == liveImage ) {
|
if (null == liveImage) {
|
||||||
liveImage = (ReusableImageAsset) image.createLiveVersion();
|
liveImage = (ReusableImageAsset) image.createLiveVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage( liveImage );
|
setImage(liveImage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,31 +197,30 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// chris gilbert - optional link
|
// chris gilbert - optional link
|
||||||
|
public Link getLink() {
|
||||||
|
Link link = null;
|
||||||
|
DataObject dobj = (DataObject) get(IMAGE_LINK);
|
||||||
|
if (dobj != null) {
|
||||||
|
|
||||||
public Link getLink() {
|
link = (Link) DomainObjectFactory.newInstance(dobj);
|
||||||
Link link = null;
|
}
|
||||||
DataObject dobj = (DataObject) get( IMAGE_LINK );
|
return link;
|
||||||
if (dobj != null) {
|
}
|
||||||
|
|
||||||
link = (Link) DomainObjectFactory.newInstance( dobj );
|
public void setLink(Link link) {
|
||||||
}
|
Assert.exists(link, Link.class);
|
||||||
return link;
|
set(IMAGE_LINK, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLink( Link link ) {
|
public void removeLink() {
|
||||||
Assert.exists( link, Link.class );
|
// when we delete the link, the image still references it in DB
|
||||||
set( IMAGE_LINK, link );
|
// 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(
|
||||||
public void removeLink() {
|
IMAGE_LINK));
|
||||||
// when we delete the link, the image still references it in DB
|
set(IMAGE_LINK, null);
|
||||||
// can't make it composite because then image is deleted if we delete
|
save();
|
||||||
// link. Have to set link to null first (I think)
|
link.delete();
|
||||||
DomainObject link = DomainObjectFactory.newInstance((DataObject)get(IMAGE_LINK));
|
|
||||||
set (IMAGE_LINK, null);
|
|
||||||
save();
|
|
||||||
link.delete();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ public class Note extends ACSObject {
|
||||||
private static final Logger s_log = Logger.getLogger( Note.class );
|
private static final Logger s_log = Logger.getLogger( Note.class );
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer is starting...");
|
||||||
DomainObjectFactory.registerInstantiator(
|
DomainObjectFactory.registerInstantiator(
|
||||||
BASE_DATA_OBJECT_TYPE,
|
BASE_DATA_OBJECT_TYPE,
|
||||||
new DomainObjectInstantiator() {
|
new DomainObjectInstantiator() {
|
||||||
|
|
@ -58,6 +59,8 @@ public class Note extends ACSObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CONTENT = "content";
|
public static final String CONTENT = "content";
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,9 @@ import com.arsdigita.util.Assert;
|
||||||
*/
|
*/
|
||||||
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
|
|
||||||
private static boolean isHideAdditionalResourceFields;
|
private static boolean isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
|
||||||
private String m_linkListName = "";
|
private String m_linkListName = "";
|
||||||
|
|
||||||
static {
|
|
||||||
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new form to edit the RelatedLink object specified
|
* Creates a new form to edit the RelatedLink object specified
|
||||||
* by the item selection model passed in.
|
* by the item selection model passed in.
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,9 @@ public class Event extends GenericArticle {
|
||||||
private static final EventConfig s_config = new EventConfig();
|
private static final EventConfig s_config = new EventConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final EventConfig getConfig() {
|
public static final EventConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,8 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This content type represents a GlossaryItem.
|
* This content type represents a GlossaryItem.
|
||||||
|
|
@ -36,62 +34,63 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class GlossaryItem extends ContentPage {
|
public class GlossaryItem extends ContentPage {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GlossaryItem.class);
|
||||||
/** PDL property name for definition */
|
/** PDL property name for definition */
|
||||||
public static final String DEFINITION = "definition";
|
public static final String DEFINITION = "definition";
|
||||||
|
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
= "com.arsdigita.cms.contenttypes.GlossaryItem";
|
"com.arsdigita.cms.contenttypes.GlossaryItem";
|
||||||
|
|
||||||
private static GlossaryItemConfig config = new GlossaryItemConfig();
|
private static GlossaryItemConfig config = new GlossaryItemConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
config.load();
|
logger.debug("Static initalizer starting...");
|
||||||
|
config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GlossaryItemConfig getConfig() {
|
public static GlossaryItemConfig getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlossaryItem() {
|
public GlossaryItem() {
|
||||||
this( BASE_DATA_OBJECT_TYPE );
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlossaryItem( BigDecimal id )
|
public GlossaryItem(BigDecimal id)
|
||||||
throws DataObjectNotFoundException {
|
throws DataObjectNotFoundException {
|
||||||
this( new OID( BASE_DATA_OBJECT_TYPE, id ) );
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlossaryItem( OID id )
|
public GlossaryItem(OID id)
|
||||||
throws DataObjectNotFoundException {
|
throws DataObjectNotFoundException {
|
||||||
super( id );
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlossaryItem( DataObject obj ) {
|
public GlossaryItem(DataObject obj) {
|
||||||
super( obj );
|
super(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlossaryItem( String type ) {
|
public GlossaryItem(String type) {
|
||||||
super( type );
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void beforeSave() {
|
public void beforeSave() {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
|
|
||||||
Assert.exists(getContentType(), ContentType.class);
|
Assert.exists(getContentType(), ContentType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* accessors *****************************************************/
|
/* accessors *****************************************************/
|
||||||
public String getDefinition() {
|
public String getDefinition() {
|
||||||
return (String) get( DEFINITION );
|
return (String) get(DEFINITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefinition( String definition ) {
|
public void setDefinition(String definition) {
|
||||||
set( DEFINITION, definition );
|
set(DEFINITION, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search stuff to allow the content type to be searchable
|
// Search stuff to allow the content type to be searchable
|
||||||
public String getSearchSummary() {
|
public String getSearchSummary() {
|
||||||
return getDefinition();
|
return getDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,9 @@ public class HealthCareFacility extends GenericOrganization {
|
||||||
* Called when the class is loaded by the Java class loader.
|
* Called when the class is loaded by the Java class loader.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,9 @@ public class MultiPartArticle extends ContentPage {
|
||||||
private static MultiPartArticleConfig s_config = new MultiPartArticleConfig();
|
private static MultiPartArticleConfig s_config = new MultiPartArticleConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultiPartArticleConfig getConfig() {
|
public static MultiPartArticleConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p><code>DomainObject</code> class to represent news item <code>ContentType</code>
|
* <p><code>DomainObject</code> class to represent news item <code>ContentType</code>
|
||||||
|
|
@ -57,6 +58,7 @@ import java.util.Date;
|
||||||
**/
|
**/
|
||||||
public class NewsItem extends GenericArticle {
|
public class NewsItem extends GenericArticle {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(NewsItem.class);
|
||||||
/** PDL property name for lead */
|
/** PDL property name for lead */
|
||||||
public static final String LEAD = "lead";
|
public static final String LEAD = "lead";
|
||||||
/** PDL property name for news date */
|
/** PDL property name for news date */
|
||||||
|
|
@ -69,7 +71,9 @@ public class NewsItem extends GenericArticle {
|
||||||
private static final NewsItemConfig s_config = new NewsItemConfig();
|
private static final NewsItemConfig s_config = new NewsItemConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final NewsItemConfig getConfig() {
|
public static final NewsItemConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
|
@ -42,6 +41,7 @@ import java.math.BigDecimal;
|
||||||
**/
|
**/
|
||||||
public class SimpleAddress extends ContentPage {
|
public class SimpleAddress extends ContentPage {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SimpleAddress.class);
|
||||||
/** PDL property name for address */
|
/** PDL property name for address */
|
||||||
public static final String ADDRESS = "address";
|
public static final String ADDRESS = "address";
|
||||||
/** PDL property name for country iso code */
|
/** PDL property name for country iso code */
|
||||||
|
|
@ -60,18 +60,20 @@ public class SimpleAddress extends ContentPage {
|
||||||
public static final String NOTES = "notes";
|
public static final String NOTES = "notes";
|
||||||
/** PDL property name for URI*/
|
/** PDL property name for URI*/
|
||||||
public static final String URI = "uri";
|
public static final String URI = "uri";
|
||||||
|
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
= "com.arsdigita.cms.contenttypes.Address";
|
"com.arsdigita.cms.contenttypes.Address";
|
||||||
|
private static final SimpleAddressConfig s_config =
|
||||||
|
new SimpleAddressConfig();
|
||||||
|
|
||||||
private static final SimpleAddressConfig s_config = new SimpleAddressConfig();
|
|
||||||
static {
|
static {
|
||||||
s_config.load();
|
logger.debug("Static initalizer starting...");
|
||||||
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finisheds. .");
|
||||||
}
|
}
|
||||||
public static final SimpleAddressConfig getConfig()
|
|
||||||
{
|
public static final SimpleAddressConfig getConfig() {
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,97 +136,96 @@ public class SimpleAddress extends ContentPage {
|
||||||
*/
|
*/
|
||||||
public void beforeSave() {
|
public void beforeSave() {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
|
|
||||||
Assert.exists(getContentType(), ContentType.class);
|
Assert.exists(getContentType(), ContentType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* accessors *****************************************************/
|
/* accessors *****************************************************/
|
||||||
public String getAddress( ) {
|
public String getAddress() {
|
||||||
return ( String ) get( ADDRESS );
|
return (String) get(ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress( String address ) {
|
public void setAddress(String address) {
|
||||||
set( ADDRESS, address );
|
set(ADDRESS, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCountryIsoCode( ) {
|
public String getCountryIsoCode() {
|
||||||
DataObject obj = ( DataObject ) get( ISO_COUNTRY_CODE );
|
DataObject obj = (DataObject) get(ISO_COUNTRY_CODE);
|
||||||
if ( obj != null ) {
|
if (obj != null) {
|
||||||
IsoCountry country = new IsoCountry( obj );
|
IsoCountry country = new IsoCountry(obj);
|
||||||
return country.getIsoCode( );
|
return country.getIsoCode();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountryIsoCode( String isoCode ) {
|
public void setCountryIsoCode(String isoCode) {
|
||||||
IsoCountry assn = null;
|
IsoCountry assn = null;
|
||||||
try {
|
try {
|
||||||
OID oid = new OID( IsoCountry.BASE_DATA_OBJECT_TYPE );
|
OID oid = new OID(IsoCountry.BASE_DATA_OBJECT_TYPE);
|
||||||
oid.set( IsoCountry.ISO_CODE, isoCode );
|
oid.set(IsoCountry.ISO_CODE, isoCode);
|
||||||
|
|
||||||
assn = new IsoCountry( oid );
|
assn = new IsoCountry(oid);
|
||||||
} catch (DataObjectNotFoundException e) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
assn = new IsoCountry( );
|
assn = new IsoCountry();
|
||||||
assn.setIsoCode( isoCode );
|
assn.setIsoCode(isoCode);
|
||||||
assn.save();
|
assn.save();
|
||||||
}
|
}
|
||||||
setAssociation( ISO_COUNTRY_CODE, assn );
|
setAssociation(ISO_COUNTRY_CODE, assn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPostalCode( ) {
|
public String getPostalCode() {
|
||||||
return ( String ) get( POSTAL_CODE );
|
return (String) get(POSTAL_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPostalCode( String postalCode ) {
|
public void setPostalCode(String postalCode) {
|
||||||
set( POSTAL_CODE, postalCode );
|
set(POSTAL_CODE, postalCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhone( ) {
|
public String getPhone() {
|
||||||
return ( String ) get( PHONE );
|
return (String) get(PHONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhone( String phone ) {
|
public void setPhone(String phone) {
|
||||||
set( PHONE, phone );
|
set(PHONE, phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMobile( ) {
|
public String getMobile() {
|
||||||
return ( String ) get( MOBILE );
|
return (String) get(MOBILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobile( String mobile ) {
|
public void setMobile(String mobile) {
|
||||||
set( MOBILE, mobile );
|
set(MOBILE, mobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFax( ) {
|
public String getFax() {
|
||||||
return ( String ) get( FAX );
|
return (String) get(FAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFax( String fax ) {
|
public void setFax(String fax) {
|
||||||
set( FAX, fax );
|
set(FAX, fax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail( ) {
|
public String getEmail() {
|
||||||
return ( String ) get( EMAIL );
|
return (String) get(EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail( String email ) {
|
public void setEmail(String email) {
|
||||||
set( EMAIL, email );
|
set(EMAIL, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotes( ) {
|
public String getNotes() {
|
||||||
return ( String ) get( NOTES );
|
return (String) get(NOTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotes( String notes ) {
|
public void setNotes(String notes) {
|
||||||
set( NOTES, notes );
|
set(NOTES, notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setURI( String uri) {
|
public void setURI(String uri) {
|
||||||
set(URI, uri);
|
set(URI, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getURI() {
|
public String getURI() {
|
||||||
return (String)get(URI);
|
return (String) get(URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,9 @@ public class SiteProxyPanel extends ContentPanel {
|
||||||
private static URLPool s_pool = new URLPool();
|
private static URLPool s_pool = new URLPool();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
URLFetcher.registerService(s_cacheServiceKey, s_pool, s_cache);
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
};
|
};
|
||||||
|
|
||||||
public SiteProxyPanel() {
|
public SiteProxyPanel() {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import com.arsdigita.kernel.User;
|
||||||
import com.arsdigita.persistence.metadata.Property;
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A survey content type that represents a survey. This is partially based on
|
* 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";
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Survey";
|
||||||
/* Config */
|
/* Config */
|
||||||
private static final SurveyConfig s_config = new SurveyConfig();
|
private static final SurveyConfig s_config = new SurveyConfig();
|
||||||
|
/* Logger to debug to static initializer */
|
||||||
|
private static final Logger logger = Logger.getLogger(Survey.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initializer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final SurveyConfig getConfig() {
|
public static final SurveyConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ public abstract class CMS {
|
||||||
};
|
};
|
||||||
private static final CMSConfig s_config = new CMSConfig();
|
private static final CMSConfig s_config = new CMSConfig();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initializer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initializer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,9 @@ public class ContentSection extends Application {
|
||||||
private static final CMSConfig s_config = new CMSConfig();
|
private static final CMSConfig s_config = new CMSConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initializer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initializer finished...");
|
||||||
}
|
}
|
||||||
// Cached properties
|
// Cached properties
|
||||||
PageResolver m_pageResolver = null;
|
PageResolver m_pageResolver = null;
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,12 @@ public class Template extends TextAsset {
|
||||||
public static final Map SUPPORTED_MIME_TYPES = new HashMap();
|
public static final Map SUPPORTED_MIME_TYPES = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer is starting...");
|
||||||
SUPPORTED_MIME_TYPES.put(JSP_MIME_TYPE,
|
SUPPORTED_MIME_TYPES.put(JSP_MIME_TYPE,
|
||||||
GlobalizationUtil.globalize("mime_type_jsp"));
|
GlobalizationUtil.globalize("mime_type_jsp"));
|
||||||
SUPPORTED_MIME_TYPES.put(XSL_MIME_TYPE,
|
SUPPORTED_MIME_TYPES.put(XSL_MIME_TYPE,
|
||||||
GlobalizationUtil.globalize("mime_type_xsl"));
|
GlobalizationUtil.globalize("mime_type_xsl"));
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.globalization.LocaleNegotiator;
|
import com.arsdigita.globalization.LocaleNegotiator;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
|
@ -29,6 +28,7 @@ import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p><code>DomainObject</code> class to represent address <code>ContentType</code>
|
* <p><code>DomainObject</code> class to represent address <code>ContentType</code>
|
||||||
|
|
@ -44,6 +44,7 @@ import java.util.TreeMap;
|
||||||
**/
|
**/
|
||||||
public class GenericAddress extends ContentPage {
|
public class GenericAddress extends ContentPage {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GenericAddress.class);
|
||||||
/** PDL property name for address */
|
/** PDL property name for address */
|
||||||
public static final String ADDRESS = "address";
|
public static final String ADDRESS = "address";
|
||||||
/** PDL property name for postal code */
|
/** PDL property name for postal code */
|
||||||
|
|
@ -54,18 +55,19 @@ public class GenericAddress extends ContentPage {
|
||||||
public static final String STATE = "state";
|
public static final String STATE = "state";
|
||||||
/** PDL property name for country iso code */
|
/** PDL property name for country iso code */
|
||||||
public static final String ISO_COUNTRY_CODE = "isoCountryCode";
|
public static final String ISO_COUNTRY_CODE = "isoCountryCode";
|
||||||
|
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
= "com.arsdigita.cms.contenttypes.GenericAddress";
|
"com.arsdigita.cms.contenttypes.GenericAddress";
|
||||||
|
|
||||||
private static GenericAddressConfig s_config = new GenericAddressConfig();
|
private static GenericAddressConfig s_config = new GenericAddressConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
s_config.load();
|
logger.debug("Static initializer is starting...");
|
||||||
|
s_config.load();
|
||||||
|
logger.debug("Static initializer finished.");
|
||||||
}
|
}
|
||||||
public static GenericAddressConfig getConfig()
|
|
||||||
{
|
public static GenericAddressConfig getConfig() {
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -128,7 +130,7 @@ public class GenericAddress extends ContentPage {
|
||||||
*/
|
*/
|
||||||
public void beforeSave() {
|
public void beforeSave() {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
|
|
||||||
Assert.exists(getContentType(), ContentType.class);
|
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
|
// Convert the iso country code to country names using the current locale
|
||||||
public static String getCountryNameFromIsoCode(String isoCountryCode) {
|
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);
|
java.util.Locale locale = new java.util.Locale("", isoCountryCode);
|
||||||
return locale.getDisplayCountry(negotiatedLocale.getLocale());
|
return locale.getDisplayCountry(negotiatedLocale.getLocale());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a sorted list auf all countries
|
// Get a sorted list auf all countries
|
||||||
public static TreeMap getSortedListOfCountries(Locale inLang) {
|
public static TreeMap getSortedListOfCountries(Locale inLang) {
|
||||||
|
|
||||||
LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "", null);
|
|
||||||
String[] countries = Locale.getISOCountries();
|
|
||||||
TreeMap <String,String> countryNames = new TreeMap<String,String>();
|
|
||||||
|
|
||||||
for(String country : countries) {
|
LocaleNegotiator negotiatedLocale = new LocaleNegotiator("", "", "",
|
||||||
if(inLang != null) {
|
null);
|
||||||
countryNames.put(new java.util.Locale("", country).getDisplayCountry(inLang), country);
|
String[] countries = Locale.getISOCountries();
|
||||||
|
TreeMap<String, String> countryNames = new TreeMap<String, String>();
|
||||||
|
|
||||||
|
for (String country : countries) {
|
||||||
|
if (inLang != null) {
|
||||||
|
countryNames.put(new java.util.Locale("", country).
|
||||||
|
getDisplayCountry(inLang), country);
|
||||||
} else {
|
} else {
|
||||||
countryNames.put(new java.util.Locale("", country).getDisplayCountry(negotiatedLocale.getLocale()), country);
|
countryNames.put(new java.util.Locale("", country).
|
||||||
|
getDisplayCountry(negotiatedLocale.getLocale()), country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This content type represents an basic contact
|
* This content type represents an basic contact
|
||||||
|
|
@ -37,6 +38,7 @@ import java.util.StringTokenizer;
|
||||||
public class GenericContact extends ContentPage implements
|
public class GenericContact extends ContentPage implements
|
||||||
RelationAttributeInterface {
|
RelationAttributeInterface {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(GenericContact.class);
|
||||||
/** PDL property names */
|
/** PDL property names */
|
||||||
public static final String PERSON = "person";
|
public static final String PERSON = "person";
|
||||||
// public static final String CONTACT_TYPE = "";
|
// public static final String CONTACT_TYPE = "";
|
||||||
|
|
@ -51,9 +53,11 @@ public class GenericContact extends ContentPage implements
|
||||||
new GenericContactConfig();
|
new GenericContactConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_config.load();
|
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 =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.contenttypes.GenericContact";
|
"com.arsdigita.cms.contenttypes.GenericContact";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,18 @@ class BaseAsset extends ResourceHandlerImpl {
|
||||||
|
|
||||||
private final static String s_defaultName = "File";
|
private final static String s_defaultName = "File";
|
||||||
|
|
||||||
private static final BigDecimalParameter s_assetId;
|
private static final BigDecimalParameter s_assetId = new BigDecimalParameter(ASSET_ID);
|
||||||
private static final OIDParameter s_oid;
|
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_assetId = new BigDecimalParameter(ASSET_ID);
|
||||||
s_oid = new OIDParameter(OID_PARAM);
|
s_oid = new OIDParameter(OID_PARAM);
|
||||||
//s_assetId.addParameterListener(new NotNullValidationListener());
|
//s_assetId.addParameterListener(new NotNullValidationListener());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private final boolean m_download;
|
private final boolean m_download;
|
||||||
private String m_disposition;
|
private String m_disposition;
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,14 @@ import java.util.Iterator;
|
||||||
*/
|
*/
|
||||||
public class SimpleXMLGenerator implements XMLGenerator {
|
public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
|
|
||||||
private static Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(SimpleXMLGenerator.class);
|
Logger.getLogger(SimpleXMLGenerator.class);
|
||||||
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.
|
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.
|
||||||
getName();
|
getName();
|
||||||
|
|
||||||
// Register general purpose adaptor for all content items
|
// Register general purpose adaptor for all content items
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initializer starting...");
|
||||||
SimpleDomainObjectTraversalAdapter adapter =
|
SimpleDomainObjectTraversalAdapter adapter =
|
||||||
new SimpleDomainObjectTraversalAdapter();
|
new SimpleDomainObjectTraversalAdapter();
|
||||||
adapter.addAssociationProperty("/object/type");
|
adapter.addAssociationProperty("/object/type");
|
||||||
|
|
@ -69,6 +70,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
|
||||||
ContentItem.BASE_DATA_OBJECT_TYPE,
|
ContentItem.BASE_DATA_OBJECT_TYPE,
|
||||||
adapter,
|
adapter,
|
||||||
ADAPTER_CONTEXT);
|
ADAPTER_CONTEXT);
|
||||||
|
s_log.debug("Static initializer finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleXMLGenerator() {
|
public SimpleXMLGenerator() {
|
||||||
|
|
|
||||||
|
|
@ -62,220 +62,235 @@ import org.apache.oro.text.regex.Perl5Matcher;
|
||||||
*/
|
*/
|
||||||
class LinkScanner {
|
class LinkScanner {
|
||||||
|
|
||||||
private static Logger s_log = Logger.getLogger(LinkScanner.class.getName());
|
private static final Logger s_log = Logger.getLogger(LinkScanner.class);
|
||||||
|
// Regexp magic. We deliberately don't use the JDK 1.4 regex features, so
|
||||||
// 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
|
||||||
// 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
|
||||||
// The option we use for matching
|
| Perl5Compiler.MULTILINE_MASK;
|
||||||
private static final int MATCH_MASK = Perl5Compiler.CASE_INSENSITIVE_MASK
|
// The HTML elements we are interested in. This must match exactly the
|
||||||
| Perl5Compiler.MULTILINE_MASK;
|
// elements listed in TAGS
|
||||||
|
private static final String ELEMS_RE = "(a|img|link)";
|
||||||
// The HTML elements we are interested in. This must match exactly the
|
// Regexp to find a tag
|
||||||
// elements listed in TAGS
|
private static final String TAG_RE = "\\<\\s*" + ELEMS_RE
|
||||||
private static final String ELEMS_RE = "(a|img|link)";
|
+ "\\s*([^>]*?)\\s*/?\\>";
|
||||||
// Regexp to find a tag
|
// Regexp to find an attribute/value pair within a tag
|
||||||
private static final String TAG_RE = "\\<\\s*" + ELEMS_RE + "\\s*([^>]*?)\\s*/?\\>";
|
private static final String ATTR_RE =
|
||||||
// Regexp to find an attribute/value pair within a tag
|
"([a-z][a-z0-9]*)\\s*=\\s*([^\\s'\"]+|'[^']*'|\"[^\"]*\")";
|
||||||
private static final String ATTR_RE = "([a-z][a-z0-9]*)\\s*=\\s*([^\\s'\"]+|'[^']*'|\"[^\"]*\")";
|
// These two variables will be initialized with precompiled patterns
|
||||||
// These two variables will be initialized with precompiled patterns
|
private static final Pattern TAG_PAT;
|
||||||
private static final Pattern TAG_PAT;
|
private static final Pattern ATTR_PAT;
|
||||||
private static final Pattern ATTR_PAT;
|
// The tags that we are interested in. The regexp ELEMS_RE must match
|
||||||
|
// exactly these tags.
|
||||||
// The tags that we are interested in. The regexp ELEMS_RE must match
|
// REF_ATTR contains for each of the TAGS which of their attribute holds
|
||||||
// exactly these tags.
|
// the link that we are going to alter.
|
||||||
// REF_ATTR contains for each of the TAGS which of their attribute holds
|
private static final String[] TAGS = {"img", "link", "a"};
|
||||||
// the link that we are going to alter.
|
private static final String[] REF_ATTR = {"src", "href", "href"};
|
||||||
private static final String [] TAGS = {"img", "link", "a"};
|
// The special oid attribute we use to figure out which tags we need to
|
||||||
private static final String [] REF_ATTR = {"src", "href", "href"};
|
// futz with.
|
||||||
// The special oid attribute we use to figure out which tags we need to
|
private static final String OID_ATTR = "oid";
|
||||||
// futz with.
|
// FIXME: These are references to what should be displayed when tag
|
||||||
private static final String OID_ATTR = "oid";
|
// rewriting can't find the live target item. These values only work for
|
||||||
|
// DP.
|
||||||
// FIXME: These are references to what should be displayed when tag
|
private static final String[] NOT_FOUND = {"/notfound.jpg",
|
||||||
// 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" };
|
"/notfound.html"};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Perl5Compiler comp = new Perl5Compiler();
|
s_log.debug("Static initializer is starting...s");
|
||||||
try {
|
Perl5Compiler comp = new Perl5Compiler();
|
||||||
TAG_PAT = comp.compile(TAG_RE, MATCH_MASK);
|
try {
|
||||||
} catch (MalformedPatternException e) {
|
TAG_PAT = comp.compile(TAG_RE, MATCH_MASK);
|
||||||
throw new RuntimeException("Failed to compile \n'" + TAG_RE +"' " + e.getMessage());
|
} catch (MalformedPatternException e) {
|
||||||
}
|
s_log.error(String.format("Failed to compile regex tag '%s' "
|
||||||
try {
|
+ "with match mask '%s':",
|
||||||
ATTR_PAT = comp.compile(ATTR_RE, MATCH_MASK);
|
TAG_RE,
|
||||||
} catch (MalformedPatternException e) {
|
MATCH_MASK),
|
||||||
throw new RuntimeException("Failed to compile \n'" + ATTR_RE +"' " + e.getMessage());
|
e);
|
||||||
}
|
throw new RuntimeException("Failed to compile \n'" + TAG_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);
|
|
||||||
}
|
}
|
||||||
}
|
try {
|
||||||
if ( oid != null ) {
|
ATTR_PAT = comp.compile(ATTR_RE, MATCH_MASK);
|
||||||
TagRef ref = new TagRef(tagType, tagStart, tagEnd, linkStart, linkEnd,
|
} catch (MalformedPatternException e) {
|
||||||
oid);
|
s_log.error(String.format("Failed to compile regex tag '%s' "
|
||||||
foundTags.add(ref);
|
+ "with match mask '%s':",
|
||||||
}
|
ATTR_RE,
|
||||||
}
|
MATCH_MASK),
|
||||||
int size = foundTags.size();
|
e);
|
||||||
return ( size > 0 ? (TagRef [])foundTags.toArray(new TagRef[size]) : null);
|
throw new RuntimeException("Failed to compile \n'" + ATTR_RE + "' " + e.
|
||||||
}
|
getMessage());
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
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() {
|
public void transform(Writer out)
|
||||||
if ( m_item == null ) {
|
throws IOException {
|
||||||
m_item = Utilities.getContentItemOrNull( oid );
|
|
||||||
// FIXME: The page with editor will contain references to draft
|
if (m_tags == null || m_tags.length == 0) {
|
||||||
// items. Fixing that requires parsing the HTML of the page
|
// Nothing to do
|
||||||
// separately. Here, we just kludge around it by getting the live
|
out.write(m_content);
|
||||||
// version of referenced items. [lutter]
|
return;
|
||||||
if ( m_item != null ) m_item = m_item.getLiveVersion();
|
}
|
||||||
}
|
|
||||||
return m_item;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui.authoring;
|
package com.arsdigita.cms.ui.authoring;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
@ -67,7 +66,6 @@ import com.arsdigita.mimetypes.converters.ConvertFormat;
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the mime-type and the body of a single {@link TextAsset}. Maintains
|
* 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
|
* 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 $
|
* @version $Id: TextAssetBody.java 1949 2009-06-25 08:30:50Z terry $
|
||||||
*/
|
*/
|
||||||
public abstract class TextAssetBody extends SecurityPropertyEditor
|
public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
implements Resettable, AuthoringStepComponent, RequestListener {
|
implements Resettable, AuthoringStepComponent, RequestListener {
|
||||||
|
|
||||||
private static Logger s_log =
|
private static Logger s_log =
|
||||||
Logger.getLogger(TextAssetBody.class);
|
Logger.getLogger(TextAssetBody.class);
|
||||||
|
|
||||||
private ItemSelectionModel m_assetModel;
|
private ItemSelectionModel m_assetModel;
|
||||||
|
|
||||||
public static final String FILE_UPLOAD = "file";
|
public static final String FILE_UPLOAD = "file";
|
||||||
public static final String TEXT_ENTRY = "text";
|
public static final String TEXT_ENTRY = "text";
|
||||||
|
|
||||||
private StringParameter m_streamlinedCreationParam;
|
private StringParameter m_streamlinedCreationParam;
|
||||||
private static final String STREAMLINED = "_streamlined";
|
private static final String STREAMLINED = "_streamlined";
|
||||||
private static final String STREAMLINED_DONE = "1";
|
private static final String STREAMLINED_DONE = "1";
|
||||||
|
|
||||||
private static final CMSConfig s_config = new CMSConfig();
|
private static final CMSConfig s_config = new CMSConfig();
|
||||||
|
|
||||||
static {
|
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
|
* be responsible for maintaining the current asset
|
||||||
*/
|
*/
|
||||||
public TextAssetBody(ItemSelectionModel assetModel) {
|
public TextAssetBody(ItemSelectionModel assetModel) {
|
||||||
this(assetModel,null);
|
this(assetModel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new GenericArticleBody component
|
* 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,
|
* may use the wizard's methods, such as stepForward and stepBack,
|
||||||
* in its process listener.
|
* in its process listener.
|
||||||
*/
|
*/
|
||||||
public TextAssetBody(ItemSelectionModel assetModel, AuthoringKitWizard parent) {
|
public TextAssetBody(ItemSelectionModel assetModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
super();
|
super();
|
||||||
m_assetModel = assetModel;
|
m_assetModel = assetModel;
|
||||||
|
|
||||||
m_streamlinedCreationParam =
|
m_streamlinedCreationParam =
|
||||||
new StringParameter(parent == null ? "item" :
|
new StringParameter(parent == null ? "item" : parent.getContentType().
|
||||||
parent.getContentType().getAssociatedObjectType() + "_body_done");
|
getAssociatedObjectType() + "_body_done");
|
||||||
|
|
||||||
if (!s_config.getHideTextAssetUploadFile()) {
|
if (!s_config.getHideTextAssetUploadFile()) {
|
||||||
PageFileForm f = getPageFileForm();
|
PageFileForm f = getPageFileForm();
|
||||||
addFileWidgets(f);
|
addFileWidgets(f);
|
||||||
add(FILE_UPLOAD, "Upload a file", f,
|
add(FILE_UPLOAD, "Upload a file", f,
|
||||||
f.getSaveCancelSection().getCancelButton());
|
f.getSaveCancelSection().getCancelButton());
|
||||||
}
|
}
|
||||||
|
|
||||||
PageTextForm t = new PageTextForm();
|
PageTextForm t = new PageTextForm();
|
||||||
|
|
@ -149,7 +148,8 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
DomainObjectPropertySheet sheet = getBodyPropertySheet(assetModel);
|
DomainObjectPropertySheet sheet = getBodyPropertySheet(assetModel);
|
||||||
sheet.add("Text Type:",
|
sheet.add("Text Type:",
|
||||||
Asset.MIME_TYPE + "." + MimeType.LABEL);
|
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);
|
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);
|
return new TextAssetBodyPropertySheet(assetModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +176,7 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
* @param state represents the current request
|
* @param state represents the current request
|
||||||
*/
|
*/
|
||||||
public TextAsset getTextAsset(PageState state) {
|
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.
|
// Create a text asset if it does not exist.
|
||||||
// This should probably be a method in GenericArticle ?
|
// This should probably be a method in GenericArticle ?
|
||||||
protected TextAsset createOrGetTextAsset(ItemSelectionModel assetModel,
|
protected TextAsset createOrGetTextAsset(ItemSelectionModel assetModel,
|
||||||
PageState s) {
|
PageState s) {
|
||||||
// Get the text asset or create a new one
|
// Get the text asset or create a new one
|
||||||
TextAsset t = getTextAsset(s);
|
TextAsset t = getTextAsset(s);
|
||||||
|
|
||||||
if(t == null) {
|
if (t == null) {
|
||||||
t = createTextAsset(s);
|
t = createTextAsset(s);
|
||||||
assetModel.setSelectedObject(s, t);
|
assetModel.setSelectedObject(s, t);
|
||||||
}
|
}
|
||||||
|
|
@ -238,8 +239,8 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
* @param state the PageState
|
* @param state the PageState
|
||||||
*/
|
*/
|
||||||
protected void maybeForwardToNextStep(PageState state) {
|
protected void maybeForwardToNextStep(PageState state) {
|
||||||
if (ContentItemPage.isStreamlinedCreationActive(state) &&
|
if (ContentItemPage.isStreamlinedCreationActive(state) && !STREAMLINED_DONE.
|
||||||
!STREAMLINED_DONE.equals(state.getValue(m_streamlinedCreationParam))) {
|
equals(state.getValue(m_streamlinedCreationParam))) {
|
||||||
state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE);
|
state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE);
|
||||||
fireCompletionEvent(state);
|
fireCompletionEvent(state);
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +258,7 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE);
|
state.setValue(m_streamlinedCreationParam, STREAMLINED_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the edit component if the streamlined
|
* Open the edit component if the streamlined
|
||||||
* creation parameter is turned on _and_ the streamlined_creation
|
* creation parameter is turned on _and_ the streamlined_creation
|
||||||
|
|
@ -270,14 +271,14 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
//if (getTextAsset(state) != null) {
|
//if (getTextAsset(state) != null) {
|
||||||
// ComponentAccess ca = (ComponentAccess) getAccessMap().get(TEXT_ENTRY);
|
// ComponentAccess ca = (ComponentAccess) getAccessMap().get(TEXT_ENTRY);
|
||||||
|
|
||||||
if (ContentItemPage.isStreamlinedCreationActive(state) &&
|
if (ContentItemPage.isStreamlinedCreationActive(state) && !STREAMLINED_DONE.
|
||||||
!STREAMLINED_DONE.equals(state.getValue(m_streamlinedCreationParam))) {
|
equals(state.getValue(m_streamlinedCreationParam))) {
|
||||||
showComponent(state, TEXT_ENTRY);
|
showComponent(state, TEXT_ENTRY);
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the form that is used to upload files. This method can
|
* 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.
|
* 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
|
* widget, auto-guesses mime type
|
||||||
*/
|
*/
|
||||||
public class PageFileForm extends Form
|
public class PageFileForm extends Form
|
||||||
implements FormProcessListener, FormValidationListener {
|
implements FormProcessListener, FormValidationListener {
|
||||||
|
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
private FileUploadSection m_fileUploadSection;
|
private FileUploadSection m_fileUploadSection;
|
||||||
// Variables saved by validate for processing
|
// Variables saved by validate for processing
|
||||||
private RequestLocal m_file_upload_content;
|
private RequestLocal m_file_upload_content;
|
||||||
private RequestLocal m_file_upload_usedINSO;
|
private RequestLocal m_file_upload_usedINSO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The text entry widget
|
* The text entry widget
|
||||||
*/
|
*/
|
||||||
|
|
@ -314,60 +314,59 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getFileUploadContent(PageState state) {
|
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
|
* Make sure that files of this type can be uploaded
|
||||||
*/
|
*/
|
||||||
private void validateFileType(MimeType mime, boolean textType)
|
private void validateFileType(MimeType mime, boolean textType)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
boolean validType = textType || (
|
boolean validType = textType || ((mime instanceof TextMimeType) && ((TextMimeType) mime).
|
||||||
(mime instanceof TextMimeType) &&
|
allowINSOConvert().booleanValue());
|
||||||
((TextMimeType)mime).allowINSOConvert().booleanValue()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!validType) {
|
if (!validType) {
|
||||||
throw new FormProcessException("Cannot load " +
|
throw new FormProcessException("Cannot load " + "files of type " + mime.
|
||||||
"files of type " + mime.getMimeType() + " into the article body.");
|
getMimeType() + " into the article body.");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean insoWorks = MimeTypeStatus.getMimeTypeStatus().
|
boolean insoWorks = MimeTypeStatus.getMimeTypeStatus().
|
||||||
getInsoFilterWorks().intValue() == 1;
|
getInsoFilterWorks().intValue() == 1;
|
||||||
|
|
||||||
if (!textType && !insoWorks) {
|
if (!textType && !insoWorks) {
|
||||||
// Can't convert. inso filter is not working. Give message.
|
// Can't convert. inso filter is not working. Give message.
|
||||||
throw new FormProcessException("Could not convert to html " +
|
throw new FormProcessException(
|
||||||
"format because interMedia INSO filter is not installed.");
|
"Could not convert to html "
|
||||||
|
+ "format because interMedia INSO filter is not installed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read in the content of the file (in bytes).
|
* read in the content of the file (in bytes).
|
||||||
*/
|
*/
|
||||||
private byte[] readFileBytes(File file) throws FormProcessException {
|
private byte[] readFileBytes(File file) throws FormProcessException {
|
||||||
byte [] file_bytes;
|
byte[] file_bytes;
|
||||||
try {
|
try {
|
||||||
FileInputStream fs = new FileInputStream(file);
|
FileInputStream fs = new FileInputStream(file);
|
||||||
file_bytes = new byte[fs.available()];
|
file_bytes = new byte[fs.available()];
|
||||||
fs.read(file_bytes);
|
fs.read(file_bytes);
|
||||||
fs.close();
|
fs.close();
|
||||||
} catch (Exception e) {
|
} 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;
|
return file_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert bytes to String, possibly using INSO filter to convert to
|
* Convert bytes to String, possibly using INSO filter to convert to
|
||||||
* HTML type
|
* HTML type
|
||||||
*/
|
*/
|
||||||
private String convertBytes(byte [] file_bytes, boolean text_type,
|
private String convertBytes(byte[] file_bytes, boolean text_type,
|
||||||
boolean [] used_inso)
|
boolean[] used_inso)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
String file_content;
|
String file_content;
|
||||||
// If mime type is not text type, try to convert to html
|
// If mime type is not text type, try to convert to html
|
||||||
if (!text_type) {
|
if (!text_type) {
|
||||||
|
|
@ -376,40 +375,43 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
// Converted successfully, flag type should be html
|
// Converted successfully, flag type should be html
|
||||||
used_inso[0] = true;
|
used_inso[0] = true;
|
||||||
} else {
|
} else {
|
||||||
throw new FormProcessException("Could not convert to html format. " +
|
throw new FormProcessException(
|
||||||
"interMedia INSO filter conversion failed.");
|
"Could not convert to html format. "
|
||||||
|
+ "interMedia INSO filter conversion failed.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Text type, no need to convert
|
// Text type, no need to convert
|
||||||
String enc = Globalization.getDefaultCharset(Kernel.getContext().getLocale());
|
String enc = Globalization.getDefaultCharset(Kernel.getContext().
|
||||||
|
getLocale());
|
||||||
try {
|
try {
|
||||||
file_content = new String(file_bytes, enc);
|
file_content = new String(file_bytes, enc);
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} 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;
|
used_inso[0] = false;
|
||||||
}
|
}
|
||||||
return file_content;
|
return file_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the contents of the html Body tag.
|
* Extract the contents of the html Body tag.
|
||||||
* (Done to prevent base and other header tags
|
* (Done to prevent base and other header tags
|
||||||
* from interfering with page display).
|
* from interfering with page display).
|
||||||
*/
|
*/
|
||||||
private String extractHTMLBody(String htmlText)
|
private String extractHTMLBody(String htmlText)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
String lc = htmlText.toLowerCase();
|
String lc = htmlText.toLowerCase();
|
||||||
int bodyStart = lc.indexOf("<body");
|
int bodyStart = lc.indexOf("<body");
|
||||||
int bodyStart_v = lc.indexOf(">",bodyStart);
|
int bodyStart_v = lc.indexOf(">", bodyStart);
|
||||||
int bodyEnd = lc.indexOf("</body>", bodyStart_v);
|
int bodyEnd = lc.indexOf("</body>", bodyStart_v);
|
||||||
if (bodyStart == -1 || bodyEnd == -1) {
|
if (bodyStart == -1 || bodyEnd == -1) {
|
||||||
final String errMsg = "The file (which should be type "
|
final String errMsg =
|
||||||
+ "HTML) is missing the <body> or </body> tag.";
|
"The file (which should be type "
|
||||||
|
+ "HTML) is missing the <body> or </body> tag.";
|
||||||
throw new FormProcessException(errMsg);
|
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
|
// Convert the file to HTML, if possible
|
||||||
File file = m_fileUploadSection.getFile(e);
|
File file = m_fileUploadSection.getFile(e);
|
||||||
byte [] file_bytes = readFileBytes(file);
|
byte[] file_bytes = readFileBytes(file);
|
||||||
boolean [] used_inso = new boolean [1];
|
boolean[] used_inso = new boolean[1];
|
||||||
String file_content = convertBytes(file_bytes, textType, used_inso);
|
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);
|
file_content = extractHTMLBody(file_content);
|
||||||
|
}
|
||||||
|
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
m_file_upload_content.set(state, file_content);
|
m_file_upload_content.set(state, file_content);
|
||||||
m_file_upload_usedINSO.set(state, new Boolean(used_inso[0]));
|
m_file_upload_usedINSO.set(state, new Boolean(used_inso[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process file upload. Must be validated first.
|
* Process file upload. Must be validated first.
|
||||||
*/
|
*/
|
||||||
|
|
@ -449,14 +451,15 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
|
|
||||||
// Get info created during validation
|
// Get info created during validation
|
||||||
String upload_content = (String) m_file_upload_content.get(state);
|
String upload_content = (String) m_file_upload_content.get(state);
|
||||||
boolean usedINSO = ((Boolean) m_file_upload_usedINSO.get(state))
|
boolean usedINSO = ((Boolean) m_file_upload_usedINSO.get(state)).
|
||||||
.booleanValue();
|
booleanValue();
|
||||||
|
|
||||||
// Set the mime type
|
// Set the mime type
|
||||||
MimeType mime = m_fileUploadSection.getMimeType(e);
|
MimeType mime = m_fileUploadSection.getMimeType(e);
|
||||||
if (usedINSO)
|
if (usedINSO) {
|
||||||
mime = MimeType.loadMimeType("text/html");
|
mime = MimeType.loadMimeType("text/html");
|
||||||
if(mime != null) {
|
}
|
||||||
|
if (mime != null) {
|
||||||
t.setMimeType(mime);
|
t.setMimeType(mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -469,7 +472,9 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
|
|
||||||
// Save everything
|
// Save everything
|
||||||
updateTextAsset(state, t);
|
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() {
|
public FileUploadSection getFileUploadSection() {
|
||||||
return m_fileUploadSection;
|
return m_fileUploadSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A form for editing the body of the text.
|
* A form for editing the body of the text.
|
||||||
*/
|
*/
|
||||||
public class PageTextForm extends Form
|
public class PageTextForm extends Form
|
||||||
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
implements FormInitListener, FormProcessListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
private SingleSelect m_mimeWidget;
|
private SingleSelect m_mimeWidget;
|
||||||
private Label m_mimeLabel;
|
private Label m_mimeLabel;
|
||||||
private TextArea m_textWidget;
|
private TextArea m_textWidget;
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The text entry widget
|
* The text entry widget
|
||||||
*/
|
*/
|
||||||
public static final String TEXT_ENTRY = "text_entry";
|
public static final String TEXT_ENTRY = "text_entry";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mime type widget
|
* The mime type widget
|
||||||
*/
|
*/
|
||||||
|
|
@ -523,7 +527,6 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are here so that TemplateBody can set them.
|
// These are here so that TemplateBody can set them.
|
||||||
|
|
||||||
public final void setMimeWidget(final SingleSelect widget) {
|
public final void setMimeWidget(final SingleSelect widget) {
|
||||||
m_mimeWidget = widget;
|
m_mimeWidget = widget;
|
||||||
}
|
}
|
||||||
|
|
@ -544,20 +547,20 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
|
|
||||||
TextAsset t = (TextAsset)m_assetModel.getSelectedObject(state);
|
TextAsset t = (TextAsset) m_assetModel.getSelectedObject(state);
|
||||||
if(t != null) {
|
if (t != null) {
|
||||||
data.put(TEXT_ENTRY, t.getText());
|
data.put(TEXT_ENTRY, t.getText());
|
||||||
MimeType m = t.getMimeType();
|
MimeType m = t.getMimeType();
|
||||||
if(m != null) {
|
if (m != null) {
|
||||||
data.put(MIME_TYPE, m.getMimeType());
|
data.put(MIME_TYPE, m.getMimeType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancels streamlined editing. */
|
/** Cancels streamlined editing. */
|
||||||
public void submitted( FormSectionEvent e ) {
|
public void submitted(FormSectionEvent e) {
|
||||||
if (getSaveCancelSection().getCancelButton()
|
if (getSaveCancelSection().getCancelButton().isSelected(e.
|
||||||
.isSelected( e.getPageState())) {
|
getPageState())) {
|
||||||
TextAssetBody.this.cancelStreamlinedCreation(e.getPageState());
|
TextAssetBody.this.cancelStreamlinedCreation(e.getPageState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -570,19 +573,23 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
TextAsset t = createOrGetTextAsset(m_assetModel, state);
|
TextAsset t = createOrGetTextAsset(m_assetModel, state);
|
||||||
|
|
||||||
// Set the mime type
|
// 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);
|
t.setMimeType(m);
|
||||||
|
|
||||||
// Get the string and normalize it
|
// 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
|
// Save everything
|
||||||
updateTextAsset(state, t);
|
updateTextAsset(state, t);
|
||||||
if(t.isNew() || t.isModified()) t.save();
|
if (t.isNew() || t.isModified()) {
|
||||||
|
t.save();
|
||||||
|
}
|
||||||
|
|
||||||
TextAssetBody.this.maybeForwardToNextStep(e.getPageState());
|
TextAssetBody.this.maybeForwardToNextStep(e.getPageState());
|
||||||
}
|
}
|
||||||
|
|
@ -593,7 +600,6 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
public SaveCancelSection getSaveCancelSection() {
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
return m_saveCancelSection;
|
return m_saveCancelSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDefaultMimeType() {
|
protected String getDefaultMimeType() {
|
||||||
|
|
@ -604,11 +610,12 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
protected void addFileWidgets(PageFileForm c) {
|
protected void addFileWidgets(PageFileForm c) {
|
||||||
|
|
||||||
c.m_fileUploadSection =
|
c.m_fileUploadSection =
|
||||||
new FileUploadSection("Text Type:", "text", getDefaultMimeType());
|
new FileUploadSection("Text Type:", "text", getDefaultMimeType());
|
||||||
c.m_fileUploadSection.getFileUploadWidget()
|
c.m_fileUploadSection.getFileUploadWidget().addValidationListener(
|
||||||
.addValidationListener(new NotNullValidationListener());
|
new NotNullValidationListener());
|
||||||
// Default to -guess- because want to use file extension to determine type.
|
// 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.add(c.m_fileUploadSection);
|
||||||
|
|
||||||
c.m_saveCancelSection = new SaveCancelSection();
|
c.m_saveCancelSection = new SaveCancelSection();
|
||||||
|
|
@ -630,20 +637,22 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
/* overridable method to put together the PageTextForm Component */
|
/* overridable method to put together the PageTextForm Component */
|
||||||
protected void addTextWidgets(PageTextForm c) {
|
protected void addTextWidgets(PageTextForm c) {
|
||||||
|
|
||||||
ColumnPanel panel = (ColumnPanel)c.getPanel();
|
ColumnPanel panel = (ColumnPanel) c.getPanel();
|
||||||
panel.setBorder(false);
|
panel.setBorder(false);
|
||||||
panel.setPadColor("#FFFFFF");
|
panel.setPadColor("#FFFFFF");
|
||||||
panel.setColumnWidth(1, "20%");
|
panel.setColumnWidth(1, "20%");
|
||||||
panel.setColumnWidth(2, "80%");
|
panel.setColumnWidth(2, "80%");
|
||||||
panel.setWidth("100%");
|
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 = new SingleSelect(PageTextForm.MIME_TYPE);
|
||||||
c.m_mimeWidget.setClassAttr("displayOneOptionAsLabel");
|
c.m_mimeWidget.setClassAttr("displayOneOptionAsLabel");
|
||||||
setMimeTypeOptions(c.m_mimeWidget);
|
setMimeTypeOptions(c.m_mimeWidget);
|
||||||
c.add(c.m_mimeWidget, ColumnPanel.LEFT);
|
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);
|
ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
c.m_textWidget = new CMSDHTMLEditor(PageTextForm.TEXT_ENTRY);
|
c.m_textWidget = new CMSDHTMLEditor(PageTextForm.TEXT_ENTRY);
|
||||||
|
|
@ -653,18 +662,20 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
|
||||||
// width, and similar size as htmlarea.
|
// width, and similar size as htmlarea.
|
||||||
// could be configurable - unset means default 100% x 400px
|
// could be configurable - unset means default 100% x 400px
|
||||||
c.m_textWidget.setMetaDataAttribute("width", "575");
|
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.m_textWidget.setWrap(CMSDHTMLEditor.SOFT);
|
||||||
c.add(c.m_textWidget, ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
|
c.add(c.m_textWidget, ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
c.m_saveCancelSection = new SaveCancelSection();
|
c.m_saveCancelSection = new SaveCancelSection();
|
||||||
c.add(c.m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
c.add(c.m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
// optionally, we clear the text of MSWord tags every time
|
// optionally, we clear the text of MSWord tags every time
|
||||||
// the text is submitted/saved
|
// the text is submitted/saved
|
||||||
if (ContentSection.getConfig().getSaveTextCleansWordTags()) {
|
if (ContentSection.getConfig().getSaveTextCleansWordTags()) {
|
||||||
c.m_saveCancelSection.getSaveButton().setOnClick("wordClean_"+PageTextForm.TEXT_ENTRY+"();");
|
c.m_saveCancelSection.getSaveButton().setOnClick("wordClean_"
|
||||||
}
|
+ PageTextForm.TEXT_ENTRY
|
||||||
|
+ "();");
|
||||||
|
}
|
||||||
|
|
||||||
c.addInitListener(c);
|
c.addInitListener(c);
|
||||||
c.addProcessListener(c);
|
c.addProcessListener(c);
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ public class FolderBrowser extends Table {
|
||||||
Assert.exists( m_currentFolder.getStateParameter() );
|
Assert.exists( m_currentFolder.getStateParameter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void register(Page p) {
|
public void register(Page p) {
|
||||||
super.register(p);
|
super.register(p);
|
||||||
|
|
||||||
|
|
@ -217,6 +218,7 @@ public class FolderBrowser extends Table {
|
||||||
m_deleteColumn.setVisible(state, canDelete);
|
m_deleteColumn.setVisible(state, canDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void respond(PageState state) throws ServletException {
|
public void respond(PageState state) throws ServletException {
|
||||||
String key = state.getControlEventName();
|
String key = state.getControlEventName();
|
||||||
String value = state.getControlEventValue();
|
String value = state.getControlEventValue();
|
||||||
|
|
@ -407,6 +409,7 @@ public class FolderBrowser extends Table {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Component getComponent(Table table, PageState state, Object value,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
|
|
@ -438,12 +441,15 @@ public class FolderBrowser extends Table {
|
||||||
private static class ActionCellRenderer implements TableCellRenderer {
|
private static class ActionCellRenderer implements TableCellRenderer {
|
||||||
private static Label s_noAction;
|
private static Label s_noAction;
|
||||||
private static ControlLink s_link;
|
private static ControlLink s_link;
|
||||||
|
private static final Logger logger = Logger.getLogger(ActionCellRenderer.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_noAction = new Label(" ", false);
|
s_noAction = new Label(" ", false);
|
||||||
s_noAction.lock();
|
s_noAction.lock();
|
||||||
s_link = new ControlLink(new Label(globalize("cms.ui.folder.delete")));
|
s_link = new ControlLink(new Label(globalize("cms.ui.folder.delete")));
|
||||||
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
||||||
|
logger.debug("Static initializer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getComponent(Table table, PageState state, Object value,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import com.arsdigita.toolbox.ui.DataTable;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,17 +116,20 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
* Delete language instance action link.
|
* Delete language instance action link.
|
||||||
*/
|
*/
|
||||||
private static class ActionCellRenderer implements TableCellRenderer {
|
private static class ActionCellRenderer implements TableCellRenderer {
|
||||||
|
private static final Logger logger = Logger.getLogger(ActionCellRenderer.class);
|
||||||
private static Label s_noAction;
|
private static Label s_noAction;
|
||||||
private static Label s_primary;
|
private static Label s_primary;
|
||||||
private static ControlLink s_link;
|
private static ControlLink s_link;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_noAction = new Label(" ", false);
|
s_noAction = new Label(" ", false);
|
||||||
s_noAction.lock();
|
s_noAction.lock();
|
||||||
s_primary = new Label(GlobalizationUtil.globalize("cms.ui.primary_instance"), false);
|
s_primary = new Label(GlobalizationUtil.globalize("cms.ui.primary_instance"), false);
|
||||||
s_primary.lock();
|
s_primary.lock();
|
||||||
s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.delete")));
|
s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.delete")));
|
||||||
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemSelectionModel m_model;
|
private ItemSelectionModel m_model;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.toolbox.ui.DataTable;
|
import com.arsdigita.toolbox.ui.DataTable;
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
import java.math.BigDecimal;
|
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
|
// Static is safe since these components will never ever change
|
||||||
private static ControlLink s_link;
|
private static ControlLink s_link;
|
||||||
|
private static final Logger logger = Logger.getLogger(AssignCellRenderer.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.templates.assign_template")));
|
s_link = new ControlLink(new Label(GlobalizationUtil.globalize("cms.ui.templates.assign_template")));
|
||||||
s_link.setClassAttr("assignTemplateLink");
|
s_link.setClassAttr("assignTemplateLink");
|
||||||
|
logger.debug("Static initializer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssignCellRenderer() {}
|
public AssignCellRenderer() {}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui.type;
|
package com.arsdigita.cms.ui.type;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.BoxPanel;
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.ControlLink;
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
|
@ -45,7 +44,6 @@ import org.apache.log4j.Logger;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the component to generate a table
|
* This class contains the component to generate a table
|
||||||
* of elements for a particular content type
|
* of elements for a particular content type
|
||||||
|
|
@ -53,8 +51,7 @@ import java.util.Iterator;
|
||||||
public class TypeElements extends BoxPanel {
|
public class TypeElements extends BoxPanel {
|
||||||
|
|
||||||
private static Logger s_log =
|
private static Logger s_log =
|
||||||
Logger.getLogger(TypeElements.class);
|
Logger.getLogger(TypeElements.class);
|
||||||
|
|
||||||
private SingleSelectionModel m_types;
|
private SingleSelectionModel m_types;
|
||||||
private Table m_elementsTable;
|
private Table m_elementsTable;
|
||||||
private TableColumn m_removeColumn;
|
private TableColumn m_removeColumn;
|
||||||
|
|
@ -91,7 +88,9 @@ public class TypeElements extends BoxPanel {
|
||||||
try {
|
try {
|
||||||
type = new ContentType(typeId);
|
type = new ContentType(typeId);
|
||||||
} catch (DataObjectNotFoundException e) {
|
} 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;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
@ -100,20 +99,25 @@ public class TypeElements extends BoxPanel {
|
||||||
* Produce remove links.
|
* Produce remove links.
|
||||||
*/
|
*/
|
||||||
private static class RemoveCellRenderer implements TableCellRenderer {
|
private static class RemoveCellRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(RemoveCellRenderer.class);
|
||||||
private static Label s_noAction;
|
private static Label s_noAction;
|
||||||
private static ControlLink s_link;
|
private static ControlLink s_link;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_noAction = new Label(" ", false);
|
s_noAction = new Label(" ", false);
|
||||||
s_noAction.lock();
|
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?");
|
s_link.setConfirmation("Permanently remove this element?");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getComponent(Table table, PageState state, Object value,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
if ( ((Boolean) value).booleanValue() ) {
|
if (((Boolean) value).booleanValue()) {
|
||||||
return s_link;
|
return s_link;
|
||||||
} else {
|
} else {
|
||||||
return s_noAction;
|
return s_noAction;
|
||||||
|
|
@ -123,10 +127,11 @@ public class TypeElements extends BoxPanel {
|
||||||
|
|
||||||
// Removes an element
|
// Removes an element
|
||||||
private class ElementRemover extends TableActionAdapter {
|
private class ElementRemover extends TableActionAdapter {
|
||||||
|
|
||||||
public void cellSelected(TableActionEvent e) {
|
public void cellSelected(TableActionEvent e) {
|
||||||
int col = e.getColumn().intValue();
|
int col = e.getColumn().intValue();
|
||||||
|
|
||||||
if ( m_removeColumn != m_elementsTable.getColumn(col) ) {
|
if (m_removeColumn != m_elementsTable.getColumn(col)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,98 +159,101 @@ public class TypeElements extends BoxPanel {
|
||||||
*/
|
*/
|
||||||
private Table makeElementsTable() {
|
private Table makeElementsTable() {
|
||||||
|
|
||||||
final String[] headers = { "Name", "Element Type", "Multiplicity", "Remove" };
|
final String[] headers = {"Name", "Element Type", "Multiplicity",
|
||||||
|
"Remove"};
|
||||||
|
|
||||||
TableModelBuilder b = new TableModelBuilder () {
|
TableModelBuilder b = new TableModelBuilder() {
|
||||||
private boolean m_locked;
|
|
||||||
|
|
||||||
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
|
DynamicObjectType dot = getDynamicObjectType(s);
|
||||||
// the object type
|
//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();
|
public int getColumnCount() {
|
||||||
Property currentProperty = null;
|
return headers.length;
|
||||||
|
}
|
||||||
|
|
||||||
public int getColumnCount() {
|
public boolean nextRow() {
|
||||||
return headers.length;
|
boolean next = declaredProperties.hasNext();
|
||||||
}
|
if (next) {
|
||||||
|
currentProperty =
|
||||||
|
(Property) declaredProperties.next();
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean nextRow() {
|
public Object getElementAt(int columnIndex) {
|
||||||
boolean next = declaredProperties.hasNext();
|
if (currentProperty == null) {
|
||||||
if (next) {
|
throw new IllegalArgumentException();
|
||||||
currentProperty = (Property) declaredProperties.next();
|
}
|
||||||
}
|
|
||||||
return next;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getElementAt(int columnIndex) {
|
switch (columnIndex) {
|
||||||
if (currentProperty == null) {
|
case 0:
|
||||||
throw new IllegalArgumentException();
|
return currentProperty.getName();
|
||||||
}
|
case 1:
|
||||||
|
String dataType = currentProperty.getType().
|
||||||
switch (columnIndex) {
|
getName();
|
||||||
case 0:
|
if (dataType.equals("String")) {
|
||||||
return currentProperty.getName();
|
return "text";
|
||||||
case 1:
|
} else if (dataType.equals("BigDecimal")) {
|
||||||
String dataType = currentProperty.getType().getName();
|
return "number";
|
||||||
if (dataType.equals("String")) {
|
} else if (dataType.equals("Date")) {
|
||||||
return "text";
|
return "date";
|
||||||
} 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();
|
|
||||||
} else {
|
} else {
|
||||||
//uses the element name as key, unique for each row
|
return dataType;
|
||||||
return currentProperty.getName();
|
|
||||||
}
|
}
|
||||||
}
|
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() {
|
public Object getKeyAt(int columnIndex) {
|
||||||
return true;
|
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() {
|
public void lock() {
|
||||||
m_locked = true;
|
m_locked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked() {
|
public boolean isLocked() {
|
||||||
return m_locked;
|
return m_locked;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Table result = new Table(b, headers);
|
Table result = new Table(b, headers);
|
||||||
CMSContainer ifemptable = new CMSContainer();
|
CMSContainer ifemptable = new CMSContainer();
|
||||||
|
|
@ -256,5 +264,4 @@ public class TypeElements extends BoxPanel {
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,12 @@ public class Page extends BlockStylable implements Container {
|
||||||
static final Collection CONTROL_EVENT_KEYS;
|
static final Collection CONTROL_EVENT_KEYS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer is starting...");
|
||||||
CONTROL_EVENT_KEYS = new ArrayList(3);
|
CONTROL_EVENT_KEYS = new ArrayList(3);
|
||||||
CONTROL_EVENT_KEYS.add(SELECTED);
|
CONTROL_EVENT_KEYS.add(SELECTED);
|
||||||
CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
|
CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
|
||||||
CONTROL_EVENT_KEYS.add(CONTROL_VALUE);
|
CONTROL_EVENT_KEYS.add(CONTROL_VALUE);
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.list.ListModel;
|
import com.arsdigita.bebop.list.ListModel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that provides a sample set of workflows and tasks. The class
|
* A class that provides a sample set of workflows and tasks. The class
|
||||||
|
|
@ -37,6 +38,7 @@ import java.util.NoSuchElementException;
|
||||||
*/
|
*/
|
||||||
public class SampleProcesses {
|
public class SampleProcesses {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SampleProcesses.class);
|
||||||
private static SampleProcesses m_instance;
|
private static SampleProcesses m_instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,6 +53,7 @@ public class SampleProcesses {
|
||||||
|
|
||||||
// Set up some default task types
|
// Set up some default task types
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Task write = new Task("Write");
|
Task write = new Task("Write");
|
||||||
write.setAssignee("Authors");
|
write.setAssignee("Authors");
|
||||||
Task edit = new Task("Edit");
|
Task edit = new Task("Edit");
|
||||||
|
|
@ -68,6 +71,7 @@ public class SampleProcesses {
|
||||||
m_allTasks.add(approve);
|
m_allTasks.add(approve);
|
||||||
m_allTasks.add(publish);
|
m_allTasks.add(publish);
|
||||||
m_allTasks.add(review);
|
m_allTasks.add(review);
|
||||||
|
logger.debug("Static initalizer finished...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static SampleProcesses getInstance() {
|
public synchronized static SampleProcesses getInstance() {
|
||||||
|
|
|
||||||
|
|
@ -84,89 +84,91 @@ public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
// load the default xsl parameter generators
|
// load the default xsl parameter generators
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
registerXSLParameterGenerator("contextPath",
|
registerXSLParameterGenerator("contextPath",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return request.getContextPath();
|
return request.getContextPath();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("root-context-prefix",
|
registerXSLParameterGenerator("root-context-prefix",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return Web.getConfig().getDispatcherContextPath();
|
return Web.getConfig().getDispatcherContextPath();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("context-prefix",
|
registerXSLParameterGenerator("context-prefix",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return Web.getContext().getRequestURL().getContextPath();
|
return Web.getContext().getRequestURL().getContextPath();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("static-prefix",
|
registerXSLParameterGenerator("static-prefix",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return Web.getContext().getRequestURL().getContextPath()
|
return Web.getContext().getRequestURL().getContextPath()
|
||||||
+ com.arsdigita.web.URL.STATIC_DIR;
|
+ com.arsdigita.web.URL.STATIC_DIR;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("dispatcher-prefix",
|
registerXSLParameterGenerator("dispatcher-prefix",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return com.arsdigita.web.URL.getDispatcherPath();
|
return com.arsdigita.web.URL.getDispatcherPath();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("dcp-on-buttons",
|
registerXSLParameterGenerator("dcp-on-buttons",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
if (Bebop.getConfig().doubleClickProtectionOnButtons()) {
|
if (Bebop.getConfig().doubleClickProtectionOnButtons()) {
|
||||||
return "true";
|
return "true";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("dcp-on-links",
|
registerXSLParameterGenerator("dcp-on-links",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
if (Bebop.getConfig().doubleClickProtectionOnLinks()) {
|
if (Bebop.getConfig().doubleClickProtectionOnLinks()) {
|
||||||
return "true";
|
return "true";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("user-agent",
|
registerXSLParameterGenerator("user-agent",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return request.getHeader("User-Agent");
|
return request.getHeader("User-Agent");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerXSLParameterGenerator("negotiated-language",
|
registerXSLParameterGenerator("negotiated-language",
|
||||||
new XSLParameterGenerator() {
|
new XSLParameterGenerator() {
|
||||||
|
|
||||||
public String generateValue(HttpServletRequest request) {
|
public String generateValue(HttpServletRequest request) {
|
||||||
return DispatcherHelper.getNegotiatedLocale().getLanguage();
|
return DispatcherHelper.getNegotiatedLocale().getLanguage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
// XXX These need to move somewhere else.
|
// 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
|
* Sets the content type of the response and then gets the PrintWriter
|
||||||
*/
|
*/
|
||||||
private PrintWriter getWriter(final HttpServletResponse resp,
|
private PrintWriter getWriter(final HttpServletResponse resp,
|
||||||
final String contentType,
|
final String contentType,
|
||||||
final String charset) {
|
final String charset) {
|
||||||
Assert.exists(contentType);
|
Assert.exists(contentType);
|
||||||
Assert.exists(charset);
|
Assert.exists(charset);
|
||||||
|
|
||||||
|
|
@ -229,8 +231,9 @@ public class PageTransformer implements PresentationManager {
|
||||||
s_log.warn("Using getOutputStream instead of getWriter");
|
s_log.warn("Using getOutputStream instead of getWriter");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new PrintWriter(new OutputStreamWriter(resp.getOutputStream(),
|
return new PrintWriter(new OutputStreamWriter(resp.
|
||||||
charset));
|
getOutputStream(),
|
||||||
|
charset));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -245,8 +248,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
* <code>PresentationManager</code> interface.
|
* <code>PresentationManager</code> interface.
|
||||||
*/
|
*/
|
||||||
public void servePage(final Document doc,
|
public void servePage(final Document doc,
|
||||||
final HttpServletRequest req,
|
final HttpServletRequest req,
|
||||||
final HttpServletResponse resp) {
|
final HttpServletResponse resp) {
|
||||||
servePage(doc, req, resp, null);
|
servePage(doc, req, resp, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,9 +268,9 @@ public class PageTransformer implements PresentationManager {
|
||||||
* to the Transformer
|
* to the Transformer
|
||||||
*/
|
*/
|
||||||
public void servePage(final Document doc,
|
public void servePage(final Document doc,
|
||||||
final HttpServletRequest req,
|
final HttpServletRequest req,
|
||||||
final HttpServletResponse resp,
|
final HttpServletResponse resp,
|
||||||
final Map params) {
|
final Map params) {
|
||||||
if (resp.isCommitted()) {
|
if (resp.isCommitted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -280,7 +283,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
Profiler.startOp("XSLT");
|
Profiler.startOp("XSLT");
|
||||||
try {
|
try {
|
||||||
final String charset = Globalization.getDefaultCharset(Kernel.getContext().getLocale());
|
final String charset = Globalization.getDefaultCharset(Kernel.
|
||||||
|
getContext().getLocale());
|
||||||
|
|
||||||
final String output = req.getParameter("output");
|
final String output = req.getParameter("output");
|
||||||
s_log.info("output=" + output);
|
s_log.info("output=" + output);
|
||||||
|
|
@ -289,12 +293,14 @@ public class PageTransformer implements PresentationManager {
|
||||||
DeveloperSupport.startStage("PresMgr get stylesheet");
|
DeveloperSupport.startStage("PresMgr get stylesheet");
|
||||||
|
|
||||||
boolean fancyErrors = Bebop.getConfig().wantFancyXSLErrors()
|
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
|
// Get the stylesheet transformer object corresponding to the
|
||||||
// current request.
|
// current request.
|
||||||
final XSLTemplate template = Templating.getTemplate(req,
|
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");
|
DeveloperSupport.endStage("PresMgr get stylesheet");
|
||||||
|
|
||||||
|
|
@ -322,7 +328,8 @@ public class PageTransformer implements PresentationManager {
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
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 {
|
try {
|
||||||
xf.transform(new DOMSource(doc.getInternalDocument()),
|
xf.transform(new DOMSource(doc.getInternalDocument()),
|
||||||
new StreamResult(writer));
|
new StreamResult(writer));
|
||||||
} catch (TransformerException ex) {
|
} catch (TransformerException ex) {
|
||||||
throw new UncheckedWrapperException(
|
throw new UncheckedWrapperException(
|
||||||
"cannot transform document", ex);
|
"cannot transform document", ex);
|
||||||
|
|
@ -351,8 +358,10 @@ public class PageTransformer implements PresentationManager {
|
||||||
|
|
||||||
// copy and paste from BasePresentationManager
|
// copy and paste from BasePresentationManager
|
||||||
if (Kernel.getConfig().isDebugEnabled()) {
|
if (Kernel.getConfig().isDebugEnabled()) {
|
||||||
Document origDoc = (Document) req.getAttribute("com.arsdigita.xml.Document");
|
Document origDoc = (Document) req.getAttribute(
|
||||||
Debugger.addDebugger(new TransformationDebugger(template.getSource(), template.getDependents()));
|
"com.arsdigita.xml.Document");
|
||||||
|
Debugger.addDebugger(new TransformationDebugger(template.
|
||||||
|
getSource(), template.getDependents()));
|
||||||
writer.print(Debugger.getDebugging(req));
|
writer.print(Debugger.getDebugging(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,8 +383,10 @@ public class PageTransformer implements PresentationManager {
|
||||||
// current request.
|
// current request.
|
||||||
template = Templating.getTemplate(
|
template = Templating.getTemplate(
|
||||||
req,
|
req,
|
||||||
Boolean.TRUE.equals(req.getAttribute(PageTransformer.FANCY_ERRORS)),
|
Boolean.TRUE.equals(req.getAttribute(
|
||||||
!Boolean.TRUE.equals(req.getAttribute(PageTransformer.CACHE_XSL_NONE)));
|
PageTransformer.FANCY_ERRORS)),
|
||||||
|
!Boolean.TRUE.equals(req.getAttribute(
|
||||||
|
PageTransformer.CACHE_XSL_NONE)));
|
||||||
endTransaction(req);
|
endTransaction(req);
|
||||||
} finally {
|
} finally {
|
||||||
DeveloperSupport.endStage("PresMgr get stylesheet");
|
DeveloperSupport.endStage("PresMgr get stylesheet");
|
||||||
|
|
@ -393,7 +404,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
resp.reset();
|
resp.reset();
|
||||||
resp.setContentType("application/zip");
|
resp.setContentType("application/zip");
|
||||||
resp.setHeader("Content-Disposition",
|
resp.setHeader("Content-Disposition",
|
||||||
"attachment; filename=\"" + prefix + ".zip\"");
|
"attachment; filename=\"" + prefix + ".zip\"");
|
||||||
DispatcherHelper.forceCacheDisable(resp);
|
DispatcherHelper.forceCacheDisable(resp);
|
||||||
|
|
||||||
template.toZIP(os, prefix);
|
template.toZIP(os, prefix);
|
||||||
|
|
@ -406,7 +417,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(output
|
throw new IllegalStateException(output
|
||||||
+ " is an unknown output");
|
+ " is an unknown output");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Profiler.stopOp("XSLT");
|
Profiler.stopOp("XSLT");
|
||||||
|
|
@ -435,7 +446,7 @@ public class PageTransformer implements PresentationManager {
|
||||||
* only the last registered generator is used.
|
* only the last registered generator is used.
|
||||||
*/
|
*/
|
||||||
public static void registerXSLParameterGenerator(String parameterName,
|
public static void registerXSLParameterGenerator(String parameterName,
|
||||||
XSLParameterGenerator parameterGenerator) {
|
XSLParameterGenerator parameterGenerator) {
|
||||||
s_XSLParameters.put(parameterName, parameterGenerator);
|
s_XSLParameters.put(parameterName, parameterGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,9 +471,9 @@ public class PageTransformer implements PresentationManager {
|
||||||
* be used in the XSL for the given name
|
* be used in the XSL for the given name
|
||||||
*/
|
*/
|
||||||
public static String getXSLParameterValue(String name,
|
public static String getXSLParameterValue(String name,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
XSLParameterGenerator generator =
|
XSLParameterGenerator generator =
|
||||||
(XSLParameterGenerator) s_XSLParameters.get(name);
|
(XSLParameterGenerator) s_XSLParameters.get(name);
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
return generator.generateValue(request);
|
return generator.generateValue(request);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -475,13 +486,14 @@ public class PageTransformer implements PresentationManager {
|
||||||
* xsl paraemters.
|
* xsl paraemters.
|
||||||
*/
|
*/
|
||||||
public static void addXSLParameters(Transformer transformer,
|
public static void addXSLParameters(Transformer transformer,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
final Iterator entries = s_XSLParameters.entrySet().iterator();
|
final Iterator entries = s_XSLParameters.entrySet().iterator();
|
||||||
|
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
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) {
|
if (value == null) {
|
||||||
// XSL does not like nulls
|
// XSL does not like nulls
|
||||||
value = "";
|
value = "";
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,9 @@ public class Category extends ACSObject {
|
||||||
private static CategorizationConfig s_config = new CategorizationConfig();
|
private static CategorizationConfig s_config = new CategorizationConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
// Quasimodo: End
|
// Quasimodo: End
|
||||||
public static final String ROOT_CATEGORY = "rootCategory";
|
public static final String ROOT_CATEGORY = "rootCategory";
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LibCheck uses the checklist mechanism to perform additional checks for
|
* LibCheck uses the checklist mechanism to perform additional checks for
|
||||||
|
|
@ -37,14 +38,16 @@ import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class LibCheck extends BaseCheck {
|
public class LibCheck extends BaseCheck {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(LibCheck.class);
|
||||||
// Integrating the packaging.MessageMap service class providing a
|
// Integrating the packaging.MessageMap service class providing a
|
||||||
// package specific message file by overriding the variable in BaseCheck.
|
// package specific message file by overriding the variable in BaseCheck.
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer starting...");
|
||||||
final InputStream in = LibCheck.class.getResourceAsStream
|
final InputStream in = LibCheck.class.getResourceAsStream
|
||||||
("libcheck.messages_linux");
|
("libcheck.messages_linux");
|
||||||
Assert.exists(in, InputStream.class);
|
Assert.exists(in, InputStream.class);
|
||||||
s_messages.load(new InputStreamReader(in));
|
s_messages.load(new InputStreamReader(in));
|
||||||
|
logger.debug("Static initializer finished...");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkJAAS() {
|
private boolean checkJAAS() {
|
||||||
|
|
|
||||||
|
|
@ -155,9 +155,11 @@ public final class Comodifications {
|
||||||
* the Proxy class do most of the work for me.
|
* the Proxy class do most of the work for me.
|
||||||
*/
|
*/
|
||||||
private static class ListHandler implements InvocationHandler {
|
private static class ListHandler implements InvocationHandler {
|
||||||
|
private static final Logger logger = Logger.getLogger(ListHandler.class);
|
||||||
private final static Set s_mutators = new HashSet();
|
private final static Set s_mutators = new HashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
registerMutator("add", new Class[] {Integer.TYPE, Object.class});
|
registerMutator("add", new Class[] {Integer.TYPE, Object.class});
|
||||||
registerMutator("add", new Class[] {Object.class});
|
registerMutator("add", new Class[] {Object.class});
|
||||||
registerMutator("addAll", new Class[] {Collection.class});
|
registerMutator("addAll", new Class[] {Collection.class});
|
||||||
|
|
@ -169,6 +171,7 @@ public final class Comodifications {
|
||||||
registerMutator("removeAll", new Class[] {Collection.class});
|
registerMutator("removeAll", new Class[] {Collection.class});
|
||||||
registerMutator("retainAll", new Class[] {Collection.class});
|
registerMutator("retainAll", new Class[] {Collection.class});
|
||||||
registerMutator("set", new Class[] {Integer.TYPE, Object.class});
|
registerMutator("set", new Class[] {Integer.TYPE, Object.class});
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Method s_iteratorMethod =
|
private final static Method s_iteratorMethod =
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,10 @@ public final class Counter {
|
||||||
|
|
||||||
private final static DecimalFormat DURATION_FMT = new DecimalFormat();
|
private final static DecimalFormat DURATION_FMT = new DecimalFormat();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
DURATION_FMT.setGroupingSize(3);
|
DURATION_FMT.setGroupingSize(3);
|
||||||
DURATION_FMT.setGroupingUsed(true);
|
DURATION_FMT.setGroupingUsed(true);
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,16 +224,20 @@ public final class LoggingProxyFactory implements LoggerConfigurator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Handler implements InvocationHandler {
|
private static class Handler implements InvocationHandler {
|
||||||
|
private static final Logger logger = Logger.getLogger(Handler.class);
|
||||||
private static final Method s_getProxiedObject;
|
private static final Method s_getProxiedObject;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
try {
|
try {
|
||||||
s_getProxiedObject =
|
s_getProxiedObject =
|
||||||
LoggingProxy.class.getMethod("getProxiedObject",
|
LoggingProxy.class.getMethod("getProxiedObject",
|
||||||
new Class[] {});
|
new Class[] {});
|
||||||
} catch (NoSuchMethodException ex) {
|
} catch (NoSuchMethodException ex) {
|
||||||
|
logger.error("Statis initalizer failed: ", ex);
|
||||||
throw new UncheckedWrapperException("failed", ex);
|
throw new UncheckedWrapperException("failed", ex);
|
||||||
}
|
}
|
||||||
|
logger.debug("Static initalizer finished...");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Config m_config;
|
private Config m_config;
|
||||||
|
|
|
||||||
|
|
@ -83,58 +83,57 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||||
public abstract class BaseDispatcherServlet extends HttpServlet
|
public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
implements Dispatcher, DispatcherConstants {
|
implements Dispatcher, DispatcherConstants {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger(
|
||||||
(BaseDispatcherServlet.class);
|
BaseDispatcherServlet.class);
|
||||||
|
|
||||||
private final static int NOT_FOUND = 0;
|
private final static int NOT_FOUND = 0;
|
||||||
private final static int STATIC_FILE = 1;
|
private final static int STATIC_FILE = 1;
|
||||||
private final static int JSP_FILE = 2;
|
private final static int JSP_FILE = 2;
|
||||||
|
|
||||||
private final static String WEB_XML_22_PUBLIC_ID =
|
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 =
|
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
|
* We use a Vector here instead of another collection because
|
||||||
* Vector is synchronized.
|
* Vector is synchronized.
|
||||||
*/
|
*/
|
||||||
private static Vector s_listenerList = new Vector();
|
private static Vector s_listenerList = new Vector();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list of active requests
|
* list of active requests
|
||||||
*/
|
*/
|
||||||
private static Vector s_activeList = new Vector();
|
private static Vector s_activeList = new Vector();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
// Add the basic request listeners.
|
// Add the basic request listeners.
|
||||||
|
|
||||||
BaseDispatcherServlet.addRequestListener(new RequestListener() {
|
BaseDispatcherServlet.addRequestListener(new RequestListener() {
|
||||||
public void requestStarted(RequestEvent re) {
|
|
||||||
DispatcherHelper.setRequest(re.getRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestFinished(RequestEvent re) {
|
public void requestStarted(RequestEvent re) {
|
||||||
// We could do this:
|
DispatcherHelper.setRequest(re.getRequest());
|
||||||
// DispatcherHelper.setRequest(null);
|
}
|
||||||
// but some later RequestListener might want to access
|
|
||||||
// the request or session. So we'll just let the
|
public void requestFinished(RequestEvent re) {
|
||||||
// DispatcherHelper hang on to one stale
|
// We could do this:
|
||||||
// HttpServletRequest (per thread). The reference will
|
// DispatcherHelper.setRequest(null);
|
||||||
// be overwritten on the next request, so we keep only
|
// but some later RequestListener might want to access
|
||||||
// a small amount of garbage.
|
// 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() {
|
BaseDispatcherServlet.addRequestListener(new RequestListener() {
|
||||||
public void requestStarted(RequestEvent re) {
|
|
||||||
Kernel.getContext().getTransaction().begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestFinished(RequestEvent re) {
|
public void requestStarted(RequestEvent re) {
|
||||||
Kernel.getContext().getTransaction().end();
|
Kernel.getContext().getTransaction().begin();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
public void requestFinished(RequestEvent re) {
|
||||||
|
Kernel.getContext().getTransaction().end();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//log to DeveloperSupport
|
//log to DeveloperSupport
|
||||||
// BaseDispatcherServlet.addRequestListener(new RequestListener() {
|
// 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
|
* it depends upon there being at least one DeveloperSupportListener when counting
|
||||||
* whether to log queries to webdevsupport.
|
* whether to log queries to webdevsupport.
|
||||||
*/
|
*/
|
||||||
com.arsdigita.developersupport.DeveloperSupport.addListener
|
com.arsdigita.developersupport.DeveloperSupport.addListener(new com.arsdigita.developersupport.DeveloperSupportListener() {
|
||||||
(new com.arsdigita.developersupport.DeveloperSupportListener() {
|
|
||||||
public void requestStart(Object request) {
|
|
||||||
s_log.debug("DS: requestStart: " + request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestEnd(Object request) {
|
public void requestStart(Object request) {
|
||||||
s_log.debug("DS: requestEnd: " + 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();
|
private List m_welcomeFiles = new ArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -177,7 +175,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
super.init();
|
super.init();
|
||||||
try {
|
try {
|
||||||
File file =
|
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
|
// all we care about is the welcome-file-list element
|
||||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||||
spf.setValidating(false);
|
spf.setValidating(false);
|
||||||
|
|
@ -220,11 +218,10 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* @throws com.arsdigita.dispatcher.RedirectException if the dispatcher
|
* @throws com.arsdigita.dispatcher.RedirectException if the dispatcher
|
||||||
* should redirect the client to the page contained in the exception
|
* should redirect the client to the page contained in the exception
|
||||||
**/
|
**/
|
||||||
protected abstract RequestContext authenticateUser
|
protected abstract RequestContext authenticateUser(HttpServletRequest req,
|
||||||
(HttpServletRequest req,
|
HttpServletResponse resp,
|
||||||
HttpServletResponse resp,
|
RequestContext ctx)
|
||||||
RequestContext ctx)
|
throws RedirectException;
|
||||||
throws RedirectException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called directly by the servlet container when this servlet is invoked
|
* Called directly by the servlet container when this servlet is invoked
|
||||||
|
|
@ -243,18 +240,17 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* throws an IOException
|
* throws an IOException
|
||||||
*/
|
*/
|
||||||
public void service(HttpServletRequest req, HttpServletResponse resp)
|
public void service(HttpServletRequest req, HttpServletResponse resp)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug
|
s_log.debug("\n*** *** *** *** *** ***\n"
|
||||||
("\n*** *** *** *** *** ***\n" +
|
+ "Servicing request for URL '" + req.getRequestURI()
|
||||||
"Servicing request for URL '" + req.getRequestURI() + "'\n" +
|
+ "'\n" + "*** *** *** *** *** ***");
|
||||||
"*** *** *** *** *** ***");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean reentrant = true;
|
boolean reentrant = true;
|
||||||
RequestContext reqCtx =
|
RequestContext reqCtx =
|
||||||
DispatcherHelper.getRequestContext(req);
|
DispatcherHelper.getRequestContext(req);
|
||||||
boolean finishedNormal = false;
|
boolean finishedNormal = false;
|
||||||
|
|
||||||
// there are two types of re-entrancy we need to consider:
|
// 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
|
// need an identifier for this particular request
|
||||||
String requestId =
|
String requestId =
|
||||||
Thread.currentThread().getName() + "|" +
|
Thread.currentThread().getName() + "|" + System.
|
||||||
System.currentTimeMillis();
|
currentTimeMillis();
|
||||||
req.setAttribute(REENTRANCE_ATTRIBUTE, requestId);
|
req.setAttribute(REENTRANCE_ATTRIBUTE, requestId);
|
||||||
s_activeList.add(requestId);
|
s_activeList.add(requestId);
|
||||||
|
|
||||||
|
|
@ -345,8 +341,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
// whole object since it might actually be a
|
// whole object since it might actually be a
|
||||||
// KernelRequestContext with user / session info
|
// KernelRequestContext with user / session info
|
||||||
if (reqCtx instanceof InitialRequestContext) {
|
if (reqCtx instanceof InitialRequestContext) {
|
||||||
((InitialRequestContext)reqCtx)
|
((InitialRequestContext) reqCtx).
|
||||||
.initializeURLFromRequest(req, true);
|
initializeURLFromRequest(req, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +378,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
Throwable rootError;
|
Throwable rootError;
|
||||||
do {
|
do {
|
||||||
rootError = t;
|
rootError = t;
|
||||||
t = ((ServletException)t).getRootCause();
|
t = ((ServletException) t).getRootCause();
|
||||||
} while (t instanceof ServletException);
|
} while (t instanceof ServletException);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
rootError = t;
|
rootError = t;
|
||||||
|
|
@ -393,9 +389,9 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
&& (rootError instanceof AbortRequestSignal)) {
|
&& (rootError instanceof AbortRequestSignal)) {
|
||||||
finishedNormal = true;
|
finishedNormal = true;
|
||||||
} else if (rootError != null
|
} else if (rootError != null
|
||||||
&& (rootError instanceof RedirectSignal)) {
|
&& (rootError instanceof RedirectSignal)) {
|
||||||
s_log.debug("rethrowing RedirectSignal", rootError);
|
s_log.debug("rethrowing RedirectSignal", rootError);
|
||||||
throw (RedirectSignal)rootError;
|
throw (RedirectSignal) rootError;
|
||||||
} else {
|
} else {
|
||||||
s_log.error("error in BaseDispatcherServlet", rootError);
|
s_log.error("error in BaseDispatcherServlet", rootError);
|
||||||
throw new ServletException(rootError);
|
throw new ServletException(rootError);
|
||||||
|
|
@ -411,13 +407,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
DeveloperSupport.endStage("BaseDispatcherServlet.service()");
|
DeveloperSupport.endStage("BaseDispatcherServlet.service()");
|
||||||
// run the request listener events
|
// run the request listener events
|
||||||
fireFinishedListener(
|
fireFinishedListener(
|
||||||
new RequestEvent(req, resp, reqCtx, false, finishedNormal));
|
new RequestEvent(req, resp, reqCtx, false,
|
||||||
|
finishedNormal));
|
||||||
// at this point, clear the attribute so
|
// at this point, clear the attribute so
|
||||||
// a secondary request will work
|
// a secondary request will work
|
||||||
// and remove the request from the list of currently-active
|
// and remove the request from the list of currently-active
|
||||||
// requests
|
// requests
|
||||||
Object requestId = req.getAttribute(REENTRANCE_ATTRIBUTE);
|
Object requestId = req.getAttribute(REENTRANCE_ATTRIBUTE);
|
||||||
synchronized(s_activeList) {
|
synchronized (s_activeList) {
|
||||||
s_activeList.remove(requestId);
|
s_activeList.remove(requestId);
|
||||||
s_activeList.notifyAll();
|
s_activeList.notifyAll();
|
||||||
}
|
}
|
||||||
|
|
@ -438,14 +435,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
**/
|
**/
|
||||||
private StartRequestRecord startRequest(HttpServletRequest req,
|
private StartRequestRecord startRequest(HttpServletRequest req,
|
||||||
HttpServletResponse resp)
|
HttpServletResponse resp)
|
||||||
throws RedirectException, IOException, ServletException {
|
throws RedirectException, IOException, ServletException {
|
||||||
|
|
||||||
// turn multipart request into wrapped request
|
// turn multipart request into wrapped request
|
||||||
// to make up for servlet 2.2 brokenness
|
// to make up for servlet 2.2 brokenness
|
||||||
req = DispatcherHelper.maybeWrapRequest(req);
|
req = DispatcherHelper.maybeWrapRequest(req);
|
||||||
|
|
||||||
RequestContext reqCtx =
|
RequestContext reqCtx =
|
||||||
new InitialRequestContext(req, getServletContext());
|
new InitialRequestContext(req, getServletContext());
|
||||||
|
|
||||||
// run the request listener events
|
// run the request listener events
|
||||||
fireStartListener(new RequestEvent(req, resp, reqCtx, true));
|
fireStartListener(new RequestEvent(req, resp, reqCtx, true));
|
||||||
|
|
@ -469,12 +466,12 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* listeners
|
* listeners
|
||||||
*/
|
*/
|
||||||
protected void fireFinishedListener(RequestEvent evt) {
|
protected void fireFinishedListener(RequestEvent evt) {
|
||||||
for (int i = 0 ; i < s_listenerList.size(); i++) {
|
for (int i = 0; i < s_listenerList.size(); i++) {
|
||||||
try {
|
try {
|
||||||
((RequestListener)s_listenerList.get(i)).requestFinished(evt);
|
((RequestListener) s_listenerList.get(i)).requestFinished(evt);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_log.error("Error running request finished listener " +
|
s_log.error("Error running request finished listener " + s_listenerList.
|
||||||
s_listenerList.get(i) + " (#" + i + ")", e);
|
get(i) + " (#" + i + ")", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -487,8 +484,8 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* listeners
|
* listeners
|
||||||
*/
|
*/
|
||||||
protected void fireStartListener(RequestEvent evt) {
|
protected void fireStartListener(RequestEvent evt) {
|
||||||
for (int i = 0 ; i < s_listenerList.size(); i++) {
|
for (int i = 0; i < s_listenerList.size(); i++) {
|
||||||
((RequestListener)s_listenerList.get(i)).requestStarted(evt);
|
((RequestListener) s_listenerList.get(i)).requestStarted(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,6 +493,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* Kludge for returning a typed 2-tuple.
|
* Kludge for returning a typed 2-tuple.
|
||||||
*/
|
*/
|
||||||
private class StartRequestRecord {
|
private class StartRequestRecord {
|
||||||
|
|
||||||
RequestContext m_reqCtx;
|
RequestContext m_reqCtx;
|
||||||
HttpServletRequest m_req;
|
HttpServletRequest m_req;
|
||||||
|
|
||||||
|
|
@ -517,10 +515,11 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
if (sema != null) {
|
if (sema != null) {
|
||||||
while (s_activeList.indexOf(sema) != -1) {
|
while (s_activeList.indexOf(sema) != -1) {
|
||||||
try {
|
try {
|
||||||
synchronized(s_activeList) {
|
synchronized (s_activeList) {
|
||||||
s_activeList.wait();
|
s_activeList.wait();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ie) { }
|
} catch (InterruptedException ie) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sess.removeAttribute(REDIRECT_SEMAPHORE);
|
sess.removeAttribute(REDIRECT_SEMAPHORE);
|
||||||
}
|
}
|
||||||
|
|
@ -545,15 +544,15 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* returns NOT_FOUND otherwise.
|
* returns NOT_FOUND otherwise.
|
||||||
*/
|
*/
|
||||||
private int concreteFileType(HttpServletRequest req)
|
private int concreteFileType(HttpServletRequest req)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
|
|
||||||
String path = DispatcherHelper.getCurrentResourcePath(req);
|
String path = DispatcherHelper.getCurrentResourcePath(req);
|
||||||
|
|
||||||
ServletContext sctx = this.getServletContext();
|
ServletContext sctx = this.getServletContext();
|
||||||
File realFile = new File(sctx.getRealPath(path));
|
File realFile = new File(sctx.getRealPath(path));
|
||||||
if (realFile.exists() &&
|
if (realFile.exists() && (!realFile.isDirectory() || hasWelcomeFile(
|
||||||
(!realFile.isDirectory() || hasWelcomeFile(realFile))) {
|
realFile))) {
|
||||||
// yup. Go there, bypass the site map.
|
// yup. Go there, bypass the site map.
|
||||||
// we have a concrete file so no forwarding to
|
// we have a concrete file so no forwarding to
|
||||||
// rewrite the request URL is necessary.
|
// rewrite the request URL is necessary.
|
||||||
|
|
@ -587,7 +586,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
|
|
||||||
private boolean trailingSlashRedirect(HttpServletRequest req,
|
private boolean trailingSlashRedirect(HttpServletRequest req,
|
||||||
HttpServletResponse resp)
|
HttpServletResponse resp)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String path = DispatcherHelper.getCurrentResourcePath(req);
|
String path = DispatcherHelper.getCurrentResourcePath(req);
|
||||||
// first, see if we have an extension
|
// first, see if we have an extension
|
||||||
if (path.lastIndexOf(".") <= path.lastIndexOf("/")) {
|
if (path.lastIndexOf(".") <= path.lastIndexOf("/")) {
|
||||||
|
|
@ -612,13 +611,14 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
* web.xml
|
* web.xml
|
||||||
*/
|
*/
|
||||||
private class WebXMLReader extends DefaultHandler {
|
private class WebXMLReader extends DefaultHandler {
|
||||||
|
|
||||||
StringBuffer m_buffer = new StringBuffer();
|
StringBuffer m_buffer = new StringBuffer();
|
||||||
|
|
||||||
public InputSource resolveEntity(String publicId, String systemId)
|
public InputSource resolveEntity(String publicId, String systemId)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
// we don't want to read the web.xml dtd
|
// we don't want to read the web.xml dtd
|
||||||
if (WEB_XML_22_PUBLIC_ID.equals(publicId)
|
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(" ");
|
StringReader reader = new StringReader(" ");
|
||||||
return new InputSource(reader);
|
return new InputSource(reader);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -645,7 +645,7 @@ public abstract class BaseDispatcherServlet extends HttpServlet
|
||||||
String qname) {
|
String qname) {
|
||||||
if (qname.equals("welcome-file-list")) {
|
if (qname.equals("welcome-file-list")) {
|
||||||
String[] welcomeFiles =
|
String[] welcomeFiles =
|
||||||
StringUtils.split(m_buffer.toString(), ',');
|
StringUtils.split(m_buffer.toString(), ',');
|
||||||
for (int i = 0; i < welcomeFiles.length; i++) {
|
for (int i = 0; i < welcomeFiles.length; i++) {
|
||||||
m_welcomeFiles.add(welcomeFiles[i].trim());
|
m_welcomeFiles.add(welcomeFiles[i].trim());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.formbuilder;
|
package com.arsdigita.formbuilder;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.event.ParameterListener;
|
import com.arsdigita.bebop.event.ParameterListener;
|
||||||
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the attribute data type that are used for form
|
* This class contains the attribute data type that are used for form
|
||||||
|
|
@ -36,8 +35,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class AttributeType {
|
public class AttributeType {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(AttributeType.class);
|
||||||
private Class m_parameterModelClass;
|
private Class m_parameterModelClass;
|
||||||
|
|
||||||
private List m_validationListeners;
|
private List m_validationListeners;
|
||||||
|
|
||||||
public AttributeType(Class parameterModelClass) {
|
public AttributeType(Class parameterModelClass) {
|
||||||
|
|
@ -46,14 +45,12 @@ public class AttributeType {
|
||||||
|
|
||||||
m_validationListeners = new java.util.ArrayList();
|
m_validationListeners = new java.util.ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard attribute types
|
* Standard attribute types
|
||||||
*/
|
*/
|
||||||
public static AttributeType INTEGER;
|
public static AttributeType INTEGER;
|
||||||
public static AttributeType TEXT;
|
public static AttributeType TEXT;
|
||||||
public static AttributeType DATE;
|
public static AttributeType DATE;
|
||||||
|
|
||||||
// The classes of the standard data types
|
// The classes of the standard data types
|
||||||
private static Class s_integerClass;
|
private static Class s_integerClass;
|
||||||
private static Class s_textClass;
|
private static Class s_textClass;
|
||||||
|
|
@ -61,12 +58,15 @@ public class AttributeType {
|
||||||
|
|
||||||
// Initialization of the standard attribute types
|
// Initialization of the standard attribute types
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
s_integerClass = Class.forName("com.arsdigita.bebop.parameters.IntegerParameter");
|
s_integerClass = Class.forName(
|
||||||
s_textClass = Class.forName("com.arsdigita.bebop.parameters.StringParameter");
|
"com.arsdigita.bebop.parameters.IntegerParameter");
|
||||||
s_dateClass = Class.forName("com.arsdigita.bebop.parameters.DateParameter");
|
s_textClass = Class.forName(
|
||||||
|
"com.arsdigita.bebop.parameters.StringParameter");
|
||||||
|
s_dateClass = Class.forName(
|
||||||
|
"com.arsdigita.bebop.parameters.DateParameter");
|
||||||
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new UncheckedWrapperException(e);
|
throw new UncheckedWrapperException(e);
|
||||||
|
|
@ -75,10 +75,10 @@ public class AttributeType {
|
||||||
INTEGER = new AttributeType(s_integerClass);
|
INTEGER = new AttributeType(s_integerClass);
|
||||||
TEXT = new AttributeType(s_textClass);
|
TEXT = new AttributeType(s_textClass);
|
||||||
DATE = new AttributeType(s_dateClass);
|
DATE = new AttributeType(s_dateClass);
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//*** Attribute Methods
|
//*** Attribute Methods
|
||||||
|
|
||||||
public Class getParameterModelClass() {
|
public Class getParameterModelClass() {
|
||||||
return m_parameterModelClass;
|
return m_parameterModelClass;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,9 @@ public class Crypto {
|
||||||
public static final String CHARACTER_ENCODING = "UTF-8";
|
public static final String CHARACTER_ENCODING = "UTF-8";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
s_log.debug("Static initalizer finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ public class URLLoginModule extends UserLoginModule {
|
||||||
|
|
||||||
private static Set s_models = new HashSet();
|
private static Set s_models = new HashSet();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_models.add(NORMAL_PARAM);
|
s_models.add(NORMAL_PARAM);
|
||||||
s_models.add(SECURE_PARAM);
|
s_models.add(SECURE_PARAM);
|
||||||
|
s_log.debug("Static initalizer finished...");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ public class ErrorReport {
|
||||||
private static final Logger s_log = Logger.getLogger(ErrorReport.class);
|
private static final Logger s_log = Logger.getLogger(ErrorReport.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
final JavaPropertyReader reader = new JavaPropertyReader
|
final JavaPropertyReader reader = new JavaPropertyReader
|
||||||
(System.getProperties());
|
(System.getProperties());
|
||||||
|
|
||||||
|
|
@ -76,6 +77,7 @@ public class ErrorReport {
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
ErrorReport.initializeAppender(dir);
|
ErrorReport.initializeAppender(dir);
|
||||||
}
|
}
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeAppender(String directory) {
|
public static void initializeAppender(String directory) {
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,13 @@ import java.util.Set;
|
||||||
* @author Ron Henderson
|
* @author Ron Henderson
|
||||||
* @version $Id: Mail.java 994 2005-11-14 14:29:25Z apevec $
|
* @version $Id: Mail.java 994 2005-11-14 14:29:25Z apevec $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Mail implements MessageType {
|
public class Mail implements MessageType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for logging.
|
||||||
|
*/
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(Mail.class);
|
||||||
private static MailConfig s_config;
|
private static MailConfig s_config;
|
||||||
|
|
||||||
public static MailConfig getConfig() {
|
public static MailConfig getConfig() {
|
||||||
|
|
@ -82,118 +86,92 @@ public class Mail implements MessageType {
|
||||||
}
|
}
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final InternetAddress[] EMPTY_ADDRESS_LIST =
|
private static final InternetAddress[] EMPTY_ADDRESS_LIST =
|
||||||
new InternetAddress[0];
|
new InternetAddress[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table of message headers.
|
* Table of message headers.
|
||||||
*/
|
*/
|
||||||
private Hashtable m_headers;
|
private Hashtable m_headers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email addresses the message is being sent to.
|
* Email addresses the message is being sent to.
|
||||||
*/
|
*/
|
||||||
private InternetAddress[] m_to;
|
private InternetAddress[] m_to;
|
||||||
|
|
||||||
private InternetAddress[] m_filteredTo = EMPTY_ADDRESS_LIST;
|
private InternetAddress[] m_filteredTo = EMPTY_ADDRESS_LIST;
|
||||||
private InternetAddress[] m_invalidTo = EMPTY_ADDRESS_LIST;
|
private InternetAddress[] m_invalidTo = EMPTY_ADDRESS_LIST;
|
||||||
private static Set s_invalidDomains = new HashSet();
|
private static Set s_invalidDomains = new HashSet();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_invalidDomains.add("example.com");
|
s_invalidDomains.add("example.com");
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email address the message is being sent from.
|
* Email address the message is being sent from.
|
||||||
*/
|
*/
|
||||||
private InternetAddress m_from;
|
private InternetAddress m_from;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email address used for replies to this message.
|
* Email address used for replies to this message.
|
||||||
*/
|
*/
|
||||||
private InternetAddress[] m_replyTo;
|
private InternetAddress[] m_replyTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email addresses that the message is being carbon-copied to.
|
* Email addresses that the message is being carbon-copied to.
|
||||||
*/
|
*/
|
||||||
private InternetAddress[] m_cc;
|
private InternetAddress[] m_cc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email addresses that the message is being blind carbon-copied to.
|
* Email addresses that the message is being blind carbon-copied to.
|
||||||
*/
|
*/
|
||||||
private InternetAddress[] m_bcc;
|
private InternetAddress[] m_bcc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message subject.
|
* Message subject.
|
||||||
*/
|
*/
|
||||||
private String m_subject;
|
private String m_subject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message body (can be text or HTML).
|
* Message body (can be text or HTML).
|
||||||
*/
|
*/
|
||||||
private String m_body;
|
private String m_body;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message body alternate (if the body is HTML)
|
* Message body alternate (if the body is HTML)
|
||||||
*/
|
*/
|
||||||
private String m_alternate;
|
private String m_alternate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encoding specification for m_body and m_alternate (optional).
|
* Encoding specification for m_body and m_alternate (optional).
|
||||||
* Default value (null) implies "us-ascii" encoding.
|
* Default value (null) implies "us-ascii" encoding.
|
||||||
*/
|
*/
|
||||||
private String m_encoding;
|
private String m_encoding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message attachments (optional)
|
* Message attachments (optional)
|
||||||
*/
|
*/
|
||||||
private MimeMultipart m_attachments;
|
private MimeMultipart m_attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique identifier for each mail send out.
|
* Unique identifier for each mail send out.
|
||||||
*/
|
*/
|
||||||
private String m_messageID;
|
private String m_messageID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session object used to send mail.
|
* Session object used to send mail.
|
||||||
*/
|
*/
|
||||||
private static Session s_session;
|
private static Session s_session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP host to connect to. Only used to override the default for
|
* SMTP host to connect to. Only used to override the default for
|
||||||
* testing purposes.
|
* testing purposes.
|
||||||
*/
|
*/
|
||||||
private static String s_host;
|
private static String s_host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP port to connect to. Only used to override the default for
|
* SMTP port to connect to. Only used to override the default for
|
||||||
* testing purposes.
|
* testing purposes.
|
||||||
*/
|
*/
|
||||||
private static String s_port;
|
private static String s_port;
|
||||||
|
|
||||||
// Constants used by Mail
|
// Constants used by Mail
|
||||||
|
|
||||||
final static String CONTENT_TYPE = "Content-Type";
|
final static String CONTENT_TYPE = "Content-Type";
|
||||||
final static String CONTENT_ID = "Content-ID";
|
final static String CONTENT_ID = "Content-ID";
|
||||||
final static String MIXED = "mixed";
|
final static String MIXED = "mixed";
|
||||||
final static String ALTERNATIVE = "alternative";
|
final static String ALTERNATIVE = "alternative";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposition of "inline"
|
* Disposition of "inline"
|
||||||
*/
|
*/
|
||||||
public final static String INLINE = javax.mail.Part.INLINE;
|
public final static String INLINE = javax.mail.Part.INLINE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposition of "attachment"
|
* Disposition of "attachment"
|
||||||
*/
|
*/
|
||||||
public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT;
|
public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for logging.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static final Logger s_log =
|
|
||||||
Logger.getLogger(Mail.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Must use the setTo, setSubject (and so on)
|
* Default constructor. Must use the setTo, setSubject (and so on)
|
||||||
|
|
@ -212,8 +190,7 @@ public class Mail implements MessageType {
|
||||||
*/
|
*/
|
||||||
public Mail(String to,
|
public Mail(String to,
|
||||||
String from,
|
String from,
|
||||||
String subject)
|
String subject) {
|
||||||
{
|
|
||||||
this(to, from, subject, null);
|
this(to, from, subject, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,8 +205,7 @@ public class Mail implements MessageType {
|
||||||
public Mail(String to,
|
public Mail(String to,
|
||||||
String from,
|
String from,
|
||||||
String subject,
|
String subject,
|
||||||
String body)
|
String body) {
|
||||||
{
|
|
||||||
m_to = (to == null ? EMPTY_ADDRESS_LIST : parseAddressField(to));
|
m_to = (to == null ? EMPTY_ADDRESS_LIST : parseAddressField(to));
|
||||||
filterRecipients();
|
filterRecipients();
|
||||||
m_from = (from == null ? null : parseAddress(from));
|
m_from = (from == null ? null : parseAddress(from));
|
||||||
|
|
@ -251,9 +227,8 @@ public class Mail implements MessageType {
|
||||||
String from,
|
String from,
|
||||||
String subject,
|
String subject,
|
||||||
String body,
|
String body,
|
||||||
String enc)
|
String enc) {
|
||||||
{
|
this(to, from, subject, body);
|
||||||
this(to,from,subject,body);
|
|
||||||
setEncoding(enc);
|
setEncoding(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,26 +240,22 @@ public class Mail implements MessageType {
|
||||||
* @param subject the subject for the message
|
* @param subject the subject for the message
|
||||||
* @param body the plain text body of the message
|
* @param body the plain text body of the message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void send(String to,
|
public static void send(String to,
|
||||||
String from,
|
String from,
|
||||||
String subject,
|
String subject,
|
||||||
String body)
|
String body)
|
||||||
throws MessagingException,
|
throws MessagingException,
|
||||||
SendFailedException
|
SendFailedException {
|
||||||
{
|
Mail msg = new Mail(to, from, subject, body);
|
||||||
Mail msg = new Mail(to,from,subject,body);
|
|
||||||
msg.send();
|
msg.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the message.
|
* Sends the message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void send()
|
public void send()
|
||||||
throws MessagingException,
|
throws MessagingException,
|
||||||
SendFailedException
|
SendFailedException {
|
||||||
{
|
|
||||||
Transport transport = getSession().getTransport();
|
Transport transport = getSession().getTransport();
|
||||||
transport.connect();
|
transport.connect();
|
||||||
send(transport);
|
send(transport);
|
||||||
|
|
@ -300,11 +271,9 @@ public class Mail implements MessageType {
|
||||||
* also such returned from the server. Applications might try
|
* also such returned from the server. Applications might try
|
||||||
* to catch this and re-schedule sending the mail.
|
* to catch this and re-schedule sending the mail.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void send(Transport transport)
|
void send(Transport transport)
|
||||||
throws MessagingException,
|
throws MessagingException,
|
||||||
SendFailedException
|
SendFailedException {
|
||||||
{
|
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
if (m_filteredTo.length > 0) {
|
if (m_filteredTo.length > 0) {
|
||||||
msg = getMessage();
|
msg = getMessage();
|
||||||
|
|
@ -312,12 +281,12 @@ public class Mail implements MessageType {
|
||||||
try {
|
try {
|
||||||
transport.sendMessage(msg, msg.getAllRecipients());
|
transport.sendMessage(msg, msg.getAllRecipients());
|
||||||
} catch (MessagingException mex) {
|
} catch (MessagingException mex) {
|
||||||
|
|
||||||
// Close the transport agent and rethrow error for
|
// Close the transport agent and rethrow error for
|
||||||
// detailed message.
|
// detailed message.
|
||||||
|
|
||||||
transport.close();
|
transport.close();
|
||||||
|
|
||||||
throw new SendFailedException("send failed: ", mex);
|
throw new SendFailedException("send failed: ", mex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -329,8 +298,8 @@ public class Mail implements MessageType {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
msg.writeTo(os);
|
msg.writeTo(os);
|
||||||
s_log.debug("message sent:\n" + os.toString() +
|
s_log.debug("message sent:\n" + os.toString()
|
||||||
"\n-- EOT --");
|
+ "\n-- EOT --");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
s_log.error("unable to log message");
|
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");
|
s_log.debug("no message sent. No valid recipients:\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_log.info("message sent to <" + Arrays.asList(m_filteredTo) + "> from <" + m_from +
|
s_log.info("message sent to <" + Arrays.asList(m_filteredTo)
|
||||||
"> subject <" + m_subject + ">");
|
+ "> from <" + m_from + "> subject <" + m_subject + ">");
|
||||||
s_log.info("messages filtered for <" + Arrays.asList(m_invalidTo) + "> from <" + m_from +
|
s_log.info("messages filtered for <" + Arrays.asList(m_invalidTo)
|
||||||
"> subject <" + m_subject + ">");
|
+ "> from <" + m_from + "> subject <" + m_subject + ">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -413,7 +382,7 @@ public class Mail implements MessageType {
|
||||||
m_headers = new Hashtable();
|
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
|
* @param enc the requested encoding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setEncoding(String enc) {
|
public void setEncoding(String enc) {
|
||||||
m_encoding = enc;
|
m_encoding = enc;
|
||||||
}
|
}
|
||||||
|
|
@ -469,12 +437,10 @@ public class Mail implements MessageType {
|
||||||
*
|
*
|
||||||
* @return the string value of the character encoding being used
|
* @return the string value of the character encoding being used
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return m_encoding;
|
return m_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an attachment to a message. This method is private but
|
* Adds an attachment to a message. This method is private but
|
||||||
* is invoked by all of the other attach methods once they've
|
* 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
|
* @param part the message part to attach
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void attach(MimeBodyPart part)
|
private void attach(MimeBodyPart part)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
if (m_attachments == null) {
|
if (m_attachments == null) {
|
||||||
m_attachments = new MimeMultipart();
|
m_attachments = new MimeMultipart();
|
||||||
}
|
}
|
||||||
|
|
@ -501,12 +465,10 @@ public class Mail implements MessageType {
|
||||||
* @param name the name of the attachment
|
* @param name the name of the attachment
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(URL url,
|
public void attach(URL url,
|
||||||
String name,
|
String name,
|
||||||
String description)
|
String description)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
attach(url, name, description, Mail.ATTACHMENT);
|
attach(url, name, description, Mail.ATTACHMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,13 +481,11 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(URL url,
|
public void attach(URL url,
|
||||||
String name,
|
String name,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
MimeBodyPart part = new MimeBodyPart();
|
MimeBodyPart part = new MimeBodyPart();
|
||||||
attach(part);
|
attach(part);
|
||||||
|
|
||||||
|
|
@ -546,12 +506,10 @@ public class Mail implements MessageType {
|
||||||
* @param name the name of the attachment
|
* @param name the name of the attachment
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(File path,
|
public void attach(File path,
|
||||||
String name,
|
String name,
|
||||||
String description)
|
String description)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
attach(path, name, description, ATTACHMENT);
|
attach(path, name, description, ATTACHMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -565,13 +523,11 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(File path,
|
public void attach(File path,
|
||||||
String name,
|
String name,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
MimeBodyPart part = new MimeBodyPart();
|
MimeBodyPart part = new MimeBodyPart();
|
||||||
attach(part);
|
attach(part);
|
||||||
|
|
||||||
|
|
@ -592,13 +548,11 @@ public class Mail implements MessageType {
|
||||||
* @param type the MIME type of the attachment
|
* @param type the MIME type of the attachment
|
||||||
* @param name the name of the attachment
|
* @param name the name of the attachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(byte[] data,
|
public void attach(byte[] data,
|
||||||
String type,
|
String type,
|
||||||
String name)
|
String name)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
attach(data, type, name, null, ATTACHMENT);
|
||||||
attach(data,type,name,null,ATTACHMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -611,16 +565,14 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(byte[] data,
|
public void attach(byte[] data,
|
||||||
String type,
|
String type,
|
||||||
String name,
|
String name,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name);
|
||||||
ByteArrayDataSource ds = new ByteArrayDataSource(data,type,name);
|
attach(ds, description, disposition);
|
||||||
attach(ds,description,disposition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -631,13 +583,11 @@ public class Mail implements MessageType {
|
||||||
* @param type the MIME type of the attachment
|
* @param type the MIME type of the attachment
|
||||||
* @param name the name of the attachment
|
* @param name the name of the attachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(String data,
|
public void attach(String data,
|
||||||
String type,
|
String type,
|
||||||
String name)
|
String name)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
attach(data, type, name, null, ATTACHMENT);
|
||||||
attach(data,type,name,null,ATTACHMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -650,16 +600,14 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(String data,
|
public void attach(String data,
|
||||||
String type,
|
String type,
|
||||||
String name,
|
String name,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name);
|
||||||
ByteArrayDataSource ds = new ByteArrayDataSource(data,type,name);
|
attach(ds, description, disposition);
|
||||||
attach(ds,description,disposition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -671,13 +619,11 @@ public class Mail implements MessageType {
|
||||||
* @param type the MIME type of the attachment
|
* @param type the MIME type of the attachment
|
||||||
* @param name the name of the attachment
|
* @param name the name of the attachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(ByteArrayInputStream is,
|
public void attach(ByteArrayInputStream is,
|
||||||
String type,
|
String type,
|
||||||
String name)
|
String name)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
attach(is, type, name, null, ATTACHMENT);
|
||||||
attach(is,type,name,null,ATTACHMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -691,15 +637,13 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(ByteArrayInputStream is,
|
public void attach(ByteArrayInputStream is,
|
||||||
String type,
|
String type,
|
||||||
String name,
|
String name,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
ByteArrayDataSource ds = new ByteArrayDataSource(is, type, name);
|
||||||
ByteArrayDataSource ds = new ByteArrayDataSource(is,type,name);
|
|
||||||
attach(ds, description, disposition);
|
attach(ds, description, disposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -713,12 +657,10 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void attach(ByteArrayDataSource dataSource,
|
protected void attach(ByteArrayDataSource dataSource,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
MimeBodyPart part = new MimeBodyPart();
|
MimeBodyPart part = new MimeBodyPart();
|
||||||
attach(part);
|
attach(part);
|
||||||
|
|
||||||
|
|
@ -730,7 +672,6 @@ public class Mail implements MessageType {
|
||||||
part.setDisposition(disposition);
|
part.setDisposition(disposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches content to a message by supplying a DataHandler. All
|
* Attaches content to a message by supplying a DataHandler. All
|
||||||
* relevant parameters (MIME type, name, ...) are determined
|
* 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.
|
* @param dh a DataHandler for some piece of content.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(DataHandler dh)
|
public void attach(DataHandler dh)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
attach(dh, null, ATTACHMENT);
|
attach(dh, null, ATTACHMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches content to a message by supplying a DataHandler. Sets
|
* Attaches content to a message by supplying a DataHandler. Sets
|
||||||
* the description and disposition of the content.
|
* the description and disposition of the content.
|
||||||
|
|
@ -754,12 +692,10 @@ public class Mail implements MessageType {
|
||||||
* @param description a description of the attachment
|
* @param description a description of the attachment
|
||||||
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
* @param disposition Mail.ATTACHMENT or Mail.INLINE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void attach(DataHandler dh,
|
public void attach(DataHandler dh,
|
||||||
String description,
|
String description,
|
||||||
String disposition)
|
String disposition)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
MimeBodyPart part = new MimeBodyPart();
|
MimeBodyPart part = new MimeBodyPart();
|
||||||
attach(part);
|
attach(part);
|
||||||
|
|
||||||
|
|
@ -775,7 +711,6 @@ public class Mail implements MessageType {
|
||||||
* initializer and any of properties that can be overridden at
|
* initializer and any of properties that can be overridden at
|
||||||
* the package level.
|
* the package level.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static synchronized Session getSession() {
|
static synchronized Session getSession() {
|
||||||
|
|
||||||
if (s_session == null) {
|
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
|
* example, to queue a number of messages to send all at once rather
|
||||||
* than invoke the Mail.send() method for each instance.)
|
* than invoke the Mail.send() method for each instance.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Message getMessage()
|
private Message getMessage()
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
// Create the message
|
// Create the message
|
||||||
MimeMessage msg = new MimeMessage(getSession());
|
MimeMessage msg = new MimeMessage(getSession());
|
||||||
|
|
||||||
|
|
@ -838,7 +771,7 @@ public class Mail implements MessageType {
|
||||||
// Encode the subject
|
// Encode the subject
|
||||||
String enc_subj;
|
String enc_subj;
|
||||||
try {
|
try {
|
||||||
enc_subj = MimeUtility.encodeText(m_subject,m_encoding,null);
|
enc_subj = MimeUtility.encodeText(m_subject, m_encoding, null);
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
s_log.warn("unable to encode subject: " + uee);
|
s_log.warn("unable to encode subject: " + uee);
|
||||||
enc_subj = m_subject;
|
enc_subj = m_subject;
|
||||||
|
|
@ -849,11 +782,11 @@ public class Mail implements MessageType {
|
||||||
if (m_headers != null) {
|
if (m_headers != null) {
|
||||||
Enumeration e = m_headers.keys();
|
Enumeration e = m_headers.keys();
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
String name = (String) e.nextElement();
|
String name = (String) e.nextElement();
|
||||||
String value = (String) m_headers.get(name);
|
String value = (String) m_headers.get(name);
|
||||||
String enc_v;
|
String enc_v;
|
||||||
try {
|
try {
|
||||||
enc_v = MimeUtility.encodeText(value,m_encoding,null);
|
enc_v = MimeUtility.encodeText(value, m_encoding, null);
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
s_log.warn("unable to encode header element: " + uee);
|
s_log.warn("unable to encode header element: " + uee);
|
||||||
enc_v = value;
|
enc_v = value;
|
||||||
|
|
@ -875,7 +808,6 @@ public class Mail implements MessageType {
|
||||||
* @param host the SMTP host to connect to
|
* @param host the SMTP host to connect to
|
||||||
* @param port the port number on that host
|
* @param port the port number on that host
|
||||||
*/
|
*/
|
||||||
|
|
||||||
synchronized static void setSmtpServer(String host, String port) {
|
synchronized static void setSmtpServer(String host, String port) {
|
||||||
s_host = host;
|
s_host = host;
|
||||||
s_port = port;
|
s_port = port;
|
||||||
|
|
@ -884,7 +816,6 @@ public class Mail implements MessageType {
|
||||||
s_session = null;
|
s_session = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the SMTP mail host for debugging and account information.
|
* Returns the SMTP mail host for debugging and account information.
|
||||||
* @return 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;
|
return s_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the content of the message to the given output stream.
|
* Writes the content of the message to the given output stream.
|
||||||
* Useful for debugging.
|
* Useful for debugging.
|
||||||
*
|
*
|
||||||
* @param os the output stream to write the message to
|
* @param os the output stream to write the message to
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void writeTo(OutputStream os)
|
public void writeTo(OutputStream os)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
getMessage().writeTo(os);
|
getMessage().writeTo(os);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
@ -919,7 +847,7 @@ public class Mail implements MessageType {
|
||||||
|
|
||||||
if (str.indexOf(",") != -1) {
|
if (str.indexOf(",") != -1) {
|
||||||
ArrayList a = new ArrayList();
|
ArrayList a = new ArrayList();
|
||||||
StringTokenizer st = new StringTokenizer(str,",",false);
|
StringTokenizer st = new StringTokenizer(str, ",", false);
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
a.add(st.nextToken());
|
a.add(st.nextToken());
|
||||||
}
|
}
|
||||||
|
|
@ -950,7 +878,7 @@ public class Mail implements MessageType {
|
||||||
* Parses an address.
|
* Parses an address.
|
||||||
*/
|
*/
|
||||||
private static InternetAddress parseAddress(String str) {
|
private static InternetAddress parseAddress(String str) {
|
||||||
String address = null;
|
String address = null;
|
||||||
String personal = null;
|
String personal = null;
|
||||||
|
|
||||||
InternetAddress addr = null;
|
InternetAddress addr = null;
|
||||||
|
|
@ -960,13 +888,13 @@ public class Mail implements MessageType {
|
||||||
if (str.indexOf(" ") == -1) {
|
if (str.indexOf(" ") == -1) {
|
||||||
address = str;
|
address = str;
|
||||||
} else {
|
} else {
|
||||||
int sp = str.lastIndexOf(" ");
|
int sp = str.lastIndexOf(" ");
|
||||||
personal = str.substring(0,sp);
|
personal = str.substring(0, sp);
|
||||||
address = str.substring(sp+1);
|
address = str.substring(sp + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addr = new InternetAddress(address,personal);
|
addr = new InternetAddress(address, personal);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
s_log.error("unable to parse address: " + str);
|
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) {
|
private static void parseHeader(String str, Hashtable headers) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
|
|
||||||
int sp = str.lastIndexOf(":");
|
int sp = str.lastIndexOf(":");
|
||||||
String name = str.substring(0, sp);
|
String name = str.substring(0, sp);
|
||||||
String value = (str.substring(sp+1)).trim();
|
String value = (str.substring(sp + 1)).trim();
|
||||||
|
|
||||||
headers.put(name,value);
|
headers.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to prepare the content of the message.
|
* Utility function to prepare the content of the message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Message prepareMessageContent(MimeMessage msg)
|
private Message prepareMessageContent(MimeMessage msg)
|
||||||
throws MessagingException
|
throws MessagingException {
|
||||||
{
|
|
||||||
if (m_alternate == null && m_attachments == null) {
|
if (m_alternate == null && m_attachments == null) {
|
||||||
|
|
||||||
// We have a plain-text message with no attachments. Use
|
// We have a plain-text message with no attachments. Use
|
||||||
|
|
@ -1122,12 +1048,14 @@ public class Mail implements MessageType {
|
||||||
filtered.add(m_to[i]);
|
filtered.add(m_to[i]);
|
||||||
} else {
|
} else {
|
||||||
invalid.add(m_to[i]);
|
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_filteredTo = (InternetAddress[]) filtered.toArray(new InternetAddress[filtered.
|
||||||
m_invalidTo = (InternetAddress[]) invalid.toArray(new InternetAddress[invalid.size()]);
|
size()]);
|
||||||
|
m_invalidTo = (InternetAddress[]) invalid.toArray(new InternetAddress[invalid.
|
||||||
|
size()]);
|
||||||
return m_filteredTo;
|
return m_filteredTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BaseCheck: Extension of the Check abstract class, which can be used as a
|
* 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 {
|
abstract public class BaseCheck extends Check {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(BaseCheck.class);
|
||||||
public static final String versionId =
|
public static final String versionId =
|
||||||
"$Id: BaseCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
|
"$Id: BaseCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
|
||||||
" by $Author: sskracic $, " +
|
" by $Author: sskracic $, " +
|
||||||
|
|
@ -53,12 +55,14 @@ abstract public class BaseCheck extends Check {
|
||||||
public static final MessageMap s_messages = new MessageMap();
|
public static final MessageMap s_messages = new MessageMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
final InputStream in = BaseCheck.class.getResourceAsStream
|
final InputStream in = BaseCheck.class.getResourceAsStream
|
||||||
("basecheck.messages_linux");
|
("basecheck.messages_linux");
|
||||||
|
|
||||||
Assert.exists(in, InputStream.class);
|
Assert.exists(in, InputStream.class);
|
||||||
|
|
||||||
s_messages.load(new InputStreamReader(in));
|
s_messages.load(new InputStreamReader(in));
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String message(final String key) {
|
public static String message(final String key) {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import java.sql.Connection;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,6 +44,7 @@ import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class CheckDB extends BaseCheck {
|
public class CheckDB extends BaseCheck {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(CheckDB.class);
|
||||||
public final static String versionId =
|
public final static String versionId =
|
||||||
"$Id: DBCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
|
"$Id: DBCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
|
||||||
" by $Author: sskracic $, " +
|
" by $Author: sskracic $, " +
|
||||||
|
|
@ -51,10 +53,12 @@ public class CheckDB extends BaseCheck {
|
||||||
// Integration of service class packaging.MessageMap.
|
// Integration of service class packaging.MessageMap.
|
||||||
// Specifies a package specific message file overriding BaseCheck
|
// Specifies a package specific message file overriding BaseCheck
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
final InputStream in = CheckDB.class.getResourceAsStream
|
final InputStream in = CheckDB.class.getResourceAsStream
|
||||||
("checkdb.messages_linux");
|
("checkdb.messages_linux");
|
||||||
Assert.exists(in, InputStream.class);
|
Assert.exists(in, InputStream.class);
|
||||||
s_messages.load(new InputStreamReader(in));
|
s_messages.load(new InputStreamReader(in));
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import org.apache.commons.cli.OptionGroup;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* Get
|
||||||
|
|
@ -49,37 +50,31 @@ import org.apache.commons.cli.PosixParser;
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
* @author Rafael H. Schloming <rhs@mit.edu>
|
||||||
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class Get extends Command {
|
class Get extends Command {
|
||||||
|
|
||||||
public final static String versionId =
|
public static final Logger logger = Logger.getLogger(Get.class);
|
||||||
"$Id: Get.java 1324 2006-09-21 22:13:16Z apevec $" +
|
public final static String versionId =
|
||||||
" by $Author: apevec $, " +
|
"$Id: Get.java 1324 2006-09-21 22:13:16Z apevec $"
|
||||||
"$DateTime: 2004/08/16 18:10:38 $";
|
+ " by $Author: apevec $, "
|
||||||
|
+ "$DateTime: 2004/08/16 18:10:38 $";
|
||||||
private static final Options OPTIONS = getOptions();
|
private static final Options OPTIONS = getOptions();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
OptionGroup group = new OptionGroup();
|
OptionGroup group = new OptionGroup();
|
||||||
group.addOption
|
group.addOption(OptionBuilder.hasArg(false).withLongOpt("all").
|
||||||
(OptionBuilder
|
withDescription("Lists all configuration parameters").create(
|
||||||
.hasArg(false)
|
"all"));
|
||||||
.withLongOpt("all")
|
group.addOption(OptionBuilder.hasArg().withArgName("PARAMETER").
|
||||||
.withDescription("Lists all configuration parameters")
|
withLongOpt("value").withDescription(
|
||||||
.create("all"));
|
"Prints a scalar value without the key").create("value"));
|
||||||
group.addOption
|
|
||||||
(OptionBuilder
|
|
||||||
.hasArg()
|
|
||||||
.withArgName("PARAMETER")
|
|
||||||
.withLongOpt("value")
|
|
||||||
.withDescription("Prints a scalar value without the key")
|
|
||||||
.create("value"));
|
|
||||||
OPTIONS.addOptionGroup(group);
|
OPTIONS.addOptionGroup(group);
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Get() {
|
public Get() {
|
||||||
super("get", "Print one or more values from a CCM " +
|
super("get", "Print one or more values from a CCM "
|
||||||
"configuration database");
|
+ "configuration database");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean run(String[] args) {
|
public boolean run(String[] args) {
|
||||||
|
|
@ -107,10 +102,9 @@ class Get extends Command {
|
||||||
|
|
||||||
String[] names;
|
String[] names;
|
||||||
if (line.hasOption("value")) {
|
if (line.hasOption("value")) {
|
||||||
names = new String[] { line.getOptionValue("value") };
|
names = new String[]{line.getOptionValue("value")};
|
||||||
if (line.getArgs().length > 0) {
|
if (line.getArgs().length > 0) {
|
||||||
System.err.println
|
System.err.println("--value option does not allow parameters");
|
||||||
("--value option does not allow parameters");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -138,10 +132,12 @@ class Get extends Command {
|
||||||
parameters.add(param);
|
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();
|
Parameter param = (Parameter) it.next();
|
||||||
Object value = config.get(param);
|
Object value = config.get(param);
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
@ -167,19 +163,20 @@ class Get extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write(Properties properties, PrintStream out)
|
private void write(Properties properties, PrintStream out)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
properties.store(baos, null);
|
properties.store(baos, null);
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
new BufferedReader(new StringReader(baos.toString()));
|
new BufferedReader(new StringReader(baos.toString()));
|
||||||
while (true) {
|
while (true) {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
if (line == null) { return; }
|
if (line == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (line.trim().startsWith("#")) {
|
if (line.trim().startsWith("#")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
out.println(line);
|
out.println(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ public class HostInit {
|
||||||
private static final Options OPTIONS = new Options();
|
private static final Options OPTIONS = new Options();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
OPTIONS.addOption
|
OPTIONS.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.hasArg()
|
.hasArg()
|
||||||
|
|
@ -109,6 +110,7 @@ public class HostInit {
|
||||||
.withLongOpt("clean")
|
.withLongOpt("clean")
|
||||||
.withDescription("Remove the destination directory before copying files")
|
.withDescription("Remove the destination directory before copying files")
|
||||||
.create());
|
.create());
|
||||||
|
s_log.debug("Static initalizer finsished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void err(String msg) {
|
private static final void err(String msg) {
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PackageTool worker class, implements the "load" command.
|
* PackageTool worker class, implements the "load" command.
|
||||||
|
|
@ -85,9 +86,11 @@ import org.apache.commons.cli.PosixParser;
|
||||||
|
|
||||||
class Load extends Command {
|
class Load extends Command {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Load.class);
|
||||||
private static final Options OPTIONS = getOptions();
|
private static final Options OPTIONS = getOptions();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
OPTIONS.addOption
|
OPTIONS.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.hasArg(false)
|
.hasArg(false)
|
||||||
|
|
@ -146,6 +149,7 @@ class Load extends Command {
|
||||||
.withDescription("Log parameter values as key-value " +
|
.withDescription("Log parameter values as key-value " +
|
||||||
"pairs in FILE")
|
"pairs in FILE")
|
||||||
.create());*/
|
.create());*/
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set
|
* Set
|
||||||
|
|
@ -43,6 +44,7 @@ import org.apache.commons.cli.PosixParser;
|
||||||
|
|
||||||
class Set extends Command {
|
class Set extends Command {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Set.class);
|
||||||
public final static String versionId =
|
public final static String versionId =
|
||||||
"$Id: Set.java 736 2005-09-01 10:46:05Z sskracic $" +
|
"$Id: Set.java 736 2005-09-01 10:46:05Z sskracic $" +
|
||||||
" by $Author: sskracic $, " +
|
" by $Author: sskracic $, " +
|
||||||
|
|
@ -51,12 +53,14 @@ class Set extends Command {
|
||||||
private static final Options OPTIONS = getOptions();
|
private static final Options OPTIONS = getOptions();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
OPTIONS.addOption
|
OPTIONS.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.hasArg(false)
|
.hasArg(false)
|
||||||
.withLongOpt("interactive")
|
.withLongOpt("interactive")
|
||||||
.withDescription("Interactively edit configuration values")
|
.withDescription("Interactively edit configuration values")
|
||||||
.create());
|
.create());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set() {
|
public Set() {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload
|
* Unload
|
||||||
|
|
@ -39,6 +40,7 @@ import org.apache.commons.cli.PosixParser;
|
||||||
|
|
||||||
class Unload extends Command {
|
class Unload extends Command {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Unload.class);
|
||||||
public final static String versionId =
|
public final static String versionId =
|
||||||
"$Id: Unload.java 736 2005-09-01 10:46:05Z sskracic $" +
|
"$Id: Unload.java 736 2005-09-01 10:46:05Z sskracic $" +
|
||||||
" by $Author: sskracic $, " +
|
" by $Author: sskracic $, " +
|
||||||
|
|
@ -47,20 +49,24 @@ class Unload extends Command {
|
||||||
private static final Options OPTIONS = new Options();
|
private static final Options OPTIONS = new Options();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
OPTIONS.addOption
|
OPTIONS.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.hasArg(false)
|
.hasArg(false)
|
||||||
.withLongOpt("config")
|
.withLongOpt("config")
|
||||||
.withDescription("Unload configuration")
|
.withDescription("Unload configuration")
|
||||||
.create());
|
.create());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set EXCLUDE = new HashSet();
|
private static final Set EXCLUDE = new HashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
EXCLUDE.add("resin.conf");
|
EXCLUDE.add("resin.conf");
|
||||||
EXCLUDE.add("resin.pid");
|
EXCLUDE.add("resin.pid");
|
||||||
EXCLUDE.add("server.xml");
|
EXCLUDE.add("server.xml");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unload() {
|
public Unload() {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||||
*/
|
*/
|
||||||
class Upgrade extends Command {
|
class Upgrade extends Command {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Upgrade.class);
|
||||||
private static final Options s_options = getOptions();
|
private static final Options s_options = getOptions();
|
||||||
|
|
||||||
private String m_from;
|
private String m_from;
|
||||||
|
|
@ -59,6 +61,7 @@ class Upgrade extends Command {
|
||||||
private final List m_scripts;
|
private final List m_scripts;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_options.addOption
|
s_options.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.isRequired()
|
.isRequired()
|
||||||
|
|
@ -79,6 +82,7 @@ class Upgrade extends Command {
|
||||||
.withLongOpt("parameters")
|
.withLongOpt("parameters")
|
||||||
.withDescription("Parameters to pass to upgrade scripts")
|
.withDescription("Parameters to pass to upgrade scripts")
|
||||||
.create());
|
.create());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Upgrade() {
|
public Upgrade() {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,9 @@ public class SessionManager {
|
||||||
|
|
||||||
private static Set s_beforeFlushProcManagers = new HashSet();
|
private static Set s_beforeFlushProcManagers = new HashSet();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
addBeforeFlushProcManager(Versions.EPM);
|
addBeforeFlushProcManager(Versions.EPM);
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
private static Set s_afterFlushProcManagers = new HashSet();
|
private static Set s_afterFlushProcManagers = new HashSet();
|
||||||
private static Map s_configurations = new HashMap();
|
private static Map s_configurations = new HashMap();
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ public class PDL {
|
||||||
new CommandLine(PDL.class.getName(), null);
|
new CommandLine(PDL.class.getName(), null);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
CMD.addSwitch(new PathSwitch(
|
CMD.addSwitch(new PathSwitch(
|
||||||
"-library-path",
|
"-library-path",
|
||||||
"PDL files appearing in this path will be searched " +
|
"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",
|
CMD.addSwitch(new BooleanSwitch("-quiet", "sets logging to ERROR and does not complain if no PDL files are found",
|
||||||
Boolean.FALSE));
|
Boolean.FALSE));
|
||||||
CMD.addSwitch(new StringSwitch("-testddl", "no clue", null));
|
CMD.addSwitch(new StringSwitch("-testddl", "no clue", null));
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,12 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class SQLRegressionGenerator {
|
public class SQLRegressionGenerator {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SQLRegressionGenerator.class);
|
||||||
static final CommandLine CMD =
|
static final CommandLine CMD =
|
||||||
new CommandLine(PDL.class.getName(), null);
|
new CommandLine(PDL.class.getName(), null);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
CMD.addSwitch(new PathSwitch(
|
CMD.addSwitch(new PathSwitch(
|
||||||
"-path",
|
"-path",
|
||||||
"PDL files appearing in this path will be processed",
|
"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",
|
CMD.addSwitch(new BooleanSwitch("-quiet", "sets logging to ERROR and does not complain if no PDL files are found",
|
||||||
Boolean.FALSE));
|
Boolean.FALSE));
|
||||||
CMD.addSwitch(new StringSwitch("-database", "target database", null));
|
CMD.addSwitch(new StringSwitch("-database", "target database", null));
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple Profiler.
|
* Simple Profiler.
|
||||||
|
|
@ -20,16 +21,19 @@ import java.util.Set;
|
||||||
* @author Alan Pevec
|
* @author Alan Pevec
|
||||||
*/
|
*/
|
||||||
public class Profiler {
|
public class Profiler {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Profiler.class);
|
||||||
private static final Set enabledOperations = new HashSet();
|
private static final Set enabledOperations = new HashSet();
|
||||||
// TODO add a configuration page under Developer Support
|
// TODO add a configuration page under Developer Support
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
enabledOperations.add("APP");
|
enabledOperations.add("APP");
|
||||||
enabledOperations.add("FILT");
|
enabledOperations.add("FILT");
|
||||||
enabledOperations.add("CMS");
|
enabledOperations.add("CMS");
|
||||||
enabledOperations.add("XML");
|
enabledOperations.add("XML");
|
||||||
enabledOperations.add("DB");
|
enabledOperations.add("DB");
|
||||||
enabledOperations.add("XSLT");
|
enabledOperations.add("XSLT");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProfilerConfig config = null;
|
private static ProfilerConfig config = null;
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,11 @@ public class QueryEngineRegistry {
|
||||||
Logger.getLogger(QueryEngineRegistry.class);
|
Logger.getLogger(QueryEngineRegistry.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
registerEngine(IndexerType.NOOP,
|
registerEngine(IndexerType.NOOP,
|
||||||
new FilterType[] {},
|
new FilterType[] {},
|
||||||
new NoopQueryEngine());
|
new NoopQueryEngine());
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.kernel.Party;
|
import com.arsdigita.kernel.Party;
|
||||||
import com.arsdigita.kernel.User;
|
import com.arsdigita.kernel.User;
|
||||||
import com.arsdigita.kernel.PersonName;
|
import com.arsdigita.kernel.PersonName;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an advanced servlet error report generator
|
* This is an advanced servlet error report generator
|
||||||
|
|
@ -44,6 +45,8 @@ import com.arsdigita.kernel.PersonName;
|
||||||
* (guru meditation) code.
|
* (guru meditation) code.
|
||||||
*/
|
*/
|
||||||
public class ServletErrorReport extends ErrorReport {
|
public class ServletErrorReport extends ErrorReport {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ServletErrorReport.class);
|
||||||
/**
|
/**
|
||||||
* The name of the Servlet request attribute which will
|
* The name of the Servlet request attribute which will
|
||||||
* contain the guru meditation code
|
* contain the guru meditation code
|
||||||
|
|
@ -52,16 +55,18 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
public static final String GURU_ERROR_REPORT = "guruErrorReport";
|
public static final String GURU_ERROR_REPORT = "guruErrorReport";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Exceptions.registerUnwrapper(
|
Exceptions.registerUnwrapper(
|
||||||
ServletException.class,
|
ServletException.class,
|
||||||
new ExceptionUnwrapper() {
|
new ExceptionUnwrapper() {
|
||||||
public Throwable unwrap(Throwable t) {
|
|
||||||
ServletException ex = (ServletException)t;
|
|
||||||
return ex.getRootCause();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public Throwable unwrap(Throwable t) {
|
||||||
|
ServletException ex = (ServletException) t;
|
||||||
|
return ex.getRootCause();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
|
}
|
||||||
private HttpServletRequest m_request;
|
private HttpServletRequest m_request;
|
||||||
private HttpServletResponse m_response;
|
private HttpServletResponse m_response;
|
||||||
|
|
||||||
|
|
@ -72,7 +77,7 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
|
|
||||||
m_request = request;
|
m_request = request;
|
||||||
m_response = response;
|
m_response = response;
|
||||||
|
|
||||||
// Take great care such that if something goes
|
// Take great care such that if something goes
|
||||||
// wrong while creating the error report, we don't
|
// wrong while creating the error report, we don't
|
||||||
// let the new exception propagate thus loosing the
|
// let the new exception propagate thus loosing the
|
||||||
|
|
@ -110,11 +115,11 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
private void addRequest() {
|
private void addRequest() {
|
||||||
ArrayList lines = new ArrayList();
|
ArrayList lines = new ArrayList();
|
||||||
|
|
||||||
lines.add("Context path: "+ m_request.getContextPath());
|
lines.add("Context path: " + m_request.getContextPath());
|
||||||
lines.add("Request URI: "+ m_request.getRequestURI());
|
lines.add("Request URI: " + m_request.getRequestURI());
|
||||||
lines.add("Query string: "+ m_request.getQueryString());
|
lines.add("Query string: " + m_request.getQueryString());
|
||||||
lines.add("Method: "+ m_request.getMethod());
|
lines.add("Method: " + m_request.getMethod());
|
||||||
lines.add("Remote user: "+ m_request.getRemoteUser());
|
lines.add("Remote user: " + m_request.getRemoteUser());
|
||||||
|
|
||||||
addSection("Request summary", lines);
|
addSection("Request summary", lines);
|
||||||
}
|
}
|
||||||
|
|
@ -127,9 +132,9 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
|
|
||||||
String lines[] = new String[cookies.length];
|
String lines[] = new String[cookies.length];
|
||||||
|
|
||||||
for (int i = 0 ; i < lines.length ;i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
lines[i] = cookies[i].getName() + ": " + cookies[i].getValue() +
|
lines[i] = cookies[i].getName() + ": " + cookies[i].getValue()
|
||||||
" (expires: " + cookies[i].getMaxAge() + ")";
|
+ " (expires: " + cookies[i].getMaxAge() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection("Cookies", lines);
|
addSection("Cookies", lines);
|
||||||
|
|
@ -139,14 +144,14 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
User user;
|
User user;
|
||||||
Party party = Kernel.getContext().getParty();
|
Party party = Kernel.getContext().getParty();
|
||||||
|
|
||||||
if ( party == null ) {
|
if (party == null) {
|
||||||
addSection("CCM User", "Party not logged in");
|
addSection("CCM User", "Party not logged in");
|
||||||
} else {
|
} else {
|
||||||
String lines[] = new String[5];
|
String lines[] = new String[5];
|
||||||
lines[0] = "Party ID: " + party.getID();
|
lines[0] = "Party ID: " + party.getID();
|
||||||
lines[1] = "Email address: " + party.getPrimaryEmail().toString();
|
lines[1] = "Email address: " + party.getPrimaryEmail().toString();
|
||||||
|
|
||||||
if ( party instanceof User ) {
|
if (party instanceof User) {
|
||||||
user = (User) party;
|
user = (User) party;
|
||||||
|
|
||||||
PersonName name = null;
|
PersonName name = null;
|
||||||
|
|
@ -186,9 +191,9 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
|
|
||||||
Enumeration props = m_request.getAttributeNames();
|
Enumeration props = m_request.getAttributeNames();
|
||||||
while (props.hasMoreElements()) {
|
while (props.hasMoreElements()) {
|
||||||
String key = (String)props.nextElement();
|
String key = (String) props.nextElement();
|
||||||
if (GURU_ERROR_REPORT.equals(key) ||
|
if (GURU_ERROR_REPORT.equals(key)
|
||||||
GURU_MEDITATION_CODE.equals(key)) {
|
|| GURU_MEDITATION_CODE.equals(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object value = m_request.getAttribute(key);
|
Object value = m_request.getAttribute(key);
|
||||||
|
|
@ -203,7 +208,7 @@ public class ServletErrorReport extends ErrorReport {
|
||||||
|
|
||||||
Enumeration props = m_request.getHeaderNames();
|
Enumeration props = m_request.getHeaderNames();
|
||||||
while (props.hasMoreElements()) {
|
while (props.hasMoreElements()) {
|
||||||
String key = (String)props.nextElement();
|
String key = (String) props.nextElement();
|
||||||
String value = m_request.getHeader(key);
|
String value = m_request.getHeader(key);
|
||||||
data.add(key + ": " + value);
|
data.add(key + ": " + value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ public class ApplyTemplates {
|
||||||
"-loop [count] -log [loglevel] -verbose -warmup [count] Stylesheet Input Output "
|
"-loop [count] -log [loglevel] -verbose -warmup [count] Stylesheet Input Output "
|
||||||
);
|
);
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_cmd.addSwitch(new StringSwitch(OPT_LOG,
|
s_cmd.addSwitch(new StringSwitch(OPT_LOG,
|
||||||
"Log4j debug level",
|
"Log4j debug level",
|
||||||
"warn"));
|
"warn"));
|
||||||
|
|
@ -69,6 +70,7 @@ public class ApplyTemplates {
|
||||||
s_cmd.addSwitch(new BooleanSwitch(OPT_VERBOSE,
|
s_cmd.addSwitch(new BooleanSwitch(OPT_VERBOSE,
|
||||||
"Display progress",
|
"Display progress",
|
||||||
Boolean.FALSE));
|
Boolean.FALSE));
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static void main(String[] args) {
|
public final static void main(String[] args) {
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
registerPatternGenerator
|
registerPatternGenerator
|
||||||
("locale", new LocalePatternGenerator());
|
("locale", new LocalePatternGenerator());
|
||||||
registerPatternGenerator
|
registerPatternGenerator
|
||||||
|
|
@ -148,6 +149,7 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
||||||
("webapps", new WebAppPatternGenerator());
|
("webapps", new WebAppPatternGenerator());
|
||||||
registerPatternGenerator
|
registerPatternGenerator
|
||||||
("host", new HostPatternGenerator());
|
("host", new HostPatternGenerator());
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String m_path = null;
|
private String m_path = null;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.templating;
|
package com.arsdigita.templating;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Bebop;
|
import com.arsdigita.bebop.Bebop;
|
||||||
import com.arsdigita.caching.CacheTable;
|
import com.arsdigita.caching.CacheTable;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
|
|
@ -58,49 +58,47 @@ import org.apache.log4j.Logger;
|
||||||
public class Templating {
|
public class Templating {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(Templating.class);
|
private static final Logger s_log = Logger.getLogger(Templating.class);
|
||||||
|
|
||||||
// just a tag to assure an implementation exists
|
// just a tag to assure an implementation exists
|
||||||
// public static final Class DEFAULT_PRESENTATION_MANAGER
|
// public static final Class DEFAULT_PRESENTATION_MANAGER
|
||||||
// = SimplePresentationManager.class;
|
// = SimplePresentationManager.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the name of the attribute that is set in the request whose
|
* This is the name of the attribute that is set in the request whose
|
||||||
* value, if present, is a collection of TransformerExceptions that
|
* value, if present, is a collection of TransformerExceptions that
|
||||||
* can be used to produce a "pretty" error.
|
* can be used to produce a "pretty" error.
|
||||||
*/
|
*/
|
||||||
public static final String FANCY_ERROR_COLLECTION = "fancyErrorCollection";
|
public static final String FANCY_ERROR_COLLECTION = "fancyErrorCollection";
|
||||||
|
|
||||||
// this was instantiated with hardcoded values, not anymore
|
// this was instantiated with hardcoded values, not anymore
|
||||||
private static CacheTable s_templates = null;
|
private static CacheTable s_templates = null;
|
||||||
private static final TemplatingConfig s_config = new TemplatingConfig();
|
private static final TemplatingConfig s_config = new TemplatingConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load("ccm-core/templating.properties");
|
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
|
Exceptions.registerUnwrapper(
|
||||||
static {
|
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,
|
// default cache size used to be 50, which is too high I reckon,
|
||||||
// each template can eat up to 4 megs
|
// each template can eat up to 4 megs
|
||||||
Integer setting = s_config.getCacheSize();
|
Integer setting = s_config.getCacheSize();
|
||||||
int cacheSize = (setting == null ? 10 : setting.intValue());
|
int cacheSize = (setting == null ? 10 : setting.intValue());
|
||||||
|
|
||||||
setting = s_config.getCacheAge();
|
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 = new CacheTable("templating", cacheSize, cacheAge);
|
||||||
s_templates.setPurgeAllowed(true);
|
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) {
|
public static synchronized XSLTemplate getTemplate(final URL source) {
|
||||||
return getTemplate(source, false, true);
|
return getTemplate(source, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an XSL template. If the template is already loaded in the
|
* Retrieves an XSL template. If the template is already loaded in the
|
||||||
* cache, it will be returned. If the template has been modified since
|
* cache, it will be returned. If the template has been modified since
|
||||||
|
|
@ -184,8 +182,8 @@ public class Templating {
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("The template for URL " + source + " is not " +
|
s_log.info("The template for URL " + source + " is not "
|
||||||
"cached; creating and caching it now");
|
+ "cached; creating and caching it now");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fancyErrors) {
|
if (fancyErrors) {
|
||||||
|
|
@ -207,8 +205,8 @@ public class Templating {
|
||||||
// probably on UtilConfig.
|
// probably on UtilConfig.
|
||||||
|
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("Template " + template + " has been modified; " +
|
s_log.info("Template " + template + " has been modified; "
|
||||||
"recreating it from scratch");
|
+ "recreating it from scratch");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fancyErrors) {
|
if (fancyErrors) {
|
||||||
|
|
@ -304,11 +302,11 @@ public class Templating {
|
||||||
root.addAttribute("version", "1.0");
|
root.addAttribute("version", "1.0");
|
||||||
|
|
||||||
while (paths.hasNext()) {
|
while (paths.hasNext()) {
|
||||||
URL path = (URL)paths.next();
|
URL path = (URL) paths.next();
|
||||||
|
|
||||||
Element imp = root.newChildElement(
|
Element imp = root.newChildElement(
|
||||||
"xsl:import",
|
"xsl:import",
|
||||||
"http://www.w3.org/1999/XSL/Transform");
|
"http://www.w3.org/1999/XSL/Transform");
|
||||||
imp.addAttribute("href", path.toString());
|
imp.addAttribute("href", path.toString());
|
||||||
|
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
|
|
@ -338,9 +336,12 @@ public class Templating {
|
||||||
HttpHost self = Web.getConfig().getHost();
|
HttpHost self = Web.getConfig().getHost();
|
||||||
|
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
if (self.getName().equals(url.getHost()) &&
|
if (self.getName().equals(url.getHost()) && ((self.getPort() == url.
|
||||||
((self.getPort() == url.getPort()) ||
|
getPort()) || (url.getPort()
|
||||||
(url.getPort() == -1 && self.getPort() == 80))) {
|
== -1
|
||||||
|
&& self.
|
||||||
|
getPort()
|
||||||
|
== 80))) {
|
||||||
|
|
||||||
if (path.startsWith("/resource")) {
|
if (path.startsWith("/resource")) {
|
||||||
// A virtual path to the servlet
|
// A virtual path to the servlet
|
||||||
|
|
@ -352,14 +353,15 @@ public class Templating {
|
||||||
return newURL;
|
return newURL;
|
||||||
} else {
|
} else {
|
||||||
// A real path to disk
|
// A real path to disk
|
||||||
final String filename = Web.getServletContext().getRealPath(path);
|
final String filename =
|
||||||
|
Web.getServletContext().getRealPath(path);
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
URL newURL = file.toURL();
|
URL newURL = file.toURL();
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Transforming resource " +
|
s_log.debug("Transforming resource " + url + " to "
|
||||||
url + " to " + newURL);
|
+ newURL);
|
||||||
}
|
}
|
||||||
return newURL;
|
return newURL;
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
|
|
@ -367,7 +369,8 @@ public class Templating {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (s_log.isDebugEnabled()) {
|
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 {
|
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;
|
private ArrayList m_errors;
|
||||||
|
|
||||||
LoggingErrorListener() {
|
LoggingErrorListener() {
|
||||||
m_errors = new ArrayList();
|
m_errors = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection getErrors() {
|
public Collection getErrors() {
|
||||||
return m_errors;
|
return m_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warning(TransformerException e) throws TransformerException {
|
public void warning(TransformerException e) throws TransformerException {
|
||||||
log(Level.WARN, e);
|
log(Level.WARN, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(TransformerException e) throws TransformerException {
|
public void error(TransformerException e) throws TransformerException {
|
||||||
log(Level.ERROR, e);
|
log(Level.ERROR, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fatalError(TransformerException e) throws TransformerException {
|
public void fatalError(TransformerException e) throws TransformerException {
|
||||||
log(Level.FATAL, e);
|
log(Level.FATAL, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log(Level level, TransformerException ex) {
|
private void log(Level level, TransformerException ex) {
|
||||||
s_log.log(level, "Transformer " + level + ": " +
|
s_log.log(level, "Transformer " + level + ": "
|
||||||
ex.getLocationAsString() + ": " + ex.getMessage(),
|
+ ex.getLocationAsString() + ": " + ex.getMessage(),
|
||||||
ex);
|
ex);
|
||||||
m_errors.add(ex);
|
m_errors.add(ex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,10 @@ public class XHTMLParser implements HTMLParser {
|
||||||
private final static Set s_emptyTags = new HashSet();
|
private final static Set s_emptyTags = new HashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer is starting...");
|
||||||
s_emptyTags.add("br");
|
s_emptyTags.add("br");
|
||||||
s_emptyTags.add("hr");
|
s_emptyTags.add("hr");
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set m_tags;
|
private final Set m_tags;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -40,15 +41,18 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
*/
|
*/
|
||||||
public class CharsetEncodingProvider implements ParameterProvider {
|
public class CharsetEncodingProvider implements ParameterProvider {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(CharsetEncodingProvider.class);
|
||||||
private static StringParameter s_encodingParam =
|
private static StringParameter s_encodingParam =
|
||||||
new StringParameter(Globalization.ENCODING_PARAM_NAME);
|
new StringParameter(Globalization.ENCODING_PARAM_NAME);
|
||||||
|
|
||||||
private static Set s_models = new HashSet();
|
private static Set s_models = new HashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_encodingParam.setDefaultValue(Globalization.DEFAULT_ENCODING);
|
s_encodingParam.setDefaultValue(Globalization.DEFAULT_ENCODING);
|
||||||
s_encodingParam.setDefaultOverridesNull(true);
|
s_encodingParam.setDefaultOverridesNull(true);
|
||||||
s_models.add(s_encodingParam);
|
s_models.add(s_encodingParam);
|
||||||
|
logger.debug("Static initalizer finished...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set getModels() {
|
public Set getModels() {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.text.NumberFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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 $
|
* @version $Revision: #4 $ $DateTime: 2004/08/16 18:10:38 $
|
||||||
**/
|
**/
|
||||||
public final class ConcurrentDict {
|
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
|
// We may want to make it possible to specify the bucket size at
|
||||||
// construction time. Hardcoding it is good enough for now.
|
// construction time. Hardcoding it is good enough for now.
|
||||||
private static final int N_BUCKETS = 64;
|
private static final int N_BUCKETS = 64;
|
||||||
|
|
@ -59,9 +61,11 @@ public final class ConcurrentDict {
|
||||||
private static final Map[] BUCKETS = new Map[N_BUCKETS];
|
private static final Map[] BUCKETS = new Map[N_BUCKETS];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
for (int ii=0; ii<N_BUCKETS; ii++) {
|
for (int ii=0; ii<N_BUCKETS; ii++) {
|
||||||
BUCKETS[ii] = new HashMap();
|
BUCKETS[ii] = new HashMap();
|
||||||
}
|
}
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final EntrySupplier m_supplier;
|
private final EntrySupplier m_supplier;
|
||||||
|
|
|
||||||
|
|
@ -249,12 +249,14 @@ public class StringUtils {
|
||||||
|
|
||||||
private static Map s_entities = new HashMap();
|
private static Map s_entities = new HashMap();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_entities.put("fraction12", "½");
|
s_entities.put("fraction12", "½");
|
||||||
s_entities.put("fraction14", "¼");
|
s_entities.put("fraction14", "¼");
|
||||||
s_entities.put("fraction34", "¾");
|
s_entities.put("fraction34", "¾");
|
||||||
s_entities.put("copyright", "©");
|
s_entities.put("copyright", "©");
|
||||||
s_entities.put("registered", "®");
|
s_entities.put("registered", "®");
|
||||||
s_entities.put("trademark", "<sup>TM</sup>");
|
s_entities.put("trademark", "<sup>TM</sup>");
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String smartTextInline(String s) {
|
private static String smartTextInline(String s) {
|
||||||
|
|
|
||||||
|
|
@ -42,17 +42,23 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class UncheckedWrapperException extends RuntimeException {
|
public class UncheckedWrapperException extends RuntimeException {
|
||||||
|
|
||||||
static {
|
private static final Logger logger = Logger.getLogger(
|
||||||
Exceptions.registerUnwrapper(
|
UncheckedWrapperException.class);
|
||||||
UncheckedWrapperException.class,
|
|
||||||
new ExceptionUnwrapper() {
|
|
||||||
public Throwable unwrap(Throwable t) {
|
|
||||||
UncheckedWrapperException ex = (UncheckedWrapperException)t;
|
|
||||||
return ex.getRootCause();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
Throwable m_rootCause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,7 +68,7 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
* exception that doesn't wrap anything, this is needed so that it
|
* exception that doesn't wrap anything, this is needed so that it
|
||||||
* can be used as a direct replacement for RuntimeException.
|
* can be used as a direct replacement for RuntimeException.
|
||||||
*/
|
*/
|
||||||
public UncheckedWrapperException (String msg) {
|
public UncheckedWrapperException(String msg) {
|
||||||
this(msg, null);
|
this(msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +80,7 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
* Constructor which takes a root cause
|
* Constructor which takes a root cause
|
||||||
* that this exception will be wrapping.
|
* that this exception will be wrapping.
|
||||||
*/
|
*/
|
||||||
public UncheckedWrapperException (Throwable rootCause) {
|
public UncheckedWrapperException(Throwable rootCause) {
|
||||||
this(null, rootCause);
|
this(null, rootCause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +90,7 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
* should be something different than rootCause.getMessage()
|
* should be something different than rootCause.getMessage()
|
||||||
* would normally provide.
|
* would normally provide.
|
||||||
*/
|
*/
|
||||||
public UncheckedWrapperException (String s, Throwable rootCause) {
|
public UncheckedWrapperException(String s, Throwable rootCause) {
|
||||||
super(s);
|
super(s);
|
||||||
this.m_rootCause = rootCause;
|
this.m_rootCause = rootCause;
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +104,9 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
*
|
*
|
||||||
* @throws UncheckedWrapperException
|
* @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);
|
Logger log = Logger.getLogger(source);
|
||||||
log.error(msg, rootCause);
|
log.error(msg, rootCause);
|
||||||
|
|
||||||
|
|
@ -121,7 +129,6 @@ public class UncheckedWrapperException extends RuntimeException {
|
||||||
|
|
||||||
// All further methods override normal throwable behavior to
|
// All further methods override normal throwable behavior to
|
||||||
// combine information w/ the root cause.
|
// combine information w/ the root cause.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string representing this exception and 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() {
|
public String getMessage() {
|
||||||
if (m_rootCause != null) {
|
if (m_rootCause != null) {
|
||||||
return super.getMessage() + " (root cause: " + m_rootCause.getMessage() + ")";
|
return super.getMessage() + " (root cause: " + m_rootCause.
|
||||||
|
getMessage() + ")";
|
||||||
} else {
|
} else {
|
||||||
return super.getMessage();
|
return super.getMessage();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,10 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class WrappedError extends Error {
|
public class WrappedError extends Error {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(WrappedError.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Exceptions.registerUnwrapper(
|
Exceptions.registerUnwrapper(
|
||||||
WrappedError.class,
|
WrappedError.class,
|
||||||
new ExceptionUnwrapper() {
|
new ExceptionUnwrapper() {
|
||||||
|
|
@ -44,6 +47,7 @@ public class WrappedError extends Error {
|
||||||
return ex.getRootCause();
|
return ex.getRootCause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Throwable m_rootCause;
|
Throwable m_rootCause;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package com.arsdigita.util.parameter;
|
package com.arsdigita.util.parameter;
|
||||||
|
|
||||||
import org.apache.commons.beanutils.converters.ClassConverter;
|
import org.apache.commons.beanutils.converters.ClassConverter;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A parameter representing a Java <code>Class</code>.
|
* A parameter representing a Java <code>Class</code>.
|
||||||
|
|
@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.ClassConverter;
|
||||||
*/
|
*/
|
||||||
public class ClassParameter extends AbstractParameter {
|
public class ClassParameter extends AbstractParameter {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ClassParameter.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Converters.set(Class.class, new ClassConverter());
|
Converters.set(Class.class, new ClassConverter());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassParameter(final String name) {
|
public ClassParameter(final String name) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package com.arsdigita.util.parameter;
|
package com.arsdigita.util.parameter;
|
||||||
|
|
||||||
import org.apache.commons.beanutils.converters.IntegerConverter;
|
import org.apache.commons.beanutils.converters.IntegerConverter;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A parameter representing a Java <code>Integer</code>.
|
* A parameter representing a Java <code>Integer</code>.
|
||||||
|
|
@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.IntegerConverter;
|
||||||
*/
|
*/
|
||||||
public class IntegerParameter extends AbstractParameter {
|
public class IntegerParameter extends AbstractParameter {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(IntegerParameter.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Converters.set(Integer.class, new IntegerConverter());
|
Converters.set(Integer.class, new IntegerConverter());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntegerParameter(final String name) {
|
public IntegerParameter(final String name) {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ final class ParameterPrinter {
|
||||||
private static final Options OPTIONS = new Options();
|
private static final Options OPTIONS = new Options();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
OPTIONS.addOption
|
OPTIONS.addOption
|
||||||
(OptionBuilder
|
(OptionBuilder
|
||||||
.hasArg(false)
|
.hasArg(false)
|
||||||
|
|
@ -77,6 +78,7 @@ final class ParameterPrinter {
|
||||||
.withArgName("FILE")
|
.withArgName("FILE")
|
||||||
.withDescription("Use list of additional Config classes from FILE")
|
.withDescription("Use list of additional Config classes from FILE")
|
||||||
.create());
|
.create());
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeXML(final PrintWriter out) {
|
private static void writeXML(final PrintWriter out) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package com.arsdigita.util.parameter;
|
package com.arsdigita.util.parameter;
|
||||||
|
|
||||||
import org.apache.commons.beanutils.converters.StringConverter;
|
import org.apache.commons.beanutils.converters.StringConverter;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A parameter representing a Java <code>String</code>.
|
* A parameter representing a Java <code>String</code>.
|
||||||
|
|
@ -32,8 +33,12 @@ import org.apache.commons.beanutils.converters.StringConverter;
|
||||||
*/
|
*/
|
||||||
public class StringParameter extends AbstractParameter {
|
public class StringParameter extends AbstractParameter {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(StringParameter.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
Converters.set(String.class, new StringConverter());
|
Converters.set(String.class, new StringConverter());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringParameter(final String name,
|
public StringParameter(final String name,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,9 @@ final class Adapter {
|
||||||
|
|
||||||
private static final Map s_converters = new HashMap();
|
private static final Map s_converters = new HashMap();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
initializeAdapters();
|
initializeAdapters();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
private Adapter() {}
|
private Adapter() {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import java.io.PrintWriter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
// new versioning
|
// new versioning
|
||||||
|
|
||||||
|
|
@ -206,6 +207,8 @@ final class DevSupport {
|
||||||
|
|
||||||
private static class DependenceFormatter implements GraphFormatter {
|
private static class DependenceFormatter implements GraphFormatter {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(DependenceFormatter.class);
|
||||||
|
|
||||||
private static final String GRAPH_ATTRS =
|
private static final String GRAPH_ATTRS =
|
||||||
GRAPH_ATTRS_HEADER +
|
GRAPH_ATTRS_HEADER +
|
||||||
" edge[style=invis];\n" +
|
" edge[style=invis];\n" +
|
||||||
|
|
@ -229,6 +232,7 @@ final class DevSupport {
|
||||||
private static final Map COLORS = new HashMap();
|
private static final Map COLORS = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
COLORS.put(NodeType.VERSIONED_TYPE,
|
COLORS.put(NodeType.VERSIONED_TYPE,
|
||||||
"[fillcolor=Tomato,comment=\"versioned type\"]");
|
"[fillcolor=Tomato,comment=\"versioned type\"]");
|
||||||
COLORS.put(NodeType.COVERSIONED_TYPE,
|
COLORS.put(NodeType.COVERSIONED_TYPE,
|
||||||
|
|
@ -236,6 +240,7 @@ final class DevSupport {
|
||||||
COLORS.put(NodeType.RECOVERABLE,
|
COLORS.put(NodeType.RECOVERABLE,
|
||||||
"[fillcolor=LemonChiffon,comment=recoverable]");
|
"[fillcolor=LemonChiffon,comment=recoverable]");
|
||||||
COLORS.put(NodeType.UNREACHABLE, "[comment=unreachable]");
|
COLORS.put(NodeType.UNREACHABLE, "[comment=unreachable]");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String graphAttributes(Graph graph) {
|
public String graphAttributes(Graph graph) {
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,13 @@ import java.io.UnsupportedEncodingException;
|
||||||
* @since ACS 4.5a
|
* @since ACS 4.5a
|
||||||
*/
|
*/
|
||||||
public class Document {
|
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 =
|
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
|
* this is the identity XSL stylesheet. We need to provide the
|
||||||
* identity transform as XSL explicitly because the default
|
* identity transform as XSL explicitly because the default
|
||||||
|
|
@ -71,43 +70,41 @@ public class Document {
|
||||||
// to the output doc with <xsl:copy>
|
// to the output doc with <xsl:copy>
|
||||||
/*
|
/*
|
||||||
private final static String identityXSL =
|
private final static String identityXSL =
|
||||||
"<xsl:stylesheet version=\"1.0\""
|
"<xsl:stylesheet version=\"1.0\""
|
||||||
+ " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
|
+ " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
|
||||||
+ "<xsl:output method=\"xml\"/>\n"
|
+ "<xsl:output method=\"xml\"/>\n"
|
||||||
+ "<xsl:template match=\"*|@*|text()\">\n"
|
+ "<xsl:template match=\"*|@*|text()\">\n"
|
||||||
+ " <xsl:copy><xsl:apply-templates select=\"node()|@*\"/></xsl:copy>"
|
+ " <xsl:copy><xsl:apply-templates select=\"node()|@*\"/></xsl:copy>"
|
||||||
+ "\n</xsl:template>\n"
|
+ "\n</xsl:template>\n"
|
||||||
+ "<xsl:template match=\"bebop:structure\" "
|
+ "<xsl:template match=\"bebop:structure\" "
|
||||||
+ " xmlns:bebop=\"http://www.arsdigita.com/bebop/1.0\">\n"
|
+ " xmlns:bebop=\"http://www.arsdigita.com/bebop/1.0\">\n"
|
||||||
+ "</xsl:template>\n"
|
+ "</xsl:template>\n"
|
||||||
+ "</xsl:stylesheet>";
|
+ "</xsl:stylesheet>";
|
||||||
*/
|
*/
|
||||||
// Explicitly create elements & attributes to avoid namespace
|
// Explicitly create elements & attributes to avoid namespace
|
||||||
// problems
|
// problems
|
||||||
private final static String identityXSL =
|
private final static String identityXSL =
|
||||||
"<xsl:stylesheet version=\"1.0\""
|
"<xsl:stylesheet version=\"1.0\""
|
||||||
+ " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
|
+ " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
|
||||||
+ "<xsl:output method=\"xml\"/>\n"
|
+ "<xsl:output method=\"xml\"/>\n"
|
||||||
+ "<xsl:template match=\"text()|comment()|processing-instruction()\">\n"
|
+ "<xsl:template match=\"text()|comment()|processing-instruction()\">\n"
|
||||||
+ " <xsl:copy/>\n"
|
+ " <xsl:copy/>\n"
|
||||||
+ "</xsl:template>\n"
|
+ "</xsl:template>\n"
|
||||||
+ "<xsl:template match=\"*\">\n"
|
+ "<xsl:template match=\"*\">\n"
|
||||||
+ " <xsl:element name=\"{name()}\" namespace=\"{namespace-uri()}\"><xsl:apply-templates select=\"node()|@*\"/></xsl:element>\n"
|
+ " <xsl:element name=\"{name()}\" namespace=\"{namespace-uri()}\"><xsl:apply-templates select=\"node()|@*\"/></xsl:element>\n"
|
||||||
+ "</xsl:template>\n"
|
+ "</xsl:template>\n"
|
||||||
+ "<xsl:template match=\"@*\">\n"
|
+ "<xsl:template match=\"@*\">\n"
|
||||||
+ " <xsl:attribute name=\"{name()}\" namespace=\"{namespace-uri()}\"><xsl:value-of select=\".\"/></xsl:attribute>\n"
|
+ " <xsl:attribute name=\"{name()}\" namespace=\"{namespace-uri()}\"><xsl:value-of select=\".\"/></xsl:attribute>\n"
|
||||||
+ "</xsl:template>\n"
|
+ "</xsl:template>\n"
|
||||||
+ "<xsl:template match=\"bebop:structure\" "
|
+ "<xsl:template match=\"bebop:structure\" "
|
||||||
+ " xmlns:bebop=\"http://www.arsdigita.com/bebop/1.0\">\n"
|
+ " xmlns:bebop=\"http://www.arsdigita.com/bebop/1.0\">\n"
|
||||||
+ "</xsl:template>\n"
|
+ "</xsl:template>\n"
|
||||||
+ "</xsl:stylesheet>";
|
+ "</xsl:stylesheet>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single <code>DocumentBuilderFactory</code> to use for
|
* A single <code>DocumentBuilderFactory</code> to use for
|
||||||
* creating Documents.
|
* creating Documents.
|
||||||
*/
|
*/
|
||||||
protected static DocumentBuilderFactory s_builder = null;
|
protected static DocumentBuilderFactory s_builder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single <code>DocumentBuilder</code> to use for
|
* A single <code>DocumentBuilder</code> to use for
|
||||||
* creating Documents.
|
* creating Documents.
|
||||||
|
|
@ -119,21 +116,23 @@ public class Document {
|
||||||
// instead to achieve independence from a JVM wide configuration.
|
// instead to achieve independence from a JVM wide configuration.
|
||||||
// Requires additional modifications in c.ad.util.xml.XML
|
// Requires additional modifications in c.ad.util.xml.XML
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_builder = DocumentBuilderFactory.newInstance();
|
s_builder = DocumentBuilderFactory.newInstance();
|
||||||
s_builder.setNamespaceAware(true);
|
s_builder.setNamespaceAware(true);
|
||||||
s_db = new ThreadLocal() {
|
s_db = new ThreadLocal() {
|
||||||
public Object initialValue() {
|
|
||||||
try {
|
public Object initialValue() {
|
||||||
return s_builder.newDocumentBuilder();
|
try {
|
||||||
} catch (ParserConfigurationException pce) {
|
return s_builder.newDocumentBuilder();
|
||||||
return null;
|
} catch (ParserConfigurationException pce) {
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
s_log.debug("Static initalized finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to build the DOM Documents that this class wraps */
|
/* Used to build the DOM Documents that this class wraps */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal DOM document being wrapped.
|
* The internal DOM document being wrapped.
|
||||||
*/
|
*/
|
||||||
|
|
@ -142,11 +141,11 @@ public class Document {
|
||||||
/**
|
/**
|
||||||
* Creates a new Document class with no root element.
|
* Creates a new Document class with no root element.
|
||||||
*/
|
*/
|
||||||
public Document( ) throws ParserConfigurationException {
|
public Document() throws ParserConfigurationException {
|
||||||
DocumentBuilder db = (DocumentBuilder)s_db.get();
|
DocumentBuilder db = (DocumentBuilder) s_db.get();
|
||||||
if (db == null) {
|
if (db == null) {
|
||||||
throw new ParserConfigurationException
|
throw new ParserConfigurationException(
|
||||||
("Unable to create a DocumentBuilder");
|
"Unable to create a DocumentBuilder");
|
||||||
}
|
}
|
||||||
m_document = db.newDocument();
|
m_document = db.newDocument();
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +157,7 @@ public class Document {
|
||||||
* @param doc the org.w3c.dom.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;
|
m_document = doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,11 +166,11 @@ public class Document {
|
||||||
*
|
*
|
||||||
* @param rootNode the element to use as the root node
|
* @param rootNode the element to use as the root node
|
||||||
*/
|
*/
|
||||||
public Document( Element rootNode ) throws ParserConfigurationException {
|
public Document(Element rootNode) throws ParserConfigurationException {
|
||||||
DocumentBuilder db = (DocumentBuilder)s_db.get();
|
DocumentBuilder db = (DocumentBuilder) s_db.get();
|
||||||
if (db == null) {
|
if (db == null) {
|
||||||
throw new ParserConfigurationException
|
throw new ParserConfigurationException(
|
||||||
("Unable to create a DocumentBuilder");
|
"Unable to create a DocumentBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_document = db.newDocument();
|
m_document = db.newDocument();
|
||||||
|
|
@ -183,24 +182,23 @@ public class Document {
|
||||||
* Creates a document from the passed in string that should
|
* Creates a document from the passed in string that should
|
||||||
* be properly formatted XML
|
* be properly formatted XML
|
||||||
*/
|
*/
|
||||||
public Document( String xmlString )
|
public Document(String xmlString)
|
||||||
throws ParserConfigurationException, org.xml.sax.SAXException {
|
throws ParserConfigurationException, org.xml.sax.SAXException {
|
||||||
this(new org.xml.sax.InputSource
|
this(new org.xml.sax.InputSource(new java.io.StringReader(xmlString)));
|
||||||
(new java.io.StringReader(xmlString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Document( byte[] xmlBytes )
|
public Document(byte[] xmlBytes)
|
||||||
throws ParserConfigurationException, org.xml.sax.SAXException {
|
throws ParserConfigurationException, org.xml.sax.SAXException {
|
||||||
this(new org.xml.sax.InputSource
|
this(new org.xml.sax.InputSource(new java.io.ByteArrayInputStream(
|
||||||
(new java.io.ByteArrayInputStream(xmlBytes)));
|
xmlBytes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Document(org.xml.sax.InputSource inputSource)
|
private Document(org.xml.sax.InputSource inputSource)
|
||||||
throws ParserConfigurationException, org.xml.sax.SAXException {
|
throws ParserConfigurationException, org.xml.sax.SAXException {
|
||||||
DocumentBuilder db = (DocumentBuilder)s_db.get();
|
DocumentBuilder db = (DocumentBuilder) s_db.get();
|
||||||
if (db == null) {
|
if (db == null) {
|
||||||
throw new ParserConfigurationException
|
throw new ParserConfigurationException(
|
||||||
("Unable to create a DocumentBuilder");
|
"Unable to create a DocumentBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
org.w3c.dom.Document domDoc;
|
org.w3c.dom.Document domDoc;
|
||||||
|
|
@ -218,7 +216,7 @@ public class Document {
|
||||||
* @param rootNode the element to use as the root node
|
* @param rootNode the element to use as the root node
|
||||||
* @return this document.
|
* @return this document.
|
||||||
*/
|
*/
|
||||||
public Document setRootElement( Element rootNode ) {
|
public Document setRootElement(Element rootNode) {
|
||||||
rootNode.importInto(m_document);
|
rootNode.importInto(m_document);
|
||||||
m_document.appendChild(rootNode.getInternalElement());
|
m_document.appendChild(rootNode.getInternalElement());
|
||||||
|
|
||||||
|
|
@ -236,7 +234,7 @@ public class Document {
|
||||||
* @param ns the element's namespace URI
|
* @param ns the element's namespace URI
|
||||||
* @return The newly created root element.
|
* @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);
|
org.w3c.dom.Element root = m_document.createElementNS(ns, elt);
|
||||||
m_document.appendChild(root);
|
m_document.appendChild(root);
|
||||||
Element wrapper = new Element();
|
Element wrapper = new Element();
|
||||||
|
|
@ -254,7 +252,7 @@ public class Document {
|
||||||
* @param elt the element name
|
* @param elt the element name
|
||||||
* @return The newly created root element.
|
* @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);
|
org.w3c.dom.Element root = m_document.createElement(elt);
|
||||||
m_document.appendChild(root);
|
m_document.appendChild(root);
|
||||||
Element wrapper = new Element();
|
Element wrapper = new Element();
|
||||||
|
|
@ -273,8 +271,6 @@ public class Document {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not a part of <code>org.jdom.Document</code>, this function returns
|
* Not a part of <code>org.jdom.Document</code>, this function returns
|
||||||
* the internal DOM representation of this document. This method should
|
* the internal DOM representation of this document. This method should
|
||||||
|
|
@ -283,7 +279,7 @@ public class Document {
|
||||||
*
|
*
|
||||||
* @return this document.
|
* @return this document.
|
||||||
*/
|
*/
|
||||||
public org.w3c.dom.Document getInternalDocument( ) {
|
public org.w3c.dom.Document getInternalDocument() {
|
||||||
return m_document;
|
return m_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,9 +302,9 @@ public class Document {
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
try {
|
try {
|
||||||
StreamSource identitySource =
|
StreamSource identitySource =
|
||||||
new StreamSource(new StringReader(identityXSL));
|
new StreamSource(new StringReader(identityXSL));
|
||||||
identity = TransformerFactory.newInstance()
|
identity = TransformerFactory.newInstance().newTransformer(
|
||||||
.newTransformer(identitySource);
|
identitySource);
|
||||||
identity.setOutputProperty("method", "xml");
|
identity.setOutputProperty("method", "xml");
|
||||||
identity.setOutputProperty("indent", (indent ? "yes" : "no"));
|
identity.setOutputProperty("indent", (indent ? "yes" : "no"));
|
||||||
identity.setOutputProperty("encoding", "UTF-8");
|
identity.setOutputProperty("encoding", "UTF-8");
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,9 @@ public class XML {
|
||||||
|
|
||||||
private static Map s_formatters = new HashMap();
|
private static Map s_formatters = new HashMap();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_formatters.put(Date.class, new DateTimeFormatter());
|
s_formatters.put(Date.class, new DateTimeFormatter());
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private XML() {}
|
private XML() {}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Column class is used to keep information about the physical schema in
|
* 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 $";
|
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.
|
* The name of this Column.
|
||||||
**/
|
**/
|
||||||
|
|
@ -353,6 +356,7 @@ public class Column extends Element {
|
||||||
private static final Map ORACLE = new HashMap();
|
private static final Map ORACLE = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
DEFAULT.put(new Integer(Types.ARRAY), "ARRAY");
|
DEFAULT.put(new Integer(Types.ARRAY), "ARRAY");
|
||||||
DEFAULT.put(new Integer(Types.BIGINT), "BIGINT");
|
DEFAULT.put(new Integer(Types.BIGINT), "BIGINT");
|
||||||
ORACLE.put(new Integer(Types.BIGINT), "integer");
|
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.TINYINT), "TINYINT");
|
||||||
DEFAULT.put(new Integer(Types.VARBINARY), "VARBINARY");
|
DEFAULT.put(new Integer(Types.VARBINARY), "VARBINARY");
|
||||||
DEFAULT.put(new Integer(Types.VARCHAR), "VARCHAR");
|
DEFAULT.put(new Integer(Types.VARCHAR), "VARCHAR");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getDatabaseType(int type) {
|
private static final String getDatabaseType(int type) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static
|
* Static
|
||||||
|
|
@ -44,6 +45,8 @@ import java.util.Map;
|
||||||
|
|
||||||
public class Static extends Expression {
|
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 $";
|
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;
|
private SQL m_sql;
|
||||||
|
|
@ -55,6 +58,7 @@ public class Static extends Expression {
|
||||||
|
|
||||||
private static final Collection s_functions = new HashSet();
|
private static final Collection s_functions = new HashSet();
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
String[] functions = {
|
String[] functions = {
|
||||||
/* sql standard functions supported by both oracle and postgres.
|
/* sql standard functions supported by both oracle and postgres.
|
||||||
* there is an added caveat that the function uses normal function
|
* 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++) {
|
for (int i = 0; i < functions.length; i++) {
|
||||||
s_functions.add(functions[i]);
|
s_functions.add(functions[i]);
|
||||||
}
|
}
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean isAllowedFunction(String s) {
|
private static final boolean isAllowedFunction(String s) {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import com.redhat.persistence.common.SQLParser;
|
||||||
import com.redhat.persistence.common.SQLToken;
|
import com.redhat.persistence.common.SQLToken;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQLSummary
|
* SQLSummary
|
||||||
|
|
@ -37,6 +38,8 @@ import java.util.HashMap;
|
||||||
|
|
||||||
class SQLSummary {
|
class SQLSummary {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SQLSummary.class);
|
||||||
|
|
||||||
private static final HashMap SUMMARIES = new HashMap();
|
private static final HashMap SUMMARIES = new HashMap();
|
||||||
|
|
||||||
public static SQLSummary get(String text) {
|
public static SQLSummary get(String text) {
|
||||||
|
|
@ -61,10 +64,12 @@ class SQLSummary {
|
||||||
private static final HashMap TYPES = new HashMap();
|
private static final HashMap TYPES = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
TYPES.put("select", new Integer(SELECT));
|
TYPES.put("select", new Integer(SELECT));
|
||||||
TYPES.put("insert into", new Integer(INSERT));
|
TYPES.put("insert into", new Integer(INSERT));
|
||||||
TYPES.put("update", new Integer(UPDATE));
|
TYPES.put("update", new Integer(UPDATE));
|
||||||
TYPES.put("delete from", new Integer(DELETE));
|
TYPES.put("delete from", new Integer(DELETE));
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int m_type;
|
private final int m_type;
|
||||||
|
|
|
||||||
|
|
@ -65,4 +65,122 @@ log4j.logger.com.arsdigita.packaging.Loader=INFO
|
||||||
#log4j.logger.com.arsdigita.london.importer=DEBUG
|
#log4j.logger.com.arsdigita.london.importer=DEBUG
|
||||||
#log4j.logger.com.arsdigita.london.terms.importer.TermItemBuilder=DEBUG
|
#log4j.logger.com.arsdigita.london.terms.importer.TermItemBuilder=DEBUG
|
||||||
#log4j.logger.com.arsdigita.categorization.Category=DEBUG
|
#log4j.logger.com.arsdigita.categorization.Category=DEBUG
|
||||||
log4j.logger.com.arsdigita.london.util.cmd.BulkPublish=DEBUG
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,11 +204,14 @@ public class CreateDocLinkSearchTable extends Table implements DMConstants{
|
||||||
*/
|
*/
|
||||||
private static class ActionCellRenderer implements TableCellRenderer {
|
private static class ActionCellRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(ActionCellRenderer.class);
|
||||||
private static ControlLink s_link;
|
private static ControlLink s_link;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_link = new ControlLink(new Label(DMConstants.FOLDER_NEW_CREATE_LINK));
|
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,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,14 @@ public class PDFConfig extends AbstractConfig {
|
||||||
private static final PDFConfig s_config = new PDFConfig();
|
private static final PDFConfig s_config = new PDFConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
try {
|
try {
|
||||||
s_config.load();
|
s_config.load();
|
||||||
} catch (java.lang.IllegalArgumentException ex) {
|
} catch (java.lang.IllegalArgumentException ex) {
|
||||||
s_log.info("Unable to load PDFConfig. This is not a problem " +
|
s_log.info("Unable to load PDFConfig. This is not a problem " +
|
||||||
"during ccm load, but is a problem at all other times");
|
"during ccm load, but is a problem at all other times");
|
||||||
}
|
}
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDFConfig() {
|
public PDFConfig() {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,9 @@ public class Forum extends Application {
|
||||||
|
|
||||||
private static final ForumConfig s_config = new ForumConfig();
|
private static final ForumConfig s_config = new ForumConfig();
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ForumConfig getConfig() {
|
public static ForumConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
// import com.arsdigita.bebop.parameters.ParameterModel;
|
// import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class that enables projects to provide their own page creators.
|
* Factory class that enables projects to provide their own page creators.
|
||||||
|
|
@ -35,38 +36,37 @@ import com.arsdigita.util.Assert;
|
||||||
*/
|
*/
|
||||||
public class ForumPageFactory {
|
public class ForumPageFactory {
|
||||||
|
|
||||||
public static final String THREAD_PAGE = "thread";
|
private static final Logger logger = Logger.getLogger(ForumPageFactory.class);
|
||||||
public static final String FORUM_PAGE = "forum";
|
public static final String THREAD_PAGE = "thread";
|
||||||
|
public static final String FORUM_PAGE = "forum";
|
||||||
private static Map pageBuilders = new HashMap();
|
private static Map pageBuilders = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// default pageBuilders are those provided with this project
|
logger.debug("Static initalizer starting...");
|
||||||
pageBuilders.put(THREAD_PAGE, new ThreadPageBuilder());
|
// default pageBuilders are those provided with this project
|
||||||
pageBuilders.put(FORUM_PAGE, new ForumPageBuilder());
|
pageBuilders.put(THREAD_PAGE, new ThreadPageBuilder());
|
||||||
}
|
pageBuilders.put(FORUM_PAGE, new ForumPageBuilder());
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
|
}
|
||||||
|
|
||||||
public static Page getPage(String pageType) {
|
public static Page getPage(String pageType) {
|
||||||
Assert.isTrue(pageBuilders.containsKey(pageType),
|
Assert.isTrue(pageBuilders.containsKey(pageType),
|
||||||
"Requested page type (" + pageType +
|
"Requested page type (" + pageType
|
||||||
") does not have a builder registered" );
|
+ ") does not have a builder registered");
|
||||||
PageBuilder builder = (PageBuilder)pageBuilders.get(pageType);
|
PageBuilder builder = (PageBuilder) pageBuilders.get(pageType);
|
||||||
Page page = builder.buildPage();
|
Page page = builder.buildPage();
|
||||||
page.lock();
|
page.lock();
|
||||||
return page;
|
return page;
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator getPages () {
|
|
||||||
return pageBuilders.keySet().iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void registerPageBuilder (String pageType, PageBuilder builder) {
|
|
||||||
pageBuilders.put(pageType, builder);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Iterator getPages() {
|
||||||
|
return pageBuilders.keySet().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerPageBuilder(String pageType, PageBuilder builder) {
|
||||||
|
pageBuilders.put(pageType, builder);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import com.arsdigita.forum.ForumContext;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,14 +47,17 @@ import java.util.Iterator;
|
||||||
*/
|
*/
|
||||||
public class TopicsList extends SimpleComponent implements Constants {
|
public class TopicsList extends SimpleComponent implements Constants {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(TopicsList.class);
|
||||||
/** List of properties a topic may have. */
|
/** List of properties a topic may have. */
|
||||||
private final static Set s_catProps;
|
private final static Set s_catProps;
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_catProps = new HashSet();
|
s_catProps = new HashSet();
|
||||||
s_catProps.add("id");
|
s_catProps.add("id");
|
||||||
s_catProps.add("name");
|
s_catProps.add("name");
|
||||||
s_catProps.add("numThreads");
|
s_catProps.add("numThreads");
|
||||||
s_catProps.add("latestPost");
|
s_catProps.add("latestPost");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.aplaws;
|
package com.arsdigita.aplaws;
|
||||||
|
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class);
|
||||||
private boolean m_wrapRoot = false;
|
private boolean m_wrapRoot = false;
|
||||||
private boolean m_wrapObjects = false;
|
private boolean m_wrapObjects = false;
|
||||||
private boolean m_wrapAttributes = false;
|
private boolean m_wrapAttributes = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Stack m_history = new Stack();
|
private Stack m_history = new Stack();
|
||||||
private HashMap m_elements = new HashMap();
|
private HashMap m_elements = new HashMap();
|
||||||
|
|
||||||
// The xs:element
|
// The xs:element
|
||||||
private Element m_element;
|
private Element m_element;
|
||||||
// The (optional) xs:complexType
|
// The (optional) xs:complexType
|
||||||
|
|
@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
// The (optional property
|
// The (optional property
|
||||||
private Property m_property;
|
private Property m_property;
|
||||||
private Stack m_properties = new Stack();
|
private Stack m_properties = new Stack();
|
||||||
|
|
||||||
private Element m_root;
|
private Element m_root;
|
||||||
private String m_rootName;
|
private String m_rootName;
|
||||||
|
|
||||||
public static final String SCHEMA_PREFIX = "xs:";
|
public static final String SCHEMA_PREFIX = "xs:";
|
||||||
|
public static final String SCHEMA_NS =
|
||||||
public static final String SCHEMA_NS =
|
"http://www.w3.org/2001/XMLSchema";
|
||||||
"http://www.w3.org/2001/XMLSchema";
|
|
||||||
|
|
||||||
private static HashMap s_types = new HashMap();
|
private static HashMap s_types = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_types.put(String.class, "xs:string");
|
s_types.put(String.class, "xs:string");
|
||||||
s_types.put(Boolean.class, "xs:boolean");
|
s_types.put(Boolean.class, "xs:boolean");
|
||||||
s_types.put(Integer.class, "xs:integer");
|
s_types.put(Integer.class, "xs:integer");
|
||||||
s_types.put(BigDecimal.class, "xs:double");
|
s_types.put(BigDecimal.class, "xs:double");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String lookupType(Class klass) {
|
protected static String lookupType(Class klass) {
|
||||||
if (s_types.containsKey(klass)) {
|
if (s_types.containsKey(klass)) {
|
||||||
return (String)s_types.get(klass);
|
return (String) s_types.get(klass);
|
||||||
}
|
}
|
||||||
return "xs:string";
|
return "xs:string";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerType(Class klass, String type) {
|
public static void registerType(Class klass, String type) {
|
||||||
s_types.put(klass, type);
|
s_types.put(klass, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObjectTypeSchemaGenerator(String rootName,
|
public ObjectTypeSchemaGenerator(String rootName,
|
||||||
String namespace) {
|
String namespace) {
|
||||||
m_root = new Element(SCHEMA_PREFIX + "schema",
|
m_root = new Element(SCHEMA_PREFIX + "schema",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_rootName = rootName;
|
m_rootName = rootName;
|
||||||
|
|
||||||
// Set the namespace for nodes defined by the schema
|
// Set the namespace for nodes defined by the schema
|
||||||
m_root.addAttribute("targetNamespace", namespace);
|
m_root.addAttribute("targetNamespace", namespace);
|
||||||
// Set the default namespace for unqualified nodes
|
// Set the default namespace for unqualified nodes
|
||||||
|
|
@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
return m_root;
|
return m_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output for root object.
|
* Determines XML output for root object.
|
||||||
* If set to true a separate element will
|
* If set to true a separate element will
|
||||||
|
|
@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element parent;
|
Element parent;
|
||||||
String name;
|
String name;
|
||||||
if (m_element == null) {
|
if (m_element == null) {
|
||||||
if (m_wrapRoot) {
|
if (m_wrapRoot) {
|
||||||
Element element = m_root.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_root.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", m_rootName);
|
element.addAttribute("name", m_rootName);
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
parent = sequence;
|
parent = sequence;
|
||||||
name = nameFromPath(path);
|
name = nameFromPath(path);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute",
|
Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
oid.addAttribute("name", "oid");
|
oid.addAttribute("name", "oid");
|
||||||
oid.addAttribute("type", "xs:string");
|
oid.addAttribute("type", "xs:string");
|
||||||
|
|
||||||
// Add to the path -> element map, not that we use this info yet
|
// Add to the path -> element map, not that we use this info yet
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
*/
|
*/
|
||||||
protected void endObject(ObjectType obj,
|
protected void endObject(ObjectType obj,
|
||||||
String path) {
|
String path) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
m_sequence = saved[2];
|
||||||
|
|
@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapAttributes) {
|
if (m_wrapAttributes) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
// XXX pdl type -> xs type mapping
|
// XXX pdl type -> xs type mapping
|
||||||
element.addAttribute("type",lookupType(property.getJavaClass()));
|
element.addAttribute("type", lookupType(property.getJavaClass()));
|
||||||
|
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
|
|
@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
// Add to element
|
// Add to element
|
||||||
m_sequence.addContent(element);
|
m_sequence.addContent(element);
|
||||||
|
|
||||||
// Add to the path -> element map
|
// Add to the path -> element map
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
// Add to element
|
// Add to element
|
||||||
m_type.addContent(element);
|
m_type.addContent(element);
|
||||||
|
|
||||||
// Add to the path -> element map
|
// Add to the path -> element map
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
}
|
}
|
||||||
|
|
@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_sequence.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
|
|
@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
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) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_sequence.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
|
|
@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
m_sequence = saved[2];
|
||||||
}
|
}
|
||||||
m_property = (Property)m_properties.pop();
|
m_property = (Property) m_properties.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.aplaws;
|
package com.arsdigita.aplaws;
|
||||||
|
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -26,18 +25,16 @@ import com.arsdigita.persistence.metadata.Property;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ObjectTypeSchemaGenerator.class);
|
||||||
private boolean m_wrapRoot = false;
|
private boolean m_wrapRoot = false;
|
||||||
private boolean m_wrapObjects = false;
|
private boolean m_wrapObjects = false;
|
||||||
private boolean m_wrapAttributes = false;
|
private boolean m_wrapAttributes = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Stack m_history = new Stack();
|
private Stack m_history = new Stack();
|
||||||
private HashMap m_elements = new HashMap();
|
private HashMap m_elements = new HashMap();
|
||||||
|
|
||||||
// The xs:element
|
// The xs:element
|
||||||
private Element m_element;
|
private Element m_element;
|
||||||
// The (optional) xs:complexType
|
// The (optional) xs:complexType
|
||||||
|
|
@ -47,41 +44,39 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
// The (optional property
|
// The (optional property
|
||||||
private Property m_property;
|
private Property m_property;
|
||||||
private Stack m_properties = new Stack();
|
private Stack m_properties = new Stack();
|
||||||
|
|
||||||
private Element m_root;
|
private Element m_root;
|
||||||
private String m_rootName;
|
private String m_rootName;
|
||||||
|
|
||||||
public static final String SCHEMA_PREFIX = "xs:";
|
public static final String SCHEMA_PREFIX = "xs:";
|
||||||
|
public static final String SCHEMA_NS =
|
||||||
public static final String SCHEMA_NS =
|
"http://www.w3.org/2001/XMLSchema";
|
||||||
"http://www.w3.org/2001/XMLSchema";
|
|
||||||
|
|
||||||
private static HashMap s_types = new HashMap();
|
private static HashMap s_types = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_types.put(String.class, "xs:string");
|
s_types.put(String.class, "xs:string");
|
||||||
s_types.put(Boolean.class, "xs:boolean");
|
s_types.put(Boolean.class, "xs:boolean");
|
||||||
s_types.put(Integer.class, "xs:integer");
|
s_types.put(Integer.class, "xs:integer");
|
||||||
s_types.put(BigDecimal.class, "xs:double");
|
s_types.put(BigDecimal.class, "xs:double");
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String lookupType(Class klass) {
|
protected static String lookupType(Class klass) {
|
||||||
if (s_types.containsKey(klass)) {
|
if (s_types.containsKey(klass)) {
|
||||||
return (String)s_types.get(klass);
|
return (String) s_types.get(klass);
|
||||||
}
|
}
|
||||||
return "xs:string";
|
return "xs:string";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerType(Class klass, String type) {
|
public static void registerType(Class klass, String type) {
|
||||||
s_types.put(klass, type);
|
s_types.put(klass, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObjectTypeSchemaGenerator(String rootName,
|
public ObjectTypeSchemaGenerator(String rootName,
|
||||||
String namespace) {
|
String namespace) {
|
||||||
m_root = new Element(SCHEMA_PREFIX + "schema",
|
m_root = new Element(SCHEMA_PREFIX + "schema",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_rootName = rootName;
|
m_rootName = rootName;
|
||||||
|
|
||||||
// Set the namespace for nodes defined by the schema
|
// Set the namespace for nodes defined by the schema
|
||||||
m_root.addAttribute("targetNamespace", namespace);
|
m_root.addAttribute("targetNamespace", namespace);
|
||||||
// Set the default namespace for unqualified nodes
|
// Set the default namespace for unqualified nodes
|
||||||
|
|
@ -95,7 +90,6 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
return m_root;
|
return m_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines XML output for root object.
|
* Determines XML output for root object.
|
||||||
* If set to true a separate element will
|
* If set to true a separate element will
|
||||||
|
|
@ -143,20 +137,23 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element parent;
|
Element parent;
|
||||||
String name;
|
String name;
|
||||||
if (m_element == null) {
|
if (m_element == null) {
|
||||||
if (m_wrapRoot) {
|
if (m_wrapRoot) {
|
||||||
Element element = m_root.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_root.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", m_rootName);
|
element.addAttribute("name", m_rootName);
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
parent = sequence;
|
parent = sequence;
|
||||||
name = nameFromPath(path);
|
name = nameFromPath(path);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -186,17 +183,17 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute",
|
Element oid = type.newChildElement(SCHEMA_PREFIX + "attribute",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
oid.addAttribute("name", "oid");
|
oid.addAttribute("name", "oid");
|
||||||
oid.addAttribute("type", "xs:string");
|
oid.addAttribute("type", "xs:string");
|
||||||
|
|
||||||
// Add to the path -> element map, not that we use this info yet
|
// Add to the path -> element map, not that we use this info yet
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
@ -209,7 +206,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
*/
|
*/
|
||||||
protected void endObject(ObjectType obj,
|
protected void endObject(ObjectType obj,
|
||||||
String path) {
|
String path) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
m_sequence = saved[2];
|
||||||
|
|
@ -223,7 +220,8 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapAttributes) {
|
if (m_wrapAttributes) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +230,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
// XXX pdl type -> xs type mapping
|
// XXX pdl type -> xs type mapping
|
||||||
element.addAttribute("type",lookupType(property.getJavaClass()));
|
element.addAttribute("type", lookupType(property.getJavaClass()));
|
||||||
|
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
|
|
@ -240,7 +238,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
// Add to element
|
// Add to element
|
||||||
m_sequence.addContent(element);
|
m_sequence.addContent(element);
|
||||||
|
|
||||||
// Add to the path -> element map
|
// Add to the path -> element map
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -256,7 +254,7 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
|
|
||||||
// Add to element
|
// Add to element
|
||||||
m_type.addContent(element);
|
m_type.addContent(element);
|
||||||
|
|
||||||
// Add to the path -> element map
|
// Add to the path -> element map
|
||||||
m_elements.put(path, element);
|
m_elements.put(path, element);
|
||||||
}
|
}
|
||||||
|
|
@ -271,26 +269,28 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_sequence.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
|
|
@ -307,12 +307,12 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
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) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
if (m_sequence == null) {
|
if (m_sequence == null) {
|
||||||
Element sequence = m_type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = m_type.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element element = m_sequence.newChildElement(SCHEMA_PREFIX + "element",
|
Element element = m_sequence.newChildElement(SCHEMA_PREFIX
|
||||||
|
+ "element",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
element.addAttribute("name", property.getName());
|
element.addAttribute("name", property.getName());
|
||||||
if (property.isNullable()) {
|
if (property.isNullable()) {
|
||||||
element.addAttribute("minOccurs", "0");
|
element.addAttribute("minOccurs", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
Element type = element.newChildElement(SCHEMA_PREFIX + "complexType",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
Element sequence = type.newChildElement(SCHEMA_PREFIX + "sequence",
|
||||||
SCHEMA_NS);
|
SCHEMA_NS);
|
||||||
|
|
||||||
// Preserve context
|
// 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_element = element;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_sequence = sequence;
|
m_sequence = sequence;
|
||||||
|
|
@ -360,12 +362,11 @@ public class ObjectTypeSchemaGenerator extends ObjectTypeTraversal {
|
||||||
String path,
|
String path,
|
||||||
Property property) {
|
Property property) {
|
||||||
if (m_wrapObjects) {
|
if (m_wrapObjects) {
|
||||||
Element[] saved = (Element[])m_history.pop();
|
Element[] saved = (Element[]) m_history.pop();
|
||||||
m_element = saved[0];
|
m_element = saved[0];
|
||||||
m_type = saved[1];
|
m_type = saved[1];
|
||||||
m_sequence = saved[2];
|
m_sequence = saved[2];
|
||||||
}
|
}
|
||||||
m_property = (Property)m_properties.pop();
|
m_property = (Property) m_properties.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,19 +33,23 @@ import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class of the AtoZ application (module)
|
* Base class of the AtoZ application (module)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AtoZ extends Application {
|
public class AtoZ extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(AtoZ.class);
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE
|
||||||
= "com.arsdigita.london.atoz.AtoZ";
|
= "com.arsdigita.london.atoz.AtoZ";
|
||||||
|
|
||||||
private static final AtoZConfig s_config = new AtoZConfig();
|
private static final AtoZConfig s_config = new AtoZConfig();
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initializer is starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initializer is finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final AtoZConfig getConfig() {
|
public static final AtoZConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.kernel.ACSObject;
|
import com.arsdigita.kernel.ACSObject;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
|
|
@ -61,12 +62,15 @@ import java.util.Date;
|
||||||
**/
|
**/
|
||||||
public class DublinCoreItem extends ContentItem {
|
public class DublinCoreItem extends ContentItem {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(DublinCoreItem.class);
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.london.cms.dublin.DublinCoreItem";
|
"com.arsdigita.london.cms.dublin.DublinCoreItem";
|
||||||
|
|
||||||
private static final DublinCoreConfig s_config = new DublinCoreConfig();
|
private static final DublinCoreConfig s_config = new DublinCoreConfig();
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final DublinCoreConfig getConfig() {
|
public static final DublinCoreConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,19 @@
|
||||||
|
|
||||||
package com.arsdigita.london.exporter;
|
package com.arsdigita.london.exporter;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Exporter {
|
public class Exporter {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Exporter.class);
|
||||||
private static ExporterConfig s_config = new ExporterConfig();
|
private static ExporterConfig s_config = new ExporterConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExporterConfig getConfig() {
|
public static ExporterConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
private Date m_archiveDate;
|
private Date m_archiveDate;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_ignoredProps = new ArrayList();
|
s_ignoredProps = new ArrayList();
|
||||||
s_ignoredProps.add(ID);
|
s_ignoredProps.add(ID);
|
||||||
s_ignoredProps.add(OID_ATTR);
|
s_ignoredProps.add(OID_ATTR);
|
||||||
|
|
@ -115,6 +116,7 @@ public class ItemParser extends DomainObjectParser {
|
||||||
s_ignoredProps.add(ARTICLE_ID);
|
s_ignoredProps.add(ARTICLE_ID);
|
||||||
s_ignoredProps.add(DEFAULT_ANCESTORS);
|
s_ignoredProps.add(DEFAULT_ANCESTORS);
|
||||||
s_ignoredProps.add(DO_NOT_SAVE);
|
s_ignoredProps.add(DO_NOT_SAVE);
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemParser(File lobDir, DomainObjectMapper mapper) {
|
public ItemParser(File lobDir, DomainObjectMapper mapper) {
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,10 @@ public class ApplicationNavigationModel implements NavigationModel {
|
||||||
new GenericNavigationModel();
|
new GenericNavigationModel();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
register(ContentSection.BASE_DATA_OBJECT_TYPE, new CMSNavigationModel());
|
register(ContentSection.BASE_DATA_OBJECT_TYPE, new CMSNavigationModel());
|
||||||
register(Navigation.BASE_DATA_OBJECT_TYPE, new DefaultNavigationModel());
|
register(Navigation.BASE_DATA_OBJECT_TYPE, new DefaultNavigationModel());
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACSObject getObject() {
|
public ACSObject getObject() {
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,13 @@ import com.arsdigita.web.ParameterMap;
|
||||||
import com.arsdigita.web.URL;
|
import com.arsdigita.web.URL;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class Navigation extends Application {
|
public class Navigation extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Navigation.class);
|
||||||
|
|
||||||
public static final String NAV_NS =
|
public static final String NAV_NS =
|
||||||
"http://ccm.redhat.com/london/navigation";
|
"http://ccm.redhat.com/london/navigation";
|
||||||
public static final String NAV_PREFIX = "nav";
|
public static final String NAV_PREFIX = "nav";
|
||||||
|
|
@ -42,7 +45,9 @@ public class Navigation extends Application {
|
||||||
private static NavigationContext s_context = new NavigationContext();
|
private static NavigationContext s_context = new NavigationContext();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NavigationConfig getConfig() {
|
public static NavigationConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.london.navigation.ui;
|
package com.arsdigita.london.navigation.ui;
|
||||||
|
|
||||||
import com.arsdigita.london.navigation.NavigationConstants;
|
import com.arsdigita.london.navigation.NavigationConstants;
|
||||||
|
|
@ -30,54 +29,59 @@ import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class TemplateURLs extends SimpleComponent {
|
public class TemplateURLs extends SimpleComponent {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(TemplateURLs.class);
|
||||||
private static final String[] s_contexts;
|
private static final String[] s_contexts;
|
||||||
|
|
||||||
// Pull out and pre-populate the template use contexts. Note that this will
|
// 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
|
// only be done once per server load, but this is ok because there's no UI
|
||||||
// for creating contexts.
|
// for creating contexts.
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
TemplateContextCollection templates = TemplateContext.retrieveAll();
|
TemplateContextCollection templates = TemplateContext.retrieveAll();
|
||||||
LinkedList buffer = new LinkedList();
|
LinkedList buffer = new LinkedList();
|
||||||
|
|
||||||
while( templates.next() ) {
|
while (templates.next()) {
|
||||||
buffer.add( templates.getTemplateContext().getContext() );
|
buffer.add(templates.getTemplateContext().getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
s_contexts = new String[buffer.size()];
|
s_contexts = new String[buffer.size()];
|
||||||
Iterator iter = buffer.iterator();
|
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();
|
s_contexts[i] = iter.next().toString();
|
||||||
}
|
}
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateURLs() {
|
public TemplateURLs() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateXML( PageState ps, Element p ) {
|
public void generateXML(PageState ps, Element p) {
|
||||||
ContentItem item = CMS.getContext().getContentItem();
|
ContentItem item = CMS.getContext().getContentItem();
|
||||||
if( null == item ) return;
|
if (null == item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Element container = p.newChildElement(
|
Element container = p.newChildElement(
|
||||||
NavigationConstants.NAV_PREFIX + ":templateContexts",
|
NavigationConstants.NAV_PREFIX + ":templateContexts",
|
||||||
NavigationConstants.NAV_NS
|
NavigationConstants.NAV_NS);
|
||||||
);
|
container.addAttribute("type", item.getContentType().getClassName());
|
||||||
container.addAttribute( "type", item.getContentType().getClassName() );
|
|
||||||
|
|
||||||
String sectionPath = item.getContentSection().getPath();
|
String sectionPath = item.getContentSection().getPath();
|
||||||
String itemPath = item.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(
|
Element context = container.newChildElement(
|
||||||
NavigationConstants.NAV_PREFIX + ":context",
|
NavigationConstants.NAV_PREFIX + ":context",
|
||||||
NavigationConstants.NAV_NS
|
NavigationConstants.NAV_NS);
|
||||||
);
|
context.addAttribute("name", s_contexts[i]);
|
||||||
context.addAttribute( "name", s_contexts[i] );
|
|
||||||
|
|
||||||
String path = sectionPath + "/tem_" + s_contexts[i] + '/' + itemPath;
|
String path = sectionPath + "/tem_" + s_contexts[i] + '/' + itemPath;
|
||||||
context.addAttribute( "path", path );
|
context.addAttribute("path", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.london.portal;
|
package com.arsdigita.london.portal;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
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.DataAssociation;
|
||||||
import com.arsdigita.persistence.DataAssociationCursor;
|
import com.arsdigita.persistence.DataAssociationCursor;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
|
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
|
||||||
import com.arsdigita.persistence.Filter;
|
import com.arsdigita.persistence.Filter;
|
||||||
|
|
@ -61,34 +60,29 @@ import java.util.LinkedList;
|
||||||
*/
|
*/
|
||||||
public class Workspace extends Application {
|
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_log.debug("Static initalizer starting...");
|
||||||
static {
|
s_config.load();
|
||||||
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;
|
|
||||||
|
|
||||||
|
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
|
* Constructor
|
||||||
|
|
@ -110,7 +104,6 @@ public class Workspace extends Application {
|
||||||
/*
|
/*
|
||||||
* public String getContextPath() { return "ccm-ldn-portal"; }
|
* public String getContextPath() { return "ccm-ldn-portal"; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return ServletPath (constant) probably should be synchron with web.xml
|
* @return ServletPath (constant) probably should be synchron with web.xml
|
||||||
|
|
@ -162,16 +155,17 @@ public class Workspace extends Application {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Workspace createWorkspace(String url, String title,
|
public static Workspace createWorkspace(String url, String title,
|
||||||
PageLayout layout, Application parent,
|
PageLayout layout,
|
||||||
|
Application parent,
|
||||||
boolean isPublic) {
|
boolean isPublic) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Creating group workspace, isPublic:" + isPublic
|
s_log.debug("Creating group workspace, isPublic:" + isPublic
|
||||||
+ " on " + url + " with parent "
|
+ " on " + url + " with parent "
|
||||||
+ (parent == null ? "none" : parent.getOID().toString()));
|
+ (parent == null ? "none" : parent.getOID().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspace workspace = (Workspace) Application.createApplication(
|
Workspace workspace = (Workspace) Application.createApplication(
|
||||||
BASE_DATA_OBJECT_TYPE, url, title, parent);
|
BASE_DATA_OBJECT_TYPE, url, title, parent);
|
||||||
workspace.setupGroups(title, isPublic);
|
workspace.setupGroups(title, isPublic);
|
||||||
workspace.setDefaultLayout(layout);
|
workspace.setDefaultLayout(layout);
|
||||||
return workspace;
|
return workspace;
|
||||||
|
|
@ -188,18 +182,19 @@ public class Workspace extends Application {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Workspace createWorkspace(String url, String title,
|
public static Workspace createWorkspace(String url, String title,
|
||||||
PageLayout layout, Application parent, User owner) {
|
PageLayout layout,
|
||||||
if (s_log.isDebugEnabled()) {
|
Application parent, User owner) {
|
||||||
s_log.debug("Creating personal workspace for " + owner.getOID()
|
if (s_log.isDebugEnabled()) {
|
||||||
+ " on " + url + " with parent "
|
s_log.debug("Creating personal workspace for " + owner.getOID()
|
||||||
+ (parent == null ? "none" : parent.getOID().toString()));
|
+ " on " + url + " with parent "
|
||||||
}
|
+ (parent == null ? "none" : parent.getOID().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
Workspace workspace = (Workspace) Application.createApplication(
|
Workspace workspace = (Workspace) Application.createApplication(
|
||||||
BASE_DATA_OBJECT_TYPE, url, title, parent);
|
BASE_DATA_OBJECT_TYPE, url, title, parent);
|
||||||
workspace.setParty(owner);
|
workspace.setParty(owner);
|
||||||
workspace.setDefaultLayout(layout);
|
workspace.setDefaultLayout(layout);
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -259,150 +254,149 @@ public class Workspace extends Application {
|
||||||
// super.beforeDelete();
|
// super.beforeDelete();
|
||||||
// Category.clearRootForObject(this);
|
// Category.clearRootForObject(this);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// This method wouldn't need to exist if permissioning used
|
// This method wouldn't need to exist if permissioning used
|
||||||
// the associations rather than direct queries which require
|
// the associations rather than direct queries which require
|
||||||
// the object to be saved
|
// the object to be saved
|
||||||
public void afterSave() {
|
public void afterSave() {
|
||||||
super.afterSave();
|
super.afterSave();
|
||||||
|
|
||||||
Party party = getParty();
|
Party party = getParty();
|
||||||
s_log.debug("Party is " + party.getDisplayName() + " for "
|
s_log.debug("Party is " + party.getDisplayName() + " for "
|
||||||
+ this.getTitle());
|
+ this.getTitle());
|
||||||
|
|
||||||
if (party instanceof User) {
|
if (party instanceof User) {
|
||||||
s_log.debug("Party is a user");
|
s_log.debug("Party is a user");
|
||||||
|
|
||||||
// Personal workspace, so give user full admin
|
// Personal workspace, so give user full admin
|
||||||
PermissionDescriptor admin = new PermissionDescriptor(
|
PermissionDescriptor admin = new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.ADMIN, this, party);
|
PrivilegeDescriptor.ADMIN, this, party);
|
||||||
PermissionService.grantPermission(admin);
|
PermissionService.grantPermission(admin);
|
||||||
|
|
||||||
} else if (party instanceof Group) {
|
} else if (party instanceof Group) {
|
||||||
s_log.debug("Party is a group");
|
s_log.debug("Party is a group");
|
||||||
|
|
||||||
// Ensure main group has the required permission
|
// Ensure main group has the required permission
|
||||||
PermissionDescriptor pd = new PermissionDescriptor(
|
PermissionDescriptor pd = new PermissionDescriptor(
|
||||||
getConfig().getWorkspacePartyPrivilege(), this, party);
|
getConfig().getWorkspacePartyPrivilege(), this, party);
|
||||||
PermissionService.grantPermission(pd);
|
PermissionService.grantPermission(pd);
|
||||||
|
|
||||||
// Now get (or create) the administrators role & grant it admin
|
// Now get (or create) the administrators role & grant it admin
|
||||||
Group members = (Group) party;
|
Group members = (Group) party;
|
||||||
Role admins = members.getRole("Administrators");
|
Role admins = members.getRole("Administrators");
|
||||||
if (admins == null) {
|
if (admins == null) {
|
||||||
admins = members.createRole("Administrators");
|
admins = members.createRole("Administrators");
|
||||||
admins.save();
|
admins.save();
|
||||||
}
|
}
|
||||||
admins.grantPermission(this, PrivilegeDescriptor.ADMIN);
|
admins.grantPermission(this, PrivilegeDescriptor.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set permission context for %all pages
|
// Set permission context for %all pages
|
||||||
WorkspacePageCollection pages = getPages();
|
WorkspacePageCollection pages = getPages();
|
||||||
while (pages.next()) {
|
while (pages.next()) {
|
||||||
WorkspacePage page = pages.getPage();
|
WorkspacePage page = pages.getPage();
|
||||||
PermissionService.setContext(page, this);
|
PermissionService.setContext(page, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupGroups(String title, boolean isPublic) {
|
private void setupGroups(String title, boolean isPublic) {
|
||||||
Group members = new Group();
|
Group members = new Group();
|
||||||
members.setName(title);
|
members.setName(title);
|
||||||
members.save();
|
members.save();
|
||||||
// set this group as subgroup of workspace application type
|
// set this group as subgroup of workspace application type
|
||||||
// although workspace applications can be nested, place all
|
// although workspace applications can be nested, place all
|
||||||
// member groups directly under main container (rather than reflecting
|
// member groups directly under main container (rather than reflecting
|
||||||
// hierarchical structure) because (a) workspace already manages its
|
// hierarchical structure) because (a) workspace already manages its
|
||||||
// own groups so doesn't need a hierarchy and (b) hierarchy would
|
// own groups so doesn't need a hierarchy and (b) hierarchy would
|
||||||
// mean for a given workspace, role would be on the same level
|
// mean for a given workspace, role would be on the same level
|
||||||
// as member groups of sub workspaces - messy & confusing
|
// as member groups of sub workspaces - messy & confusing
|
||||||
getApplicationType().getGroup().addSubgroup(members);
|
getApplicationType().getGroup().addSubgroup(members);
|
||||||
|
|
||||||
Role admins = members.createRole("Administrators");
|
Role admins = members.createRole("Administrators");
|
||||||
admins.save();
|
admins.save();
|
||||||
|
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
Party thePublic;
|
Party thePublic;
|
||||||
try {
|
try {
|
||||||
thePublic = (Party) DomainObjectFactory.newInstance(new OID(
|
thePublic = (Party) DomainObjectFactory.newInstance(new OID(
|
||||||
User.BASE_DATA_OBJECT_TYPE,
|
User.BASE_DATA_OBJECT_TYPE,
|
||||||
PermissionManager.VIRTUAL_PUBLIC_ID));
|
PermissionManager.VIRTUAL_PUBLIC_ID));
|
||||||
} catch (DataObjectNotFoundException ex) {
|
} catch (DataObjectNotFoundException ex) {
|
||||||
throw new UncheckedWrapperException("cannot find the public",
|
throw new UncheckedWrapperException("cannot find the public",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
members.addMemberOrSubgroup(thePublic);
|
members.addMemberOrSubgroup(thePublic);
|
||||||
members.save();
|
members.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
setParty(members);
|
setParty(members);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorkspaceCollection retrieveAll() {
|
public static WorkspaceCollection retrieveAll() {
|
||||||
return retrieveAll(null);
|
return retrieveAll(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorkspaceCollection retrieveAll(Application parent) {
|
public static WorkspaceCollection retrieveAll(Application parent) {
|
||||||
DataCollection wks = SessionManager.getSession().retrieve(
|
DataCollection wks = SessionManager.getSession().retrieve(
|
||||||
BASE_DATA_OBJECT_TYPE);
|
BASE_DATA_OBJECT_TYPE);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
wks.addEqualsFilter("parentResource.id", parent.getID());
|
wks.addEqualsFilter("parentResource.id", parent.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WorkspaceCollection(wks);
|
return new WorkspaceCollection(wks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Workspace retrieveSubworkspaceForParty(Party owner)
|
public Workspace retrieveSubworkspaceForParty(Party owner)
|
||||||
throws DataObjectNotFoundException {
|
throws DataObjectNotFoundException {
|
||||||
|
|
||||||
DataCollection wks = SessionManager.getSession().retrieve(
|
DataCollection wks = SessionManager.getSession().retrieve(
|
||||||
BASE_DATA_OBJECT_TYPE);
|
BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
wks.addEqualsFilter("parentResource.id", getID());
|
wks.addEqualsFilter("parentResource.id", getID());
|
||||||
wks.addEqualsFilter(PARTY_ID, owner.getID());
|
wks.addEqualsFilter(PARTY_ID, owner.getID());
|
||||||
|
|
||||||
if (wks.next()) {
|
if (wks.next()) {
|
||||||
Workspace workspace = (Workspace) Application
|
Workspace workspace = (Workspace) Application.retrieveApplication(wks.
|
||||||
.retrieveApplication(wks.getDataObject());
|
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() {
|
public void delete() {
|
||||||
clearPages();
|
clearPages();
|
||||||
|
|
||||||
super.delete();
|
super.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPages() {
|
public void clearPages() {
|
||||||
WorkspacePageCollection pages = getPages();
|
WorkspacePageCollection pages = getPages();
|
||||||
while (pages.next()) {
|
while (pages.next()) {
|
||||||
WorkspacePage page = pages.getPage();
|
WorkspacePage page = pages.getPage();
|
||||||
page.delete();
|
page.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultLayout(PageLayout layout) {
|
public void setDefaultLayout(PageLayout layout) {
|
||||||
setAssociation(DEFAULT_LAYOUT, layout);
|
setAssociation(DEFAULT_LAYOUT, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageLayout getDefaultLayout() {
|
public PageLayout getDefaultLayout() {
|
||||||
return (PageLayout) DomainObjectFactory
|
return (PageLayout) DomainObjectFactory.newInstance((DataObject) get(
|
||||||
.newInstance((DataObject) get(DEFAULT_LAYOUT));
|
DEFAULT_LAYOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParty(Party party) {
|
public void setParty(Party party) {
|
||||||
setAssociation(PARTY, party);
|
setAssociation(PARTY, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Party getParty() {
|
public Party getParty() {
|
||||||
return (Party) DomainObjectFactory.newInstance((DataObject) get(PARTY));
|
return (Party) DomainObjectFactory.newInstance((DataObject) get(PARTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleCollection getRoles() {
|
public RoleCollection getRoles() {
|
||||||
Party party = getParty();
|
Party party = getParty();
|
||||||
|
|
@ -461,12 +455,12 @@ public class Workspace extends Application {
|
||||||
|
|
||||||
public PartyCollection getNonParticipants() {
|
public PartyCollection getNonParticipants() {
|
||||||
DataCollection dc =
|
DataCollection dc =
|
||||||
SessionManager.getSession()
|
SessionManager.getSession().retrieve(
|
||||||
.retrieve("com.arsdigita.kernel.User");
|
"com.arsdigita.kernel.User");
|
||||||
// .retrieve("com.arsdigita.kernel.Party");
|
// .retrieve("com.arsdigita.kernel.Party");
|
||||||
Filter f = dc
|
Filter f =
|
||||||
.addNotInSubqueryFilter
|
dc.addNotInSubqueryFilter("id",
|
||||||
("id", "com.arsdigita.london.portal.WorkspaceParticipantIDs");
|
"com.arsdigita.london.portal.WorkspaceParticipantIDs");
|
||||||
f.set("workspaceID", getID());
|
f.set("workspaceID", getID());
|
||||||
return new PartyCollection(dc);
|
return new PartyCollection(dc);
|
||||||
}
|
}
|
||||||
|
|
@ -484,8 +478,8 @@ public class Workspace extends Application {
|
||||||
* alphabetical order.</p>
|
* alphabetical order.</p>
|
||||||
**/
|
**/
|
||||||
public Iterator getParticipantInitials() {
|
public Iterator getParticipantInitials() {
|
||||||
DataQuery query = SessionManager.getSession().retrieveQuery
|
DataQuery query = SessionManager.getSession().retrieveQuery(
|
||||||
("com.arsdigita.london.portal.WorkspaceParticipantInitials");
|
"com.arsdigita.london.portal.WorkspaceParticipantInitials");
|
||||||
query.setParameter("workspaceID", getID());
|
query.setParameter("workspaceID", getID());
|
||||||
|
|
||||||
LinkedList result = new LinkedList();
|
LinkedList result = new LinkedList();
|
||||||
|
|
@ -508,7 +502,7 @@ public class Workspace extends Application {
|
||||||
Assert.exists(initial);
|
Assert.exists(initial);
|
||||||
Assert.isTrue(initial.length() == 1, "Initial needs length 1");
|
Assert.isTrue(initial.length() == 1, "Initial needs length 1");
|
||||||
Assert.isTrue(initial.equals(initial.toUpperCase()),
|
Assert.isTrue(initial.equals(initial.toUpperCase()),
|
||||||
"Initial must be uppercase");
|
"Initial must be uppercase");
|
||||||
|
|
||||||
//DataAssociationCursor dac =
|
//DataAssociationCursor dac =
|
||||||
// ((DataAssociation) get("participants")).cursor();
|
// ((DataAssociation) get("participants")).cursor();
|
||||||
|
|
@ -516,32 +510,33 @@ public class Workspace extends Application {
|
||||||
// ("id", "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial");
|
// ("id", "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial");
|
||||||
|
|
||||||
DataCollection dc =
|
DataCollection dc =
|
||||||
SessionManager.getSession()
|
SessionManager.getSession().retrieve(
|
||||||
.retrieve("com.arsdigita.kernel.User");
|
"com.arsdigita.kernel.User");
|
||||||
Filter f = dc.addInSubqueryFilter
|
Filter f =
|
||||||
("id", "com.arsdigita.london.portal.WorkspaceParticipantsWithInitial");
|
dc.addInSubqueryFilter("id",
|
||||||
|
"com.arsdigita.london.portal.WorkspaceParticipantsWithInitial");
|
||||||
f.set("workspaceID", getID());
|
f.set("workspaceID", getID());
|
||||||
f.set("nameInitial", initial);
|
f.set("nameInitial", initial);
|
||||||
|
|
||||||
return new PartyCollection(dc);
|
return new PartyCollection(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkspacePageCollection getPages() {
|
public WorkspacePageCollection getPages() {
|
||||||
DataAssociation pages = (DataAssociation) get(PAGES);
|
DataAssociation pages = (DataAssociation) get(PAGES);
|
||||||
return new WorkspacePageCollection(pages.cursor());
|
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
|
// loop through the pages and look for the previous one
|
||||||
WorkspacePageCollection pages = getPages();
|
WorkspacePageCollection pages = getPages();
|
||||||
pages.addOrder(WorkspacePage.SORT_KEY);
|
pages.addOrder(WorkspacePage.SORT_KEY);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
WorkspacePage previous = null;
|
WorkspacePage previous = null;
|
||||||
WorkspacePage current = null;
|
WorkspacePage current = null;
|
||||||
|
|
||||||
while (pages.next()) {
|
while (pages.next()) {
|
||||||
current = pages.getPage();
|
current = pages.getPage();
|
||||||
if (current.equals(workspacePage)) {
|
if (current.equals(workspacePage)) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
// current is first
|
// current is first
|
||||||
|
|
@ -555,19 +550,19 @@ public class Workspace extends Application {
|
||||||
}
|
}
|
||||||
previous = current;
|
previous = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void movePageRight(WorkspacePage workspacePage) {
|
public void movePageRight(WorkspacePage workspacePage) {
|
||||||
|
|
||||||
// loop through the pages and look for the next one
|
// loop through the pages and look for the next one
|
||||||
WorkspacePageCollection pages = getPages();
|
WorkspacePageCollection pages = getPages();
|
||||||
pages.addOrder(WorkspacePage.SORT_KEY);
|
pages.addOrder(WorkspacePage.SORT_KEY);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
WorkspacePage previous = null;
|
WorkspacePage previous = null;
|
||||||
WorkspacePage current = null;
|
WorkspacePage current = null;
|
||||||
|
|
||||||
while (pages.next()) {
|
while (pages.next()) {
|
||||||
current = pages.getPage();
|
current = pages.getPage();
|
||||||
if (previous != null && previous.equals(workspacePage)) {
|
if (previous != null && previous.equals(workspacePage)) {
|
||||||
int currentKey = current.getSortKey();
|
int currentKey = current.getSortKey();
|
||||||
int previousKey = previous.getSortKey();
|
int previousKey = previous.getSortKey();
|
||||||
|
|
@ -577,73 +572,73 @@ public class Workspace extends Application {
|
||||||
}
|
}
|
||||||
previous = current;
|
previous = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePage(WorkspacePage workspacePage) {
|
public void removePage(WorkspacePage workspacePage) {
|
||||||
WorkspacePageCollection pages = getPages();
|
WorkspacePageCollection pages = getPages();
|
||||||
pages.addOrder(WorkspacePage.SORT_KEY);
|
pages.addOrder(WorkspacePage.SORT_KEY);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (pages.next()) {
|
while (pages.next()) {
|
||||||
WorkspacePage page = pages.getPage();
|
WorkspacePage page = pages.getPage();
|
||||||
if (page.equals(workspacePage)) {
|
if (page.equals(workspacePage)) {
|
||||||
page.delete();
|
page.delete();
|
||||||
} else {
|
} else {
|
||||||
page.setSortKey(i++);
|
page.setSortKey(i++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkspacePage addPage(String title, String description) {
|
public WorkspacePage addPage(String title, String description) {
|
||||||
DataAssociationCursor pages = ((DataAssociation) get(PAGES)).cursor();
|
DataAssociationCursor pages = ((DataAssociation) get(PAGES)).cursor();
|
||||||
pages.addOrder(WorkspacePage.SORT_KEY + " desc");
|
pages.addOrder(WorkspacePage.SORT_KEY + " desc");
|
||||||
int max = -1;
|
int max = -1;
|
||||||
if (pages.next()) {
|
if (pages.next()) {
|
||||||
DataObject dobj = pages.getDataObject();
|
DataObject dobj = pages.getDataObject();
|
||||||
Integer tab = (Integer) dobj.get(WorkspacePage.SORT_KEY);
|
Integer tab = (Integer) dobj.get(WorkspacePage.SORT_KEY);
|
||||||
max = tab.intValue();
|
max = tab.intValue();
|
||||||
pages.close();
|
pages.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return addPage(title, description, getDefaultLayout(), max + 1);
|
return addPage(title, description, getDefaultLayout(), max + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkspacePage addPage(String title, String description,
|
public WorkspacePage addPage(String title, String description,
|
||||||
PageLayout layout, int sortKey) {
|
PageLayout layout, int sortKey) {
|
||||||
return WorkspacePage.create(title, description, layout, this, sortKey);
|
return WorkspacePage.create(title, description, layout, this, sortKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTheme(WorkspaceTheme theme) {
|
public void setTheme(WorkspaceTheme theme) {
|
||||||
set("theme", theme);
|
set("theme", theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkspaceTheme getTheme() {
|
public WorkspaceTheme getTheme() {
|
||||||
DataObject dobj;
|
DataObject dobj;
|
||||||
|
|
||||||
dobj = (DataObject) get("theme");
|
dobj = (DataObject) get("theme");
|
||||||
|
|
||||||
if (dobj == null)
|
if (dobj == null) {
|
||||||
return null;
|
return null;
|
||||||
else {
|
} else {
|
||||||
WorkspaceTheme theme = new WorkspaceTheme(dobj);
|
WorkspaceTheme theme = new WorkspaceTheme(dobj);
|
||||||
return theme;
|
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() {
|
public WorkspaceCollection getChildWorkspaces() {
|
||||||
DataQuery query = SessionManager.getSession().retrieveQuery
|
DataQuery query = SessionManager.getSession().retrieveQuery(
|
||||||
("com.arsdigita.london.portal.childWorkspacesForApplicationID");
|
"com.arsdigita.london.portal.childWorkspacesForApplicationID");
|
||||||
query.setParameter("applicationID", getID());
|
query.setParameter("applicationID", getID());
|
||||||
|
|
||||||
DataCollection collection =
|
DataCollection collection =
|
||||||
new DataQueryDataCollectionAdapter(query, "workspace");
|
new DataQueryDataCollectionAdapter(query, "workspace");
|
||||||
//collection.addEqualsFilter("isArchived", Boolean.FALSE);
|
//collection.addEqualsFilter("isArchived", Boolean.FALSE);
|
||||||
|
|
||||||
query.close();
|
query.close();
|
||||||
|
|
@ -670,93 +665,92 @@ public class Workspace extends Application {
|
||||||
return applications;
|
return applications;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's the description for a Workspace.
|
* Get's the description for a Workspace.
|
||||||
*/
|
*/
|
||||||
// public String getDescription() {
|
// public String getDescription() {
|
||||||
// return (String) get("description");
|
// return (String) get("description");
|
||||||
// }
|
// }
|
||||||
|
/**
|
||||||
/**
|
* Set's the description for a Workspace.
|
||||||
* Set's the description for a Workspace.
|
*/
|
||||||
*/
|
|
||||||
// public void setDescription(String description) {
|
// public void setDescription(String description) {
|
||||||
// set("description", 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public User getOwner() {
|
||||||
* Sets the user who owns the workspace
|
return (User) get("owner");
|
||||||
*
|
}
|
||||||
* @param user
|
|
||||||
*/
|
|
||||||
public void setOwner(User user) {
|
|
||||||
s_log.debug("setOwner called for " + this.getDisplayName());
|
|
||||||
set("owner", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getOwner() {
|
public static Workspace createPersonalWorkspace(final User owner) {
|
||||||
return (User) get("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 "
|
String url = "" + owner.getID();
|
||||||
+ owner.getDisplayName());
|
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();
|
// TODO the setOwner method should probably deal with all the
|
||||||
String title = "Personal Workspace for " + owner.getDisplayName();
|
// permissions then later on ownership could be changed
|
||||||
Application parent = Application
|
Group group = (Group) workspace.getParty();
|
||||||
.retrieveApplicationForPath(PersonalPortalPage.PERSONAL_PORTAL_PATH);
|
group.addMember(owner);
|
||||||
final Workspace workspace = createWorkspace(url, title, parent, false);
|
workspace.setOwner(owner);
|
||||||
|
new KernelExcursion() {
|
||||||
|
|
||||||
// TODO the setOwner method should probably deal with all the
|
public void excurse() {
|
||||||
// permissions then later on ownership could be changed
|
setEffectiveParty(Kernel.getSystemParty());
|
||||||
Group group = (Group) workspace.getParty();
|
PermissionDescriptor pd = new PermissionDescriptor(
|
||||||
group.addMember(owner);
|
PrivilegeDescriptor.ADMIN, workspace, owner);
|
||||||
workspace.setOwner(owner);
|
PermissionService.grantPermission(pd);
|
||||||
new KernelExcursion() {
|
}
|
||||||
public void excurse() {
|
}.run();
|
||||||
setEffectiveParty(Kernel.getSystemParty());
|
// check that the user is no longer system user
|
||||||
PermissionDescriptor pd = new PermissionDescriptor(
|
Party party = KernelHelper.getCurrentEffectiveParty();
|
||||||
PrivilegeDescriptor.ADMIN, workspace, owner);
|
s_log.debug("party after excurse is " + party.getDisplayName());
|
||||||
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");
|
Role admins = group.getRole("Administrators");
|
||||||
if (admins == null) {
|
if (admins == null) {
|
||||||
admins = group.createRole("Administrators");
|
admins = group.createRole("Administrators");
|
||||||
admins.add(owner);
|
admins.add(owner);
|
||||||
admins.save();
|
admins.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace.setDefaultLayout(PageLayout.getDefaultLayout());
|
workspace.setDefaultLayout(PageLayout.getDefaultLayout());
|
||||||
|
|
||||||
// set the parent app to null
|
// set the parent app to null
|
||||||
// so that the base personal portal doesn't appear anywhere
|
// so that the base personal portal doesn't appear anywhere
|
||||||
workspace.setParentApplication(null);
|
workspace.setParentApplication(null);
|
||||||
|
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Workspace retrievePersonalWorkspace(User owner) {
|
public static Workspace retrievePersonalWorkspace(User owner) {
|
||||||
DataCollection personalWorkspaces = SessionManager.getSession()
|
DataCollection personalWorkspaces = SessionManager.getSession().retrieve(
|
||||||
.retrieve(BASE_DATA_OBJECT_TYPE);
|
BASE_DATA_OBJECT_TYPE);
|
||||||
personalWorkspaces.addEqualsFilter("owner", owner.getID());
|
personalWorkspaces.addEqualsFilter("owner", owner.getID());
|
||||||
|
|
||||||
if (personalWorkspaces.next()) {
|
if (personalWorkspaces.next()) {
|
||||||
Workspace workspace = (Workspace) Application
|
Workspace workspace = (Workspace) Application.retrieveApplication(personalWorkspaces.
|
||||||
.retrieveApplication(personalWorkspaces.getDataObject());
|
getDataObject());
|
||||||
if (personalWorkspaces.next())
|
if (personalWorkspaces.next()) {
|
||||||
s_log.error("more than one personal workspaces for this user!!");
|
s_log.error("more than one personal workspaces for this user!!");
|
||||||
personalWorkspaces.close();
|
}
|
||||||
|
personalWorkspaces.close();
|
||||||
return workspace;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return workspace;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.arsdigita.london.portal.portlet;
|
package com.arsdigita.london.portal.portlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -42,126 +41,121 @@ import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
public class RSSFeedPortletHelper {
|
public class RSSFeedPortletHelper {
|
||||||
|
|
||||||
private static final Logger s_log = Logger
|
private static final Logger s_log = Logger.getLogger(
|
||||||
.getLogger(RSSFeedPortletHelper.class);
|
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 {
|
public static Iterator getExternalFeeds() {
|
||||||
URLFetcher.registerService(CACHE_SERVICE_KEY, pool, cache);
|
return parseRSSFeed(com.arsdigita.web.URL.there(
|
||||||
};
|
"/channels/rss/external.rss", null).getURL());
|
||||||
|
}
|
||||||
|
|
||||||
public static Element getRSSElement(String location) {
|
public static Iterator getACSJFeeds(String host) {
|
||||||
s_log.debug("getRSSElement from " + location);
|
return parseRSSFeed(host);
|
||||||
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 getACSJHosts() {
|
public static Iterator parseRSSFeed(String location) {
|
||||||
return parseRSSFeed(com.arsdigita.web.URL.there(
|
List list = new ArrayList();
|
||||||
"/channels/rss/acsj.rss", null).getURL());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator getExternalFeeds() {
|
try {
|
||||||
return parseRSSFeed(com.arsdigita.web.URL.there(
|
URL url = new URL(location);
|
||||||
"/channels/rss/external.rss", null).getURL());
|
URLConnection con = url.openConnection();
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator getACSJFeeds(String host) {
|
InputStream is = con.getInputStream();
|
||||||
return parseRSSFeed(host);
|
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) {
|
return list.iterator();
|
||||||
List list = new ArrayList();
|
}
|
||||||
|
|
||||||
try {
|
protected static class ItemExtractor extends DefaultHandler {
|
||||||
URL url = new URL(location);
|
|
||||||
URLConnection con = url.openConnection();
|
|
||||||
|
|
||||||
InputStream is = con.getInputStream();
|
private List m_items;
|
||||||
try {
|
private boolean m_item;
|
||||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
private String m_url;
|
||||||
SAXParser parser = spf.newSAXParser();
|
private String m_title;
|
||||||
parser.parse(is, new ItemExtractor(list));
|
private StringBuffer m_scratch;
|
||||||
} 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
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
public void endElement(String uri, String localName, String qn) {
|
||||||
|
if (m_item == true) {
|
||||||
private String m_url;
|
if (qn.equals("title")) {
|
||||||
|
m_title = m_scratch.toString();
|
||||||
private String m_title;
|
} else if (qn.equals("link")) {
|
||||||
|
m_url = m_scratch.toString();
|
||||||
private StringBuffer m_scratch;
|
} else if (qn.equals("item")) {
|
||||||
|
m_items.add(new String[]{m_url, m_title});
|
||||||
public ItemExtractor(List items) {
|
m_item = false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
package com.arsdigita.london.portal.ui;
|
package com.arsdigita.london.portal.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Image;
|
import com.arsdigita.bebop.Image;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains Images for the various CW icons. These image
|
* This class contains Images for the various CW icons. These image
|
||||||
|
|
@ -25,6 +26,8 @@ import com.arsdigita.bebop.Image;
|
||||||
**/
|
**/
|
||||||
public class Icons {
|
public class Icons {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Icons.class);
|
||||||
|
|
||||||
public static final Image USER_16;
|
public static final Image USER_16;
|
||||||
public static final Image GROUP_16;
|
public static final Image GROUP_16;
|
||||||
public static final Image LEFT_16;
|
public static final Image LEFT_16;
|
||||||
|
|
@ -40,6 +43,7 @@ public class Icons {
|
||||||
public static final Image TRASH_16;
|
public static final Image TRASH_16;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
USER_16 = new Image("/packages/workspace/www/assets/User16.gif");
|
USER_16 = new Image("/packages/workspace/www/assets/User16.gif");
|
||||||
USER_16.setBorder("0");
|
USER_16.setBorder("0");
|
||||||
USER_16.lock();
|
USER_16.lock();
|
||||||
|
|
@ -97,5 +101,6 @@ public class Icons {
|
||||||
TRASH_16 = new Image("/packages/workspace/www/assets/delete.gif");
|
TRASH_16 = new Image("/packages/workspace/www/assets/delete.gif");
|
||||||
TRASH_16.setBorder("0");
|
TRASH_16.setBorder("0");
|
||||||
TRASH_16.lock();
|
TRASH_16.lock();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ abstract class GrantsTable extends Table {
|
||||||
private static TableCellRenderer[] s_viewCellRenderers;
|
private static TableCellRenderer[] s_viewCellRenderers;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
int n = Grant.s_interestingPrivileges.length;
|
int n = Grant.s_interestingPrivileges.length;
|
||||||
s_editCellRenderers = new TableCellRenderer[n];
|
s_editCellRenderers = new TableCellRenderer[n];
|
||||||
s_viewCellRenderers = new TableCellRenderer[n];
|
s_viewCellRenderers = new TableCellRenderer[n];
|
||||||
|
|
@ -134,6 +135,7 @@ abstract class GrantsTable extends Table {
|
||||||
s_viewCellRenderers[i] =
|
s_viewCellRenderers[i] =
|
||||||
new ViewPrivilegeCellRenderer(Grant.s_interestingPrivileges[i]);
|
new ViewPrivilegeCellRenderer(Grant.s_interestingPrivileges[i]);
|
||||||
}
|
}
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-request label for renderer getComponent calls
|
// Per-request label for renderer getComponent calls
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,25 @@ import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
|
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class of the RSS application (module).
|
* Base class of the RSS application (module).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RSS extends Application {
|
public class RSS extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(RSS.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE
|
||||||
= "com.arsdigita.london.rss.RSS";
|
= "com.arsdigita.london.rss.RSS";
|
||||||
|
|
||||||
|
|
||||||
private static final RSSConfig s_config = new RSSConfig();
|
private static final RSSConfig s_config = new RSSConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,9 @@ public class RSSService {
|
||||||
private static final RSSConfig s_config = new RSSConfig();
|
private static final RSSConfig s_config = new RSSConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RSSConfig getConfig() {
|
public static RSSConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,24 @@ import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
|
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for the search application (module)
|
* Base class for the search application (module)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Search extends Application {
|
public class Search extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Search.class);
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE
|
||||||
= "com.arsdigita.london.search.Search";
|
= "com.arsdigita.london.search.Search";
|
||||||
|
|
||||||
private static SearchConfig s_config = new SearchConfig();
|
private static SearchConfig s_config = new SearchConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchConfig getConfig() {
|
public static SearchConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,25 @@ import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
|
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class of the shortcuts application.
|
* Base class of the shortcuts application.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Shortcuts extends Application {
|
public class Shortcuts extends Application {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Shortcuts.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE
|
public static final String BASE_DATA_OBJECT_TYPE
|
||||||
= "com.arsdigita.london.shortcuts.Shortcuts";
|
= "com.arsdigita.london.shortcuts.Shortcuts";
|
||||||
|
|
||||||
private static ShortcutsConfig s_config = new ShortcutsConfig();
|
private static ShortcutsConfig s_config = new ShortcutsConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
logger.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortcutsConfig getConfig() {
|
public static ShortcutsConfig getConfig() {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ public class Subsite extends Application {
|
||||||
private static final SubsiteConfig s_config = new SubsiteConfig();
|
private static final SubsiteConfig s_config = new SubsiteConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
s_log.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final SubsiteContext s_context = new SubsiteContext();
|
private static final SubsiteContext s_context = new SubsiteContext();
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue