cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r365336 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: layout/impl/ pluto/servlet/ profile/impl/
Date Mon, 02 Jan 2006 12:15:32 GMT
Author: cziegeler
Date: Mon Jan  2 04:15:23 2006
New Revision: 365336

URL: http://svn.apache.org/viewcvs?rev=365336&view=rev
Log:
Fix bug in layout creation; add new simple test profile manager for testing jsr 168 portlets

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
  (with props)
Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletResponseImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java?rev=365336&r1=365335&r2=365336&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
Mon Jan  2 04:15:23 2006
@@ -243,8 +243,8 @@
         Layout layout = null;
         try {
             Class clazz = ClassUtils.loadClass( layoutDescription.getClassName() );
-            Constructor constructor = clazz.getConstructor(new Class[] {String.class});
-            layout = (Layout)constructor.newInstance(new Object[] {id});
+            Constructor constructor = clazz.getConstructor(new Class[] {String.class, String.class});
+            layout = (Layout)constructor.newInstance(new Object[] {id, layoutName});
         } catch (Exception e) {
             throw new LayoutException("Unable to create new layout instance for: " + layoutDescription
, e );
         }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletResponseImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletResponseImpl.java?rev=365336&r1=365335&r2=365336&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletResponseImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletResponseImpl.java
