[portal-commits] JBoss Portal SVN: r6033 - in trunk/core/src/main/org/jboss/portal/core: metadata and 2 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Thu Jan 18 11:28:48 EST 2007


Author: julien at jboss.com
Date: 2007-01-18 11:28:48 -0500 (Thu, 18 Jan 2007)
New Revision: 6033

Added:
   trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/
   trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/PreferencesMetaData.java
Removed:
   trunk/core/src/main/org/jboss/portal/core/metadata/InstanceMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/InstancesMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/PreferencesMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/PropertyHelper.java
   trunk/core/src/main/org/jboss/portal/core/metadata/SecurityConstraintMetaData.java
Modified:
   trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
Log:
- move instance metadata to a more appropriate package
- removed unused classes

Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -30,8 +30,8 @@
 import org.jboss.portal.common.util.XML;
 import org.jboss.portal.common.value.StringValue;
 import org.jboss.portal.common.value.Value;
-import org.jboss.portal.core.metadata.InstanceMetaData;
-import org.jboss.portal.core.metadata.PreferencesMetaData;
+import org.jboss.portal.core.model.instance.metadata.InstanceMetaData;
+import org.jboss.portal.core.model.instance.metadata.PreferencesMetaData;
 import org.jboss.portal.core.metadata.ServiceMetaData;
 import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
 import org.jboss.portal.core.model.instance.DuplicateInstanceException;

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/InstanceMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/InstanceMetaData.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/InstanceMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -1,276 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.core.metadata;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.metadata.MetaData;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.value.Value;
-import org.jboss.portal.core.model.instance.DuplicateInstanceException;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.security.RoleSecurityBinding;
-import org.jboss.portal.security.SecurityConstants;
-import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
-import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
-import org.w3c.dom.Element;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represent metadata of an instance.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceMetaData implements MetaData
-{
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(InstanceMetaData.class);
-
-   /** The instance id. */
-   private String id;
-
-   /** The specific preferences of this instance. */
-   private PreferencesMetaData preferences;
-
-   /** The portlet referenced by the instance. */
-   private String portletRef;
-
-   /** The security constraints. */
-   private SecurityConstraintsMetaData securityConstraints;
-
-   public InstanceMetaData()
-   {
-   }
-
-   public String getId()
-   {
-      return id;
-   }
-
-   public void setId(String id)
-   {
-      this.id = id;
-   }
-
-   public PreferencesMetaData getPreferences()
-   {
-      return preferences;
-   }
-
-   public void setPreferences(PreferencesMetaData preferences)
-   {
-      this.preferences = preferences;
-   }
-
-   public String getPortletRef()
-   {
-      return portletRef;
-   }
-
-   public void setPortletRef(String portletRef)
-   {
-      this.portletRef = portletRef;
-   }
-
-   public SecurityConstraintsMetaData getSecurityConstraints()
-   {
-      return securityConstraints;
-   }
-
-   public void setSecurityConstraints(SecurityConstraintsMetaData securityConstraints)
-   {
-      this.securityConstraints = securityConstraints;
-   }
-
-   public static InstanceMetaData buildMetaData(Element instanceElt)
-   {
-      String instanceName = XML.asString(XML.getUniqueChild(instanceElt, "instance-id", true));
-      String componentRef = XML.asString(XML.getUniqueChild(instanceElt, "portlet-ref", true));
-
-      // Configure preferences override
-      PreferencesMetaData preferencesMD = new PreferencesMetaData();
-      Element preferencesElt = XML.getUniqueChild(instanceElt, "preferences", false);
-      if (preferencesElt != null)
-      {
-         for (Iterator i = buildPreferencesMetaData(preferencesElt).values().iterator(); i.hasNext();)
-         {
-            PreferenceMetaData preferenceMD = (PreferenceMetaData)i.next();
-            preferencesMD.addPreference(preferenceMD);
-         }
-      }
-
-      // Create the meta data
-      InstanceMetaData instanceMD = new InstanceMetaData();
-      instanceMD.setId(instanceName);
-      instanceMD.setPortletRef(componentRef);
-      instanceMD.setPreferences(preferencesMD);
-
-      // Add the security constraints
-      Element securityConstraintElt = XML.getUniqueChild(instanceElt, "security-constraint", false);
-      if (securityConstraintElt != null)
-      {
-         SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
-         instanceMD.setSecurityConstraints(securityConstraintsMD);
-      }
-
-      //
-      return instanceMD;
-   }
-
-   /**
-    * @param instanceElt the instance xml element
-    * @param pwaId       the portlet application id
-    */
-   public static InstanceMetaData buildLegacyMetaData(Element instanceElt, String pwaId)
-   {
-      Element instanceNameElt = XML.getUniqueChild(instanceElt, "instance-name", true);
-      Element componentRefElt = XML.getUniqueChild(instanceElt, "component-ref", true);
-
-      //
-      String instanceName = XML.asString(instanceNameElt);
-      String componentRef = XML.asString(componentRefElt);
-
-      //
-      int dotIndex = componentRef.indexOf('.');
-
-      //
-      if (dotIndex == -1)
-      {
-         log.warn("Bad component ref " + componentRef);
-      }
-      else
-      {
-         String appId = componentRef.substring(0, dotIndex);
-         if (appId.equals(pwaId) == false)
-         {
-            log.warn("The instance " + instanceName + " will not be created because the component referenced is outside of the same web app " + componentRef);
-         }
-         else
-         {
-            String portletRef = componentRef.substring(dotIndex + 1);
-
-            if (portletRef.length() == 0)
-            {
-               log.warn("Zero portlet ref length are not considered " + componentRef);
-            }
-            else
-            {
-               log.debug("Adding legacy instance " + instanceName);
-
-               //
-               InstanceMetaData instanceMD = new InstanceMetaData();
-               instanceMD.setId(instanceName);
-               instanceMD.setPortletRef(portletRef);
-
-               // Configure preferences
-               PreferencesMetaData preferencesMD = new PreferencesMetaData();
-               Element preferencesElt = XML.getUniqueChild(instanceElt, "preferences", false);
-               if (preferencesElt != null)
-               {
-                  for (Iterator j = InstanceMetaData.buildPreferencesMetaData(preferencesElt).values().iterator(); j.hasNext();)
-                  {
-                     PreferenceMetaData preferenceMD = (PreferenceMetaData)j.next();
-                     preferencesMD.addPreference(preferenceMD);
-                  }
-               }
-
-               // Add the security constraints
-               Element securityConstraintElt = XML.getUniqueChild(instanceElt, "security-constraint", false);
-               if (securityConstraintElt != null)
-               {
-                  SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
-                  instanceMD.setSecurityConstraints(securityConstraintsMD);
-               }
-
-               //
-               return instanceMD;
-            }
-         }
-      }
-
-      //
-      return null;
-   }
-
-   public static Map buildPreferencesMetaData(Element portletPreferencesElt)
-   {
-      Map preferences = new HashMap();
-      for (Iterator i = XML.getChildrenIterator(portletPreferencesElt, "preference"); i.hasNext();)
-      {
-         Element preferenceElt = (Element)i.next();
-         PreferenceMetaData preference = buildPreferenceMetaData(preferenceElt);
-         preferences.put(preference.getName(), preference);
-      }
-      return preferences;
-   }
-
-   public static PreferenceMetaData buildPreferenceMetaData(Element preferenceElt)
-   {
-      PreferenceMetaData preferenceMD = new PreferenceMetaData();
-      List valuesElt = XML.getChildren(preferenceElt, "value");
-      String[] values = new String[valuesElt.size()];
-      for (int i = 0; i < valuesElt.size(); i++)
-      {
-         values[i] = XML.asString((Element)valuesElt.get(i));
-      }
-      Element readOnlyElt = XML.getUniqueChild(preferenceElt, "read-only", false);
-      boolean readOnly = false;
-      if (readOnlyElt != null)
-      {
-         String value = XML.asString(readOnlyElt);
-         if ("true".equals(value))
-         {
-            readOnly = true;
-         }
-         else if ("false".equals(value))
-         {
-            readOnly = false;
-         }
-         else
-         {
-            // log.debug("Unrecognized value for read only " + value);
-            readOnly = false;
-         }
-      }
-      else
-      {
-         readOnly = false;
-      }
-      preferenceMD.setName(XML.asString(XML.getUniqueChild(preferenceElt, "name", true)));
-      preferenceMD.setReadOnly(readOnly);
-      preferenceMD.setValues(values);
-      return preferenceMD;
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/InstancesMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/InstancesMetaData.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/InstancesMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.core.metadata;
-
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.NoSuchInstanceException;
-import org.jboss.portal.portlet.PortletInvokerException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstancesMetaData
-{
-
-   private Map instances;
-
-   public InstancesMetaData()
-   {
-      instances = new HashMap();
-   }
-
-   public Map getInstances()
-   {
-      return instances;
-   }
-
-   public void setInstances(Map instances)
-   {
-      this.instances = instances;
-   }
-
-   public interface BuildContext
-   {
-      InstanceContainer getContainer();
-
-      String resolvePortletRef(String ref);
-   }
-
-   public void destroy(InstanceContainer container)
-   {
-      for (Iterator i = instances.values().iterator(); i.hasNext();)
-      {
-         InstanceMetaData instanceMD = (InstanceMetaData)i.next();
-         try
-         {
-            container.destroyDefinition(instanceMD.getId());
-         }
-         catch (NoSuchInstanceException e)
-         {
-            e.printStackTrace();
-         }
-         catch (PortletInvokerException e)
-         {
-            e.printStackTrace();
-         }
-      }
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/PreferencesMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PreferencesMetaData.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/PreferencesMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.core.metadata;
-
-import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PreferencesMetaData
-{
-
-   private Map map = new HashMap();
-
-   public void addPreference(PreferenceMetaData preference)
-   {
-      map.put(preference.getName(), preference);
-   }
-
-   public Iterator iterator()
-   {
-      return map.values().iterator();
-   }
-
-   public int size()
-   {
-      return map.size();
-   }
-
-   public PreferenceMetaData getPreference(String key)
-   {
-      return (PreferenceMetaData)map.get(key);
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/PropertyHelper.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PropertyHelper.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/PropertyHelper.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -1,68 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.core.metadata;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.XML;
-import org.w3c.dom.Element;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Helper class to handle properties / maps of properties.
- *
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public class PropertyHelper
-{
-   private static Logger log = Logger.getLogger(PropertyHelper.class);
-
-   /**
-    * Convert the "property" child nodes of the provided node into a <code>java.util.Map</code> of property name and
-    * value.
-    *
-    * @param propertiesElt the paret element in the Dom tree that will be inspected for 'property' child nodes
-    * @return a Map of all the found properties, keyed by property name
-    */
-   public static Map buildPropertiesMap(Element propertiesElt)
-   {
-      Map properties = new HashMap();
-      List propertyElts = XML.getChildren(propertiesElt, "property");
-      for (int i = 0; i < propertyElts.size(); i++)
-      {
-         Element propertyElt = (Element)propertyElts.get(i);
-         Element nameElt = XML.getUniqueChild(propertyElt, "name", true);
-         Element valueElt = XML.getUniqueChild(propertyElt, "value", true);
-         String name = XML.asString(nameElt);
-         String value = XML.asString(valueElt);
-
-         //
-         log.debug("Found property " + name + " = " + value);
-         properties.put(name, value);
-      }
-      return properties;
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/SecurityConstraintMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/SecurityConstraintMetaData.java	2007-01-18 16:17:04 UTC (rev 6032)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/SecurityConstraintMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -1,122 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.core.metadata;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Holder of information for one security constraint. <p>A security constraint can be created by the deployer,
- * containing the information of one security-constraint element in the descriptor, or it can be created via a UI for
- * dynamic security policy creation. In both cases, the constraint will be added to the PortalPolicy for the secured
- * portal object.</p>
- *
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- * @see org.jboss.portal.core.security.PortalPolicy
- */
-public final class SecurityConstraintMetaData implements Serializable
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 2237631466093073685L;
-   private String displayName;
-   private String actions;
-   private String roles;
-
-   public String getDisplayName()
-   {
-      return (displayName == null ? "" : displayName);
-   }
-
-   public String getActions()
-   {
-      return (actions == null ? "" : actions);
-   }
-
-   public String getRoles()
-   {
-      return (roles == null ? "" : roles);
-   }
-
-   public List getActionList()
-   {
-      return buildListFromString(actions);
-   }
-
-   public List getRoleList()
-   {
-      return buildListFromString(roles);
-   }
-
-   public void setDisplayName(String displayName)
-   {
-      this.displayName = displayName;
-   }
-
-   public void setActions(String actions)
-   {
-      // make it pretty
-      this.actions = buildStringFromList(buildListFromString(actions));
-   }
-
-   public void setRoles(String roles)
-   {
-      // make it pretty
-      this.roles = buildStringFromList(buildListFromString(roles));
-   }
-
-   public String toString()
-   {
-      return "SecurityConstraintMetaData: " + displayName + "; actions [" + actions + "] roles [" + roles + "]";
-   }
-
-   private List buildListFromString(String src)
-   {
-      StringTokenizer tokens = new StringTokenizer(src, ",");
-      List list = new ArrayList();
-      while (tokens.hasMoreTokens())
-      {
-         list.add(tokens.nextToken().trim());
-      }
-      return Collections.unmodifiableList(list);
-   }
-
-   private String buildStringFromList(List tokens)
-   {
-      StringBuffer list = new StringBuffer();
-
-      for (int i = 0; i < tokens.size(); i++)
-      {
-         if (i > 0)
-         {
-            list.append(", ");
-         }
-         list.append(((String)tokens.get(i)).trim());
-      }
-
-      return list.toString();
-   }
-}

Copied: trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java (from rev 6022, trunk/core/src/main/org/jboss/portal/core/metadata/InstanceMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java	                        (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -0,0 +1,264 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * 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.jboss.portal.core.model.instance.metadata;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.metadata.MetaData;
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
+import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
+import org.w3c.dom.Element;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represent metadata of an instance.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InstanceMetaData implements MetaData
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(InstanceMetaData.class);
+
+   /** The instance id. */
+   private String id;
+
+   /** The specific preferences of this instance. */
+   private PreferencesMetaData preferences;
+
+   /** The portlet referenced by the instance. */
+   private String portletRef;
+
+   /** The security constraints. */
+   private SecurityConstraintsMetaData securityConstraints;
+
+   public InstanceMetaData()
+   {
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   public PreferencesMetaData getPreferences()
+   {
+      return preferences;
+   }
+
+   public void setPreferences(PreferencesMetaData preferences)
+   {
+      this.preferences = preferences;
+   }
+
+   public String getPortletRef()
+   {
+      return portletRef;
+   }
+
+   public void setPortletRef(String portletRef)
+   {
+      this.portletRef = portletRef;
+   }
+
+   public SecurityConstraintsMetaData getSecurityConstraints()
+   {
+      return securityConstraints;
+   }
+
+   public void setSecurityConstraints(SecurityConstraintsMetaData securityConstraints)
+   {
+      this.securityConstraints = securityConstraints;
+   }
+
+   public static InstanceMetaData buildMetaData(Element instanceElt)
+   {
+      String instanceName = XML.asString(XML.getUniqueChild(instanceElt, "instance-id", true));
+      String componentRef = XML.asString(XML.getUniqueChild(instanceElt, "portlet-ref", true));
+
+      // Configure preferences override
+      PreferencesMetaData preferencesMD = new PreferencesMetaData();
+      Element preferencesElt = XML.getUniqueChild(instanceElt, "preferences", false);
+      if (preferencesElt != null)
+      {
+         for (Iterator i = buildPreferencesMetaData(preferencesElt).values().iterator(); i.hasNext();)
+         {
+            PreferenceMetaData preferenceMD = (PreferenceMetaData)i.next();
+            preferencesMD.addPreference(preferenceMD);
+         }
+      }
+
+      // Create the meta data
+      InstanceMetaData instanceMD = new InstanceMetaData();
+      instanceMD.setId(instanceName);
+      instanceMD.setPortletRef(componentRef);
+      instanceMD.setPreferences(preferencesMD);
+
+      // Add the security constraints
+      Element securityConstraintElt = XML.getUniqueChild(instanceElt, "security-constraint", false);
+      if (securityConstraintElt != null)
+      {
+         SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
+         instanceMD.setSecurityConstraints(securityConstraintsMD);
+      }
+
+      //
+      return instanceMD;
+   }
+
+   /**
+    * @param instanceElt the instance xml element
+    * @param pwaId       the portlet application id
+    */
+   public static InstanceMetaData buildLegacyMetaData(Element instanceElt, String pwaId)
+   {
+      Element instanceNameElt = XML.getUniqueChild(instanceElt, "instance-name", true);
+      Element componentRefElt = XML.getUniqueChild(instanceElt, "component-ref", true);
+
+      //
+      String instanceName = XML.asString(instanceNameElt);
+      String componentRef = XML.asString(componentRefElt);
+
+      //
+      int dotIndex = componentRef.indexOf('.');
+
+      //
+      if (dotIndex == -1)
+      {
+         log.warn("Bad component ref " + componentRef);
+      }
+      else
+      {
+         String appId = componentRef.substring(0, dotIndex);
+         if (appId.equals(pwaId) == false)
+         {
+            log.warn("The instance " + instanceName + " will not be created because the component referenced is outside of the same web app " + componentRef);
+         }
+         else
+         {
+            String portletRef = componentRef.substring(dotIndex + 1);
+
+            if (portletRef.length() == 0)
+            {
+               log.warn("Zero portlet ref length are not considered " + componentRef);
+            }
+            else
+            {
+               log.debug("Adding legacy instance " + instanceName);
+
+               //
+               InstanceMetaData instanceMD = new InstanceMetaData();
+               instanceMD.setId(instanceName);
+               instanceMD.setPortletRef(portletRef);
+
+               // Configure preferences
+               PreferencesMetaData preferencesMD = new PreferencesMetaData();
+               Element preferencesElt = XML.getUniqueChild(instanceElt, "preferences", false);
+               if (preferencesElt != null)
+               {
+                  for (Iterator j = InstanceMetaData.buildPreferencesMetaData(preferencesElt).values().iterator(); j.hasNext();)
+                  {
+                     PreferenceMetaData preferenceMD = (PreferenceMetaData)j.next();
+                     preferencesMD.addPreference(preferenceMD);
+                  }
+               }
+
+               // Add the security constraints
+               Element securityConstraintElt = XML.getUniqueChild(instanceElt, "security-constraint", false);
+               if (securityConstraintElt != null)
+               {
+                  SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
+                  instanceMD.setSecurityConstraints(securityConstraintsMD);
+               }
+
+               //
+               return instanceMD;
+            }
+         }
+      }
+
+      //
+      return null;
+   }
+
+   public static Map buildPreferencesMetaData(Element portletPreferencesElt)
+   {
+      Map preferences = new HashMap();
+      for (Iterator i = XML.getChildrenIterator(portletPreferencesElt, "preference"); i.hasNext();)
+      {
+         Element preferenceElt = (Element)i.next();
+         PreferenceMetaData preference = buildPreferenceMetaData(preferenceElt);
+         preferences.put(preference.getName(), preference);
+      }
+      return preferences;
+   }
+
+   public static PreferenceMetaData buildPreferenceMetaData(Element preferenceElt)
+   {
+      PreferenceMetaData preferenceMD = new PreferenceMetaData();
+      List valuesElt = XML.getChildren(preferenceElt, "value");
+      String[] values = new String[valuesElt.size()];
+      for (int i = 0; i < valuesElt.size(); i++)
+      {
+         values[i] = XML.asString((Element)valuesElt.get(i));
+      }
+      Element readOnlyElt = XML.getUniqueChild(preferenceElt, "read-only", false);
+      boolean readOnly = false;
+      if (readOnlyElt != null)
+      {
+         String value = XML.asString(readOnlyElt);
+         if ("true".equals(value))
+         {
+            readOnly = true;
+         }
+         else if ("false".equals(value))
+         {
+            readOnly = false;
+         }
+         else
+         {
+            // log.debug("Unrecognized value for read only " + value);
+            readOnly = false;
+         }
+      }
+      else
+      {
+         readOnly = false;
+      }
+      preferenceMD.setName(XML.asString(XML.getUniqueChild(preferenceElt, "name", true)));
+      preferenceMD.setReadOnly(readOnly);
+      preferenceMD.setValues(values);
+      return preferenceMD;
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/PreferencesMetaData.java (from rev 6022, trunk/core/src/main/org/jboss/portal/core/metadata/PreferencesMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/PreferencesMetaData.java	                        (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/PreferencesMetaData.java	2007-01-18 16:28:48 UTC (rev 6033)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * 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.jboss.portal.core.model.instance.metadata;
+
+import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PreferencesMetaData
+{
+
+   private Map map = new HashMap();
+
+   public void addPreference(PreferenceMetaData preference)
+   {
+      map.put(preference.getName(), preference);
+   }
+
+   public Iterator iterator()
+   {
+      return map.values().iterator();
+   }
+
+   public int size()
+   {
+      return map.size();
+   }
+
+   public PreferenceMetaData getPreference(String key)
+   {
+      return (PreferenceMetaData)map.get(key);
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/instance/metadata/PreferencesMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the portal-commits mailing list