portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletregistry PortletRegistryComponentImpl.java
Date Thu, 18 Mar 2004 06:08:04 GMT
dlestrat    2004/03/17 22:08:04

  Modified:    components/registry/src/java/org/apache/jetspeed/components/portletregistry
                        PortletRegistryComponentImpl.java
  Log:
  Changes made to registry to migrate to OJB RC5.
  
  Revision  Changes    Path
  1.3       +76 -12    jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistryComponentImpl.java
  
  Index: PortletRegistryComponentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistryComponentImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortletRegistryComponentImpl.java	15 Mar 2004 19:34:29 -0000	1.2
  +++ PortletRegistryComponentImpl.java	18 Mar 2004 06:08:04 -0000	1.3
  @@ -37,6 +37,15 @@
   import org.apache.pluto.om.common.ObjectID;
   import org.apache.pluto.om.portlet.PortletApplicationDefinition;
   
  +import org.apache.jetspeed.om.impl.PortletDisplayNameImpl;
  +import org.apache.jetspeed.om.portlet.impl.PortletDefinitionLocalizedFieldImpl;
  +import org.apache.jetspeed.om.impl.LanguageImpl;
  +import org.apache.jetspeed.om.portlet.impl.ContentTypeImpl;
  +import org.apache.jetspeed.om.impl.PortletInitParameterImpl;
  +import org.apache.jetspeed.om.preference.impl.DefaultPreferenceImpl;
  +import org.apache.jetspeed.om.impl.SecurityRoleRefImpl;
  +import org.apache.jetspeed.om.impl.PortletDescriptionImpl;
  +
   /**
    * <p>
    * PortletRegistryComponentImpl
  @@ -73,7 +82,6 @@
       private Class portletDefClass;
       private Class portletAppClass;
   
  -
       /**
        *  
        */
  @@ -105,7 +113,7 @@
        *         RegistryException
        */
       public Language createLanguage(Locale locale, String title, String shortTitle, String
description, Collection keywords)
  -    throws RegistryException
  +        throws RegistryException
       {
           try
           {
  @@ -243,7 +251,8 @@
           {
               if (portlet.getPortletApplicationDefinition() == null)
               {
  -                final String msg = "getPortletDefinitionByIdentifier() returned a PortletDefinition
that has no parent PortletApplication.";
  +                final String msg =
  +                    "getPortletDefinitionByIdentifier() returned a PortletDefinition that
has no parent PortletApplication.";
                   log.error(msg);
                   throw new IllegalStateException(msg);
               }
  @@ -274,7 +283,7 @@
           if (split < 1)
           {
               throw new IllegalArgumentException(
  -            "The unique portlet name, \"" + name + "\";  is not well formed.  No \"::\"
delimiter was found.");
  +                "The unique portlet name, \"" + name + "\";  is not well formed.  No \"::\"
delimiter was found.");
           }
           String appName = name.substring(0, split);
           String portletName = name.substring((split + 2), name.length());
  @@ -289,9 +298,18 @@
           {
               if (portlet.getPortletApplicationDefinition() == null)
               {
  -                final String msg = "getPortletDefinitionByUniqueName() returned a PortletDefinition
that has no parent PortletApplication.";
  -                log.error(msg);
  -                throw new IllegalStateException(msg);
  +                filter = store.newFilter();
  +                filter.addEqualTo("name", appName);
  +                query = store.newQuery(portletAppClass, filter);
  +                MutablePortletApplication app = (MutablePortletApplication) store.getObjectByQuery(query);
  +                if (null == app)
  +                {
  +                    final String msg =
  +                        "getPortletDefinitionByUniqueName() returned a PortletDefinition
that has no parent PortletApplication.";
  +                    log.error(msg);
  +                    throw new IllegalStateException(msg);
  +                }
  +                portlet.setPortletApplicationDefinition(app);
               }
               return getStoreableInstance(portlet);
           }
  @@ -382,17 +400,63 @@
       {
           PersistenceStore store = getPersistenceStore();
           prepareTransaction(store);
  +
  +        Filter filter = store.newFilter();
           try
           {
               Iterator portlets = app.getPortletDefinitionList().iterator();
               while (portlets.hasNext())
               {
  -                // portlets are getting cascade deleted but
  -                // content type and langs asocciated are not
  -                store.deletePersistent(portlets.next());
  +                PortletDefinitionImpl curPortlet = (PortletDefinitionImpl) portlets.next();
  +
  +                filter.addEqualTo("parentId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(PortletDefinitionLocalizedFieldImpl.class,
filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("parentId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(PortletDisplayNameImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("portletId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(LanguageImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("portletId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(ContentTypeImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("parentId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(PortletInitParameterImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("parentId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(DefaultPreferenceImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("portletId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(SecurityRoleRefImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("parentId", curPortlet.getId());
  +                store.deleteAll(store.newQuery(PortletDescriptionImpl.class, filter));
  +                store.getTransaction().checkpoint();
  +
  +                filter = store.newFilter();
  +                filter.addEqualTo("id", curPortlet.getId());
  +                store.deleteAll(store.newQuery(PortletDefinitionImpl.class, filter));
  +                store.getTransaction().checkpoint();
               }
  -            store.deletePersistent(app);            
  -            store.getTransaction().checkpoint();            
  +            filter = store.newFilter();
  +            filter.addEqualTo("id", app.getId());
  +            store.deleteAll(store.newQuery(MutablePortletApplication.class, filter));
  +            store.getTransaction().checkpoint();
           }
           catch (LockFailedException e)
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message