Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java (working copy) @@ -349,18 +349,17 @@ { throw new FailedToStorePortletDefinitionException("Cannot clone to portlet named " + newPortletName + ", name already exists"); } + + // create new portlet in source portlet application + PortletDefinition copy = source.getApplication().addPortlet(newPortletName); - PortletDefinitionImpl copy = new PortletDefinitionImpl(); + // First set display name - // First set the name and display name - - copy.setPortletName(newPortletName); DisplayName displayName = copy.addDisplayName(JetspeedLocale.getDefaultLocale().getLanguage()); displayName.setDisplayName(newPortletName); // And, then, copy all attributes - copy.setApplication(source.getApplication()); copy.setPortletClass(source.getPortletClass()); copy.setResourceBundle(source.getResourceBundle()); copy.setPreferenceValidatorClassname(source.getPreferenceValidatorClassname()); @@ -451,7 +450,6 @@ copy.getSupportedPublicRenderParameters().addAll(source.getSupportedPublicRenderParameters()); //savePortletDefinition(copy); - source.getApplication().getPortlets().add(copy); try { updatePortletApplication(source.getApplication()); Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java (working copy) @@ -16,9 +16,10 @@ */ package org.apache.jetspeed.components.portletpreferences; -import java.util.ArrayList; import java.util.Collection; +import org.apache.jetspeed.util.ojb.CollectionUtils; + /** *

