diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAddressPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAddressPropertiesStep.java index 27970ae83..65d63017b 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAddressPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericContactAddressPropertiesStep.java @@ -69,11 +69,11 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep { localize(), new EditAddressWorkflowLockedComponentAccess( reattachAddressSheet, itemModel), reattachAddressSheet. getSaveCancelSection().getCancelButton()); - add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil. + /*add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil. globalize("cms.contenttypes.ui.contact.edit_address").localize(), new EditAddressWorkflowLockedComponentAccess(editAddressSheet, itemModel), - editAddressSheet.getSaveCancelSection().getCancelButton()); + editAddressSheet.getSaveCancelSection().getCancelButton());*/ add(DELETE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.contact.delete_address").localize(), diff --git a/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java b/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java index d297fd1c1..2cd200466 100755 --- a/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java +++ b/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java @@ -34,34 +34,31 @@ import java.util.HashMap; import org.apache.log4j.Logger; /** - * This is a factory class to support instantiation of an appropriate - * domain object class from a given data object. - *
- * The architecture of the persistence and domain layers intentionally - * does not impose a simple one-to-one correspondence between data object - * types and domain object classes. It is possible for multiple domain - * object classes to encapsulate a given data object. It is also possible - * that a single domain object class can encapsulate data objects of - * different types. The primary factory design objectives are: + * This is a factory class to support instantiation of an appropriate domain + * object class from a given data object.
The architecture of the + * persistence and domain layers intentionally does not impose a simple + * one-to-one correspondence between data object types and domain object + * classes. It is possible for multiple domain object classes to encapsulate a + * given data object. It is also possible that a single domain object class can + * encapsulate data objects of different types. The primary factory design + * objectives are: * - *
DomainObjectInstantiator, that can make use of any
- * properties of the given data object.
+ * DomainObjectInstantiator, that can make use of any properties of
+ * the given data object.
*
- * DomainObjectInstantiator has been registered
- * with the factory for type X, and even then, it may be possible for
- * the instantiator code to examine other properties of the data object
- * and decide that the given data object is not supported (presumably
- * because there is no sensible way to choose which domain object class
- * should be instantiated for the particular data object).
- * DomainObjectInstantiator has been registered with the factory
+ * for type X, and even then, it may be possible for the instantiator code to
+ * examine other properties of the data object and decide that the given data
+ * object is not supported (presumably because there is no sensible way to
+ * choose which domain object class should be instantiated for the particular
+ * data object). The process of instantiating the domain object involves delegating to - * a {@link DomainObjectInstantiator}. The instantiator may use any + * a {@link DomainObjectInstantiator}. The instantiator may use any * information about the DataObject to produce the appropriate domain * object.
- * + * *The result may be null if there is no instantiator registered for the
- * dataObjectType of the specified dataObject, OR if the registered
- * instantiator does not support instantiation of the specified
+ * dataObjectType of the specified
+ * dataObject, OR if the registered instantiator does not
+ * support instantiation of the specified
* dataObject.
null, if called with the null data object
- * parameter. The result may also be null if no domain object
- * could be instantiated for the given data object.
+ * @return A domain object that encapuslates the given dataObject. Returns
+ * null, if called with the
+ * null data object parameter. The result may also be
+ * null if no domain object could be instantiated for the given
+ * data object.
*
* @throws InstantiatorNotFoundException if no Instantiator could be found
* @throws PersistenceException
@@ -109,28 +113,34 @@ public class DomainObjectFactory {
public static DomainObject newInstance(DataObject dataObject)
throws PersistenceException, InstantiatorNotFoundException {
- if ( dataObject == null ) { return null; }
+ if (dataObject == null) {
+ return null;
+ }
if (s_log.isInfoEnabled()) {
s_log.info("Instantiating " + dataObject.getOID());
}
- /* A instantiator may delegate to another instantiator depending on the
- data object. That other instantiator may in turn delegate to
- a different instantiator, and so on. We get the final instantiator
- by recursed calls to resolveInstantiator until the returned
- instantiator doesn't change. */
+ /*
+ * A instantiator may delegate to another instantiator depending on the
+ * data object. That other instantiator may in turn delegate to a
+ * different instantiator, and so on. We get the final instantiator by
+ * recursed calls to resolveInstantiator until the returned instantiator
+ * doesn't change.
+ */
DomainObjectInstantiator delegator = null;
DomainObjectInstantiator delegate =
- getInstantiator(dataObject.getObjectType());
+ getInstantiator(dataObject.getObjectType());
if (s_log.isDebugEnabled()) {
s_log.debug("Initial delegate " + delegate);
}
- /* keep calling resolveInstantiator until the result doesn't change */
- while (delegate!=null && delegate != delegator) {
+ /*
+ * keep calling resolveInstantiator until the result doesn't change
+ */
+ while (delegate != null && delegate != delegator) {
delegator = delegate;
delegate = delegator.resolveInstantiator(dataObject);
if (s_log.isDebugEnabled()) {
@@ -139,9 +149,8 @@ public class DomainObjectFactory {
}
if (delegate == null) {
- throw new InstantiatorNotFoundException (
- "No instantiator found for dataObject " + dataObject
- );
+ throw new InstantiatorNotFoundException(
+ "No instantiator found for dataObject " + dataObject);
}
if (s_log.isDebugEnabled()) {
@@ -151,14 +160,14 @@ public class DomainObjectFactory {
}
/**
- * Instantiate a domain object given an OID. This method is a wrapper
- * around newInstance(DataObject).
+ * Instantiate a domain object given an OID. This method is a wrapper around
+ * newInstance(DataObject).
*
- * @param oid the oid of the data object for which to instantiate
- * a domain object.
+ * @param oid the oid of the data object for which to instantiate a domain
+ * object.
*
- * @return A domain object that encapuslates the dataObject identified
- * by oid. The result may be null if no domain object could be
+ * @return A domain object that encapuslates the dataObject identified by
+ * oid. The result may be null if no domain object could be
* instantiated for the specified data object.
*
* @throws DataObjectNotFoundException if object could not be retrieved.
@@ -168,23 +177,24 @@ public class DomainObjectFactory {
* @see DomainObject
*/
public static DomainObject newInstance(OID oid)
- throws InstantiatorNotFoundException {
+ throws InstantiatorNotFoundException {
- if ( oid == null ) { return null; }
+ if (oid == null) {
+ return null;
+ }
Session session = SessionManager.getSession();
if (session == null) {
- throw new RuntimeException("Could not retrieve a session from " +
- "the session manager while instantiating " +
- "a class with OID = " + oid.toString());
+ throw new RuntimeException("Could not retrieve a session from "
+ + "the session manager while instantiating "
+ + "a class with OID = " + oid.toString());
}
- DataObject dataObject=session.retrieve(oid);
+ DataObject dataObject = session.retrieve(oid);
if (dataObject == null) {
- throw new DataObjectNotFoundException
- ("Could not retrieve a DataObject with " +
- "OID = " + oid.toString());
+ throw new DataObjectNotFoundException("Could not retrieve a DataObject with "
+ + "OID = " + oid.toString());
}
return newInstance(dataObject);
@@ -192,28 +202,27 @@ public class DomainObjectFactory {
}
/**
- * Register an instantiator for the data object type specified
- * by dataObjectType. The registered instantiator will be
- * used by newInstance() for data objects whose type is equal to
- * the type specified by dataObjectType. That is,
- * when newInstance(x) is executued, the specified
- * instantiator will be used if the specified
- * dataObjectType is equal to x.getObjectType().
+ * Register an instantiator for the data object type specified by
+ * dataObjectType. The registered instantiator will be used by
+ * newInstance() for data objects whose type is equal to the type specified
+ * by dataObjectType. That is, when
+ * newInstance(x) is executued, the specified
+ * instantiator will be used if the specified dataObjectType
+ * is equal to
+ * x.getObjectType().
*
- * - * Any object type that does not have an instantiator registered with + *
Any object type that does not have an instantiator registered with * this factory is not supported by the factory. * - *
- * If another instantiator was already registered for the specified + *
If another instantiator was already registered for the specified
* object type, the previous instantiator is replaced and returned.
*
- * @param dataObjectType The data object type for which to register
- * the instantiator specified by instantiator
+ * @param dataObjectType The data object type for which to register the
+ * instantiator specified by instantiator
*
- * @param instantiator The instantiator that will handle data objects
- * of the data object type specified by dataObjectType when
- * newInstance() is called.
+ * @param instantiator The instantiator that will handle data objects of the
+ * data object type specified by dataObjectType when newInstance() is
+ * called.
*
* @pre dataObjectType!= null
*
@@ -227,16 +236,15 @@ public class DomainObjectFactory {
* @see com.arsdigita.persistence.DataObject
* @see DomainObject
*/
- public synchronized static DomainObjectInstantiator
- registerInstantiator(ObjectType dataObjectType,
- DomainObjectInstantiator instantiator)
- {
+ public synchronized static DomainObjectInstantiator registerInstantiator(
+ ObjectType dataObjectType,
+ DomainObjectInstantiator instantiator) {
if (null == dataObjectType) {
throw new InstantiatorRegistryException("null", instantiator);
}
- return (DomainObjectInstantiator)
- s_instantiators.put(dataObjectType, instantiator);
+ return (DomainObjectInstantiator) s_instantiators.put(dataObjectType,
+ instantiator);
}
/**
@@ -244,26 +252,27 @@ public class DomainObjectFactory {
* registerInstantiator(ObjectType, DomainObjectInstantiator).
*
* @param dataObjectType The fully qualified name of the data object type
- * for which to register the specified instantiator.
- * The qualified name is the model name followed by a '.'
- * followed by the object type name (e.g. "com.arsdigita.kernel.Party").
+ * for which to register the specified instantiator. The qualified
+ * name is the model name followed by a '.' followed by the object type name
+ * (e.g. "com.arsdigita.kernel.Party").
*
- * @param instantiator The instantiator that will handle data objects
- * of the type specified by typeName when this newInstance() is
- * called.
+ * @param instantiator The instantiator that will handle data objects of the
+ * type specified by typeName when this newInstance() is called.
*
- * @pre SessionManager.getMetadataRoot().getObjectType(dataObjectType) != null
+ * @pre SessionManager.getMetadataRoot().getObjectType(dataObjectType) !=
+ * null
*
* @return DomainObjectInstantiator The previous instantiator that was
* registered with this factory for this object type.
*
- * @throws InstantiatorRegistryException if the dataObjectType does not exist
+ * @throws InstantiatorRegistryException if the dataObjectType does not
+ * exist
*
* @see #registerInstantiator(ObjectType, DomainObjectInstantiator)
*/
public static DomainObjectInstantiator registerInstantiator(
- String dataObjectType,
- DomainObjectInstantiator instantiator) {
+ String dataObjectType,
+ DomainObjectInstantiator instantiator) {
MetadataRoot meta = SessionManager.getMetadataRoot();
ObjectType objectType = meta.getObjectType(dataObjectType);
@@ -276,21 +285,19 @@ public class DomainObjectFactory {
/**
* Get the registered instantiator for the specified object type.
*
- * @param dataObjectType The data object type whose registered
- * instantiator is to be returned
+ * @param dataObjectType The data object type whose registered instantiator
+ * is to be returned
*
* @return The instantiator that is registered for the specified object
* type.
*
* @see #registerInstantiator(ObjectType,DomainObjectInstantiator)
*/
- public synchronized static DomainObjectInstantiator
- getRegisteredInstantiator(ObjectType dataObjectType)
- {
+ public synchronized static DomainObjectInstantiator getRegisteredInstantiator(
+ ObjectType dataObjectType) {
return (DomainObjectInstantiator) s_instantiators.get(dataObjectType);
}
-
/**
* Wrapper around getRegisteredInstantiator(ObjectType).
*
@@ -298,54 +305,52 @@ public class DomainObjectFactory {
* whose registered instantiator is to be returned
*
* @return The instantiator that is registered for the specified object
- * type. The qualified name is the model name followed by a '.'
- * followed by the object type name (e.g. "com.arsdigita.kernel.Party").
+ * type. The qualified name is the model name followed by a '.' followed by
+ * the object type name (e.g. "com.arsdigita.kernel.Party").
*
* @see #getRegisteredInstantiator(ObjectType)
* @see #registerInstantiator(ObjectType,DomainObjectInstantiator)
*/
- public synchronized static DomainObjectInstantiator
- getRegisteredInstantiator(String dataObjectType)
- {
+ public synchronized static DomainObjectInstantiator getRegisteredInstantiator(
+ String dataObjectType) {
MetadataRoot meta = SessionManager.getMetadataRoot();
return getRegisteredInstantiator(meta.getObjectType(dataObjectType));
}
-
/**
- * Get the registered or inherited instantiator for the specified
- * object type. That is, get the instantiator that is registered
- * for the specified object type or its closest supertype that has
- * a registered instantiator (or null if there is no supertype that
- * has a registered instantiator).
+ * Get the registered or inherited instantiator for the specified object
+ * type. That is, get the instantiator that is registered for the specified
+ * object type or its closest supertype that has a registered instantiator
+ * (or null if there is no supertype that has a registered instantiator).
*
- * @param dataObjectType The data object type whose registered or
- * inherited instantiator is to be returned
+ * @param dataObjectType The data object type whose registered or inherited
+ * instantiator is to be returned
*
- * @return The registered or inherited instantiator for the specified
- * object type.
+ * @return The registered or inherited instantiator for the specified object
+ * type.
*
* @see #registerInstantiator(ObjectType,DomainObjectInstantiator)
*/
- public synchronized static DomainObjectInstantiator
- getInstantiator(ObjectType dataObjectType)
- {
+ public synchronized static DomainObjectInstantiator getInstantiator(
+ ObjectType dataObjectType) {
ObjectType type = dataObjectType;
if (s_log.isDebugEnabled()) {
s_log.debug("Initial type " + (type == null ? null : type.getName()));
}
- while (type!=null && !s_instantiators.containsKey(type)) {
+ while (type != null && !s_instantiators.containsKey(type)) {
type = type.getSupertype();
if (s_log.isDebugEnabled()) {
- s_log.debug("Parent type " + (type == null ? null : type.getName()));
+ s_log.debug("Parent type " + (type == null ? null
+ : type.getName()));
}
}
if (s_log.isDebugEnabled()) {
s_log.debug("Final type " + (type == null ? null : type.getName()));
}
if (type != null) {
- DomainObjectInstantiator instantiator = (DomainObjectInstantiator)
- s_instantiators.get(type);
+ DomainObjectInstantiator instantiator =
+ (DomainObjectInstantiator) s_instantiators.
+ get(type);
if (s_log.isDebugEnabled()) {
s_log.debug("Found instantiator " + instantiator);
}
@@ -361,26 +366,23 @@ public class DomainObjectFactory {
* @param dataObjectType The fully qualified name of the data object type
* whose registered or inherited instantiator is to be returned
*
- * @return The registered or inherited instantiator for the specified
- * object type. The qualified name is the model name followed by a '.'
- * followed by the object type name (e.g. "com.arsdigita.kernel.Party").
+ * @return The registered or inherited instantiator for the specified object
+ * type. The qualified name is the model name followed by a '.' followed by
+ * the object type name (e.g. "com.arsdigita.kernel.Party").
*
* @see #getInstantiator(ObjectType)
* @see #registerInstantiator(ObjectType,DomainObjectInstantiator)
*/
- public synchronized static DomainObjectInstantiator
- getInstantiator(String dataObjectType)
- {
+ public synchronized static DomainObjectInstantiator getInstantiator(
+ String dataObjectType) {
MetadataRoot meta = SessionManager.getMetadataRoot();
return getInstantiator(meta.getObjectType(dataObjectType));
}
/**
- * Package scope method for clearing the factory of registered instantiators.
- *
- * It is ONLY for use by Domain TestCases. - *
- * If you use this method outside that context, YOU WILL BE FLOGGED!! + * Package scope method for clearing the factory of registered + * instantiators.
It is ONLY for use by Domain TestCases.
If you use + * this method outside that context, YOU WILL BE FLOGGED!! */ static synchronized void resetFactory() { s_instantiators = new HashMap();