portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r505014 [4/11] - in /portals/jetspeed-2/trunk: components/serializer/ components/serializer/src/java/org/apache/jetspeed/serializer/ components/serializer/src/java/org/apache/jetspeed/serializer/objects/ etc/ etc/sql/ etc/xsd/ jetspeed-api/...
Date Thu, 08 Feb 2007 19:31:03 GMT
Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,647 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLBinding;
+
+import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
+import org.apache.jetspeed.om.preference.impl.PrefsPreference;
+import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
+import org.apache.jetspeed.prefs.PreferencesProvider;
+import org.apache.jetspeed.serializer.objects.JSApplication;
+import org.apache.jetspeed.serializer.objects.JSApplications;
+import org.apache.jetspeed.serializer.objects.JSEntities;
+import org.apache.jetspeed.serializer.objects.JSEntity;
+import org.apache.jetspeed.serializer.objects.JSEntityPreference;
+import org.apache.jetspeed.serializer.objects.JSEntityPreferences;
+import org.apache.jetspeed.serializer.objects.JSNVPElements;
+import org.apache.jetspeed.serializer.objects.JSPortlet;
+import org.apache.jetspeed.serializer.objects.JSPortlets;
+import org.apache.jetspeed.serializer.objects.JSSecondaryData;
+import org.apache.pluto.om.common.Preference;
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.portlet.PortletDefinitionList;
+
+/**
+ * Jetspeed Serializer - Secondary Data
+ * <p>
+ * The Serializer is capable of reading and writing additional content of the
+ * Jetspeed environment such as entities and preferences to and from XML files.
+ * The component can be used from a standalone java application for seeding a
+ * new database or from a running portal as an administrative backup/restore
+ * function.
+ * <p>
+ * 
+ * @author <a href="mailto:hajo@bluesunrise.com">Hajo Birthelmer</a>
+ * @version $Id: $
+ */
+public class JetspeedSerializerSecondaryImpl extends JetspeedSerializerBase
+		implements
+			JetspeedSerializer
+{
+
+	boolean overwrite = true;
+	int refCouter = 0;
+
+	private PortletEntityAccessComponent entityAccess = null;
+
+	private PortletRegistry registry;
+
+	private PreferencesProvider prefProvider;
+
+	protected Class getSerializerDataClass()
+	{
+		return JSSecondaryData.class;
+	}
+
+	protected String getSerializerDataTag()
+	{
+		return TAG_SECONDARYSNAPSHOT;
+	}
+
+	public JetspeedSerializerSecondaryImpl()
+	{
+		super();
+	}
+
+	/**
+	 * hand over existing component manager
+	 * 
+	 * @param cm
+	 */
+	public JetspeedSerializerSecondaryImpl(ComponentManager cm)
+	{
+		super(cm);
+	}
+
+	/**
+	 * This constructor takes the application root, the search path for the boot
+	 * component configuration files and the search path for the application
+	 * component configuration files.
+	 * <p>
+	 * For example: new JetspeedSerializerImpl("./", "assembly/boot/*.xml",
+	 * "assembly/*.xml") will establish the current directory as the root,
+	 * process all xml files in the assembly/boot directory before processing
+	 * all xml files in the assembly directory itself.
+	 * 
+	 * @param appRoot
+	 *            working directory
+	 * @param bootConfig
+	 *            boot (primary) file or files (wildcards are allowed)
+	 * @param appConfig
+	 *            application (secondary) file or files (wildcards are allowed)
+	 */
+	public JetspeedSerializerSecondaryImpl(String appRoot, String[] bootConfig,
+			String[] appConfig) throws SerializerException
+	{
+		super(appRoot, bootConfig, appConfig);
+	}
+
+	/**
+	 * reset instruction flags to default settings (all true)
+	 * 
+	 */
+	protected void resetSettings()
+	{
+		setSetting(JetspeedSerializer.KEY_PROCESS_USERS, false);
+		setSetting(JetspeedSerializer.KEY_PROCESS_CAPABILITIES, false);
+		setSetting(JetspeedSerializer.KEY_PROCESS_PROFILER, false);
+		setSetting(JetspeedSerializer.KEY_PROCESS_USER_PREFERENCES, true);
+		setSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING, true);
+		setSetting(JetspeedSerializer.KEY_BACKUP_BEFORE_PROCESS, true);
+	}
+
+	/**
+	 * On import, get the basic SnapShot data
+	 * 
+	 */
+	protected void getSnapshotData()
+	{
+		logMe("date created : "
+				+ ((JSSecondaryData) getSnapshot()).getDateCreated());
+		logMe("software Version : "
+				+ ((JSSecondaryData) getSnapshot()).getSavedVersion());
+		logMe("software SUbVersion : "
+				+ ((JSSecondaryData) getSnapshot()).getSavedSubversion());
+	}
+
+	/**
+	 * On export, set the basic SnapShot data
+	 * 
+	 */
+	protected void setSnapshotData()
+	{
+		super.setSnapshotData();
+	}
+
+	private JSPortlet exportPD(PortletDefinition pd) throws SerializerException
+	{
+
+		boolean processedAnyEntities = false;
+		try
+		{
+			Collection col = entityAccess.getPortletEntities(pd);
+			if ((col == null) || (col.size() == 0))
+				return null;
+			JSPortlet portlet = new JSPortlet();
+			portlet.setName(pd.getName());
+			Iterator list = null;
+			try
+			{
+				list = col.iterator();
+			} catch (Exception e)
+			{
+				throw new SerializerException(
+						SerializerException.GET_EXISTING_OBJECTS
+								.create(new String[]
+								{"entityAccess", e.getMessage()}));
+			}
+			JSEntities entities = new JSEntities();
+
+			while (list.hasNext())
+			{
+				MutablePortletEntity entity = (MutablePortletEntity) list
+						.next();
+				JSEntity jsEntity = exportEntityPref(entity);
+				if (jsEntity != null)
+					entities.add(jsEntity);
+
+			}
+			System.out.println("-----processedAnyEntities for PD="
+					+ pd.getName());
+			portlet.setEntities(entities);
+			return portlet;
+
+		} catch (Exception e)
+		{
+			throw new SerializerException(
+					SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
+							.create(new String[]
+							{"Entity", e.getMessage()}));
+		}
+	}
+
+	JSEntity exportEntityPref(MutablePortletEntity entity)
+	{
+		JSEntity jsEntity = new JSEntity();
+		jsEntity.setId(entity.getId().toString());
+		String rootForEntity = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
+				+ entity.getId();
+		try
+		{
+			if (!(Preferences.userRoot().nodeExists(rootForEntity)))
+			{
+				// System.out.println("No preferences exist for entity "+
+				// entity.getId());
+				return jsEntity;
+			}
+
+			Preferences prefNode = Preferences.userRoot().node(rootForEntity);
+			String[] children = prefNode.childrenNames();
+			if ((children != null) && (children.length > 0))
+			{
+				JSEntityPreferences permissions = new JSEntityPreferences();
+
+				for (int i = 0; i < children.length; i++)
+				{
+					JSEntityPreference permission = processPreferenceNode(
+							entity, children[i]);
+					if (permission != null)
+						permissions.add(permission);
+				}
+				System.out.println("processed preferences for entity="
+						+ entity.getId());
+				jsEntity.setEntityPreferences(permissions);
+				return jsEntity;
+				// processPreferenceNode(entity,prefNode,null);
+			}
+			return jsEntity;
+		} catch (Exception e)
+		{
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	JSEntityPreference processPreferenceNode(MutablePortletEntity entity,
+			String child)
+	{
+		boolean processedAny = false;
+
+		String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
+				+ entity.getId() + "/" + child + "/"
+				+ PrefsPreference.PORTLET_PREFERENCES_ROOT;
+		Preferences prefNode = Preferences.userRoot().node(prefNodePath);
+
+		if (prefNode == null)
+			return null;
+		JSEntityPreference permission = new JSEntityPreference();
+		permission.setName(child);
+
+		try
+		{
+			PrefsPreferenceSetImpl preferenceSet = new PrefsPreferenceSetImpl(
+					prefNode);
+			if (preferenceSet.size() == 0)
+				return null;
+			Iterator it = preferenceSet.iterator();
+			JSNVPElements v = new JSNVPElements();
+
+			while (it.hasNext())
+			{
+				Preference pref = (Preference) it.next();
+				String name = pref.getName();
+				Iterator ii = pref.getValues();
+				while (ii.hasNext())
+				{
+					processedAny = true;
+					Object o = ii.next();
+					v.add(name, o.toString());
+				}
+			}
+			if (v.size() > 0)
+			{
+				permission.setPreferences(v);
+				return permission;
+			}
+			return null;
+		} catch (Exception e)
+		{
+			e.printStackTrace();
+			return null;
+
+		}
+
+	}
+
+	private JSApplication exportPA(MutablePortletApplication pa)
+			throws SerializerException
+	{
+
+		JSApplication app = new JSApplication();
+		System.out.println("--processed PA " + pa.getName() + " with id="
+				+ pa.getId());
+		app.setID(pa.getId().toString());
+		app.setName(pa.getName());
+		/**
+		 * while more PAs for each portletDef
+		 * list:entityMan:getPortletEntity(pd)
+		 */
+		PortletDefinitionList portletList = pa.getPortletDefinitionList(); // .get(JetspeedObjectID.createFromString(TEST_PORTLET));
+		Iterator pi = portletList.iterator();
+		PortletDefinition pd = null;
+
+		JSPortlets portlets = new JSPortlets();
+		while (pi.hasNext())
+		{
+			try
+			{
+				pd = (PortletDefinition) pi.next();
+				JSPortlet p = exportPD(pd);
+				if (p != null)
+				{
+					System.out.println("--processed PA " + pa.getName()
+							+ " with pd=" + pd.getName());
+					portlets.add(p);
+				} else
+					System.out.println("--processed PA " + pa.getName()
+							+ " with NULL pd=" + pd.getName());
+
+			} catch (Exception e)
+			{
+				throw new SerializerException(
+						SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
+								.create(new String[]
+								{"PortletDefinition", e.getMessage()}));
+			}
+		}
+		app.setPortlets(portlets);
+		return app;
+	}
+
+	private JSApplications exportEntities() throws SerializerException
+	{
+		registry = (PortletRegistry) getCM()
+				.getComponent(
+						"org.apache.jetspeed.components.portletregistry.PortletRegistry");
+		if (registry == null)
+			throw new SerializerException(
+					SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
+							.create("org.apache.jetspeed.components.portletregistry.PortletRegistry"));
+		Object o = getCM()
+				.getComponent(
+						"org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent");
+		this.entityAccess = (PortletEntityAccessComponent) o;
+		if (entityAccess == null)
+			throw new SerializerException(
+					SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
+							.create("org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"));
+
+		JSApplications applications = new JSApplications();
+
+		Collection col = registry.getPortletApplications();
+		if ((col == null) || (col.size() == 0))
+			return applications;
+		Iterator list = null;
+		try
+		{
+			list = col.iterator();
+		} catch (Exception e)
+		{
+			throw new SerializerException(
+					SerializerException.GET_EXISTING_OBJECTS
+							.create(new String[]
+							{"registry", e.getMessage()}));
+		}
+		while (list.hasNext())
+		{
+			try
+			{
+				MutablePortletApplication pa = (MutablePortletApplication) list
+						.next();
+				// PortletApplicationDefinition pa =
+				// (PortletApplicationDefinition)list.next();
+				applications.add(exportPA(pa));
+			} catch (Exception e)
+			{
+				throw new SerializerException(
+						SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
+								.create(new String[]
+								{"PortletApplicationDefinition", e.getMessage()}));
+			}
+		}
+
+		return applications;
+	}
+
+	/**
+	 * The workhorse for importing data
+	 * 
+	 * @param binding
+	 *            established XML binding
+	 * @return
+	 * @throws SerializerException
+	 */
+	protected void processImport() throws SerializerException
+	{
+		this.logMe("*********reinstalling data*********");
+
+		logMe("creating entities");
+		importEntities();
+	}
+
+	/**
+	 * The workhorse for exporting data
+	 * 
+	 * @param binding
+	 *            established XML binding
+	 * @return
+	 * @throws SerializerException
+	 */
+	protected void processExport(String name, XMLBinding binding)
+			throws SerializerException
+	{
+		this.logMe("*********collecting data*********");
+		/** first create the snapshot file */
+
+		this.setSnapshot(new JSSecondaryData(name));
+
+		setSnapshotData();
+
+		JSApplications apps = exportEntities();
+		((JSSecondaryData) this.getSnapshot()).setApplications(apps);
+		/**
+		 * 
+		 * if (this.getSetting(JetspeedSerializer.KEY_PROCESS_ENTITIES)) {
+		 * logMe("collecting entities"); exportEntities(); } else
+		 * logMe("entities skipped");
+		 * 
+		 * if (this.getSetting(JetspeedSerializer.KEY_PROCESS_PREFERENCES)) {
+		 * logMe("collecting preferences"); exportPreferences(); } else
+		 * logMe("preferences skipped");
+		 */
+
+	}
+
+	/**
+	 * Setup the binding for the different classes, mapping each extracted class
+	 * to a unique tag name in the XML
+	 * 
+	 * @param binding
+	 */
+	protected void setupAliases(XMLBinding binding)
+	{
+		binding.setAlias(JSApplication.class, "PortletApplication");
+		binding.setAlias(JSApplications.class, "PortletApplications");
+		binding.setAlias(JSPortlet.class, "Portlet");
+		binding.setAlias(JSPortlets.class, "Portlets");
+		binding.setAlias(JSEntity.class, "Entity");
+		binding.setAlias(JSEntities.class, "Entities");
+		binding.setAlias(JSEntityPreference.class, "Principal");
+		binding.setAlias(JSEntityPreferences.class, "Settings");
+		binding.setAlias(JSSecondaryData.class, "RegistryData");
+		binding.setAlias(JSNVPElements.class, "preferences");
+
+		binding.setAlias(String.class, "String");
+		binding.setAlias(Integer.class, "int");
+		binding.setClassAttribute(null);
+
+	}
+
+	private void importEntities() throws SerializerException
+	{
+		overwrite = getSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING);
+
+		registry = (PortletRegistry) getCM()
+				.getComponent(
+						"org.apache.jetspeed.components.portletregistry.PortletRegistry");
+		if (registry == null)
+			throw new SerializerException(
+					SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
+							.create("org.apache.jetspeed.components.portletregistry.PortletRegistry"));
+		Object o = getCM()
+				.getComponent(
+						"org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent");
+		this.entityAccess = (PortletEntityAccessComponent) o;
+		if (entityAccess == null)
+			throw new SerializerException(
+					SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
+							.create("org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"));
+		
+		JSApplications applications = ((JSSecondaryData)this.getSnapshot()).getApplications();
+
+		if (applications == null)
+		{
+			System.out.println("NO DATA!!!!!!");
+			return;
+		}
+		Iterator it = applications.iterator();
+		while (it.hasNext())
+		{
+			JSApplication app = (JSApplication)it.next();
+			MutablePortletApplication portletApp = registry.getPortletApplication(app.getName());
+			if (portletApp != null)
+			{
+				importPA(app,portletApp);
+			}
+		}
+	}
+
+	void importPA(JSApplication app, MutablePortletApplication pa)
+	throws SerializerException
+	{
+
+		
+		System.out.println("--processed PA " + pa.getName() + " with id="
+		+ pa.getId());
+		/**
+		 * while more PAs for each portletDef
+		 * list:entityMan:getPortletEntity(pd)
+		 */
+		
+		Iterator pi = app.getPortlets().iterator();
+		while (pi.hasNext())
+		{
+			JSPortlet portlet = (JSPortlet)pi.next();
+			PortletDefinition pd  = pa.getPortletDefinitionByName(portlet.getName());
+			if (pd != null)
+			{
+				importPD(portlet,pd); 
+			}
+		}
+	}
+	
+	private void importPD(JSPortlet portlet, PortletDefinition pd) throws SerializerException
+	{
+
+		JSEntities entities = portlet.getEntities();
+		Iterator it = entities.iterator();
+		while (it.hasNext())
+		{
+			JSEntity entity = (JSEntity)it.next();
+			MutablePortletEntity portletEntity = entityAccess.getPortletEntity(entity.getId());
+			if (portletEntity == null)
+			{
+				portletEntity = entityAccess.newPortletEntityInstance(pd, entity.getId());
+				try
+				{
+					entityAccess.storePortletEntity(portletEntity);
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+				}
+			}
+			// check preferences
+			
+			importEntityPref(entity , portletEntity);
+		}
+	}
+
+	private void importEntityPref(JSEntity entity , MutablePortletEntity portletEntity)
+	{
+
+		// do I carry any preferences?
+		JSEntityPreferences preferences = entity.getEntityPreferences();
+		if ((preferences == null) || (preferences.size() == 0))
+			return;
+		
+		
+		//since I do have preferences let us make sure we have a root node
+		
+		String rootForEntity = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
+				+ portletEntity.getId();
+		try
+		{
+			Preferences prefNode = Preferences.userRoot().node(rootForEntity); // will create it if it doesn't exist
+			
+			
+			Iterator it = preferences.iterator();
+			while (it.hasNext())
+			{
+				JSEntityPreference preference = (JSEntityPreference)it.next();
+				
+				// do we have preferences for this one?
+				importPreferenceNode(preference,portletEntity);
+			}
+			
+		
+		} catch (Exception e)
+		{
+			e.printStackTrace();
+			return;
+		}
+
+	}
+
+	private void importPreferenceNode(JSEntityPreference preference, MutablePortletEntity entity)
+	{
+
+		String child = preference.getName();
+		
+		String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
+				+ entity.getId() + "/" + child + "/"
+				+ PrefsPreference.PORTLET_PREFERENCES_ROOT;
+		Preferences prefNode = Preferences.userRoot().node(prefNodePath);
+
+		if (prefNode == null)
+			return ;
+
+		JSNVPElements prefList = preference.getPreferences();
+		try
+		{
+			PrefsPreferenceSetImpl preferenceSet = new PrefsPreferenceSetImpl(
+					prefNode);
+			
+			Iterator it = prefList.getMyMap().keySet().iterator();
+			
+			while (it.hasNext())
+			{
+				String key = (String)it.next();
+				String value = (String)prefList.getMyMap().get(key);
+				Preference p = preferenceSet.get(key);
+				if ((p == null) || (overwrite))
+				{
+					
+					Vector v = new Vector();
+					v.add(value);
+					preferenceSet.add(key, v);
+System.out.println("Entity " + entity.getId() + " updated with preference " + key + "=" + value);					
+				}
+			}
+			preferenceSet.flush();
+			return;
+		} catch (Exception e)
+		{
+			e.printStackTrace();
+			return;
+
+		}
+
+	}
+	
+	
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplication.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplication.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplication.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Jetspeed Serialized (JS) User
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JSApplication
+{
+
+    private String name;
+
+    private String id;
+
+
+
+    private JSPortlets portlets = null;
+
+
+    public JSApplication()
+    {
+    }
+
+
+    public String getID()
+    {
+        return id;
+    }
+
+ 
+    public void setID(String id)
+    {
+        this.id = id;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+ 
+    public String getName()
+    {
+        return name;
+    }
+
+  
+  
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSApplication.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSApplication g = (JSApplication) o;
+                String s = g.getName();
+                if ((s != null) && (s.length() > 0))
+                	xml.setAttribute("name", s);
+                
+				xml.add(g.id, "ID",String.class);
+                xml.add(g.portlets);
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSApplication g = (JSApplication) o;
+                g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
+                
+                
+ 
+                Object o1 = xml.get("ID",String.class);
+                if (o1 instanceof String) g.id = StringEscapeUtils.unescapeHtml((String) o1);
+
+				while (xml.hasNext())
+				{
+					o1 = xml.getNext(); // mime
+					
+					
+					if (o1 instanceof JSPortlets)
+					{
+						g.portlets = (JSPortlets) o1;
+					}
+                }
+                
+ 
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+    };
+
+
+ 
+
+
+	public JSPortlets getPortlets()
+	{
+		return portlets;
+	}
+
+	public void setPortlets(JSPortlets portlets)
+	{
+		this.portlets = portlets;
+	}
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplications.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplications.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplications.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSApplications.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+
+/**
+ * Simple wrapper class for XML serialization
+ * @author hajo
+ *
+ */
+public class JSApplications extends ArrayList
+{
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntities.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntities.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntities.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntities.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+
+/**
+ * Simple wrapper class for XML serialization
+ * @author hajo
+ *
+ */
+public class JSEntities extends ArrayList
+{
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntity.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntity.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntity.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntity.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Jetspeed Serialized (JS) User
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JSEntity
+{
+
+    private String id;
+
+
+    private JSEntityPreferences entityPreferences = null;
+
+
+    public JSEntity()
+    {
+    }
+
+    
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+
+    
+    public String getId()
+    {
+        return id;
+    }
+
+        /**
+     * @param entityPreferences
+     *            The entityPreferences to set.
+     */
+    public void setEntityPreferences(JSEntityPreferences entityPreferences)
+    {
+        this.entityPreferences = entityPreferences;
+    }
+
+    /**
+     * @return Returns the entityPreferences.
+     */
+    public JSEntityPreferences getEntityPreferences()
+    {
+        return entityPreferences;
+    }
+
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSEntity.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSEntity g = (JSEntity) o;
+                String s = g.getId();
+                if ((s != null) && (s.length() > 0))
+                	xml.setAttribute("id", s);
+                if ((g.entityPreferences != null)  && (g.entityPreferences .size()>0))
+                	xml.add(g.entityPreferences);
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSEntity g = (JSEntity) o;
+                g.id = StringEscapeUtils.unescapeHtml(xml.getAttribute("id", "unknown"));
+                
+                
+                Object o1 = null;
+ 
+
+				while (xml.hasNext())
+				{
+					o1 = xml.getNext(); // mime
+					
+	                           if (o1 instanceof JSEntityPreferences)
+	                            g.entityPreferences  = (JSEntityPreferences) o1;
+	            }
+                
+ 
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+    };
+
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreference.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreference.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreference.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Jetspeed Serialized (JS) User
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JSEntityPreference
+{
+
+    private String principalName;
+
+
+    private JSNVPElements preferences = null;
+
+
+    public JSEntityPreference()
+    {
+    }
+
+   
+
+    public void setName(String principalName)
+    {
+        this.principalName = principalName;
+    }
+
+ 
+    public String getName()
+    {
+        return principalName;
+    }
+
+  
+    /**
+     * @return Returns the preferences.
+     */
+    public JSNVPElements getPreferences()
+    {
+        return preferences;
+    }
+
+    /**
+     * @param preferences
+     *            The preferences to set.
+     */
+    public void setPreferences(Preferences preferences)
+    {
+        this.preferences = new JSNVPElements(preferences);
+    }
+
+
+    /**
+     * @param preferences
+     *            The preferences to set.
+     */
+    public void setPreferences(JSNVPElements preferences)
+    {
+        this.preferences = preferences;
+    }
+
+
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSEntityPreference.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSEntityPreference g = (JSEntityPreference) o;
+                String s = g.getName();
+                if ((s == null) || (s.length() == 0)) s = "no-principal";
+                xml.setAttribute("name", s);
+                if ((g.preferences != null) && (g.preferences.size()>0))
+                	xml.add(g.preferences);
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSEntityPreference g = (JSEntityPreference) o;
+                g.principalName = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "no-principal"));
+                
+                
+                Object o1 = null;
+ 
+
+				while (xml.hasNext())
+				{
+					o1 = xml.getNext(); // mime
+					
+		                        if (o1 instanceof JSNVPElements)
+		                        	g.preferences  = (JSNVPElements) o1;
+                }
+                
+ 
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+    };
+
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreferences.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreferences.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreferences.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSEntityPreferences.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+
+/**
+ * Simple wrapper class for XML serialization
+ * @author hajo
+ *
+ */
+public class JSEntityPreferences extends ArrayList
+{
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElement.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElement.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElement.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+/**
+ * Serialized Name Value Pairs <info> <name>user.first.name</name> <value>Paul</value>
+ * </info>
+ * 
+ * @author <a href="mailto:hajo@bluesunrsie.com">Hajo Birthelmer</a>
+ * @version $Id: $
+ */
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.sax.Attributes;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.pluto.om.common.Preference;
+
+public class JSNVPElement
+{
+
+	
+    private String key;
+    private String value;
+    public JSNVPElement() {};
+    public JSNVPElement(String key, String value)
+    {
+    	this.key = key;
+    	this.value = value;
+    }
+
+         private static final XMLFormat XML = new XMLFormat(JSNVPElement.class)
+        {
+            public boolean isReferencable() {
+                return false; // Always manipulates by value.
+            }
+            public void write(Object o, OutputElement xml)
+            throws XMLStreamException
+            {
+                // xml.add((String) g.get(_key), _key, String.class);
+            	xml.add(((JSNVPElement)o).key,"name",String.class);
+            	xml.add(((JSNVPElement)o).value,"value",String.class);
+            }
+            public void read(InputElement xml, Object o)
+            {
+                try
+                {
+                    JSNVPElement g = (JSNVPElement) o;
+                    g.key = StringEscapeUtils.unescapeHtml((String)xml.get("name", String.class));
+                    g.value = StringEscapeUtils.unescapeHtml((String)xml.get("value", String.class));
+                } catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
+        };
+		public String getKey()
+		{
+			return key;
+		}
+		public void setKey(String key)
+		{
+			this.key = key;
+		}
+		public String getValue()
+		{
+			return value;
+		}
+		public void setValue(String value)
+		{
+			this.value = value;
+		}
+    }
+    
+    

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElements.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElements.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElements.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNVPElements.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+/**
+ * Serialized Name Value Pairs <info> <name>user.first.name</name> <value>Paul</value>
+ * </info>
+ * 
+ * @author <a href="mailto:hajo@bluesunrsie.com">Hajo Birthelmer</a>
+ * @version $Id: $
+ */
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.sax.Attributes;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.pluto.om.common.Preference;
+
+public class JSNVPElements
+{
+
+    private HashMap myMap = new HashMap();
+
+    public int size()
+    {
+    	return myMap.size();
+    	
+    }
+    public JSNVPElements()
+    {
+    }
+    
+ 
+    public HashMap getMyMap()
+	{
+		return myMap;
+	}
+
+    public void add(String key, String value)
+    {
+    	myMap.put(key,value);
+    }
+
+	/**
+     * @param arg0
+     */
+    public JSNVPElements(Preferences preferences)
+    {
+        try
+        {
+            String[] strings = preferences.keys();
+            if ((strings != null) && (strings.length > 0))
+            {
+                int i = strings.length;
+                for (int j = 0; j < i; j++)
+                    myMap.put(strings[j], preferences.get(strings[j], "?????"));
+            }
+
+        } catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSNVPElements.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSNVPElements g = (JSNVPElements) o;
+                Iterator _it = g.myMap.keySet().iterator();
+                while (_it.hasNext())
+                {
+                    String _key = (String) _it.next();
+                    JSNVPElement elem = new JSNVPElement(_key,(String)g.myMap.get(_key));
+                    xml.add(elem,"preference",JSNVPElement.class);
+                }
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+
+            try
+            {
+                JSNVPElements g = (JSNVPElements) o;
+                Object o1 = null;
+                
+
+				while (xml.hasNext())
+				{
+					JSNVPElement elem = (JSNVPElement)xml.get("preference",JSNVPElement.class);
+                    g.myMap.put(elem.getKey(), elem.getValue());
+				}
+            } catch (Exception e)
+            {
+                /**
+                 * while annoying invalid entries in the file should be
+                 * just disregarded
+                 */
+                e.printStackTrace();
+            }
+        }
+    };
+
+    
+    
+}

Modified: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNameValuePairs.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNameValuePairs.java?view=diff&rev=505014&r1=505013&r2=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNameValuePairs.java (original)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSNameValuePairs.java Thu Feb  8 11:31:01 2007
@@ -1,130 +1,140 @@
-/*
- * Copyright 2000-2004 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.jetspeed.serializer.objects;
-
-/**
- * Serialized Name Value Pairs <info> <name>user.first.name</name> <value>Paul</value>
- * </info>
- * 
- * @author <a href="mailto:hajo@bluesunrsie.com">Hajo Birthelmer</a>
- * @version $Id: $
- */
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.prefs.Preferences;
-
-import javolution.xml.XMLFormat;
-import javolution.xml.sax.Attributes;
-import javolution.xml.stream.XMLStreamException;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-public class JSNameValuePairs
-{
-
-    private HashMap myMap = new HashMap();
-
-    public JSNameValuePairs()
-    {
-    }
-    
- 
-    public HashMap getMyMap()
-	{
-		return myMap;
-	}
-
-
-	/**
-     * @param arg0
-     */
-    public JSNameValuePairs(Preferences preferences)
-    {
-        try
-        {
-            String[] strings = preferences.keys();
-            if ((strings != null) && (strings.length > 0))
-            {
-                int i = strings.length;
-                for (int j = 0; j < i; j++)
-                    myMap.put(strings[j], preferences.get(strings[j], "?????"));
-            }
-
-        } catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /***************************************************************************
-     * SERIALIZER
-     */
-    private static final XMLFormat XML = new XMLFormat(JSNameValuePairs.class)
-    {
-
-        public void write(Object o, OutputElement xml)
-                throws XMLStreamException
-        {
-            try
-            {
-                JSNameValuePairs g = (JSNameValuePairs) o;
-                Iterator _it = g.myMap.keySet().iterator();
-                while (_it.hasNext())
-                {
-                    String _key = (String) _it.next();
-                    // xml.add((String) g.get(_key), _key, String.class);
-                    xml.setAttribute(_key, (String) g.myMap.get(_key));
-                }
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-
-        public void read(InputElement xml, Object o)
-        {
-
-            try
-            {
-                JSNameValuePairs g = (JSNameValuePairs) o;
-                Attributes attribs = xml.getAttributes();
-                int len = attribs.getLength();
-
-                for (int i = 0; i < len; i++)
-                {
-                    try
-                    {
-                        String _key = StringEscapeUtils.unescapeHtml(attribs.getLocalName(i).toString());
-                        String _value = StringEscapeUtils.unescapeHtml(attribs.getValue(i).toString());
-                        g.myMap.put(_key, _value);
-                    } catch (Exception e)
-                    {
-                        /**
-                         * while annoying invalid entries in the file should be
-                         * just disregarded
-                         */
-                        e.printStackTrace();
-                    }
-                }
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-    };
-
-}
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+/**
+ * Serialized Name Value Pairs <info> <name>user.first.name</name> <value>Paul</value>
+ * </info>
+ * 
+ * @author <a href="mailto:hajo@bluesunrsie.com">Hajo Birthelmer</a>
+ * @version $Id: $
+ */
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.sax.Attributes;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.pluto.om.common.Preference;
+
+public class JSNameValuePairs
+{
+
+    private HashMap myMap = new HashMap();
+
+    public int size()
+    {
+    	return myMap.size();
+    	
+    }
+    public JSNameValuePairs()
+    {
+    }
+    
+ 
+    public HashMap getMyMap()
+	{
+		return myMap;
+	}
+
+    public void add(String key, String value)
+    {
+    	myMap.put(key,value);
+    }
+
+	/**
+     * @param arg0
+     */
+    public JSNameValuePairs(Preferences preferences)
+    {
+        try
+        {
+            String[] strings = preferences.keys();
+            if ((strings != null) && (strings.length > 0))
+            {
+                int i = strings.length;
+                for (int j = 0; j < i; j++)
+                    myMap.put(strings[j], preferences.get(strings[j], "?????"));
+            }
+
+        } catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSNameValuePairs.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSNameValuePairs g = (JSNameValuePairs) o;
+                Iterator _it = g.myMap.keySet().iterator();
+                while (_it.hasNext())
+                {
+                    String _key = (String) _it.next();
+                    // xml.add((String) g.get(_key), _key, String.class);
+                    xml.setAttribute(_key, (String) g.myMap.get(_key));
+                }
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+
+            try
+            {
+                JSNameValuePairs g = (JSNameValuePairs) o;
+                Attributes attribs = xml.getAttributes();
+                int len = attribs.getLength();
+
+                for (int i = 0; i < len; i++)
+                {
+                    try
+                    {
+                        String _key = StringEscapeUtils.unescapeHtml(attribs.getLocalName(i).toString());
+                        String _value = StringEscapeUtils.unescapeHtml(attribs.getValue(i).toString());
+                        g.myMap.put(_key, _value);
+                    } catch (Exception e)
+                    {
+                        /**
+                         * while annoying invalid entries in the file should be
+                         * just disregarded
+                         */
+                        e.printStackTrace();
+                    }
+                }
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+    };
+
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlet.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlet.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlet.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Jetspeed Serialized (JS) User
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JSPortlet
+{
+
+    private String name;
+
+
+    private JSEntities entities = null;
+
+
+    public JSPortlet()
+    {
+    }
+
+    
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    
+    public String getName()
+    {
+        return name;
+    }
+
+        /**
+     * @param entities
+     *            The entities to set.
+     */
+    public void setEntities(JSEntities entities)
+    {
+        this.entities = entities;
+    }
+
+    /**
+     * @return Returns the entities.
+     */
+    public JSEntities getEntities()
+    {
+        return entities;
+    }
+
+    /***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSPortlet.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSPortlet g = (JSPortlet) o;
+                String s = g.getName();
+                if ((s != null) && (s.length() > 0))
+                	xml.setAttribute("name", s);
+                xml.add(g.entities);
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSPortlet g = (JSPortlet) o;
+                g.name = StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
+                
+                
+                Object o1 = null;
+ 
+
+				while (xml.hasNext())
+				{
+					o1 = xml.getNext(); // mime
+					
+	                           if (o1 instanceof JSEntities)
+	                            g.entities  = (JSEntities) o1;
+	            }
+                
+ 
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+    };
+
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlets.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlets.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlets.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSPortlets.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+
+/**
+ * Simple wrapper class for XML serialization
+ * @author hajo
+ *
+ */
+public class JSPortlets extends ArrayList
+{
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+public class JSSecondaryData extends JSSnapshot
+{
+
+    public static final int softwareVersion = 1;
+
+    public static final int softwareSubVersion = 0;
+
+     private String encryption;
+
+
+    private JSApplications applications;
+
+
+    /**
+     * check the software version and subvversion against the saved
+     * version...and verify whether it is compatible...
+     * 
+     * @return the current software can process this file
+     */
+    public boolean checkVersion()
+    {
+        return true;
+    }
+    
+    /**
+     * @return Returns the softwareSubVersion.
+     */
+    public int getSoftwareSubVersion()
+    {
+        return softwareSubVersion;
+    }
+
+    /**
+     * @return Returns the softwareVersion.
+     */
+    public int getSoftwareVersion()
+    {
+        return softwareVersion;
+    }
+
+
+    public JSSecondaryData()
+    {
+    	super();
+        System.out.println("JSSecondaryData Class created");
+    }
+
+    public JSSecondaryData(String name)
+    {
+        super();
+        
+        applications = new JSApplications();
+    }
+
+ 
+    /***************************************************************************
+     * SERIALIZER
+     */
+    protected static final XMLFormat XML = new XMLFormat(JSSecondaryData.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+        	
+            try
+            {
+
+                JSSnapshot.XML.write(o,xml);
+
+                JSSecondaryData g = (JSSecondaryData) o;
+                
+                
+                /** implicitly named (through binding) fields here */
+
+                xml.add(g.getApplications()); 
+                
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+            	JSSnapshot.XML.read(xml, o); // Calls parent read.
+                JSSecondaryData g = (JSSecondaryData) o;
+
+                while (xml.hasNext())
+                {
+                    Object o1 = xml.getNext(); // mime
+
+                    if (o1 instanceof JSApplications)
+                        g.applications = (JSApplications) o1;
+                }
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+    };
+
+ 
+    
+
+    /**
+     * @param applications
+     *            The applications to set.
+     */
+    public void setApplications(JSApplications applications)
+    {
+        this.applications = applications;
+    }
+
+	public JSApplications getApplications()
+	{
+		return applications;
+	}
+
+
+}

Added: portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSeedData.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSeedData.java?view=auto&rev=505014
==============================================================================
--- portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSeedData.java (added)
+++ portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSeedData.java Thu Feb  8 11:31:01 2007
@@ -0,0 +1,382 @@
+/*
+ * Copyright 2000-2004 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.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+import javolution.xml.XMLBinding;
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+public class JSSeedData extends JSSnapshot
+{
+
+    public static final int softwareVersion = 1;
+
+    public static final int softwareSubVersion = 0;
+
+     private String encryption;
+
+    private JSMimeTypes mimeTypes;
+
+    private JSMediaTypes mediaTypes;
+
+    private JSClients clients;
+
+    private JSCapabilities capabilities;
+
+    private JSRoles roles;
+
+    private JSGroups groups;
+
+    private JSUsers users;
+
+    private JSPermissions permissions;
+
+    private JSProfilingRules rules;
+
+    private String defaultRule;
+
+    /**
+     * check the software version and subvversion against the saved
+     * version...and verify whether it is compatible...
+     * 
+     * @return the current software can process this file
+     */
+    public boolean checkVersion()
+    {
+        return true;
+    }
+    
+    /**
+     * @return Returns the softwareSubVersion.
+     */
+    public int getSoftwareSubVersion()
+    {
+        return softwareSubVersion;
+    }
+
+    /**
+     * @return Returns the softwareVersion.
+     */
+    public int getSoftwareVersion()
+    {
+        return softwareVersion;
+    }
+
+
+    public JSSeedData()
+    {
+    	super();
+        System.out.println("JSSeedData Class created");
+    }
+
+    public JSSeedData(String name)
+    {
+        super();
+        
+        mimeTypes = new JSMimeTypes();
+        mediaTypes = new JSMediaTypes();
+        clients = new JSClients();
+        capabilities = new JSCapabilities();
+        roles = new JSRoles();
+        groups = new JSGroups();
+        users = new JSUsers();
+        permissions = new JSPermissions();
+        rules = new JSProfilingRules();
+    }
+
+ 
+    /***************************************************************************
+     * SERIALIZER
+     */
+    protected static final XMLFormat XML = new XMLFormat(JSSeedData.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+        	
+            try
+            {
+
+                JSSnapshot.XML.write(o,xml);
+
+                JSSeedData g = (JSSeedData) o;
+                
+                xml.add(g.getDefaultRule(), "default_rule", String.class);
+
+                xml.add(g.encryption,"encryption",String.class);
+                
+                /** implicitly named (through binding) fields here */
+
+                xml.add(g.getMimeTypes());
+                xml.add(g.getMediaTypes());
+                xml.add(g.getCapabilities());
+                xml.add(g.getClients());
+                
+                xml.add(g.getRoles()); 
+                xml.add(g.getGroups());
+                xml.add(g.getUsers()); 
+                
+                xml.add(g.getPermissions());
+                xml.add(g.getRules());
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+            	JSSnapshot.XML.read(xml, o); // Calls parent read.
+                JSSeedData g = (JSSeedData) o;
+                Object o1 = xml.get("default_rule",String.class);
+                if (o1 instanceof String) g.defaultRule = StringEscapeUtils.unescapeHtml((String) o1);
+                o1 = xml.get("encryption",String.class);
+                if (o1 instanceof String) g.encryption = StringEscapeUtils.unescapeHtml((String) o1);
+
+                while (xml.hasNext())
+                {
+                    o1 = xml.getNext(); // mime
+
+                    if (o1 instanceof JSMimeTypes)
+                        g.mimeTypes = (JSMimeTypes) o1;
+                    else if (o1 instanceof JSMediaTypes)
+                        g.mediaTypes = (JSMediaTypes) o1;
+                    else if (o1 instanceof JSClients)
+                        g.clients = (JSClients) o1;
+                    else if (o1 instanceof JSCapabilities)
+                        g.capabilities = (JSCapabilities) o1;
+                    else if (o1 instanceof JSRoles)
+                        g.roles = (JSRoles) o1;
+                    else if (o1 instanceof JSGroups)
+                        g.groups = (JSGroups) o1;
+                    else if (o1 instanceof JSUsers)
+                        g.users = (JSUsers) o1;
+                    else if (o1 instanceof JSPermissions)
+                        g.permissions = (JSPermissions) o1;
+                    else if (o1 instanceof JSProfilingRules)
+                        g.rules = (JSProfilingRules) o1;
+                }
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+    };
+
+
+    /**
+     * @return Returns the groups.
+     */
+    public JSGroups getGroups()
+    {
+        return groups;
+    }
+
+    /**
+     * @param groups
+     *            The groups to set.
+     */
+    public void setGroups(JSGroups groups)
+    {
+        this.groups = groups;
+    }
+
+    /**
+     * @return Returns the roles.
+     */
+    public JSRoles getRoles()
+    {
+        return roles;
+    }
+
+    /**
+     * @param roles
+     *            The roles to set.
+     */
+    public void setRoles(JSRoles roles)
+    {
+        this.roles = roles;
+    }
+
+    /**
+     * @return Returns the roles.
+     */
+    public JSUsers getUsers()
+    {
+        return users;
+    }
+
+    /**
+     * @return Returns the encryption.
+     */
+    public String getEncryption()
+    {
+        return encryption;
+    }
+
+    /**
+     * @param encryption
+     *            The encryption to set.
+     */
+    public void setEncryption(String encryption)
+    {
+        this.encryption = encryption;
+    }
+
+
+    /**
+     * @return Returns the capabilities.
+     */
+    public JSCapabilities getCapabilities()
+    {
+        return capabilities;
+    }
+
+    /**
+     * @param capabilities
+     *            The capabilities to set.
+     */
+    public void setCapabilities(JSCapabilities capabilities)
+    {
+        this.capabilities = capabilities;
+    }
+
+    /**
+     * @return Returns the clients.
+     */
+    public JSClients getClients()
+    {
+        return clients;
+    }
+
+    /**
+     * @param clients
+     *            The clients to set.
+     */
+    public void setClients(JSClients clients)
+    {
+        this.clients = clients;
+    }
+
+ 
+
+    /**
+     * @return Returns the mediaTypes.
+     */
+    public JSMediaTypes getMediaTypes()
+    {
+        return mediaTypes;
+    }
+
+    /**
+     * @param mediaTypes
+     *            The mediaTypes to set.
+     */
+    public void setMediaTypes(JSMediaTypes mediaTypes)
+    {
+        this.mediaTypes = mediaTypes;
+    }
+
+    /**
+     * @return Returns the mimeTypes.
+     */
+    public JSMimeTypes getMimeTypes()
+    {
+        return mimeTypes;
+    }
+
+    /**
+     * @param mimeTypes
+     *            The mimeTypes to set.
+     */
+    public void setMimeTypes(JSMimeTypes mimeTypes)
+    {
+        this.mimeTypes = mimeTypes;
+    }
+
+ 
+ 
+
+    /**
+     * @param users
+     *            The users to set.
+     */
+    public void setUsers(JSUsers users)
+    {
+        this.users = users;
+    }
+
+    /**
+     * @return Returns the permissions.
+     */
+    public JSPermissions getPermissions()
+    {
+        return permissions;
+    }
+
+    /**
+     * @param permissions
+     *            The permissions to set.
+     */
+    public void setPermissions(JSPermissions permissions)
+    {
+        this.permissions = permissions;
+    }
+
+    /**
+     * @return Returns the rules.
+     */
+    public JSProfilingRules getRules()
+    {
+        return rules;
+    }
+
+    /**
+     * @param rules
+     *            The rules to set.
+     */
+    public void setRules(JSProfilingRules rules)
+    {
+        this.rules = rules;
+    }
+
+    /**
+     * @return Returns the defaultRule.
+     */
+    public String getDefaultRule()
+    {
+        return defaultRule;
+    }
+
+    /**
+     * @param defaultRule
+     *            The defaultRule to set.
+     */
+    public void setDefaultRule(String defaultRule)
+    {
+        this.defaultRule = defaultRule;
+    }
+
+}



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


Mime
View raw message