[portletswap-commits] JBoss PortletSwap SVN: r224 - in src/server/trunk: server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl and 13 other directories.

portletswap-commits at lists.jboss.org portletswap-commits at lists.jboss.org
Mon Jan 28 08:26:48 EST 2008


Author: thomas.heute at jboss.com
Date: 2008-01-28 08:26:48 -0500 (Mon, 28 Jan 2008)
New Revision: 224

Added:
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/AbstractDirectoryService.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/ModuleFilter.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/CategoryFilter.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/TypeFilter.java
   src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/DisplayNameModel.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModel.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelFactory.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelProvider.java
   src/server/trunk/server-webapp/src/main/resources/result.xsd
   src/server/trunk/server-webapp/src/test/resources/resultGetCategories.xml
Removed:
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java
   src/server/trunk/server-webapp/src/main/resources/result.xsd
Modified:
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java
   src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java
   src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java
   src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java
   src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java
   src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java
Log:


Modified: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -24,10 +24,10 @@
 
 import java.util.List;
 
-import org.jboss.portletswap.filter.Filter;
+import org.jboss.portletswap.filter.ModuleFilter;
+import org.jboss.portletswap.filter.CategoryFilter;
 import org.jboss.portletswap.model.Category;
 import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.Type;
 
 /**
  * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
@@ -48,23 +48,16 @@
     */
    public List<Module> getModules(boolean published, Ordering ordering);
 
-   public List<Module> getModules(boolean published, Type type);
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters);
 
-   public List<Module> getModules(boolean published, Type type, Ordering ordering);
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters, Ordering ordering);
 
-   public List<Module> getModules(boolean published, Category category);
+   public List<Category> getCategories(boolean published);
 
-   public List<Module> getModules(boolean published, Category category, Ordering ordering);
+   public List<Category> getCategories(boolean published, Ordering ordering);
 
-   public List<Module> getModules(boolean published, Filter filter);
+   public List<Category> getCategories(boolean published, List<CategoryFilter> filters);
 
-   public List<Module> getModules(boolean published, Filter filter, Ordering ordering);
-
-   public List<Module> getModules(boolean published, List<Filter> filters);
-
-   public List<Module> getModules(boolean published, List<Filter> filters, Ordering ordering);
-
-   public List<Category> getCategories(boolean published);
-
+   public List<Category> getCategories(boolean published, List<CategoryFilter> filters, Ordering ordering);
 }
 

Added: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/AbstractDirectoryService.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/AbstractDirectoryService.java	                        (rev 0)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/AbstractDirectoryService.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * 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.portletswap.directory.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.Ordering;
+import org.jboss.portletswap.filter.CategoryFilter;
+import org.jboss.portletswap.filter.ModuleFilter;
+import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.Module;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDirectoryService implements DirectoryService
+{
+
+   public List<Category> getCategories(boolean published)
+   {
+      return getCategories(published, Ordering.NO_SPECIAL_ORDER);
+   }
+   
+   public List<Category> getCategories(boolean published, Ordering ordering)
+   {
+      return getCategories(published, new ArrayList<CategoryFilter>(), ordering);
+   }
+
+   public List<Category> getCategories(boolean published, List<CategoryFilter> filters)
+   {
+      return getCategories(published, filters, Ordering.NO_SPECIAL_ORDER);
+   }
+
+   public abstract List<Category> getCategories(boolean published, List<CategoryFilter> filters, Ordering ordering);
+
+   public List<Module> getModules(boolean published)
+   {
+      return getModules(published, Ordering.NO_SPECIAL_ORDER);
+   }
+
+   public List<Module> getModules(boolean published, Ordering ordering)
+   {
+      return getModules(published, new ArrayList<ModuleFilter>(), ordering);
+   }
+
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters)
+   {
+      return getModules(published, filters, Ordering.NO_SPECIAL_ORDER);
+   }
+
+   public abstract List<Module> getModules(boolean published, List<ModuleFilter> filters, Ordering ordering);
+
+}
+

Modified: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -26,7 +26,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -35,10 +34,10 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 
-import org.jboss.portletswap.DirectoryService;
 import org.jboss.portletswap.Ordering;
-import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.filter.Filter;
+import org.jboss.portletswap.directory.impl.AbstractDirectoryService;
+import org.jboss.portletswap.filter.CategoryFilter;
+import org.jboss.portletswap.filter.ModuleFilter;
 import org.jboss.portletswap.jcr.JCRService;
 import org.jboss.portletswap.model.Category;
 import org.jboss.portletswap.model.Module;
@@ -50,7 +49,7 @@
  * @version $Revision$
  */
 @SuppressWarnings("serial")
-public class DirectoryServiceImpl implements DirectoryService, Serializable
+public class DirectoryServiceImpl extends AbstractDirectoryService implements Serializable
 {
 
 
@@ -66,12 +65,25 @@
       this.jcrService = jcrService;
    }
    
-   public List<Module> getModules(boolean published)
+   private String orderby(Ordering ordering)
    {
-      return getModules(published, Ordering.NO_SPECIAL_ORDER);
+      if (Ordering.NAME_ASC.equals(ordering.name()))
+      {
+         return "ORDER BY ps:name";
+      }
+      else if (Ordering.NAME_DESC.equals(ordering.name()))
+      {
+         return " ORDER BY ps:name DESC";
+      }
+      else if (Ordering.NO_SPECIAL_ORDER.equals(ordering.name()))
+      {
+         return "";
+      }
+      return "";
    }
 
