[gatein-commits] gatein SVN: r268 - in components/mop/trunk/core/src: main/java/org/gatein/mop/core/api/content and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Oct 5 06:23:31 EDT 2009


Author: julien_viet
Date: 2009-10-05 06:23:30 -0400 (Mon, 05 Oct 2009)
New Revision: 268

Added:
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/Gadget.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetContentProvider.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetState.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletContentProvider.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletDefinition.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferenceState.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferencesState.java
Removed:
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/portlet/
   components/mop/trunk/core/src/test/java/org/gatein/mop/core/impl/
Modified:
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPService.java
   components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java
   components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java
Log:
handle gadget state customization for now 


Modified: components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPService.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPService.java	2009-10-05 10:21:28 UTC (rev 267)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPService.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -43,8 +43,13 @@
 import org.gatein.mop.core.api.workspace.content.ContextSpecialization;
 import org.gatein.mop.core.api.workspace.content.WorkspaceClone;
 import org.gatein.mop.core.api.workspace.content.WorkspaceSpecialization;
-import org.gatein.mop.core.api.workspace.content.portlet.PortletPreferencesState;
-import org.gatein.mop.core.api.workspace.content.portlet.PortletPreferenceState;
+import org.gatein.mop.core.content.portlet.PortletPreferencesState;
+import org.gatein.mop.core.content.portlet.PortletPreferenceState;
+import org.gatein.mop.core.content.portlet.Preferences;
+import org.gatein.mop.core.content.portlet.PortletContentProvider;
+import org.gatein.mop.core.content.gadget.GadgetState;
+import org.gatein.mop.core.content.gadget.Gadget;
+import org.gatein.mop.core.content.gadget.GadgetContentProvider;
 import org.gatein.mop.core.api.content.ContentManagerRegistry;
 import org.gatein.mop.core.api.content.CustomizationContextProviderRegistry;
 
@@ -113,18 +118,28 @@
     builder.add(ContextSpecialization.class);
     builder.add(WorkspaceClone.class);
     builder.add(WorkspaceSpecialization.class);
+
+    //
     builder.add(PortletPreferencesState.class);
     builder.add(PortletPreferenceState.class);
 
     //
+    builder.add(GadgetState.class);
+
+    //
     chrome = builder.build();
     
     //
     CustomizationContextProviderRegistry customizationContextResolvers = new CustomizationContextProviderRegistry();
 
     //
+    ContentManagerRegistry cmr = new ContentManagerRegistry();
+    cmr.register(Preferences.CONTENT_TYPE, new PortletContentProvider());
+    cmr.register(Gadget.CONTENT_TYPE, new GadgetContentProvider());
+
+    //
     this.chrome = builder.build();
-    this.contentManagerRegistry = new ContentManagerRegistry();
+    this.contentManagerRegistry = cmr;
     this.customizationContextResolvers = customizationContextResolvers;
   }
 

Modified: components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java	2009-10-05 10:21:28 UTC (rev 267)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -39,7 +39,7 @@
     providers = new HashMap<String, ContentRegistration>();
   }
 