* The database representation of a preference object @@ -117,11 +118,12 @@ return id; } + @SuppressWarnings("unchecked") public Collection getPreferenceValues() { if (values == null) { - values = new ArrayList(); + values = CollectionUtils.createCollection(); } return values; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserDataConstraintImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserDataConstraintImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserDataConstraintImpl.java (working copy) @@ -18,13 +18,13 @@ package org.apache.jetspeed.om.portlet.impl; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.apache.jetspeed.om.portlet.Description; import org.apache.jetspeed.om.portlet.UserDataConstraint; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -40,11 +40,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ContainerRuntimeOptionImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ContainerRuntimeOptionImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ContainerRuntimeOptionImpl.java (working copy) @@ -23,6 +23,7 @@ import org.apache.jetspeed.om.portlet.ContainerRuntimeOption; import org.apache.jetspeed.om.portlet.ContainerRuntimeOptionValue; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -53,12 +54,13 @@ { this.name = name; } - + + @SuppressWarnings("unchecked") public void addValue(String value) { if (values == null) { - values = new ArrayList(); + values = CollectionUtils.createList(); } for (ContainerRuntimeOptionValue param : this.values) { @@ -70,11 +72,12 @@ values.add(new ContainerRuntimeOptionValueImpl(value)); } + @SuppressWarnings("unchecked") public List getValues() { if (values == null) { - values = new ArrayList(); + values = CollectionUtils.createList(); } List vals = new ArrayList(); for (ContainerRuntimeOptionValue v : this.values) Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PublicRenderParameterImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PublicRenderParameterImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PublicRenderParameterImpl.java (working copy) @@ -28,6 +28,7 @@ import org.apache.jetspeed.om.portlet.PortletQName; import org.apache.jetspeed.om.portlet.PublicRenderParameter; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -160,11 +161,12 @@ return result; } + @SuppressWarnings("unchecked") public void addAlias(QName alias) { if (aliases == null) { - aliases = new ArrayList(); + aliases = CollectionUtils.createList(); } if (!containsAlias(alias)) { @@ -188,11 +190,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterImpl.java (working copy) @@ -30,6 +30,7 @@ import org.apache.jetspeed.om.portlet.FilterLifecycle; import org.apache.jetspeed.om.portlet.InitParam; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -49,12 +50,13 @@ { return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } - + + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } @@ -78,11 +80,12 @@ return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale); } + @SuppressWarnings("unchecked") public List getDisplayNames() { if (displayNames == null) { - displayNames = new ArrayList(); + displayNames = CollectionUtils.createList(); } return displayNames; } @@ -121,11 +124,12 @@ filterClass = value; } + @SuppressWarnings("unchecked") public List getLifecycles() { if (lifecycles == null) { - lifecycles = new ArrayList(); + lifecycles = CollectionUtils.createList(); } List result = new ArrayList(); for (FilterLifecycle flc : lifecycles) @@ -135,11 +139,12 @@ return result; } + @SuppressWarnings("unchecked") public void addLifecycle(String name) { if (lifecycles == null) { - lifecycles = new ArrayList(); + lifecycles = CollectionUtils.createList(); } for (FilterLifecycle flc : this.lifecycles) { @@ -163,11 +168,12 @@ return null; } + @SuppressWarnings("unchecked") public List getInitParams() { if (initParams == null) { - initParams = new ArrayList(); + initParams = CollectionUtils.createList(); } return initParams; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleRefImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleRefImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleRefImpl.java (working copy) @@ -17,7 +17,6 @@ package org.apache.jetspeed.om.portlet.impl; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -25,6 +24,7 @@ import org.apache.jetspeed.om.portlet.SecurityRoleRef; import org.apache.jetspeed.util.HashCodeBuilder; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @@ -89,12 +89,13 @@ { return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } - + + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomPortletModeImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomPortletModeImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomPortletModeImpl.java (working copy) @@ -16,7 +16,6 @@ */ package org.apache.jetspeed.om.portlet.impl; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -25,6 +24,7 @@ import org.apache.jetspeed.om.portlet.CustomPortletMode; import org.apache.jetspeed.om.portlet.Description; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; public class CustomPortletModeImpl implements CustomPortletMode { @@ -97,11 +97,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/EventDefinitionImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/EventDefinitionImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/EventDefinitionImpl.java (working copy) @@ -28,6 +28,7 @@ import org.apache.jetspeed.om.portlet.EventDefinition; import org.apache.jetspeed.om.portlet.PortletQName; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -57,11 +58,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } @@ -131,12 +133,13 @@ } return result; } - + + @SuppressWarnings("unchecked") public void addAlias(QName alias) { if (aliases == null) { - aliases = new ArrayList(); + aliases = CollectionUtils.createList(); } if (!containsAlias(alias)) { Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeRefImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeRefImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeRefImpl.java (working copy) @@ -16,7 +16,6 @@ */ package org.apache.jetspeed.om.portlet.impl; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -24,6 +23,7 @@ import org.apache.jetspeed.om.portlet.UserAttribute; import org.apache.jetspeed.om.portlet.UserAttributeRef; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** *

User attribute ref implementation.

@@ -89,12 +89,13 @@ { return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } - + + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/UserAttributeImpl.java (working copy) @@ -16,13 +16,13 @@ */ package org.apache.jetspeed.om.portlet.impl; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.apache.jetspeed.om.portlet.Description; import org.apache.jetspeed.om.portlet.UserAttribute; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** *

User attribute implementation.

@@ -53,11 +53,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityConstraintImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityConstraintImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityConstraintImpl.java (working copy) @@ -28,6 +28,7 @@ import org.apache.jetspeed.om.portlet.SecurityConstraint; import org.apache.jetspeed.om.portlet.UserDataConstraint; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -44,11 +45,12 @@ return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale); } + @SuppressWarnings("unchecked") public List getDisplayNames() { if (displayNames == null) { - displayNames = new ArrayList(); + displayNames = CollectionUtils.createList(); } return displayNames; } @@ -67,11 +69,12 @@ return d; } + @SuppressWarnings("unchecked") public List getPortletNames() { if (portletNames == null) { - portletNames = new ArrayList(); + portletNames = CollectionUtils.createList(); } List result = new ArrayList(); for (SecuredPortlet sp : portletNames) @@ -81,11 +84,12 @@ return result; } + @SuppressWarnings("unchecked") public void addPortletName(String portletName) { if (portletNames == null) { - portletNames = new ArrayList(); + portletNames = CollectionUtils.createList(); } for (SecuredPortlet sp : portletNames) { Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InitParamImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InitParamImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InitParamImpl.java (working copy) @@ -18,7 +18,6 @@ package org.apache.jetspeed.om.portlet.impl; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -26,8 +25,8 @@ import org.apache.jetspeed.om.portlet.InitParam; import org.apache.jetspeed.util.HashCodeBuilder; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; - /** * @author Scott T. Weaver */ @@ -90,12 +89,13 @@ { return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } - + + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ListenerImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ListenerImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/ListenerImpl.java (working copy) @@ -18,7 +18,6 @@ package org.apache.jetspeed.om.portlet.impl; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -28,6 +27,7 @@ import org.apache.jetspeed.om.portlet.DisplayName; import org.apache.jetspeed.om.portlet.Listener; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -56,11 +56,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } @@ -84,11 +85,12 @@ return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale); } + @SuppressWarnings("unchecked") public List getDisplayNames() { if (displayNames == null) { - displayNames = new ArrayList(); + displayNames = CollectionUtils.createList(); } return displayNames; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (working copy) @@ -53,6 +53,7 @@ import org.apache.jetspeed.om.portlet.UserAttribute; import org.apache.jetspeed.om.portlet.UserAttributeRef; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.PersistenceBrokerAware; import org.apache.ojb.broker.PersistenceBrokerException; @@ -107,7 +108,7 @@ private List containerRuntimeOptions; private List userAttributeRefs; - private List services = new ArrayList(); + private List services; private List localeEncodingMappingList; @@ -249,11 +250,12 @@ /** * @see org.apache.jetspeed.om.portlet.PortletApplication#getMetadata() */ + @SuppressWarnings("unchecked") public GenericMetadata getMetadata() { if(metadataFields == null) { - metadataFields = new ArrayList(); + metadataFields = CollectionUtils.createCollection(); } GenericMetadata metadata = new PortletApplicationMetadataImpl(); @@ -267,11 +269,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } @@ -295,11 +298,12 @@ return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale); } + @SuppressWarnings("unchecked") public List getDisplayNames() { if (displayNames == null) { - displayNames = new ArrayList(); + displayNames = CollectionUtils.createList(); } return displayNames; } @@ -318,11 +322,12 @@ return d; } + @SuppressWarnings("unchecked") public List getSecurityRoles() { if (roles == null) { - roles = new ArrayList(); + roles = CollectionUtils.createList(); } return roles; } @@ -354,11 +359,12 @@ return null; } + @SuppressWarnings("unchecked") public List getPortlets() { if (portlets == null) { - portlets = new ArrayList(); + portlets = CollectionUtils.createList(); } return portlets; } @@ -376,11 +382,12 @@ return portlet; } + @SuppressWarnings("unchecked") public List getEventDefinitions() { if (eventDefinitions == null) { - eventDefinitions = new ArrayList(); + eventDefinitions = CollectionUtils.createList(); } return eventDefinitions; } @@ -418,11 +425,12 @@ return null; } + @SuppressWarnings("unchecked") public List getPublicRenderParameters() { if (publicRenderParameters == null) { - publicRenderParameters = new ArrayList(); + publicRenderParameters = CollectionUtils.createList(); } return publicRenderParameters; } @@ -492,11 +500,12 @@ } } + @SuppressWarnings("unchecked") public List getCustomPortletModes() { if (customPortletModes == null) { - customPortletModes = new ArrayList(); + customPortletModes = CollectionUtils.createList(); } return customPortletModes; } @@ -546,11 +555,12 @@ return null; } + @SuppressWarnings("unchecked") public List getCustomWindowStates() { if (customWindowStates == null) { - customWindowStates = new ArrayList(); + customWindowStates = CollectionUtils.createList(); } return customWindowStates; } @@ -655,11 +665,12 @@ return null; } + @SuppressWarnings("unchecked") public List getUserAttributes() { if (userAttributes == null) { - userAttributes = new ArrayList(); + userAttributes = CollectionUtils.createList(); } return userAttributes; } @@ -688,11 +699,12 @@ return null; } + @SuppressWarnings("unchecked") public List getUserAttributeRefs() { if (userAttributeRefs == null) { - userAttributeRefs = new ArrayList(); + userAttributeRefs = CollectionUtils.createList(); } return userAttributeRefs; } @@ -709,11 +721,12 @@ return uar; } + @SuppressWarnings("unchecked") public List getSecurityConstraints() { if (securityConstraints == null) { - securityConstraints = new ArrayList(); + securityConstraints = CollectionUtils.createList(); } return securityConstraints; } @@ -774,11 +787,12 @@ return null; } + @SuppressWarnings("unchecked") public List getFilters() { if (filters == null) { - filters = new ArrayList(); + filters = CollectionUtils.createList(); } return filters; } @@ -807,11 +821,12 @@ return null; } + @SuppressWarnings("unchecked") public List getFilterMappings() { if (filterMappings == null) { - filterMappings = new ArrayList(); + filterMappings = CollectionUtils.createList(); } return filterMappings; } @@ -828,11 +843,12 @@ return fm; } + @SuppressWarnings("unchecked") public List getListeners() { if (listeners == null) { - listeners = new ArrayList(); + listeners = CollectionUtils.createList(); } return listeners; } @@ -864,11 +880,12 @@ return null; } + @SuppressWarnings("unchecked") public List getContainerRuntimeOptions() { if (containerRuntimeOptions == null) { - containerRuntimeOptions = new ArrayList(); + containerRuntimeOptions = CollectionUtils.createList(); } return containerRuntimeOptions; } @@ -905,20 +922,22 @@ return localeEncodingMappings; } + @SuppressWarnings("unchecked") public void addLocaleEncodingMapping(Locale locale, String encoding) { if (localeEncodingMappingList == null) { - localeEncodingMappingList = new ArrayList(); + localeEncodingMappingList = CollectionUtils.createList(); } localeEncodingMappingList.add(new LocaleEncodingMappingImpl(locale, encoding)); } + @SuppressWarnings("unchecked") public List getJetspeedServices() { if (services == null) { - this.services = new ArrayList(); + this.services = CollectionUtils.createList(); } return services; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/SecurityRoleImpl.java (working copy) @@ -16,13 +16,13 @@ */ package org.apache.jetspeed.om.portlet.impl; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.apache.jetspeed.om.portlet.Description; import org.apache.jetspeed.om.portlet.SecurityRole; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @@ -51,12 +51,13 @@ { return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } - + + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterMappingImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterMappingImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FilterMappingImpl.java (working copy) @@ -23,6 +23,7 @@ import org.apache.jetspeed.om.portlet.FilterMapping; import org.apache.jetspeed.om.portlet.FilteredPortlet; +import org.apache.jetspeed.util.ojb.CollectionUtils; /** * @version $Id$ @@ -43,11 +44,12 @@ filterName = value; } + @SuppressWarnings("unchecked") public List getPortletNames() { if (portletNames == null) { - portletNames = new ArrayList(); + portletNames = CollectionUtils.createList(); } List result = new ArrayList(); for (FilteredPortlet fp : portletNames) @@ -57,11 +59,12 @@ return result; } + @SuppressWarnings("unchecked") public void addPortletName(String name) { if (portletNames == null) { - portletNames = new ArrayList(); + portletNames = CollectionUtils.createList(); } for (FilteredPortlet fp : this.portletNames) { Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java (working copy) @@ -46,6 +46,7 @@ import org.apache.jetspeed.om.portlet.Supports; import org.apache.jetspeed.util.HashCodeBuilder; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.PersistenceBrokerAware; import org.apache.ojb.broker.PersistenceBrokerException; @@ -209,21 +210,23 @@ return lang; } + @SuppressWarnings("unchecked") public List getLanguages() { if ( languages == null ) { - languages = new ArrayList(); + languages = CollectionUtils.createList(); } return languages; } + @SuppressWarnings("unchecked") public Language addLanguage(Locale locale) { // ensure languages exist if ( languages == null ) { - languages = new ArrayList(); + languages = CollectionUtils.createList(); } for (Language l : languages) @@ -285,11 +288,12 @@ preferenceValidatorClassname = string; } + @SuppressWarnings("unchecked") public GenericMetadata getMetadata() { if (metadataFields == null) { - metadataFields = new ArrayList(); + metadataFields = CollectionUtils.createCollection(); } GenericMetadata metadata = new PortletDefinitionMetadataImpl(); @@ -426,11 +430,12 @@ return null; } + @SuppressWarnings("unchecked") public List getContainerRuntimeOptions() { if (containerRuntimeOptions == null) { - containerRuntimeOptions = new ArrayList(); + containerRuntimeOptions = CollectionUtils.createList(); } return containerRuntimeOptions; } @@ -458,11 +463,12 @@ return null; } + @SuppressWarnings("unchecked") public List getSecurityRoleRefs() { if (securityRoleRefs == null) { - securityRoleRefs = new ArrayList(); + securityRoleRefs = CollectionUtils.createList(); } return securityRoleRefs; } @@ -496,11 +502,12 @@ return null; } + @SuppressWarnings("unchecked") public List getSupports() { if (supports == null) { - supports = new ArrayList(); + supports = CollectionUtils.createList(); } return supports; } @@ -536,11 +543,12 @@ // noop: use addLanguage(Locale) instead } + @SuppressWarnings("unchecked") public List getSupportedPublicRenderParameters() { if (supportedPublicRenderParameters == null) { - supportedPublicRenderParameters = new ArrayList(); + supportedPublicRenderParameters = CollectionUtils.createList(); } List params = new ArrayList(); for (SupportedPublicRenderParameter param : this.supportedPublicRenderParameters) @@ -550,11 +558,12 @@ return params; } + @SuppressWarnings("unchecked") public void addSupportedPublicRenderParameter(String identifier) { if (supportedPublicRenderParameters == null) { - supportedPublicRenderParameters = new ArrayList(); + supportedPublicRenderParameters = CollectionUtils.createList(); } for (SupportedPublicRenderParameter param : this.supportedPublicRenderParameters) { @@ -596,11 +605,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } @@ -625,11 +635,12 @@ return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale); } + @SuppressWarnings("unchecked") public List getDisplayNames() { if (displayNames == null) { - displayNames = new ArrayList(); + displayNames = CollectionUtils.createList(); } return displayNames; } @@ -660,11 +671,12 @@ return null; } + @SuppressWarnings("unchecked") public List getInitParams() { if (initParams == null) { - initParams = new ArrayList(); + initParams = CollectionUtils.createList(); } return initParams; } @@ -681,11 +693,12 @@ return param; } + @SuppressWarnings("unchecked") public List getSupportedProcessingEvents() { if (supportedProcessingEvents == null) { - supportedProcessingEvents = new ArrayList(); + supportedProcessingEvents = CollectionUtils.createList(); } return supportedProcessingEvents; } @@ -711,11 +724,12 @@ return this.addSupportedProcessingEvent(qname); } + @SuppressWarnings("unchecked") public List getSupportedPublishingEvents() { if (supportedPublishingEvents == null) { - supportedPublishingEvents = new ArrayList(); + supportedPublishingEvents = CollectionUtils.createList(); } return supportedPublishingEvents; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomWindowStateImpl.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomWindowStateImpl.java (revision 775409) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/CustomWindowStateImpl.java (working copy) @@ -16,7 +16,6 @@ */ package org.apache.jetspeed.om.portlet.impl; -import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -25,6 +24,7 @@ import org.apache.jetspeed.om.portlet.CustomWindowState; import org.apache.jetspeed.om.portlet.Description; import org.apache.jetspeed.util.JetspeedLocale; +import org.apache.jetspeed.util.ojb.CollectionUtils; public class CustomWindowStateImpl implements CustomWindowState { @@ -97,11 +97,12 @@ return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale); } + @SuppressWarnings("unchecked") public List getDescriptions() { if (descriptions == null) { - descriptions = new ArrayList(); + descriptions = CollectionUtils.createList(); } return descriptions; } Index: components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionUtils.java =================================================================== --- components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionUtils.java (revision 0) +++ components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionUtils.java (revision 0) @@ -0,0 +1,346 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jetspeed.util.ojb; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +import org.apache.ojb.broker.ManageableCollection; +import org.apache.ojb.broker.PersistenceBroker; +import org.apache.ojb.broker.PersistenceBrokerException; +import org.apache.ojb.broker.util.collections.IRemovalAwareCollection; +import org.apache.ojb.broker.util.collections.RemovalAwareCollection; +import org.apache.ojb.broker.util.collections.RemovalAwareList; + +/** + * CollectionUtils + * + * @author David Sean Taylor + * @version $Id: $ + */ +public class CollectionUtils +{ + /** + * OJB 1.0.3 requires collections to be removal aware. + * Thus we can't seem to get away with just creating ArrayLists + * This issue on occurs when persisting newly create object collections + * When persisting objects retrieved with OJB, this issue does not occur + * + * @see JS2-590 + * @return + */ + + @SuppressWarnings("unchecked") + public static final Collection createCollection() + { + // highly concurrent applications will require using + // createSynchronizedCollection() here instead of this OJB + // native type which is not synchronized. + return new RemovalAwareCollection(); + } + + /** + * Synchronized OJB removal aware collection. + */ + @SuppressWarnings("unchecked") + public static class SynchronizedRemovalAwareCollection implements Collection, ManageableCollection, IRemovalAwareCollection + { + private static final long serialVersionUID = 1L; + + private RemovalAwareCollection collection = new RemovalAwareCollection(); + + public synchronized boolean add(Object e) + { + return collection.add(e); + } + + public synchronized boolean addAll(Collection c) + { + return collection.addAll(c); + } + + public synchronized void clear() + { + collection.clear(); + } + + public synchronized boolean contains(Object o) + { + return collection.contains(o); + } + + public synchronized boolean containsAll(Collection c) + { + return collection.containsAll(c); + } + + public synchronized boolean isEmpty() + { + return collection.isEmpty(); + } + + public synchronized Iterator iterator() + { + return collection.iterator(); + } + + public synchronized boolean remove(Object o) + { + return collection.remove(o); + } + + public synchronized boolean removeAll(Collection c) + { + return collection.removeAll(c); + } + + public synchronized boolean retainAll(Collection c) + { + return collection.retainAll(c); + } + + public synchronized int size() + { + return collection.size(); + } + + public synchronized Object[] toArray() + { + return collection.toArray(); + } + + public synchronized Object[] toArray(Object[] a) + { + return collection.toArray(a); + } + + public synchronized void afterStore(PersistenceBroker broker) throws PersistenceBrokerException + { + collection.afterStore(broker); + } + + public synchronized void ojbAdd(Object anObject) + { + collection.ojbAdd(anObject); + } + + public synchronized void ojbAddAll(ManageableCollection otherCollection) + { + collection.ojbAddAll(otherCollection); + } + + public synchronized Iterator ojbIterator() + { + return collection.ojbIterator(); + } + } + + @SuppressWarnings("unchecked") + public static final Collection createSynchronizedCollection() + { + // if OJB collections are to be synchronized, collection-class + // attributes for collection-descriptor need to be set in the + // OJB mappings to ensure that collections are synchronized + // when read from the database, (unsynchronized removal aware + // collections are the default): + // + // + // + // here, return synchronized manageable/removal aware + // collection; note that simply wrapping a RemovalAwareCollection + // using Collections.synchronizedCollection() will not work since + // OJB collections that are removal aware must implement the + // ManageableCollection, IRemovalAwareCollection interfaces. + return new SynchronizedRemovalAwareCollection(); + } + + @SuppressWarnings("unchecked") + public static final List createList() + { + // highly concurrent applications will require using + // createSynchronizedList() here instead of this OJB + // native type which is not synchronized. + return new RemovalAwareList(); + } + + /** + * Synchronized OJB removal aware list. + */ + @SuppressWarnings("unchecked") + public static class SynchronizedRemovalAwareList implements List, ManageableCollection, IRemovalAwareCollection + { + private static final long serialVersionUID = 1L; + + private RemovalAwareList list = new RemovalAwareList(); + + public synchronized void add(int index, Object element) + { + list.add(index, element); + } + + public synchronized boolean add(Object e) + { + return list.add(e); + } + + public synchronized boolean addAll(Collection c) + { + return list.addAll(c); + } + + public synchronized boolean addAll(int index, Collection c) + { + return list.addAll(index, c); + } + + public synchronized void clear() + { + list.clear(); + } + + public synchronized boolean contains(Object o) + { + return list.contains(o); + } + + public synchronized boolean containsAll(Collection c) + { + return list.containsAll(c); + } + + public synchronized Object get(int index) + { + return list.get(index); + } + + public synchronized int indexOf(Object o) + { + return list.indexOf(o); + } + + public synchronized boolean isEmpty() + { + return list.isEmpty(); + } + + public synchronized Iterator iterator() + { + return list.iterator(); + } + + public synchronized int lastIndexOf(Object o) + { + return list.lastIndexOf(o); + } + + public synchronized ListIterator listIterator() + { + return list.listIterator(); + } + + public synchronized ListIterator listIterator(int index) + { + return list.listIterator(index); + } + + public synchronized Object remove(int index) + { + return list.remove(index); + } + + public synchronized boolean remove(Object o) + { + return list.remove(o); + } + + public synchronized boolean removeAll(Collection c) + { + return list.removeAll(c); + } + + public synchronized boolean retainAll(Collection c) + { + return list.retainAll(c); + } + + public synchronized Object set(int index, Object element) + { + return list.set(index, element); + } + + public synchronized int size() + { + return list.size(); + } + + public synchronized List subList(int fromIndex, int toIndex) + { + return list.subList(fromIndex, toIndex); + } + + public synchronized Object[] toArray() + { + return list.toArray(); + } + + public synchronized Object[] toArray(Object[] a) + { + return list.toArray(a); + } + + public synchronized void afterStore(PersistenceBroker broker) throws PersistenceBrokerException + { + list.afterStore(broker); + } + + public synchronized void ojbAdd(Object anObject) + { + list.ojbAdd(anObject); + } + + public synchronized void ojbAddAll(ManageableCollection otherCollection) + { + list.ojbAddAll(otherCollection); + } + + public synchronized Iterator ojbIterator() + { + return list.ojbIterator(); + } + } + + @SuppressWarnings("unchecked") + public static final List createSynchronizedList() + { + // if OJB lists are to be synchronized, collection-class + // attributes for collection-descriptor need to be set in the + // OJB mappings to ensure that lists are synchronized when + // read from the database, (unsynchronized removal aware + // lists are the default): + // + // + // + // here, return synchronized manageable/removal aware list; + // note that simply wrapping a RemovalAwareList using + // Collections.synchronizedList() will not work since + // OJB lists that are removal aware must implement the + // ManageableCollection, IRemovalAwareCollection interfaces. + return new SynchronizedRemovalAwareList(); + } +}