Mon Jan  2 04:15:23 2006
@@ -100,7 +100,7 @@
     }
 
     /**
-     * @see javax.servlet.http.HttpServletResponse#redirect(java.lang.String)
+     * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
      */
     public void sendRedirect(String arg0) throws IOException {
         this.redirectURL = arg0;

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=365336&r1=365335&r2=365336&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Mon Jan  2 04:15:23 2006
@@ -143,7 +143,7 @@
                         if ( cid.getCopletData() != null ) {
                             // now invoke login on each instance
                             CopletAdapter adapter;
-                            adapter = this.portalService.getComponentManager().getCopletAdapter(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
+                            adapter = this.portalService.getComponentManager().getCopletAdapter(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
                           
                             adapter.login( cid );
                         }
                     }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=365336&r1=365335&r2=365336&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Mon Jan  2 04:15:23 2006
@@ -31,6 +31,7 @@
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.portal.PortalRuntimeException;
@@ -106,6 +107,9 @@
     /** The parameters for the profile configuration. */
     protected Parameters parameters;
 
+    /** The profiler loader/saver. */
+    protected ProfileLS loader;
+
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
@@ -121,6 +125,25 @@
         this.parameters = params;
     }
 
+    /**
+     * @see org.apache.cocoon.portal.impl.AbstractComponent#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.loader);
+            this.loader = null;
+        }
+        super.dispose();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.impl.AbstractComponent#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        super.service(manager);
+        this.loader = (ProfileLS)this.manager.lookup(ProfileLS.ROLE);
+    }
+
     protected ProfileImpl getUserProfile(String layoutKey) {
         if ( layoutKey == null ) {
             layoutKey = this.portalService.getDefaultLayoutKey();
@@ -324,43 +347,34 @@
     protected Profile loadProfile(final String layoutKey) 
     throws Exception {
         final PortalUser info = (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
-        ProfileLS loader = null;
-        try {
-            loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
-            final ProfileImpl profile = new ProfileImpl(layoutKey);
+        final ProfileImpl profile = new ProfileImpl(layoutKey);
 
-            // first "load" the global data
-            profile.setCopletBaseDatas( this.getGlobalBaseDatas(loader, layoutKey) );
-            profile.setCopletDatas( this.getGlobalDatas(loader, info, profile, layoutKey)
);
-
-            // now load the user/group specific data
-            if ( !this.getCopletInstanceDatas(loader, profile, info, CATEGORY_USER, layoutKey)
) {
-                if ( info.getGroup() == null || !this.getCopletInstanceDatas(loader, profile,
info, CATEGORY_GROUP, layoutKey)) {
-                    if ( !this.getCopletInstanceDatas(loader, profile, info, CATEGORY_GLOBAL,
layoutKey) ) {
-                        throw new ProcessingException("No profile for copletinstancedatas
found.");
-                    }
+        // first "load" the global data
+        profile.setCopletBaseDatas( this.getGlobalBaseDatas(layoutKey) );
+        profile.setCopletDatas( this.getGlobalDatas(info, profile, layoutKey) );
+
+        // now load the user/group specific data
+        if ( !this.getCopletInstanceDatas(profile, info, CATEGORY_USER, layoutKey) ) {
+            if ( info.getGroup() == null || !this.getCopletInstanceDatas(profile, info, CATEGORY_GROUP,
layoutKey)) {
+                if ( !this.getCopletInstanceDatas(profile, info, CATEGORY_GLOBAL, layoutKey)
) {
+                    throw new ProcessingException("No profile for copletinstancedatas found.");
                 }
             }
+        }
 
-            if ( !this.getLayout(loader, profile, info, CATEGORY_USER, layoutKey) ) {
-                if ( info.getGroup() == null || !this.getLayout(loader, profile, info, CATEGORY_GROUP,
layoutKey)) {
-                    if ( !this.getLayout(loader, profile, info, CATEGORY_GLOBAL, layoutKey)
) {
-                        throw new ProcessingException("No profile for layout found.");
-                    }
+        if ( !this.getLayout(profile, info, CATEGORY_USER, layoutKey) ) {
+            if ( info.getGroup() == null || !this.getLayout(profile, info, CATEGORY_GROUP,
layoutKey)) {
+                if ( !this.getLayout(profile, info, CATEGORY_GLOBAL, layoutKey) ) {
+                    throw new ProcessingException("No profile for layout found.");
                 }
             }
-
-            this.storeUserProfile(layoutKey, profile);
-            return profile;
-        } catch (ServiceException se) {
-            throw new ProfileException("Unable to get component profilels.", se);
-        } finally {
-            this.manager.release( loader );
         }
+
+        this.storeUserProfile(layoutKey, profile);
+        return profile;
     }
 
-    protected Map getGlobalBaseDatas(final ProfileLS  loader,
-                                     final String     layoutKey)
+    protected Map getGlobalBaseDatas(final String     layoutKey)
     throws Exception {
         // if we already have loaded the profile and don't check
         // for changes, just return the profile
@@ -410,8 +424,7 @@
         }
     }
 
-    protected Map getGlobalDatas(final ProfileLS   loader,
-                                 final PortalUser  info,
+    protected Map getGlobalDatas(final PortalUser  info,
                                  final ProfileImpl profile,
                                  final String      layoutKey)
     throws Exception {
@@ -477,8 +490,7 @@
         return false;
     }
 
-    protected boolean getCopletInstanceDatas(final ProfileLS   loader,
-                                             final ProfileImpl profile,
+    protected boolean getCopletInstanceDatas(final ProfileImpl profile,
                                              final PortalUser  info,
                                              final String      category,
                                              final String      layoutKey)
@@ -508,8 +520,7 @@
         }
     }
 
-    protected boolean getLayout(final ProfileLS   loader,
-                                final ProfileImpl profile,
+    protected boolean getLayout(final ProfileImpl profile,
                                 final PortalUser  info,
                                 final String      category,
                                 final String      layoutKey)
@@ -581,9 +592,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstanceDatas(java.lang.String)
      */
     public void saveUserCopletInstanceDatas(String layoutKey) {
-        ProfileLS adapter = null;
         try {
-            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
             if (layoutKey == null) {
                 layoutKey = this.portalService.getDefaultLayoutKey();
             }
@@ -598,12 +607,10 @@
                                           this.getUser(),
                                           false,
                                           layoutKey);
-            adapter.saveProfile(key, parameters, profile.getCopletInstanceDataObjects());
+            this.loader.saveProfile(key, parameters, profile.getCopletInstanceDataObjects());
         } catch (Exception e) {
             // TODO
             throw new ProfileException("Exception during save profile", e);
-        } finally {
-            this.manager.release(adapter);
         }
     }
 