-  public synchronized void register(ContentType<?> contentType, ContentProvider contentProvider) {
+  public synchronized <S> void register(ContentType<S> contentType, ContentProvider<S> contentProvider) {
     if (contentType == null) {
       throw new NullPointerException();
     }

Added: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/Gadget.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/Gadget.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/Gadget.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.gatein.mop.core.content.gadget;
+
+import org.gatein.mop.api.content.ContentType;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Gadget {
+
+  /** . */
+  public static final ContentType<Gadget> CONTENT_TYPE = new ContentType<Gadget>("application/gadget", Gadget.class);
+
+  /** . */
+  private String userPref;
+
+  public String getUserPref() {
+    return userPref;
+  }
+
+  public void setUserPref(String userPref) {
+    this.userPref = userPref;
+  }
+}

Added: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetContentProvider.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetContentProvider.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetContentProvider.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.gatein.mop.core.content.gadget;
+
+import org.gatein.mop.spi.content.ContentProvider;
+import org.gatein.mop.spi.content.GetState;
+import org.gatein.mop.spi.content.StateContainer;
+import org.gatein.mop.core.api.workspace.content.AbstractCustomization;
+import org.chromattic.api.ChromatticSession;
+import org.chromattic.api.UndeclaredRepositoryException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GadgetContentProvider implements ContentProvider<Gadget> {
+
+  public GetState<Gadget> getState(String contentId) {
+    throw new UnsupportedOperationException();
+  }
+
+  public Gadget combine(List<Gadget> states) {
+    throw new UnsupportedOperationException();
+  }
+
+  public void setState(StateContainer container, Gadget state) {
+    try {
+      ChromatticSession session = ((AbstractCustomization)container).session;
+      String containerId = session.getId(container);
+      Node node = session.getJCRSession().getNodeByUUID(containerId);
+
+      //
+      GadgetState prefs;
+      if (node.hasNode("state")) {
+        Node stateNode = node.getNode("state");
+        prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+        if (state == null) {
+          session.remove(prefs);
+          return;
+        }
+      } else {
+        if (state == null) {
+          return;
+        } else {
+          Node stateNode = node.addNode("state", "mop:portletpreferences");
+          prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+        }
+      }
+
+      //
+      prefs.setUserPrefs(state.getUserPref());
+    }
+    catch (RepositoryException e) {
+      throw new UndeclaredRepositoryException(e);
+    }
+  }
+
+  public Gadget getState(StateContainer container) {
+    try {
+      ChromatticSession session = ((AbstractCustomization)container).session;
+      String containerId = session.getId(container);
+      Node node = session.getJCRSession().getNodeByUUID(containerId);
+
+      //
+      GadgetState prefs;
+      if (node.hasNode("state")) {
+        Node stateNode = node.getNode("state");
+        prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+        Gadget gadget = new Gadget();
+        gadget.setUserPref(prefs.getUserPrefs());
+        return gadget;
+      } else {
+        return null;
+      }
+    }
+    catch (RepositoryException e) {
+      throw new UndeclaredRepositoryException(e);
+    }
+  }
+
+  public Class<Gadget> getStateType() {
+    return Gadget.class;
+  }
+}

Added: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetState.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetState.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/gadget/GadgetState.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.gatein.mop.core.content.gadget;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:gadget")
+public abstract class GadgetState {
+
+  @Property(name = "userprefs")
+  public abstract String getUserPrefs();
+
+  public abstract void setUserPrefs(String userPrefs);
+
+
+}

Copied: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletContentProvider.java (from rev 261, components/mop/trunk/core/src/test/java/org/gatein/mop/core/impl/portlet/PortletContentProvider.java)
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletContentProvider.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletContentProvider.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,136 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.gatein.mop.core.content.portlet;
+
+import org.gatein.mop.spi.content.ContentProvider;
+import org.gatein.mop.spi.content.GetState;
+import org.gatein.mop.spi.content.StateContainer;
+import org.gatein.mop.core.content.portlet.Preference;
+import org.gatein.mop.core.content.portlet.Preferences;
+import org.gatein.mop.core.api.workspace.content.AbstractCustomization;
+import org.gatein.mop.core.content.portlet.PortletPreferencesState;
+import org.chromattic.api.ChromatticSession;
+import org.chromattic.api.UndeclaredRepositoryException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletContentProvider implements ContentProvider<Preferences> {
+
+  /** . */
+  private Map<String, PortletDefinition> definitions;
+
+  public PortletContentProvider() {
+    definitions = new HashMap<String, PortletDefinition>();
+  }
+
+  public void addPortletDefinition(String name, Preferences preferences) {
+    definitions.put(name, new PortletDefinition(name, preferences));
+  }
+
+  public GetState<Preferences> getState(String contentId) {
+    PortletDefinition def = definitions.get(contentId);
+    if (def != null) {
+      return new GetState<Preferences>(def.getPreferences());
+    } else {
+      return null;
+    }
+  }
+
+  public Preferences combine(List<Preferences> states) {
+    Map<String, Preference> entries = new HashMap<String, Preference>();
+
+    //
+    for (Preferences preferences : states) {
+      for (Preference preference : preferences) {
+        Preference previous = entries.get(preference.getName());
+        if (previous == null || !previous.isReadOnly()) {
+          entries.put(preference.getName(), preference);
+        }
+      }
+    }
+
+    //
+    return new Preferences(entries);
+  }
+
+  public void setState(StateContainer container, Preferences state) {
+    try {
+      ChromatticSession session = ((AbstractCustomization)container).session;
+      String containerId = session.getId(container);
+      Node node = session.getJCRSession().getNodeByUUID(containerId);
+
+      //
+      PortletPreferencesState prefs;
+      if (node.hasNode("state")) {
+        Node stateNode = node.getNode("state");
+        prefs = (PortletPreferencesState)session.findById(Object.class, stateNode.getUUID());
+        if (state == null) {
+          session.remove(prefs);
+          return;
+        }
+      } else {
+        if (state == null) {
+          return;
+        } else {
+          Node stateNode = node.addNode("state", "mop:portletpreferences");
+          prefs = (PortletPreferencesState)session.findById(Object.class, stateNode.getUUID());
+        }
+      }
+
+      //
+      prefs.setPayload(state);
+    }
+    catch (RepositoryException e) {
+      throw new UndeclaredRepositoryException(e);
+    }
+  }
+
+  public Preferences getState(StateContainer container) {
+    try {
+      ChromatticSession session = ((AbstractCustomization)container).session;
+      String containerId = session.getId(container);
+      Node node = session.getJCRSession().getNodeByUUID(containerId);
+
+      //
+      PortletPreferencesState prefs;
+      if (node.hasNode("state")) {
+        Node stateNode = node.getNode("state");
+        prefs = (PortletPreferencesState)session.findById(Object.class, stateNode.getUUID());
+        return (Preferences)prefs.getPayload();
+      } else {
+        return null;
+      }
+    }
+    catch (RepositoryException e) {
+      throw new UndeclaredRepositoryException(e);
+    }
+  }
+
+  public Class<Preferences> getStateType() {
+    return Preferences.class;
+  }
+}

Copied: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletDefinition.java (from rev 233, components/mop/trunk/core/src/test/java/org/gatein/mop/core/impl/portlet/PortletDefinition.java)
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletDefinition.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletDefinition.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.gatein.mop.core.content.portlet;
+
+import org.gatein.mop.core.content.portlet.Preferences;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletDefinition {
+
+  /** . */
+  private final String name;
+
+  /** . */
+  private final Preferences preferences;
+
+  public PortletDefinition(String name, Preferences preferences) {
+    this.name = name;
+    this.preferences = preferences;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public Preferences getPreferences() {
+    return preferences;
+  }
+}

Copied: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferenceState.java (from rev 233, components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/portlet/PortletPreferenceState.java)
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferenceState.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferenceState.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,57 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.gatein.mop.core.content.portlet;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.ManyToOne;
+import org.chromattic.api.annotations.Name;
+import org.chromattic.api.annotations.Property;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:portletpreference")
+public abstract class PortletPreferenceState {
+
+  @ManyToOne
+  public abstract PortletPreferenceState getParent();
+
+  @Name
+  public abstract String getName();
+
+  @Property(name = "value")
+  public abstract List<String> getValue();
+
+  public abstract void setValue(List<String> value);
+
+  @Property(name = "value")
+  public abstract List<String> getValues();
+
+  public abstract void setValues(List<String> value);
+
+  @Property(name = "readonly")
+  public abstract boolean getReadOnly();
+
+  public abstract void setReadOnly(boolean readOnly);
+
+
+}
\ No newline at end of file

Copied: components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferencesState.java (from rev 261, components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/portlet/PortletPreferencesState.java)
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferencesState.java	                        (rev 0)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/content/portlet/PortletPreferencesState.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.gatein.mop.core.content.portlet;
+
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.RelatedMappedBy;
+import org.gatein.mop.core.content.portlet.Preferences;
+import org.gatein.mop.core.content.portlet.Preference;
+import org.gatein.mop.core.content.portlet.PreferencesBuilder;
+import org.gatein.mop.core.api.workspace.content.AbstractCustomization;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at NodeMapping(name = "mop:portletpreferences")
+public abstract class PortletPreferencesState {
+
+  /** . */
+  private Preferences payload;
+
+  @OneToMany
+  public abstract Map<String, PortletPreferenceState> getChildren();
+
+  @Create
+  public abstract PortletPreferenceState create();
+
+  @OneToOne
+  @RelatedMappedBy("state")
+  public abstract AbstractCustomization getCustomization();
+
+  private void setPayload(Preferences payload) {
+
+    this.payload = payload;
+
+    //
+    Map<String, PortletPreferenceState> entries = getChildren();
+    entries.clear();
+
+    for (Preference pref : payload) {
+      PortletPreferenceState prefState = create();
+      entries.put(pref.getName(), prefState);
+      prefState.setValue(pref.getValues());
+      prefState.setReadOnly(pref.isReadOnly());
+    }
+  }
+
+  public void setPayload(Object payload) {
+    setPayload((Preferences)payload);
+  }
+
+  public Object getPayload() {
+    if (payload == null) {
+      PreferencesBuilder builder = new PreferencesBuilder();
+      for (PortletPreferenceState entry : getChildren().values()) {
+        builder.add(entry.getName(), entry.getValues(), entry.getReadOnly());
+      }
+      payload = builder.build();
+    }
+    return payload;
+  }
+}
\ No newline at end of file

Modified: components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java
===================================================================
--- components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java	2009-10-05 10:21:28 UTC (rev 267)
+++ components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java	2009-10-05 10:23:30 UTC (rev 268)
@@ -24,7 +24,7 @@
 
 import org.gatein.mop.core.content.portlet.Preference;
 import org.gatein.mop.core.content.portlet.Preferences;
-import org.gatein.mop.core.impl.portlet.PortletContentProvider;
+import org.gatein.mop.core.content.portlet.PortletContentProvider;
 
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
@@ -48,8 +48,8 @@
     //
     pomService.start();
 
-    //
-    pomService.getContentManagerRegistry().register(Preferences.CONTENT_TYPE, portletContentProvider);
+    // Not needed for now
+    // pomService.getContentManagerRegistry().register(Preferences.CONTENT_TYPE, portletContentProvider);
 
     //
     this.pomService = pomService;



More information about the gatein-commits mailing list