cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r329185 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: persistence/castor/ profile/impl/ scratchpad/
Date Fri, 28 Oct 2005 12:30:45 GMT
Author: cziegeler
Date: Fri Oct 28 05:30:34 2005
New Revision: 329185

URL: http://svn.apache.org/viewcvs?rev=329185&view=rev
Log:
Remove obsolete classes for castor

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
  (with props)
Removed:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/CopletBaseDataManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/CopletDataManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/CopletInstanceDataManager.java
Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletbasedata.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletdata.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletinstancedata.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
Fri Oct 28 05:30:34 2005
@@ -19,6 +19,7 @@
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -99,6 +100,9 @@
                             Object       object,
                             Map          parameters)
     throws ConverterException {
+        if ( object instanceof Collection && !(object instanceof CollectionWrapper)
) {
+            object = new CollectionWrapper((Collection)object);
+        }
         Writer writer = new OutputStreamWriter(stream);
 		try {
 			Marshaller marshaller = new Marshaller( writer );

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java?rev=329185&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
(added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
Fri Oct 28 05:30:34 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005 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.persistence.castor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Holds mapped instances.
+ *
+ * @version $Id$
+ */
+public class CollectionWrapper implements Collection {
+
+    protected Collection objects;
+
+    public CollectionWrapper() {
+        this.objects = new ArrayList();
+    }
+
+    public CollectionWrapper(Collection c) {
+        this.objects = c;
+    }
+
+    public Collection getObjects() {
+        return this.objects;
+    }
+
+    /**
+     * @see java.util.Collection#add(java.lang.Object)
+     */
+    public boolean add(Object o) {
+        return this.objects.add(o);
+    }
+
+    /**
+     * @see java.util.Collection#addAll(java.util.Collection)
+     */
+    public boolean addAll(Collection c) {
+        return this.objects.addAll(c);
+    }
+
+    /**
+     * @see java.util.Collection#clear()
+     */
+    public void clear() {
+        this.objects.clear();
+    }
+
+    /**
+     * @see java.util.Collection#contains(java.lang.Object)
+     */
+    public boolean contains(Object o) {
+        return this.objects.contains(o);
+    }
+
+    /**
+     * @see java.util.Collection#containsAll(java.util.Collection)
+     */
+    public boolean containsAll(Collection c) {
+        return this.objects.containsAll(c);
+    }
+
+    /**
+     * @see java.util.Collection#isEmpty()
+     */
+    public boolean isEmpty() {
+        return this.objects.isEmpty();
+    }
+
+    /**
+     * @see java.util.Collection#iterator()
+     */
+    public Iterator iterator() {
+        return this.objects.iterator();
+    }
+
+    /**
+     * @see java.util.Collection#remove(java.lang.Object)
+     */
+    public boolean remove(Object o) {
+        return this.objects.remove(o);
+    }
+
+    /**
+     * @see java.util.Collection#removeAll(java.util.Collection)
+     */
+    public boolean removeAll(Collection c) {
+        return this.objects.removeAll(c);
+    }
+
+    /**
+     * @see java.util.Collection#retainAll(java.util.Collection)
+     */
+    public boolean retainAll(Collection c) {
+        return this.objects.retainAll(c);
+    }
+
+    /**
+     * @see java.util.Collection#size()
+     */
+    public int size() {
+        return this.objects.size();
+    }
+
+    /**
+     * @see java.util.Collection#toArray()
+     */
+    public Object[] toArray() {
+        return this.objects.toArray();
+    }
+
+    /**
+     * @see java.util.Collection#toArray(java.lang.Object[])
+     */
+    public Object[] toArray(Object[] a) {
+        return this.objects.toArray(a);
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/CollectionWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletbasedata.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletbasedata.xml?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletbasedata.xml
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletbasedata.xml
Fri Oct 28 05:30:34 2005
@@ -18,10 +18,10 @@
 <mapping>
   <description>Coplet base data mapping file</description>
 
-  <class name="org.apache.cocoon.portal.profile.impl.CopletBaseDataManager">
+  <class name="org.apache.cocoon.portal.persistence.castor.CollectionWrapper">
     <map-to xml="coplets" />
 
-    <field name="copletBaseData"
+    <field name="objects"
            type="org.apache.cocoon.portal.coplet.CopletBaseData"
            collection="collection">
       <bind-xml auto-naming="deriveByClass" />

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletdata.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletdata.xml?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletdata.xml
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletdata.xml
Fri Oct 28 05:30:34 2005
@@ -24,10 +24,11 @@
     </field>
   </class>  
 
-  <class name="org.apache.cocoon.portal.profile.impl.CopletDataManager">
+  <class name="org.apache.cocoon.portal.persistence.castor.CollectionWrapper">
     <map-to xml="coplets" />
 
-    <field name="copletData" type="org.apache.cocoon.portal.coplet.CopletData"
+    <field name="objects"
+           type="org.apache.cocoon.portal.coplet.CopletData"
            collection="collection">
       <bind-xml auto-naming="deriveByClass"/>
     </field>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletinstancedata.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletinstancedata.xml?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletinstancedata.xml
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/persistence/castor/copletinstancedata.xml
Fri Oct 28 05:30:34 2005
@@ -42,10 +42,10 @@
     </field>
   </class>
 
-  <class name="org.apache.cocoon.portal.profile.impl.CopletInstanceDataManager">
+  <class name="org.apache.cocoon.portal.persistence.castor.CollectionWrapper">
     <map-to xml="coplets" />
 
-    <field name="copletInstanceData"
+    <field name="objects"
            type="org.apache.cocoon.portal.coplet.CopletInstanceData"
            collection="collection">
       <bind-xml auto-naming="deriveByClass"/>

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=329185&r1=329184&r2=329185&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
Fri Oct 28 05:30:34 2005
@@ -421,7 +421,7 @@
         // we have to load/reload
         synchronized ( this ) {
             final Map objects = new HashMap();
-            final Iterator i = ((CopletBaseDataManager)loader.loadProfile(key, MAP_FOR_BASE_DATA)).getCopletBaseData().iterator();
+            final Iterator i = ((Collection)loader.loadProfile(key, MAP_FOR_BASE_DATA)).iterator();
             while ( i.hasNext() ) {
                 final CopletBaseData current = (CopletBaseData)i.next();
                 objects.put(current.getId(), current);
@@ -478,7 +478,7 @@
 
         synchronized ( this ) {
             final Map objects = new HashMap();
-            final Iterator i = ((CopletDataManager)loader.loadProfile(key, parameters)).getCopletData().iterator();
+            final Iterator i = ((Collection)loader.loadProfile(key, parameters)).iterator();
             while ( i.hasNext() ) {
                 final CopletData current = (CopletData)i.next();
                 objects.put(current.getId(), current);
@@ -521,8 +521,8 @@
                        profile.getCopletDatasMap());
 
         try {
-            CopletInstanceDataManager cidm = (CopletInstanceDataManager)loader.loadProfile(key,
parameters);
-            profile.setCopletInstanceDatas(cidm.getCopletInstanceData());
+            Collection cidm = (Collection)loader.loadProfile(key, parameters);
+            profile.setCopletInstanceDatas(cidm);
             this.prepareObject(profile.getCopletInstanceDatasMap());
 
             return true;
@@ -625,9 +625,7 @@
                                           this.getUser(),
                                           false,
                                           layoutKey);
-            // FIXME - we should be able to save without creating a CopletInstanceDataManager
-            CopletInstanceDataManager cidm = new CopletInstanceDataManager(profile.getCopletInstanceDatasMap());
-            adapter.saveProfile(key, parameters, cidm);
+            adapter.saveProfile(key, parameters, profile.getCopletInstanceDataObjects());
         } catch (Exception e) {
             // TODO
             throw new ProfileException("Exception during save profile", e);

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Fri Oct 28 05:30:34 2005
@@ -79,11 +79,16 @@
                     return layout;
             }
 
-            CopletInstanceDataManager copletInstanceDataManager = getCopletInstanceDataManager();
-
+            Collection c = getCopletInstanceDataManager();
+            final Map objectMap = new HashMap();
+            final Iterator i = c.iterator();
+            while ( i.hasNext() ) {
+                CopletInstanceData current = (CopletInstanceData)i.next();
+                objectMap.put(current.getId(), current);
+            }
             Map parameters = new HashMap();
             parameters.put("profiletype", "layout");
-            parameters.put("objectmap", copletInstanceDataManager.getCopletInstanceData());
+            parameters.put("objectmap", objectMap);
 
             Map map = new LinkedMap();
             map.put("base", this.profilesPath);
@@ -145,19 +150,19 @@
         }
     }
 
-    private CopletDataManager getCopletDataManager() 
+    private Map getCopletDataManager() 
     throws Exception {
         final String portalName = this.portalService.getPortalName();
         // ensure that profile is loaded
         this.getCopletInstanceDataManager();
-        return (CopletDataManager)this.copletDataManagers.get(portalName);
+        return (Map)this.copletDataManagers.get(portalName);
     }
 
-    private CopletInstanceDataManager getCopletInstanceDataManager() 
+    private Collection getCopletInstanceDataManager() 
     throws Exception {
         String portalName = this.portalService.getPortalName();
-        CopletInstanceDataManager copletInstanceDataManager =
-            (CopletInstanceDataManager) this.copletInstanceDataManagers.get(portalName);
+        Collection copletInstanceDataManager =
+            (Collection) this.copletInstanceDataManagers.get(portalName);
         if (copletInstanceDataManager != null) {
             return copletInstanceDataManager;
         }
@@ -175,31 +180,42 @@
             map.put("portalname", this.portalService.getPortalName());
             map.put("profile", "coplet");
             map.put("name", "basedata");
-            CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager) adapter.loadProfile(map,
parameters);
+            Collection cBase = (Collection) adapter.loadProfile(map, parameters);
+            final Map copletBaseDataManager = new HashMap();
+            Iterator i = cBase.iterator();
+            while ( i.hasNext() ) {
+                final CopletData current = (CopletData)i.next();
+                copletBaseDataManager.put(current.getId(), current);
+            }
 
             //CopletData
             parameters.clear();
             parameters.put("profiletype", "copletdata");
-            parameters.put("objectmap", copletBaseDataManager.getCopletBaseData());
+            parameters.put("objectmap", copletBaseDataManager);
 
             map.clear();
             map.put("base", this.profilesPath);
             map.put("portalname", this.portalService.getPortalName());
             map.put("profile", "coplet");
             map.put("name", "data");
-            CopletDataManager copletDataManager = (CopletDataManager) adapter.loadProfile(map,
parameters);
-
+            Collection c = (Collection) adapter.loadProfile(map, parameters);
+            final Map copletDataManager = new HashMap();
+            i = c.iterator();
+            while ( i.hasNext() ) {
+                final CopletData current = (CopletData)i.next();
+                copletDataManager.put(current.getId(), current);
+            }
             //CopletInstanceData
             parameters.clear();
             parameters.put("profiletype", "copletinstancedata");
-            parameters.put("objectmap", copletDataManager.getCopletData());
+            parameters.put("objectmap", copletDataManager);
 
             map.clear();
             map.put("base", this.profilesPath);
             map.put("portalname", this.portalService.getPortalName());
             map.put("profile", "coplet");
             map.put("name", "instancedata");
-            copletInstanceDataManager = (CopletInstanceDataManager) adapter.loadProfile(map,
parameters);
+            copletInstanceDataManager = (Collection) adapter.loadProfile(map, parameters);
 
             // store managers
             this.copletInstanceDataManagers.put(portalName, copletInstanceDataManager);
@@ -217,7 +233,7 @@
         // TODO - we should store a map in the static profile manager
         //        instead of going through the collection each time
         try {
-            final Iterator i = this.getCopletInstanceDataManager().getCopletInstanceData().iterator();
+            final Iterator i = this.getCopletInstanceDataManager().iterator();
             while ( i.hasNext() ) {
                 final CopletInstanceData current = (CopletInstanceData) i.next();
                 if ( current.getId().equals(copletID) ) {
@@ -235,7 +251,7 @@
      */
     public CopletData getCopletData(String copletDataId) {
         try {
-            Iterator i = getCopletInstanceDataManager().getCopletInstanceData().iterator();
+            Iterator i = getCopletInstanceDataManager().iterator();
             boolean found = false;
             CopletInstanceData current = null;
             while ( !found && i.hasNext() ) {
@@ -257,7 +273,7 @@
     public List getCopletInstanceData(CopletData data) {
         List coplets = new ArrayList();
         try {
-            Iterator iter = getCopletInstanceDataManager().getCopletInstanceData().iterator();
+            Iterator iter = getCopletInstanceDataManager().iterator();
             while (iter.hasNext()){
                 CopletInstanceData current = (CopletInstanceData) iter.next();
                 if (current.getCopletData().equals(data)) {
@@ -284,7 +300,7 @@
      */
     public Collection getCopletDatas() {
         try {
-            return this.getCopletDataManager().getCopletData();
+            return this.getCopletDataManager().values();
         } catch (Exception e) {
             throw new ProfileException("Error in getCopletDatas.", e);
         }
@@ -295,7 +311,7 @@
      */
     public Collection getCopletInstanceDatas() {
         try {
-            return this.getCopletInstanceDataManager().getCopletInstanceData();
+            return this.getCopletInstanceDataManager();
         } catch (Exception e) {
             throw new ProfileException("Error in getCopletInstanceDatas.", e);
         }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java?rev=329185&r1=329184&r2=329185&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java Fri
Oct 28 05:30:34 2005
@@ -270,7 +270,7 @@
     public Map getCopletDatasMap() {
         return this.copletDatas;
     }
-    
+
     public Map getCopletBaseDatasMap() {
         return this.copletBaseDatas;
     }



Mime
View raw message