@@ -611,9 +618,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(java.lang.String)
      */
     public void saveUserLayout(String layoutKey) {
-        ProfileLS adapter = null;
         try {
-            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
             if (layoutKey == null) {
                 layoutKey = this.portalService.getDefaultLayoutKey();
             }
@@ -628,12 +633,10 @@
                                           this.getUser(), 
                                           false,
                                           layoutKey);
-            adapter.saveProfile(key, parameters, profile.getRootLayout());
+            this.loader.saveProfile(key, parameters, profile.getRootLayout());
         } catch (Exception e) {
             // TODO
             throw new ProfileException("Exception during save profile", e);
-        } finally {
-            this.manager.release(adapter);
         }
     }
 
@@ -652,18 +655,11 @@
      */
     public Collection getCopletBaseDatas() {
         if ( this.copletBaseDatas.objects == null ) {
-            ProfileLS loader = null;
             try {
-                loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
-
                 // first "load" the global data
-                this.getGlobalBaseDatas(loader, this.portalService.getDefaultLayoutKey());
-            } catch (ServiceException se) {
-                throw new ProfileException("Unable to get component profilels.", se);
+                this.getGlobalBaseDatas(this.portalService.getDefaultLayoutKey());
             } catch (Exception e) {
                 throw new ProfileException("Unable to load global base datas.", e);
-            } finally {
-                this.manager.release( loader );
             }            
         }
         return this.copletBaseDatas.objects.values();

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java?rev=365336&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
(added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
Mon Jan  2 04:15:23 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.cocoon.portal.profile.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cocoon.portal.coplet.CopletData;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.layout.CompositeLayout;
+import org.apache.cocoon.portal.layout.Item;
+import org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl;
+import org.apache.cocoon.portal.layout.impl.CopletLayout;
+import org.apache.cocoon.portal.profile.PortalUser;
+import org.apache.cocoon.portal.scratchpad.Profile;
+import org.apache.cocoon.portal.scratchpad.ProfileImpl;
+
+/**
+ * This is an extension of the {@link GroupBasedProfileManager} to test
+ * all deployed (JSR 168) coplets. It provides a generated profile for
+ * the user with the id "test".
+ *
+ * @version $Id$
+ */
+public class TestProfileManager extends GroupBasedProfileManager {
+
+    protected Profile loadProfile(final String layoutKey) 
+    throws Exception {
+        final PortalUser info = (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
+        if ( info.getUserName().equals("test") ) {
+            final ProfileImpl profile = new ProfileImpl(layoutKey);
+
+            // first "load" the global data
+            profile.setCopletBaseDatas( this.getGlobalBaseDatas( layoutKey) );
+            profile.setCopletDatas( this.getGlobalDatas( info, profile, layoutKey) );
+
+            // create root layout
+            CompositeLayout rootLayout = new CompositeLayoutImpl("root", "row");
+
+            // create coplet instances and layouts
+            final List instances = new ArrayList();
+            final Iterator i = this.deployedCopletDatas.values().iterator();
+            while ( i.hasNext() ) {
+                final CopletData cd = (CopletData)i.next();
+                final CopletInstanceData cid = new CopletInstanceData(cd.getId() + "-1");
+                cid.setCopletData(cd);
+                instances.add(cid);
+                final CopletLayout copletLayout = new CopletLayout(null, "coplet");
+                copletLayout.setCopletInstanceData(cid);
+                copletLayout.setLayoutRendererName("portlet-window");
+                final Item item = new Item();
+                item.setLayout(copletLayout);
+                rootLayout.addItem(item);
+            }
+            profile.setCopletInstanceDatas(instances);
+            this.prepareObject(instances);
+
+            this.prepareObject(rootLayout);
+            profile.setRootLayout(rootLayout);
+
+            this.storeUserProfile(layoutKey, profile);
+            return profile;
+        } else {
+            return super.loadProfile(layoutKey);
+        }
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message