-   public List<Module> getModules(boolean published, Ordering ordering)
+   /*
+   public List<Module> getModules(boolean published, Category category)
    {
       String workspace = JCRService.MODULE_WORKSPACE_NAME;
       if (published)
@@ -84,7 +96,7 @@
       {
          session = jcrService.openSession(workspace);
          QueryManager queryManager = session.getWorkspace().getQueryManager();
-         Query query = queryManager.createQuery("SELECT * from ps:module " + orderby(ordering), Query.SQL);
+         Query query = queryManager.createQuery("SELECT * from ps:module where ps:categories = '" + category.getId() + "'", Query.SQL);
          QueryResult queryResult = query.execute();
          
          NodeIterator it = queryResult.getNodes();
@@ -113,38 +125,11 @@
       }
       return null;
    }
+   */
 
-   private String orderby(Ordering ordering)
+   @Override
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters, Ordering ordering)
    {
-      if (Ordering.NAME_ASC.equals(ordering.name()))
-      {
-         return "ORDER BY ps:name";
-      }
-      else if (Ordering.NAME_DESC.equals(ordering.name()))
-      {
-         return " ORDER BY ps:name DESC";
-      }
-      else if (Ordering.NO_SPECIAL_ORDER.equals(ordering.name()))
-      {
-         return "";
-      }
-      return "";
-   }
-
-   public List<Module> getModules(boolean published, Type type)
-   {
-      // FIXME getModules
-      return null;
-   }
-
-   public List<Module> getModules(boolean published, Type type, Ordering ordering)
-   {
-      // FIXME getModules
-      return null;
-   }
-
-   public List<Module> getModules(boolean published, Category category)
-   {
       String workspace = JCRService.MODULE_WORKSPACE_NAME;
       if (published)
       {
@@ -156,7 +141,7 @@
       {
          session = jcrService.openSession(workspace);
          QueryManager queryManager = session.getWorkspace().getQueryManager();
-         Query query = queryManager.createQuery("SELECT * from ps:module where ps:categories = '" + category.getId() + "'", Query.SQL);
+         Query query = queryManager.createQuery("SELECT * from " + JCRModuleImpl.NODE_TYPE + " " + orderby(ordering), Query.SQL);
          QueryResult queryResult = query.execute();
          
          NodeIterator it = queryResult.getNodes();
@@ -164,17 +149,17 @@
          while (it.hasNext())
          {
             Node node = it.nextNode();
-            if (node.isNodeType("ps:module"))
+            if (node.isNodeType(JCRModuleImpl.NODE_TYPE))
             {
-               result.add(new JCRModuleImpl(jcrService, node));
+               Module module = new JCRModuleImpl(jcrService, node);
+               if (acceptModule(filters, module))
+               {
+                  result.add(new JCRModuleImpl(jcrService, node));
+               }
             }
          }
          return result;
       }
-      catch (ItemNotFoundException e)
-      {
-         return null;
-      }
       catch (RepositoryException e)
       {
          e.printStackTrace();
@@ -185,39 +170,34 @@
       }
       return null;
    }
-
-   public List<Module> getModules(boolean published, Category category, Ordering ordering)
+   
+   public boolean acceptModule(List<ModuleFilter> filters, Module module)
    {
-      // FIXME getModules
-      return null;
+      for (ModuleFilter filter: filters)
+      {
+         if (!filter.accept(module))
+         {
+            return false;
+         }
+      }
+      return true;
    }
 
-   public List<Module> getModules(boolean published, Filter filter)
+   public boolean acceptCategory(List<CategoryFilter> filters, Category category)
    {
-      // FIXME getModules
-      return null;
+      for (CategoryFilter filter: filters)
+      {
+         if (!filter.accept(category))
+         {
+            return false;
+         }
+      }
+      return true;
    }
 
-   public List<Module> getModules(boolean published, Filter filter, Ordering ordering)
+   @Override
+   public List<Category> getCategories(boolean published, List<CategoryFilter> filters, Ordering ordering)
    {
-      // FIXME getModules
-      return null;
-   }
-
-   public List<Module> getModules(boolean published, List<Filter> filters)
-   {
-      // FIXME getModules
-      return null;
-   }
-
-   public List<Module> getModules(boolean published, List<Filter> filters, Ordering ordering)
-   {
-      // FIXME getModules
-      return null;
-   }
-
-   public List<Category> getCategories(boolean published)
-   {
       String workspace = JCRService.MODULE_WORKSPACE_NAME;
       if (published)
       {
@@ -237,7 +217,11 @@
          while (it.hasNext())
          {
             Node node = it.nextNode();
-            result.add(new JCRCategoryImpl(jcrService, node));
+            Category category = new JCRCategoryImpl(jcrService, node);
+            if (acceptCategory(filters, category))
+            {
+               result.add(category);
+            }
          }
          return result;
       }

Modified: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -32,12 +32,11 @@
 import java.util.TreeSet;
 
 import org.jboss.portal.common.util.Tools;
-import org.jboss.portletswap.DirectoryService;
 import org.jboss.portletswap.Ordering;
 import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.filter.CategoryFilter;
-import org.jboss.portletswap.filter.Filter;
-import org.jboss.portletswap.filter.TypeFilter;
+import org.jboss.portletswap.filter.ModuleFilter;
+import org.jboss.portletswap.filter.module.CategoryFilter;
+import org.jboss.portletswap.filter.module.TypeFilter;
 import org.jboss.portletswap.model.Category;
 import org.jboss.portletswap.model.Module;
 
@@ -45,7 +44,7 @@
  * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  * @version $Revision$
  */
-public class DirectoryServiceImpl implements DirectoryService
+public class DirectoryServiceImpl extends org.jboss.portletswap.directory.impl.AbstractDirectoryService
 {
    private Map<Object, Module> modules;
    
@@ -83,25 +82,25 @@
 
    public List<Module> getModules(boolean published, Category category, Ordering ordering)
    {
-      List<Filter> filters = new ArrayList<Filter>();
+      List<ModuleFilter> filters = new ArrayList<ModuleFilter>();
       filters.add(new CategoryFilter(category));
       return getModules(published, filters);
    }
 
-   public List<Module> getModules(boolean published, Filter filter)
+   public List<Module> getModules(boolean published, ModuleFilter filter)
    {
       return getModules(published, filter, Ordering.NO_SPECIAL_ORDER);
    }
    
 
-   public List<Module> getModules(boolean published, Filter filter, Ordering ordering)
+   public List<Module> getModules(boolean published, ModuleFilter filter, Ordering ordering)
    {
-      List<Filter> list = new ArrayList<Filter>();
+      List<ModuleFilter> list = new ArrayList<ModuleFilter>();
       list.add(filter);
       return getModules(published, list, ordering);
    }
    
-   public List<Module> getModules(boolean published, List<Filter> filters, Ordering ordering)
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters, Ordering ordering)
    {
       Set<Module> result = null;
       Comparator<Module> comparator = getComparator(ordering);
@@ -116,7 +115,7 @@
       for(Module module: modules.values())
       {
          boolean accept = true;
-         for (Filter filter:filters)
+         for (ModuleFilter filter:filters)
          {
             if (!filter.accept(module))
             {
@@ -131,7 +130,7 @@
       return Tools.toList(result.iterator());
    }
 
-   public List<Module> getModules(boolean published, List<Filter> filters)
+   public List<Module> getModules(boolean published, List<ModuleFilter> filters)
    {
       return getModules(published, filters, Ordering.NO_SPECIAL_ORDER);
    }
@@ -162,7 +161,9 @@
       return null;
    }
 
-   public List<Category> getCategories(boolean published)
+   @Override
+   public List<Category> getCategories(boolean published, List<org.jboss.portletswap.filter.CategoryFilter> filters,
+         Ordering ordering)
    {
       // FIXME getCategories
       return null;

Deleted: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,56 +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.portletswap.filter;
-
-import org.jboss.portletswap.model.Category;
-import org.jboss.portletswap.model.Module;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class CategoryFilter implements Filter
-{
-
-   private Category category;
-   
-   public CategoryFilter(Category category)
-   {
-      this.category = category;
-   }
-   
-   public boolean accept(Module module)
-   {
-      /** TODO: do it recursively */
-      if (module.getCategories().contains(category))
-      {
-         return true;
-      }
-      else
-      {
-         return false;
-      }
-   }
-
-}
-

Deleted: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,36 +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.portletswap.filter;
-
-import org.jboss.portletswap.model.Module;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public interface Filter
-{
-
-   public boolean accept(Module module);
-}
-

Copied: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/ModuleFilter.java (from rev 216, src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java)
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/ModuleFilter.java	                        (rev 0)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/ModuleFilter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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.portletswap.filter;
+
+import org.jboss.portletswap.model.Module;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface ModuleFilter
+{
+
+   public boolean accept(Module module);
+}
+

Deleted: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,55 +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.portletswap.filter;
-
-import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.model.Module;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class TypeFilter implements Filter
-{
-
-   private Type type;
-   
-   public TypeFilter(Type type)
-   {
-      this.type = type;
-   }
-   
-   public boolean accept(Module module)
-   {
-      if (module.getType().equals(type))
-      {
-         return true;
-      }
-      else
-      {
-         return false;
-      }
-   }
-
-}
-

Copied: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/CategoryFilter.java (from rev 216, src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java)
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/CategoryFilter.java	                        (rev 0)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/CategoryFilter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.portletswap.filter.module;
+
+import java.util.List;
+
+import org.jboss.portletswap.filter.ModuleFilter;
+import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.Module;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CategoryFilter implements ModuleFilter
+{
+
+   private Category category;
+   
+   public CategoryFilter(Category category)
+   {
+      this.category = category;
+   }
+   
+   public boolean accept(Module module)
+   {
+      List<Category> categories = module.getCategories();
+      
+      for (Category tmpCategory: categories)
+      {
+         if (category.getId().equals(tmpCategory.getId()))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+
+}
+

Copied: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/TypeFilter.java (from rev 216, src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java)
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/TypeFilter.java	                        (rev 0)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/module/TypeFilter.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.portletswap.filter.module;
+
+import org.jboss.portletswap.filter.ModuleFilter;
+import org.jboss.portletswap.model.Type;
+import org.jboss.portletswap.model.Module;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class TypeFilter implements ModuleFilter
+{
+
+   private Type type;
+   
+   public TypeFilter(Type type)
+   {
+      this.type = type;
+   }
+   
+   public boolean accept(Module module)
+   {
+      if (module.getType().equals(type))
+      {
+         return true;
+      }
+      else
+      {
+         return false;
+      }
+   }
+
+}
+

Modified: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -55,6 +55,7 @@
 
    public static final String ROOT_MODULE_NODENAME = "org.jboss.portletswap.root_module";
    public static final String NODE_NAME = "ps:module";
+   public static final String NODE_TYPE = "ps:module";
    public static final String DESCRIPTION_NODENAME = "ps:description";
    public static final String ARTIFACTS_NODENAME = "ps:artifacts";
    public static final String DESCRIPTION_LANG_ATTRIBUTENAME = "jcr:language";

Modified: src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -25,6 +25,7 @@
 import static org.jboss.unit.api.Assert.assertEquals;
 import static org.jboss.unit.api.Assert.assertNull;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.jcr.Node;
@@ -33,6 +34,8 @@
 import javax.jcr.Session;
 
 import org.jboss.portletswap.PortletswapException;
+import org.jboss.portletswap.filter.module.CategoryFilter;
+import org.jboss.portletswap.filter.ModuleFilter;
 import org.jboss.portletswap.jcr.JCRService;
 import org.jboss.portletswap.jcr.JCRServiceImpl;
 import org.jboss.portletswap.model.Category;
@@ -180,12 +183,17 @@
       module2 = repositoryService.storeModule(module2);
       List<Module> modules = directoryService.getModules(false);
       assertEquals(2, modules.size());
-      modules = directoryService.getModules(false, category);
+      List<ModuleFilter> filters = new ArrayList<ModuleFilter>();
+      filters.add(new CategoryFilter(category));
+      modules = directoryService.getModules(false, filters);
+      System.out.println("*************************************************");
+      System.out.println(module.getCategories().get(0));
+      System.out.println(category);
       assertEquals(1, modules.size());
       module2.addCategory(category);
-      modules = directoryService.getModules(false, category);
+      modules = directoryService.getModules(false, filters);
       assertEquals(2, modules.size());
-      modules = directoryService.getModules(true, category);
+      modules = directoryService.getModules(true, filters);
       assertEquals(0, modules.size());
    }
 }

Added: src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java
===================================================================
--- src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java	                        (rev 0)
+++ src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/CompatibilityLevel.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.portletswap.model;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public enum CompatibilityLevel {
+
+   COMPATIBLE, INCOMPATIBLE, UNKNOWN
+}
+

Modified: src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java
===================================================================
--- src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -35,7 +35,7 @@
    
    private String text;
 
-   protected License()
+   public License()
    {
       
    }

Deleted: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,37 +0,0 @@
-package org.jboss.portletswap.metadata;
-
-import java.util.Locale;
-
-public class DisplayNameModel {
-
-   private Locale lang;
-
-   private String text;
-
-   public DisplayNameModel(Locale lang, String text)
-   {
-      this.lang = lang;
-      this.text = text;
-   }
-
-   public DisplayNameModel(Locale lang)
-   {
-      this.lang = lang;
-   }
-
-   public Locale getLang() {
-      return lang;
-   }
-
-   public void setLang(Locale lang) {
-      this.lang = lang;
-   }
-
-   public String getText() {
-      return text;
-   }
-
-   public void setText(String text) {
-      this.text = text;
-   }
-}

Deleted: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,54 +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.portletswap.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.portletswap.model.Category;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ResultModel
-{
-   private List<Category> categories;
-
-   public ResultModel()
-   {
-      categories = new ArrayList<Category>();
-   }
-   
-   public List<Category> getCategories()
-   {
-      return categories;
-   }
-
-   public void addCategory(Category category)
-   {
-      categories.add(category);
-   }
-
-}
-

Deleted: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,124 +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.portletswap.metadata;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.i18n.LocalizedString.Value;
-import org.jboss.portletswap.model.Category;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ResultModelFactory implements ObjectModelFactory
-{
-
-   public Object completeRoot(Object arg0, UnmarshallingContext arg1, String arg2, String arg3)
-   {
-      return arg0;
-   }
-
-   public ResultModel newRoot(Object arg0, UnmarshallingContext arg1, String arg2, String arg3, Attributes arg4)
-   {
-      return new ResultModel();
-   }
-
-   public Object newChild(ResultModel result,
-         UnmarshallingContext context,
-         String namespaceURI,
-         String localName,
-         Attributes attrs)
-   {
-      Object child = null;
-      if("category".equals(localName))
-      {
-         child = new Category();
-      }
-      return child;
-   }
-   
-   public Object newChild(Category result,
-         UnmarshallingContext context,
-         String namespaceURI,
-         String localName,
-         Attributes attrs)
-   {
-      Object child = null;
-      if("displayName".equals(localName))
-      {
-         child = new DisplayNameModel(new Locale(attrs.getValue("lang")));
-      }
-      return child;
-   }
-
-   public void setValue(DisplayNameModel displayName, UnmarshallingContext navigator,
-                String namespaceUri, String localName, String value)
-   {
-      displayName.setText(value);
-   }
-
-   /**
-    * Called when parsing character is complete.
-    */
-   public void addChild(ResultModel result, Category category, UnmarshallingContext arg1, String arg2, String arg3)
-   {
-      result.addCategory(category);
-   }
-
-   /**
-    * Called when parsing character is complete.
-    */
-   public void addChild(Category category, Category childCategory, UnmarshallingContext arg1, String arg2, String arg3)
-   {
-      category.addChild(childCategory);
-   }
-
-   /**
-    * Called when parsing character is complete.
-    */
-   public void addChild(Category category, DisplayNameModel displayName, UnmarshallingContext arg1, String arg2, String arg3)
-   {
-      LocalizedString lString = category.getDisplayName();
-      @SuppressWarnings("unchecked")
-      Map<Locale, Value> values = lString.getValues();
-      Map<Locale, String> result = new HashMap<Locale, String>();
-      Iterator<Value> it = values.values().iterator();
-      while (it.hasNext())
-      {
-         Value value = it.next();
-         result.put(value.getLocale(), value.getString());
-      }
-      result.put(displayName.getLang(), displayName.getText());
-      category.setDisplayName(new LocalizedString(result, lString.getDefaultLocale()));
-   }
-
-}
-

Deleted: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,117 +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.portletswap.metadata;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.jboss.portal.common.i18n.LocalizedString.Value;
-import org.jboss.portletswap.model.Category;
-import org.jboss.xb.binding.MarshallingContext;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ResultModelProvider implements org.jboss.xb.binding.ObjectModelProvider
-{
-
-   public ResultModel getRoot(Object object, MarshallingContext arg1, String namespaceURI, String localName)
-   {
-      return (ResultModel)object;
-   }
-   
-   public List<Category> getChildren(ResultModel result, String namespaceUri, String localName)
-   {
-      if ("category".equals(localName))
-      {
-         return result.getCategories();
-      }
-      return null;
-   }
-
-   public Object getChildren(Category category, String namespaceUri, String localName)
-   {
-      if ("category".equals(localName))
-      {
-         List<Category> children = new ArrayList<Category>();
-         children.addAll(category.getChildren());
-         return children;
-      }
-      else if ("displayName".equals(localName))
-      {
-         List<DisplayNameModel> children = new ArrayList<DisplayNameModel>();
-         if (category.getDisplayName() != null)
-         {
-            @SuppressWarnings("unchecked")
-            Map<Locale, Value> map = category.getDisplayName().getValues();
-            Iterator<Value> it = map.values().iterator();
-            while (it.hasNext())
-            {
-               Value value = it.next();
-               children.add(new DisplayNameModel(value.getLocale(), value.getString()));
-            }
-         }
-         return children;
-      }
-      return null;
-   }
-
-
-   public String getAttributeValue(Category category, String namespaceUri, String localName)
-   {
-      String value = null;
-      if("id".equals(localName))
-      {
-         value = category.getId().toString();
-      }
-      else
-      {
-         value = null;
-      }
-      return value;
-   }
-
-   public String getAttributeValue(DisplayNameModel displayName, String namespaceUri, String localName)
-   {
-      String value = null;
-      if("lang".equals(localName))
-      {
-         value = displayName.getLang().toString();
-      }
-      else
-      {
-         value = null;
-      }
-      return value;
-   }
-      
-   public Object getElementValue(DisplayNameModel displayName, String namespaceUri, String localName)
-   {
-      return displayName.getText();
-   }
-}
-

Copied: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/DisplayNameModel.java (from rev 216, src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java)
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/DisplayNameModel.java	                        (rev 0)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/DisplayNameModel.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,37 @@
+package org.jboss.portletswap.metadata.parsing;
+
+import java.util.Locale;
+
+public class DisplayNameModel {
+
+   private Locale lang;
+
+   private String text;
+
+   public DisplayNameModel(Locale lang, String text)
+   {
+      this.lang = lang;
+      this.text = text;
+   }
+
+   public DisplayNameModel(Locale lang)
+   {
+      this.lang = lang;
+   }
+
+   public Locale getLang() {
+      return lang;
+   }
+
+   public void setLang(Locale lang) {
+      this.lang = lang;
+   }
+
+   public String getText() {
+      return text;
+   }
+
+   public void setText(String text) {
+      this.text = text;
+   }
+}

Added: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModel.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModel.java	                        (rev 0)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModel.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.portletswap.metadata.parsing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portletswap.model.Artifact;
+import org.jboss.portletswap.model.Category;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ResultModel
+{
+   private List<Category> categories;
+
+   private List<Artifact> artifacts;
+
+   public ResultModel()
+   {
+      categories = new ArrayList<Category>();
+      artifacts = new ArrayList<Artifact>();
+   }
+   
+   public List<Category> getCategories()
+   {
+      return categories;
+   }
+
+   public void addCategory(Category category)
+   {
+      categories.add(category);
+   }
+   
+   public void addArtifact(Artifact artifact)
+   {
+      artifacts.add(artifact);
+   }
+
+   public List<Artifact> getArtifacts()
+   {
+      return artifacts;
+   }
+}
+

Added: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelFactory.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelFactory.java	                        (rev 0)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelFactory.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * 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.portletswap.metadata.parsing;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString.Value;
+import org.jboss.portletswap.model.Category;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ResultModelFactory implements ObjectModelFactory
+{
+
+   public Object completeRoot(Object arg0, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      return arg0;
+   }
+
+   public ResultModel newRoot(Object arg0, UnmarshallingContext arg1, String arg2, String arg3, Attributes arg4)
+   {
+      return new ResultModel();
+   }
+
+   public Object newChild(ResultModel result,
+         UnmarshallingContext context,
+         String namespaceURI,
+         String localName,
+         Attributes attrs)
+   {
+      Object child = null;
+      if("category".equals(localName))
+      {
+         child = new Category();
+      }
+      return child;
+   }
+   
+   public Object newChild(Category result,
+         UnmarshallingContext context,
+         String namespaceURI,
+         String localName,
+         Attributes attrs)
+   {
+      Object child = null;
+      if("displayName".equals(localName))
+      {
+         child = new DisplayNameModel(new Locale(attrs.getValue("lang")));
+      }
+      return child;
+   }
+
+   public void setValue(DisplayNameModel displayName, UnmarshallingContext navigator,
+                String namespaceUri, String localName, String value)
+   {
+      displayName.setText(value);
+   }
+
+   /**
+    * Called when parsing character is complete.
+    */
+   public void addChild(ResultModel result, Category category, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      result.addCategory(category);
+   }
+
+   /**
+    * Called when parsing character is complete.
+    */
+   public void addChild(Category category, Category childCategory, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      category.addChild(childCategory);
+   }
+
+   /**
+    * Called when parsing character is complete.
+    */
+   public void addChild(Category category, DisplayNameModel displayName, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      LocalizedString lString = category.getDisplayName();
+      @SuppressWarnings("unchecked")
+      Map<Locale, Value> values = lString.getValues();
+      Map<Locale, String> result = new HashMap<Locale, String>();
+      Iterator<Value> it = values.values().iterator();
+      while (it.hasNext())
+      {
+         Value value = it.next();
+         result.put(value.getLocale(), value.getString());
+      }
+      result.put(displayName.getLang(), displayName.getText());
+      category.setDisplayName(new LocalizedString(result, lString.getDefaultLocale()));
+   }
+
+}
+

Copied: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelProvider.java (from rev 216, src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java)
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelProvider.java	                        (rev 0)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/parsing/ResultModelProvider.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,175 @@
+/******************************************************************************
+ * 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.portletswap.metadata.parsing;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.portal.common.i18n.LocalizedString.Value;
+import org.jboss.portletswap.model.Artifact;
+import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.FileArtifact;
+import org.jboss.portletswap.model.License;
+import org.jboss.xb.binding.MarshallingContext;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ResultModelProvider implements org.jboss.xb.binding.ObjectModelProvider
+{
+
+   public ResultModel getRoot(Object object, MarshallingContext arg1, String namespaceURI, String localName)
+   {
+      return (ResultModel)object;
+   }
+   
+   public Object getChildren(ResultModel result, String namespaceUri, String localName)
+   {
+      if (localName.equals("categories"))
+      {
+         List<Category> categories = result.getCategories();
+         if (categories.size() != 0)
+         {
+            return result.getCategories();
+         }
+      }
+      else if (localName.equals("artifacts"))
+      {
+         List<Artifact> artifacts = result.getArtifacts();
+         if (artifacts.size() != 0)
+         {
+            return result.getArtifacts();
+         }
+      }
+      return null;
+   }
+
+   public Object getChildren(Category category, String namespaceUri, String localName)
+   {
+      if ("category".equals(localName))
+      {
+         return category.getChildren();
+      }
+      else if ("displayName".equals(localName))
+      {
+         List<DisplayNameModel> children = new ArrayList<DisplayNameModel>();
+         if (category.getDisplayName() != null)
+         {
+            @SuppressWarnings("unchecked")
+            Map<Locale, Value> map = category.getDisplayName().getValues();
+            Iterator<Value> it = map.values().iterator();
+            while (it.hasNext())
+            {
+               Value value = it.next();
+               children.add(new DisplayNameModel(value.getLocale(), value.getString()));
+            }
+         }
+         return children;
+      }
+      return null;
+   }
+
+   public Object getChildren(FileArtifact artifact, String namespaceUri, String localName)
+   {
+      if ("displayName".equals(localName))
+      {
+         List<DisplayNameModel> children = new ArrayList<DisplayNameModel>();
+         if (artifact.getDisplayName() != null)
+         {
+            @SuppressWarnings("unchecked")
+            Map<Locale, Value> map = artifact.getDisplayName().getValues();
+            Iterator<Value> it = map.values().iterator();
+            while (it.hasNext())
+            {
+               Value value = it.next();
+               children.add(new DisplayNameModel(value.getLocale(), value.getString()));
+            }
+         }
+         return children;
+      }
+      else if ("license".equals(localName))
+      {
+         return artifact.getLicense();
+      }
+      return null;
+   }
+
+   public String getAttributeValue(FileArtifact artifact, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("id".equals(localName))
+      {
+         value = artifact.getId().toString();
+      }
+      return value;
+   }
+
+   public String getAttributeValue(Category category, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("id".equals(localName))
+      {
+         value = category.getId().toString();
+      }
+      return value;
+   }
+
+   public String getAttributeValue(DisplayNameModel displayName, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("lang".equals(localName))
+      {
+         value = displayName.getLang().toString();
+      }
+      else
+      {
+         value = null;
+      }
+      return value;
+   }
+      
+   public Object getElementValue(DisplayNameModel displayName, String namespaceUri, String localName)
+   {
+      return displayName.getText();
+   }
+
+   public String getAttributeValue(License license, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("id".equals(localName))
+      {
+         value = license.getName().toString();
+      }
+      return value;
+   }
+
+   public Object getElementValue(License license, String namespaceUri, String localName)
+   {
+      return license.getName();
+   }
+}
+

Modified: src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java
===================================================================
--- src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -18,8 +18,8 @@
 
 import org.jboss.portal.common.i18n.LocalizedString;
 //import org.jboss.portletswap.RepositoryService;
-import org.jboss.portletswap.metadata.ResultModel;
-import org.jboss.portletswap.metadata.ResultModelProvider;
+import org.jboss.portletswap.metadata.parsing.ResultModel;
+import org.jboss.portletswap.metadata.parsing.ResultModelProvider;
 import org.jboss.portletswap.model.Artifact;
 import org.jboss.portletswap.model.Category;
 import org.jboss.portletswap.model.FileArtifact;
@@ -42,6 +42,8 @@
 // private DirectoryService directoryService;
 
    private Category rootCategory;
+   
+   private Artifact artifact;
 
    @Override
    public void destroy()
@@ -82,7 +84,7 @@
       category3.setDisplayName(new LocalizedString("foobar"));
 
       Module module = new Module("Toto");
-      Artifact artifact = new FileArtifact(Type.JSR168PORTLET, module, new File("/tmp"), new ByteArrayInputStream(new byte[0]));
+      artifact = new FileArtifact(Type.JSR168PORTLET, module, new File("/tmp"), new ByteArrayInputStream(new byte[0]));
       module.addArtifact(artifact);
    }
 
@@ -121,12 +123,24 @@
 
       if ("categories".equals(command))
       {
-         printCategories(pw, getCategoriesResult());
+         returnCategories(pw, getCategoriesResult());
       }
+      else if ("artifacts".equals(command))
+      {
+         returnCategories(pw, getArtifactsResult());
+      }
+      
       pw.flush();
       pw.close();
    }
 
+   private ResultModel getArtifactsResult()
+   {
+      ResultModel result = new ResultModel();
+      result.addArtifact(artifact);
+      return result;
+   }
+
    private ResultModel getCategoriesResult()
    {
       ResultModel result = new ResultModel();
@@ -134,7 +148,7 @@
       return result;
    }
 
-   private void printCategories(Writer writer, ResultModel result)
+   private void returnCategories(Writer writer, ResultModel result)
    {
       XercesXsMarshaller marshaller = new XercesXsMarshaller();
       marshaller.addRootElement("http://www.portletswap.com/directory", "", "result");

Deleted: src/server/trunk/server-webapp/src/main/resources/result.xsd
===================================================================
--- src/server/trunk/server-webapp/src/main/resources/result.xsd	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/main/resources/result.xsd	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema 
-	targetNamespace="http://www.portletswap.com/directory"
-	xmlns:ps="http://www.portletswap.com/directory"
-	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	elementFormDefault="qualified">
-
-	<xsd:element name="result" type="ps:result"></xsd:element>
-
-	<xsd:complexType name="result">
-		<xsd:sequence>
-			<xsd:element ref="ps:category" maxOccurs="unbounded" minOccurs="0">
-			</xsd:element>
-		</xsd:sequence>
-	</xsd:complexType>
-
-	<xsd:element name="category" type="ps:category"></xsd:element>
-
-	<xsd:complexType name="category">
-		<xsd:sequence>
-
-			<xsd:element name="displayName" type="ps:displayName"
-				maxOccurs="unbounded" minOccurs="0">
-				
-			</xsd:element>
-
-			<xsd:element name="category" type="ps:category"
-				maxOccurs="unbounded" minOccurs="0">
-			</xsd:element>
-		</xsd:sequence>
-
-		<xsd:attribute name="id" type="xsd:string"></xsd:attribute>
-	</xsd:complexType>
-
-	<xsd:complexType name="displayName">
-		<xsd:simpleContent>
-             <xsd:extension base="xsd:string">
-                 <xsd:attribute name="lang" type="xsd:string">
-                 </xsd:attribute>
-             </xsd:extension>
-        </xsd:simpleContent>
-	</xsd:complexType>
-
-
-	
-    <xsd:simpleType name="test">
-    	<xsd:restriction base="xsd:string"></xsd:restriction>
-    </xsd:simpleType>
-</xsd:schema>
\ No newline at end of file

Added: src/server/trunk/server-webapp/src/main/resources/result.xsd
===================================================================
--- src/server/trunk/server-webapp/src/main/resources/result.xsd	                        (rev 0)
+++ src/server/trunk/server-webapp/src/main/resources/result.xsd	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema 
+	targetNamespace="http://www.portletswap.com/directory"
+	xmlns:ps="http://www.portletswap.com/directory"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	elementFormDefault="qualified">
+
+	<xsd:element name="result" type="ps:result"></xsd:element>
+
+	<xsd:complexType name="result">
+		<xsd:sequence>
+			<xsd:element name="categories" type="ps:categories" maxOccurs="1" minOccurs="0">
+			</xsd:element>
+			<xsd:element name="artifacts" type="ps:artifacts" maxOccurs="1" minOccurs="0">
+			</xsd:element>
+		</xsd:sequence>
+	</xsd:complexType>
+	
+	<xsd:complexType name="categories">
+		<xsd:sequence>
+			<xsd:element name="category" type="ps:category"
+				maxOccurs="unbounded" minOccurs="1">
+			</xsd:element>
+		</xsd:sequence>
+	</xsd:complexType>	
+
+	<xsd:complexType name="artifacts">
+		<xsd:sequence>
+			<xsd:element name="artifact" type="ps:artifact"
+				maxOccurs="unbounded" minOccurs="1">
+			</xsd:element>
+		</xsd:sequence>
+	</xsd:complexType>	
+
+
+	<xsd:complexType name="category">
+		<xsd:sequence>
+
+			<xsd:element name="displayName" type="ps:displayName"
+				maxOccurs="unbounded" minOccurs="0">
+				
+			</xsd:element>
+
+			<xsd:element name="category" type="ps:category"
+				maxOccurs="unbounded" minOccurs="0">
+			</xsd:element>
+		</xsd:sequence>
+
+		<xsd:attribute name="id" type="xsd:string"></xsd:attribute>
+	</xsd:complexType>
+
+	<xsd:complexType name="displayName">
+		<xsd:simpleContent>
+             <xsd:extension base="xsd:string">
+                 <!-- xsd:attribute name="lang" type="xsd:string">
+                 </xsd:attribute-->
+             </xsd:extension>
+        </xsd:simpleContent>
+	</xsd:complexType>
+
+	<xsd:complexType name="artifact">
+		<xsd:sequence>
+			<xsd:element name="displayName" type="ps:displayName"
+				maxOccurs="unbounded" minOccurs="0">
+			</xsd:element>
+			<xsd:element name="license" type="ps:license"
+				maxOccurs="1" minOccurs="1">
+			</xsd:element>
+			<xsd:element name="compatibilityLevel" type="xsd:string"
+				maxOccurs="1" minOccurs="1">
+			</xsd:element>
+		</xsd:sequence>
+		<xsd:attribute name="id" type="xsd:string"></xsd:attribute>
+	</xsd:complexType>
+
+	<xsd:complexType name="license">
+		<xsd:simpleContent>
+             <xsd:extension base="xsd:string">
+                 <xsd:attribute name="id" type="xsd:string">
+                 </xsd:attribute>
+             </xsd:extension>
+        </xsd:simpleContent>
+	</xsd:complexType>
+
+</xsd:schema>
\ No newline at end of file

Modified: src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java
===================================================================
--- src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -1,7 +1,12 @@
 package org.jboss.portletswap.metadata;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.io.Writer;
 import java.util.HashMap;
 import java.util.Locale;
@@ -10,7 +15,14 @@
 import junit.framework.TestCase;
 
 import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.metadata.parsing.ResultModel;
+import org.jboss.portletswap.metadata.parsing.ResultModelProvider;
+import org.jboss.portletswap.model.Artifact;
 import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.FileArtifact;
+import org.jboss.portletswap.model.License;
+import org.jboss.portletswap.model.Module;
+import org.jboss.portletswap.model.Type;
 import org.jboss.xb.binding.ObjectModelProvider;
 import org.jboss.xb.binding.XercesXsMarshaller;
 import org.xml.sax.SAXException;
@@ -28,11 +40,69 @@
       marshaller.declareNamespace("", "http://www.portletswap.com/directory");
       
       ObjectModelProvider provider = new ResultModelProvider();
+      Writer writer = new StringWriter();
+      try
+      {
+//         Writer writer = new FileWriter("src/test/resources/resultGetCategories.xml");
+         
+         marshaller.marshal("src/main/resources/result.xsd", provider, getCategoriesResult(), writer);
+         writer.flush();
+         writer.close();
+      }
+      catch (IOException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (SAXException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
 
-      Writer writer = new PrintWriter(System.out);
       try
       {
-         marshaller.marshal("src/main/resources/result.xsd", provider, getResult(), writer);
+         Reader file = new FileReader("src/test/resources/resultGetCategories.xml");
+         Reader reader = new StringReader(writer.toString());
+
+         char[] comparedBuffer = new char[1024];
+         char[] compareToBuffer = new char[1024];
+         while (file.read(comparedBuffer, 0, comparedBuffer.length) != -1)
+         {
+            int read = reader.read(compareToBuffer, 0, compareToBuffer.length);
+            if (read == -1)
+            {
+               fail();
+            }
+            else
+            {
+               assertEquals(new String(comparedBuffer), new String(compareToBuffer));
+            }
+         }
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();
+      }
+      
+   }
+ 
+   public void testMarshallArtifacts()
+   {
+      
+      XercesXsMarshaller marshaller = new XercesXsMarshaller();
+      marshaller.addRootElement("http://www.portletswap.com/directory", "", "result");
+      
+      // declare default namespace
+      marshaller.declareNamespace("", "http://www.portletswap.com/directory");
+      
+      ObjectModelProvider provider = new ResultModelProvider();
+
+      Writer writer = new StringWriter();
+      try
+      {
+//        writer = new FileWriter("src/test/resources/resultGetArtifacts.xml");
+         marshaller.marshal("src/main/resources/result.xsd", provider, getArtifactsResult(), writer);
          writer.flush();
          writer.close();
 
@@ -47,28 +117,73 @@
          // FIXME
          e.printStackTrace();
       }
-   }
-   
-   private ResultModel getResult()
+
+      try
+      {
+         Reader file = new FileReader("src/test/resources/resultGetArtifacts.xml");
+         Reader reader = new StringReader(writer.toString());
+
+         char[] comparedBuffer = new char[1024];
+         char[] compareToBuffer = new char[1024];
+         while (file.read(comparedBuffer, 0, comparedBuffer.length) != -1)
+         {
+            int read = reader.read(compareToBuffer, 0, compareToBuffer.length);
+            if (read == -1)
+            {
+               fail();
+            }
+            else
+            {
+               assertEquals(new String(comparedBuffer), new String(compareToBuffer));
+            }
+         }
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();
+      }
+}
+
+   private ResultModel getCategoriesResult()
    {
       ResultModel result = new ResultModel();
       Category category1 = new Category(Category.ROOT_CATEGORY_NAME);
-      ((Category)category1).setId("id");
-/*
-      Category category2 = new CategoryImpl("2222-3333-4444");
-      Category category3 = new CategoryImpl("3333-4444-5555");
-*/
+      ((Category)category1).setId("1");
+
+      Category category2 = new Category("2222-3333-4444");
+      category2.setId("2");
+      Category category3 = new Category("3333-4444-5555");
+      category3.setId("3");
+
       result.addCategory(category1);
-/*
+
       category2.addChild(category3);
-*/
+
       Map<Locale, String> map = new HashMap<Locale, String>();
       map.put(new Locale("fr"), "Mon display nom");
       map.put(new Locale("en"), "My display name");
       category1.setDisplayName(new LocalizedString(map, Locale.ENGLISH));
-/*
+
       result.addCategory(category2);
-*/
+      
       return result;
    }
+
+   private ResultModel getArtifactsResult()
+   {
+      ResultModel result = new ResultModel();
+      
+      Module module = new Module();
+      
+      Artifact artifact1 = null;
+      artifact1 = new FileArtifact(Type.JSR168PORTLET, module, new File("/tmp/toto"), new ByteArrayInputStream("foo".getBytes()));
+      artifact1.setName("foo");
+      artifact1.setId("id1");
+      artifact1.setLicense(new License("LGPL", "JGPL TEXT"));
+      result.addArtifact(artifact1);
+
+      return result;
+   }
+
+
 }

Modified: src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java
===================================================================
--- src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java	2008-01-28 08:33:42 UTC (rev 223)
+++ src/server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java	2008-01-28 13:26:48 UTC (rev 224)
@@ -27,6 +27,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.jboss.portletswap.metadata.parsing.ResultModel;
+import org.jboss.portletswap.metadata.parsing.ResultModelFactory;
 import org.jboss.xb.binding.JBossXBException;
 import org.jboss.xb.binding.ObjectModelFactory;
 import org.jboss.xb.binding.Unmarshaller;

Added: src/server/trunk/server-webapp/src/test/resources/resultGetCategories.xml
===================================================================
--- src/server/trunk/server-webapp/src/test/resources/resultGetCategories.xml	                        (rev 0)
+++ src/server/trunk/server-webapp/src/test/resources/resultGetCategories.xml	2008-01-28 13:26:48 UTC (rev 224)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<result xmlns="http://www.portletswap.com/directory">
+   <categories>
+      <category id="1">
+         <displayName>My display name</displayName>
+         <displayName>Mon display nom</displayName>
+      </category>
+      <category id="2">
+         <category id="3"></category>
+      </category>
+   </categories>
+</result>
\ No newline at end of file




More information about the portletswap-commits mailing list