[jboss-svn-commits] JBoss PortletSwap SVN: r202 - server and 96 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jan 20 14:18:42 EST 2008


Author: thomas.heute at jboss.com
Date: 2008-01-20 14:18:42 -0500 (Sun, 20 Jan 2008)
New Revision: 202

Added:
   server/
   server/trunk/
   server/trunk/build/
   server/trunk/build/licences/
   server/trunk/build/licences/JBossEULA.txt
   server/trunk/build/misc/
   server/trunk/build/misc/codeguide.html
   server/trunk/build/pom.xml
   server/trunk/client-portlet/
   server/trunk/client-portlet/client-portlet/
   server/trunk/client-portlet/client-portlet/.classpath
   server/trunk/client-portlet/client-portlet/.project
   server/trunk/client-portlet/client-portlet/pom.xml
   server/trunk/client-portlet/client-portlet/src/
   server/trunk/client-portlet/client-portlet/src/main/
   server/trunk/client-portlet/client-portlet/src/main/java/
   server/trunk/client-portlet/client-portlet/src/main/resources/
   server/trunk/client-portlet/client-portlet/src/main/webapp/
   server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/
   server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/faces-config.xml
   server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/lib/
   server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/web.xml
   server/trunk/client-portlet/client-portlet/src/test/
   server/trunk/client-portlet/client-portlet/src/test/java/
   server/trunk/client-portlet/client-portlet/src/test/resources/
   server/trunk/client-portlet/client-portlet/src/test/resources/jboss-unit.xml
   server/trunk/client-portlet/metadata-lib/
   server/trunk/client-portlet/metadata-lib/.classpath
   server/trunk/client-portlet/metadata-lib/.project
   server/trunk/client-portlet/metadata-lib/pom.xml
   server/trunk/client-portlet/metadata-lib/src/
   server/trunk/client-portlet/metadata-lib/src/main/
   server/trunk/client-portlet/metadata-lib/src/main/java/
   server/trunk/client-portlet/metadata-lib/src/main/resources/
   server/trunk/client-portlet/metadata-lib/src/main/webapp/
   server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/
   server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/faces-config.xml
   server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/lib/
   server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/web.xml
   server/trunk/client-portlet/metadata-lib/src/test/
   server/trunk/client-portlet/metadata-lib/src/test/java/
   server/trunk/client-portlet/metadata-lib/src/test/resources/
   server/trunk/client-portlet/metadata-lib/src/test/resources/jboss-unit.xml
   server/trunk/client-portlet/pom.xml
   server/trunk/pom.xml
   server/trunk/server-service/
   server/trunk/server-service/pom.xml
   server/trunk/server-service/server-lib/
   server/trunk/server-service/server-lib/.classpath
   server/trunk/server-service/server-lib/.project
   server/trunk/server-service/server-lib/pom.xml
   server/trunk/server-service/server-lib/src/
   server/trunk/server-service/server-lib/src/main/
   server/trunk/server-service/server-lib/src/main/java/
   server/trunk/server-service/server-lib/src/main/java/org/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Artifact.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/ArtifactType.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Category.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Module.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Ordering.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/RepositoryService.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Type.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/FileArtifact.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/ReferencedArtifact.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/AbstractArtifactImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/FileArtifactImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/LicenseImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/AbstractCategory.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/jcr/CategoryImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/memory/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/memory/CategoryImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRService.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRServiceImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/Author.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/CompatibilityList.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/License.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/AbstractModule.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/jcr/ModuleImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/memory/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/memory/ModuleImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteCategoryException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteModuleException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/PublishModuleException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveCategoryException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveModuleException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreArtifactException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreCategoryException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreLicenseException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreModuleException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/UnpublishModuleException.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/
   server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceImpl.java
   server/trunk/server-service/server-lib/src/main/resources/
   server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
   server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml
   server/trunk/server-service/server-lib/src/main/resources/log4j.properties
   server/trunk/server-service/server-lib/src/main/resources/settings.xml
   server/trunk/server-service/server-lib/src/test/
   server/trunk/server-service/server-lib/src/test/java/
   server/trunk/server-service/server-lib/src/test/java/org/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceTestCase.java
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/jcr/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/jcr/JCRServiceTestCase.java
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/
   server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceTestCase.java
   server/trunk/server-service/server-lib/src/test/resources/
   server/trunk/server-service/server-lib/src/test/resources/jboss-unit.xml
   server/trunk/server-service/server-service/
   server/trunk/server-service/server-service/.classpath
   server/trunk/server-service/server-service/.project
   server/trunk/server-service/server-service/pom.xml
   server/trunk/server-service/server-service/src/
   server/trunk/server-service/server-service/src/main/
   server/trunk/server-service/server-service/src/main/java/
   server/trunk/server-service/server-service/src/main/java/org/
   server/trunk/server-service/server-service/src/main/java/org/jboss/
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapService.java
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapServiceMBean.java
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRService.java
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRServiceMBean.java
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryService.java
   server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryServiceMBean.java
   server/trunk/server-service/server-service/src/main/resources/
   server/trunk/server-service/server-service/src/main/resources/META-INF/
   server/trunk/server-service/server-service/src/main/resources/META-INF/jboss-service.xml
   server/trunk/server-service/server-service/src/test/
   server/trunk/server-service/server-service/src/test/java/
   server/trunk/server-service/server-service/src/test/resources/
   server/trunk/server-webapp/
   server/trunk/server-webapp/.classpath
   server/trunk/server-webapp/.project
   server/trunk/server-webapp/pom.xml
   server/trunk/server-webapp/src/
   server/trunk/server-webapp/src/main/
   server/trunk/server-webapp/src/main/java/
   server/trunk/server-webapp/src/main/java/org/
   server/trunk/server-webapp/src/main/java/org/jboss/
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/
   server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java
   server/trunk/server-webapp/src/main/resources/
   server/trunk/server-webapp/src/main/resources/result.xsd
   server/trunk/server-webapp/src/main/resources/settings.xml
   server/trunk/server-webapp/src/main/webapp/
   server/trunk/server-webapp/src/main/webapp/WEB-INF/
   server/trunk/server-webapp/src/main/webapp/WEB-INF/web.xml
   server/trunk/server-webapp/src/test/
   server/trunk/server-webapp/src/test/java/
   server/trunk/server-webapp/src/test/java/org/
   server/trunk/server-webapp/src/test/java/org/jboss/
   server/trunk/server-webapp/src/test/java/org/jboss/portletswap/
   server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/
   server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java
   server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java
   server/trunk/server-webapp/src/test/resources/
   server/trunk/server-webapp/src/test/resources/test.xml
Log:
Import


Added: server/trunk/build/licences/JBossEULA.txt
===================================================================
--- server/trunk/build/licences/JBossEULA.txt	                        (rev 0)
+++ server/trunk/build/licences/JBossEULA.txt	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,106 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software 
+Packages, regardless of the delivery mechanism.  Each Software Package is a collective work 
+under U.S. Copyright Law.  Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to 
+the user ("Client") a license to the applicable collective work(s) pursuant to the 
+GNU Lesser General Public License v. 2.1 except for the following Software Packages: 
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the 
+GNU General Public License v.2; 
+
+(b) JBoss Rules, which is licensed pursuant to the Apache  License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the 
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database, 
+it may purchase a license from Sleepycat Software); 
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1, 
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various 
+royalty-free patent licenses.  
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1.  The Software.  "Software Packages" refer to the various software modules that are created and made available 
+for distribution by the JBoss.org open source community at http://www.jboss.org.   Each of the Software Packages 
+may be comprised of hundreds of software components.  The end user license agreement for each component is located in 
+the component's source code.  With the exception of certain image files identified in Section 2 below, 
+the license terms for the components permit Client to copy, modify, and redistribute the component, 
+in both source code and binary code forms.  This agreement does not limit Client's rights under, 
+or grant Client rights that supersede, the license terms of any particular component.
+
+2.  Intellectual Property Rights.  The Software Packages are owned by Red Hat and others and are protected under copyright 
+and other laws.  Title to the Software Packages and any component, or to any copy, modification, or merged portion shall 
+remain with the aforementioned, subject to the applicable license.  The "JBoss" trademark, "Red Hat" trademark, the 
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates 
+in the U.S. and other countries.  This agreement permits Client to distribute unmodified copies of the Software Packages 
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's 
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/.  Client must abide by 
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified. 
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at 
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.  
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.  
+
+3.  Limited Warranty.  Except as specifically stated in this Paragraph 3 or a license for a particular 
+component, to the maximum extent permitted under applicable law, the Software Packages and the 
+components are provided and licensed "as is" without warranty of any kind, expressed or implied, 
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.  
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in 
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.  
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements 
+or that the operation of the Software Packages will be entirely error free or appear precisely as described 
+in the accompanying documentation. This warranty extends only to the party that purchases the Services 
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor. 
+
+4.  Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies 
+described below are accepted by Client as its only remedies.  Red Hat's entire liability, and Client's 
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of 
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or 
+refund the money paid by Client for the Software.  To the maximum extent permitted by applicable law, 
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential 
+damages, including lost profits or lost savings arising out of the use or inability to use the Software, 
+even if Red Hat or such dealer has been advised of the possibility of such damages.  In no event shall 
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this 
+Agreement during the twelve months preceding the action.
+
+5.  Export Control.  As required by U.S. law, Client represents and warrants that it: 
+(a) understands that the Software Packages are subject to export controls under the 
+U.S. Commerce Department's Export Administration Regulations ("EAR"); 
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations 
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria); 
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity, 
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government; 
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or 
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by 
+regulation or specific license; 
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software 
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual 
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and 
+address (including country) of each transferee; 
+
+and (f) understands that countries other than the United States may restrict the import, use, or 
+export of encryption products and that it shall be solely responsible for compliance with any such 
+import, use, or export restrictions.
+
+6.  Third Party Programs. Red Hat may distribute third party software programs with the Software Packages 
+that are not part of the Software Packages and which Client must install separately.  These third party 
+programs are subject to their own license terms.  The license terms either accompany the programs or 
+can be viewed at http://www.redhat.com/licenses/.  If Client does not agree to abide by the applicable 
+license terms for such programs, then Client may not install them.  If Client wishes to install the programs 
+on more than one system or transfer the programs to another party, then Client must contact the licensor 
+of the programs.
+
+7.  General.  If any provision of this agreement is held to be unenforceable, that shall not affect the 
+enforceability of the remaining provisions.  This License Agreement shall be governed by the laws of the 
+State of North Carolina and of the United States, without regard to any conflict of laws provisions, 
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc.  All rights reserved.  
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.  
+All other trademarks are the property of their respective owners. 
+
+	Page 1 of 1	18 October 2006

Added: server/trunk/build/misc/codeguide.html
===================================================================
--- server/trunk/build/misc/codeguide.html	                        (rev 0)
+++ server/trunk/build/misc/codeguide.html	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,133 @@
+<html>
+
+<head>
+<style type="text/css">
+pre { border-style:solid; border-width:thin; padding:5px; background-color:#EEEEFF;}
+span.bad { text-decoration:line-through; }
+span.important { font-weight:bold; color:red; }
+</style>
+</head>
+
+<body>
+
+<h2>Coding Conventions</h2>
+
+<h3>Some more general guidelines</h3>
+<ul>
+<li>Fully qualified imports should be used, rather than importing x.y.*.</li>
+<li>Use newlines for opening braces, so that the top and bottom braces can be visually matched.</li>
+<li>Aid visual separation of logical steps by introducing newlines and appropriate comments above them.</li>
+</ul>
+
+
+<h3>A class that conforms to JBoss coding guidelines</h3>
+
+<pre>
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2007, 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 x;
+
+// <span class="important">Explicit imports</span>
+import a.b.C1; // <span class="important">good</span>
+import a.b.C2;
+import a.b.C3;
+
+// <span class="important">Do not write</span>
+<span class="bad">import a.b.*;</span>  // <span class="important">bad</span>
+
+// <span class="important">DO NOT USE "TAB" TO INDENT CODE USE *3* SPACES FOR PORTABILITY AMONG EDITORS</span>
+
+/**
+ * A description of this class.
+ *
+ * @see SomeRelatedClass.
+ *
+ * @version &lt;tt&gt;$Revision: 7755 $&lt;/tt&gt;
+ * @author  &lt;a href="mailto:{email}"&gt;{full name}&lt;/a&gt;
+ */
+public class X
+   extends Y
+   implements Z
+{
+   public void startService() throws Exception
+   { 
+      // Use the newline for the opening bracket so we can match top              
+      // and bottom bracket visually
+      
+      Class cls = Class.forName(dataSourceClass);
+      vendorSource = (XADataSource)cls.newInstance();
+      
+      // Jump a line between logically distinct <span class="important">steps</span> and add<
+      // line of comment to it
+      cls = vendorSource.getClass();
+
+      // Comment lines <span class="important">always</span> start with an uppercase
+      // except if it is the second line
+      if(properties != null) 
+      {
+      
+         try
+         {
+         }
+         catch (IOException ioe)
+         {
+         }
+         for (Iterator i = props.entrySet().iterator(); i.hasNext();)
+         {
+            
+            // Get the name and value for the attributes
+            Map.Entry entry = (Map.Entry) i.next();
+            String attributeName = (String) entry.getKey();
+            String attributeValue = (String) entry.getValue();
+            
+            // Print the debug message
+            log.debug("Setting attribute '" + attributeName + "' to '" + attributeValue + "'");
+            
+            // get the attribute 
+            Method setAttribute =
+            cls.getMethod("set" + attributeName, new Class[] { String.class });
+            
+            // And set the value  
+            setAttribute.invoke(vendorSource, new Object[] { attributeValue });
+         }
+      }
+      
+      <span class="bad">// this is a <span class="important">bad</span> comment line because it starts with a lower case</span>
+      vendorSource.getXAConnection().close();
+      
+      // Bind in JNDI
+      bind(new InitialContext(), "java:/"+getPoolName(),
+         new Reference(vendorSource.getClass().getName(),
+            getClass().getName(), null));
+
+      // Block must always be delimited explicitely
+      if (0 == 0)
+      <span class="important">{</span>
+         System.out.println(true);
+      <span class="important">}</span>
+
+   }
+}
+</pre>
+</body>
+</html>


Property changes on: server/trunk/build/misc/codeguide.html
___________________________________________________________________
Name: svn:executable
   + 

Added: server/trunk/build/pom.xml
===================================================================
--- server/trunk/build/pom.xml	                        (rev 0)
+++ server/trunk/build/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  This pom functions as a default configuration.  The subproject
+  poms each inherit configuration from this one.
+
+  When adding version information for an artifact please do the following
+  - add a version property for the specific version
+  - add a dependency in the dependencyManagement section which refers to
+    the property
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <parent>
+      <groupId>org.jboss.portal</groupId>
+      <artifactId>jboss-portal-parent</artifactId>
+      <version>1-SNAPSHOT</version>
+   </parent>
+   <modelVersion>4.0.0</modelVersion>
+   <groupId>org.jboss.portletswap</groupId>
+   <artifactId>module-parent</artifactId>
+   <version>1.0-CR1</version>
+   <packaging>pom</packaging>
+   <name>PortletSwap Parent</name>
+
+   <!--All artifacts versions should be defined here-->
+   <properties>
+      <version.junit>3.8.1</version.junit>
+      <version.jboss.unit>1.2.0-SNAPSHOT</version.jboss.unit>
+   </properties>
+
+
+   <!--JBoss reporitories to be able to grab jboss-portal-parent pom-->
+   <repositories>
+      <repository>
+         <id>repository.jboss.org</id>
+         <name>JBoss Repository</name>
+         <layout>default</layout>
+         <url>http://repository.jboss.org/maven2/</url>
+         <snapshots>
+            <enabled>false</enabled>
+         </snapshots>
+      </repository>
+      <repository>
+         <id>snapshots.jboss.org</id>
+         <name>JBoss Snapshots Repository</name>
+         <layout>default</layout>
+         <url>http://snapshots.jboss.org/maven2/</url>
+         <snapshots>
+            <enabled>true</enabled>
+         </snapshots>
+         <releases>
+            <enabled>false</enabled>
+         </releases>
+      </repository>
+   </repositories>
+
+
+   <build>
+      <!--It is important to specify version for every plugin to avoid build errors
+          when maven grab newer version with different behaviour-->
+
+      <plugins>
+         <!--The <skip>true</skip> will by disable default surefire call in all submodules-->
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <version>2.3.1</version>
+            <configuration>
+               <skip>true</skip>
+            </configuration>
+         </plugin>
+      </plugins>
+
+      <pluginManagement>
+         <plugins>
+            <!--Only needed if you use jboss-unit maven2 plugin for tests (used in module-c)-->
+            <plugin>
+               <groupId>org.jboss.unit</groupId>
+               <artifactId>jboss-unit-tooling-maven2</artifactId>
+               <version>1.2.0-SNAPSHOT</version>
+            </plugin>
+         </plugins>
+      </pluginManagement>
+
+   </build>
+
+
+
+   <!--Sample additional plugin repository. This one is not needed if you don't use maven-antrun-extended-plugin
+       (used in module-c)-->
+   <pluginRepositories>
+      <pluginRepository>
+         <id>java.net maven repository</id>
+         <url>http://download.java.net/maven/2/</url>
+         <snapshots>
+            <enabled>true</enabled>
+         </snapshots>
+      </pluginRepository>
+   </pluginRepositories>
+
+   <dependencyManagement>
+      <!-- The parent pom manages the inter-dependencies of the modules. -->
+      <dependencies>
+         <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${version.junit}</version>
+         </dependency>
+         <dependency>
+            <groupId>org.jboss.unit</groupId>
+            <artifactId>jboss-unit</artifactId>
+            <version>${version.jboss.unit}</version>
+         </dependency>
+         <dependency>
+            <groupId>org.jboss.unit</groupId>
+            <artifactId>jboss-unit-tooling-ant</artifactId>
+            <version>${version.jboss.unit}</version>
+         </dependency>
+      </dependencies>
+   </dependencyManagement>
+
+</project>

Added: server/trunk/client-portlet/client-portlet/.classpath
===================================================================
--- server/trunk/client-portlet/client-portlet/.classpath	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/.classpath	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1-sources.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-api-1.2_04-p02.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-facelets-1.1.9.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-portlet-1.2.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/portlet-api-1.0.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/modules"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: server/trunk/client-portlet/client-portlet/.project
===================================================================
--- server/trunk/client-portlet/client-portlet/.project	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/.project	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>client-portlet</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: server/trunk/client-portlet/client-portlet/pom.xml
===================================================================
--- server/trunk/client-portlet/client-portlet/pom.xml	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>org.jboss.portletswap</groupId>
+		<artifactId>module-parent</artifactId>
+		<version>1.0-CR1</version>
+		<relativePath>../build/pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>client-portlet</artifactId>
+	<packaging>war</packaging>
+	<name>JBoss PortletSwap Client portlet</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>com.sun.facelets</groupId>
+			<artifactId>jsf-facelets</artifactId>
+			<version>1.1.9</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.faces.portlet</groupId>
+			<artifactId>jsf-portlet</artifactId>
+			<version>1.2</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.faces</groupId>
+			<artifactId>jsf-api</artifactId>
+			<version>1.2_04-p02</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.portlet</groupId>
+			<artifactId>portlet-api</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+	</dependencies>
+
+</project>
\ No newline at end of file

Added: server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/faces-config.xml	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/faces-config.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+    version="1.2">
+
+</faces-config>

Added: server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/web.xml
===================================================================
--- server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/src/main/webapp/WEB-INF/web.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+  <display-name>client-portlet</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+  <servlet>
+    <servlet-name>Faces Servlet</servlet-name>
+    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Faces Servlet</servlet-name>
+    <url-pattern>*.jsf</url-pattern>
+  </servlet-mapping>
+</web-app>
\ No newline at end of file

Added: server/trunk/client-portlet/client-portlet/src/test/resources/jboss-unit.xml
===================================================================
--- server/trunk/client-portlet/client-portlet/src/test/resources/jboss-unit.xml	                        (rev 0)
+++ server/trunk/client-portlet/client-portlet/src/test/resources/jboss-unit.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+   xmlns="urn:jboss:jboss-unit:1.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+   <pojo>
+      <test>
+         <class name="org.jboss.portal.templatemodule.c.SampleModuleCTest"/>
+      </test>
+   </pojo>
+</jboss-unit>
\ No newline at end of file

Added: server/trunk/client-portlet/metadata-lib/.classpath
===================================================================
--- server/trunk/client-portlet/metadata-lib/.classpath	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/.classpath	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1-sources.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-api-1.2_04-p02.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-facelets-1.1.9.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/jsf-portlet-1.2.jar"/>
+	<classpathentry kind="lib" path="target/client-portlet-1.0-CR1/WEB-INF/lib/portlet-api-1.0.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/modules"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: server/trunk/client-portlet/metadata-lib/.project
===================================================================
--- server/trunk/client-portlet/metadata-lib/.project	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/.project	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>metadata-lib</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: server/trunk/client-portlet/metadata-lib/pom.xml
===================================================================
--- server/trunk/client-portlet/metadata-lib/pom.xml	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>org.jboss.portletswap</groupId>
+		<artifactId>module-parent</artifactId>
+		<version>1.0-CR1</version>
+		<relativePath>../build/pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>metadata-lib</artifactId>
+	<packaging>jar</packaging>
+	<name>JBoss PortletSwap Metadata lib</name>
+
+	<dependencies/>
+
+</project>

Added: server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/faces-config.xml	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/faces-config.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+    version="1.2">
+
+</faces-config>

Added: server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/web.xml
===================================================================
--- server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/src/main/webapp/WEB-INF/web.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+  <display-name>client-portlet</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+  <servlet>
+    <servlet-name>Faces Servlet</servlet-name>
+    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Faces Servlet</servlet-name>
+    <url-pattern>*.jsf</url-pattern>
+  </servlet-mapping>
+</web-app>
\ No newline at end of file

Added: server/trunk/client-portlet/metadata-lib/src/test/resources/jboss-unit.xml
===================================================================
--- server/trunk/client-portlet/metadata-lib/src/test/resources/jboss-unit.xml	                        (rev 0)
+++ server/trunk/client-portlet/metadata-lib/src/test/resources/jboss-unit.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+   xmlns="urn:jboss:jboss-unit:1.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+   <pojo>
+      <test>
+         <class name="org.jboss.portal.templatemodule.c.SampleModuleCTest"/>
+      </test>
+   </pojo>
+</jboss-unit>
\ No newline at end of file

Added: server/trunk/client-portlet/pom.xml
===================================================================
--- server/trunk/client-portlet/pom.xml	                        (rev 0)
+++ server/trunk/client-portlet/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <parent>
+      <groupId>org.jboss.portletswap</groupId>
+      <artifactId>module-parent</artifactId>
+      <version>1.0-CR1</version>
+      <relativePath>../build/pom.xml</relativePath>
+   </parent>
+   <modelVersion>4.0.0</modelVersion>
+   <artifactId>client-portlet-service-aggregator</artifactId>
+   <packaging>pom</packaging>
+   <name>JBoss PortletSwap Client Portlet Aggregator</name>
+
+   <modules>
+      <module>client-portlet</module>
+      <module>metadata-lib</module>
+   </modules>
+
+</project>

Added: server/trunk/pom.xml
===================================================================
--- server/trunk/pom.xml	                        (rev 0)
+++ server/trunk/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,43 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+   <groupId>org.jboss.portletswap</groupId>
+   <artifactId>module-aggregator</artifactId>
+   <packaging>pom</packaging>
+   <name>Portletswap Aggregator</name>
+   <version>0.0.1</version>
+   <url>http://www.portletswap.com</url>
+
+   <dependencies>
+   		<dependency>
+			<groupId>org.jboss.portal.common</groupId>
+			<artifactId>jboss-portal-modules-common</artifactId>
+			<version>1.1.0-SNAPSHOT</version>
+		</dependency>
+   </dependencies>
+
+   <!--Repository definition needed to deploy artifacts into JBoss maven repositories-->
+   <distributionManagement>
+      <repository>
+         <!--Copy the distribution jar file to a local checkout of the maven repository
+          -  This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+         <id>repository.jboss.org</id>
+         <url>file://${jboss.repository.root}</url>
+      </repository>
+      <snapshotRepository>
+         <id>snapshots.jboss.org</id>
+         <name>JBoss Snapshot Repository</name>
+         <url>dav:https://snapshots.jboss.org/maven2</url>
+         <uniqueVersion>true</uniqueVersion>
+      </snapshotRepository>
+   </distributionManagement>
+
+   <modules>
+      <module>build</module>
+      <module>server-service</module>
+      <module>client-portlet</module>
+      <module>server-webapp</module>
+   </modules>
+
+
+</project>
\ No newline at end of file

Added: server/trunk/server-service/pom.xml
===================================================================
--- server/trunk/server-service/pom.xml	                        (rev 0)
+++ server/trunk/server-service/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <parent>
+      <groupId>org.jboss.portletswap</groupId>
+      <artifactId>module-parent</artifactId>
+      <version>1.0-CR1</version>
+      <relativePath>../build/pom.xml</relativePath>
+   </parent>
+   <modelVersion>4.0.0</modelVersion>
+   <artifactId>server-service-aggregator</artifactId>
+   <packaging>pom</packaging>
+   <name>JBoss PortletSwap Server Service Aggregator</name>
+
+   <modules>
+      <module>server-lib</module>
+      <module>server-service</module>
+   </modules>
+
+</project>
\ No newline at end of file

Added: server/trunk/server-service/server-lib/.classpath
===================================================================
--- server/trunk/server-service/server-lib/.classpath	                        (rev 0)
+++ server/trunk/server-service/server-lib/.classpath	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="lib" path="target/server-lib-1.0-CR1-sources.jar"/>
+	<classpathentry kind="lib" path="target/server-lib-1.0-CR1.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/test-classes"/>
+</classpath>

Added: server/trunk/server-service/server-lib/.project
===================================================================
--- server/trunk/server-service/server-lib/.project	                        (rev 0)
+++ server/trunk/server-service/server-lib/.project	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>server-lib</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: server/trunk/server-service/server-lib/pom.xml
===================================================================
--- server/trunk/server-service/server-lib/pom.xml	                        (rev 0)
+++ server/trunk/server-service/server-lib/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,175 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>org.jboss.portletswap</groupId>
+		<artifactId>module-parent</artifactId>
+		<version>1.0-CR1</version>
+		<relativePath>../../build/pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>server-lib</artifactId>
+	<packaging>jar</packaging>
+	<name>JBoss PortletSwap Server Lib</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-api</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-core</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>1.4.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.microcontainer</groupId>
+			<artifactId>jboss-kernel</artifactId>
+			<version>2.0.0.Beta9</version>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.portal.common</groupId>
+			<artifactId>jboss-portal-modules-common</artifactId>
+			<version>1.1.0-SNAPSHOT</version>
+		</dependency>
+
+		<!--TEST SCOPE-->
+		<dependency>
+			<groupId>org.jboss.unit</groupId>
+			<artifactId>jboss-unit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<!--Example of JBoss Unit tests with maven2 plugin-->
+			<plugin>
+				<groupId>org.jboss.unit</groupId>
+				<artifactId>jboss-unit-tooling-maven2</artifactId>
+				<executions>
+					<execution>
+						<phase>test</phase>
+						<goals>
+							<goal>execute</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<testsuites>
+						<testsuite>
+							<config>jboss-unit.xml</config>
+						</testsuite>
+					</testsuites>
+					<reports>
+						<xml>target/tests/reports/xml</xml>
+						<html>target/tests/reports/html</html>
+					</reports>
+				</configuration>
+			</plugin>
+
+			<!--If tests require to start AS with cargo and do more complex stuff you should consider using antrun-->
+			<plugin>
+				<!--<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>-->
+
+				<!--A temporary fork of orginal extended plugin until they update to newer ant version-->
+				<groupId>
+					org.jvnet.maven-antrun-extended-plugin
+				</groupId>
+
+				<artifactId>maven-antrun-extended-plugin</artifactId>
+				<version>1.13</version>
+
+				<dependencies>
+
+					<dependency>
+						<groupId>org.jboss.unit</groupId>
+						<artifactId>jboss-unit-tooling-ant</artifactId>
+						<version>${version.jboss.unit}</version>
+					</dependency>
+
+
+				</dependencies>
+				<executions>
+					<execution>
+						<id>test</id>
+						<!-- Can be used in test phase instead -->
+						<phase>integration-test</phase>
+						<configuration>
+							<tasks>
+
+								<!--Get access to maven classpath-->
+								<property name="compile_classpath"
+									refid="maven.compile.classpath" />
+								<property name="runtime_classpath"
+									refid="maven.runtime.classpath" />
+								<property name="test_classpath"
+									refid="maven.test.classpath" />
+								<property name="plugin_classpath"
+									refid="maven.plugin.classpath" />
+
+								<property name="project.version"
+									value="${project.version}" />
+
+								<!--This way you can get access to direct path of jars in maven classpath-->
+								<property
+									name="dependency.jboss-unit.jar"
+									value="${maven.dependency.org.jboss.unit.jboss-unit.jar.path}" />
+								<echo
+									message="Direct path to JBoss Unit jar: ${dependency.jboss-unit.jar}" />
+
+								<!-- You can redirect ant call to separate build.xml file -->
+								<!--<ant antfile="${basedir}/src/test/build.xml">-->
+								<!--<target name="tests"/>-->
+								<!--</ant>-->
+
+								<taskdef name="jboss-unit"
+									classname="org.jboss.unit.tooling.ant.JBossUnitTask"
+									classpath="${plugin_classpath}" />
+
+								<!--Use of JBoss Unit ant plugin-->
+								<jboss-unit>
+
+									<tests config="jboss-unit.xml">
+
+									</tests>
+
+									<reports>
+										<xml
+											toDir="target/tests/reports/xml/local" />
+										<html
+											toDir="target/tests/reports/html/local" />
+									</reports>
+
+									<classpath>
+										<pathelement
+											location="target/classes" />
+										<pathelement
+											location="target/test-classes" />
+										<pathelement
+											path="${test_classpath}" />
+									</classpath>
+
+								</jboss-unit>
+
+							</tasks>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+		</plugins>
+
+	</build>
+
+
+</project>
\ No newline at end of file

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Artifact.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Artifact.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Artifact.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.metadata.CompatibilityList;
+import org.jboss.portletswap.metadata.License;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Artifact
+{
+
+   public Object getId();
+   
+   public String getName();
+   
+   public ArtifactType getArtifactType();
+   
+   public Type getType();
+
+   public LocalizedString getDescription();
+
+   public void setDescription(LocalizedString description);
+
+   public LocalizedString getDisplayName();
+
+   public void setDisplayName(LocalizedString displayName);
+
+   public CompatibilityList getCompatibilityList();
+
+   public void setCompatibilityList(CompatibilityList compatibilityList);
+
+   public License getLicense();
+
+   public void setLicense(License license);
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/ArtifactType.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/ArtifactType.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/ArtifactType.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public enum ArtifactType {
+
+   FILE_ARTIFACT_TYPE
+   
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Category.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Category.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Category.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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;
+
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Category
+{  
+   
+   public static final String ROOT_CATEGORY_NAME = "org.jboss.portletswap.RootCategoryNode";
+
+   public Category getParent();
+   
+   public void addChild(Category category);
+   
+   public List<Category> getChildren();
+   
+   public Object getId();
+   
+   public String getName();
+   
+   public LocalizedString getDisplayName();
+   
+   public void setDisplayName(LocalizedString displayName);
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/DirectoryService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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;
+
+import java.util.List;
+
+import org.jboss.portletswap.filter.Filter;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface DirectoryService
+{
+
+   /**
+    * Get all the latest versions of all modules
+    * @return the latest versions of all modules
+    */
+   public List<Module> getModules(boolean published);
+
+   /**
+    * Get all the latest versions of all modules
+    * @return the latest versions of all modules
+    */
+   public List<Module> getModules(boolean published, Ordering ordering);
+
+   public List<Module> getModules(boolean published, Type type);
+
+   public List<Module> getModules(boolean published, Type type, Ordering ordering);
+
+   public List<Module> getModules(boolean published, Category category);
+
+   public List<Module> getModules(boolean published, Category category, Ordering ordering);
+
+   public List<Module> getModules(boolean published, Filter filter);
+
+   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);
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Module.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Module.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Module.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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;
+
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.metadata.Author;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Module
+{
+
+   public void setId(Object id);
+   
+   public Object getId();
+   
+   public String getName();
+   
+   public Type getType();
+
+   public Version getVersion();
+   
+   public LocalizedString getDescription();
+
+   public List<Author> getAuthors();
+
+   public void setDescription(LocalizedString localizedString);
+   
+   public List<Artifact> getArtifacts();
+   
+   public void addArtifact(Artifact artifact);
+
+   public List<Category> getCategories();
+
+   public void addCategory(Category category);
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Ordering.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Ordering.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Ordering.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public enum Ordering {
+
+   NAME_ASC, NAME_DESC, NO_SPECIAL_ORDER
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/RepositoryService.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/RepositoryService.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/RepositoryService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portletswap.metadata.License;
+import org.jboss.portletswap.repository.DeleteCategoryException;
+import org.jboss.portletswap.repository.DeleteModuleException;
+import org.jboss.portletswap.repository.PublishModuleException;
+import org.jboss.portletswap.repository.RetrieveCategoryException;
+import org.jboss.portletswap.repository.RetrieveModuleException;
+import org.jboss.portletswap.repository.StoreArtifactException;
+import org.jboss.portletswap.repository.StoreCategoryException;
+import org.jboss.portletswap.repository.StoreLicenseException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.UnpublishModuleException;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface RepositoryService
+{
+   /**
+    * Retrieves a module by its id
+    * 
+    * @param id of the module to retrieve
+    * @return The module, null if such a module could not be found
+    */
+   public Module getModule(Object id) throws RetrieveModuleException;
+
+   /**
+    * Store a new module or version of a module
+    * 
+    * @param module to store
+    * @return the module
+    * @throws StoreModuleException if the module could not be stored
+    */
+   public Module storeModule(Module module) throws StoreModuleException;
+   
+   /**
+    * Delete a module
+    * 
+    * @param name of the module to delete
+    * @throws DeleteModuleException if the deletion could not happen
+    */
+   public void deleteModule(Module module) throws DeleteModuleException;
+
+   public Module publishModule(Module module) throws PublishModuleException;
+   
+   public void unpublishModule(Module module) throws UnpublishModuleException;
+   
+   public Category storeCategory(Category category) throws StoreCategoryException;
+   
+   public Category getCategory(Object id) throws RetrieveCategoryException;
+   
+   public void deleteCategory(Category category) throws DeleteCategoryException;
+   
+   public Artifact storeArtifact(Module module, Artifact artifact) throws StoreArtifactException;
+
+   public License storeLicense(License license) throws StoreLicenseException;
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Type.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Type.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/Type.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public enum Type {
+
+   JSR168PORTLET, JSR286PORTLET, THEME, MIXED, OTHER
+   
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/FileArtifact.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/FileArtifact.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/FileArtifact.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.artifact;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.jboss.portletswap.Artifact;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface FileArtifact extends Artifact
+{
+   public InputStream getInputStream();
+   
+   public File getFile();
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/ReferencedArtifact.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/ReferencedArtifact.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/ReferencedArtifact.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.artifact;
+
+import java.net.URL;
+
+import org.jboss.portletswap.Artifact;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface ReferencedArtifact extends Artifact
+{
+   public URL getUrl();
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/AbstractArtifactImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/AbstractArtifactImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/AbstractArtifactImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * 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.artifact.impl;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.ArtifactType;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.metadata.CompatibilityList;
+import org.jboss.portletswap.metadata.License;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractArtifactImpl implements Artifact
+{
+   private Object id;
+   
+   private String name;
+   
+   private ArtifactType artifactType;
+   
+   private Type type;
+   
+   private LocalizedString description;
+   
+   private LocalizedString displayName;
+   
+   private CompatibilityList compatibilityList;
+   
+   private License license;
+
+   public ArtifactType getArtifactType()
+   {
+      return artifactType;
+   }
+
+   public void setArtifactType(ArtifactType artifactType)
+   {
+      this.artifactType = artifactType;
+   }
+
+   public Type getType()
+   {
+      return type;
+   }
+
+   public void setType(Type type)
+   {
+      this.type = type;
+   }
+
+   public LocalizedString getDescription()
+   {
+      return description;
+   }
+
+   public void setDescription(LocalizedString description)
+   {
+      this.description = description;
+   }
+
+   public LocalizedString getDisplayName()
+   {
+      return displayName;
+   }
+
+   public void setDisplayName(LocalizedString displayName)
+   {
+      this.displayName = displayName;
+   }
+
+   public CompatibilityList getCompatibilityList()
+   {
+      return compatibilityList;
+   }
+
+   public void setCompatibilityList(CompatibilityList compatibilityList)
+   {
+      this.compatibilityList = compatibilityList;
+   }
+
+   public License getLicense()
+   {
+      return license;
+   }
+
+   public void setLicense(License license)
+   {
+      this.license = license;
+   }
+
+   public Object getId()
+   {
+      return id;
+   }
+
+   public void setId(Object id)
+   {
+      this.id = id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/FileArtifactImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/FileArtifactImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/FileArtifactImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * 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.artifact.impl.jcr;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.ArtifactType;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.artifact.FileArtifact;
+import org.jboss.portletswap.artifact.impl.AbstractArtifactImpl;
+import org.jboss.portletswap.jcr.JCRService;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FileArtifactImpl extends AbstractArtifactImpl implements FileArtifact 
+{
+   
+   private InputStream inputStream;
+   
+   private File file;
+
+   public FileArtifactImpl(Type type, File file, InputStream inputStream)
+   {
+      setType(type);
+      this.inputStream = inputStream;
+      this.file = file;
+   }
+
+   public FileArtifactImpl(JCRService jcrService, Node node) throws RepositoryException
+   {
+      setName(node.getName());
+      setId(node.getUUID());
+      
+      Property typeProperty = node.getProperty("ps:type");
+      setType(Type.valueOf(typeProperty.getString()));
+     
+      // Description
+      NodeIterator it = node.getNodes("ps:description");
+      Map<Locale, String> values = new HashMap<Locale, String>();
+      while (it.hasNext())
+      {
+         Node tmpNode = it.nextNode();
+         Locale locale = new Locale(tmpNode.getProperty("jcr:language").getString());
+         String value = tmpNode.getProperty("ps:value").getString();
+         values.put(locale, value);
+      }
+      setDescription(new LocalizedString(values, Locale.ENGLISH));
+
+      // DisplayName
+      it = node.getNodes("ps:displayName");
+      values = new HashMap<Locale, String>();
+      while (it.hasNext())
+      {
+         Node tmpNode = it.nextNode();
+         Locale locale = new Locale(tmpNode.getProperty("jcr:language").getString());
+         String value = tmpNode.getProperty("ps:value").getString();
+         values.put(locale, value);
+      }
+      setDisplayName(new LocalizedString(values, Locale.ENGLISH));
+      
+      // Compatibility List
+      // TODO
+      
+      // License
+      Property property = node.getProperty("ps:license");
+      Node licenseNode = node.getSession().getNodeByUUID(property.getString());
+      setLicense(new LicenseImpl(jcrService, licenseNode));
+      
+      this.inputStream = node.getProperty("ps:file").getStream();
+   }
+
+   public InputStream getInputStream()
+   {
+      return inputStream;
+   }
+
+   public File getFile()
+   {
+      return file;
+   }
+   
+   public ArtifactType getArtifactType()
+   {
+      return ArtifactType.FILE_ARTIFACT_TYPE;
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/LicenseImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/LicenseImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/artifact/impl/jcr/LicenseImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * 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.artifact.impl.jcr;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.metadata.License;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LicenseImpl implements License
+{
+   private String id;
+   
+   private String name;
+   
+   private String text;
+
+   public LicenseImpl(String name, String text)
+   {
+      this.name = name;
+      this.text = text;
+   }
+   
+   public LicenseImpl(JCRService jcrService, Node licenseNode) throws RepositoryException
+   {
+      id = licenseNode.getUUID();
+      name = licenseNode.getProperty("ps:name").getString();
+      text = licenseNode.getProperty("ps:text").getString();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getText()
+   {
+      return text;
+   }
+   
+   public String getId()
+   {
+      return id;
+   }
+
+   public void setId(String id)
+   {
+      this.id = id;
+      
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/AbstractCategory.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/AbstractCategory.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/AbstractCategory.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * 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.category.impl;
+
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.Category;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractCategory implements Category
+{
+   
+   private Object id;
+   
+   private LocalizedString displayName;
+   
+   private String name;
+   
+   public abstract Category getParent();
+   
+   public abstract void addChild(Category category);
+
+   public abstract List<Category> getChildren();
+
+   public Object getId()
+   {
+      return id;
+   }
+   
+   public void setId(Object id)
+   {
+      if (this.id == null)
+      {
+         this.id = id;
+      }
+      else
+      {
+         throw new IllegalStateException("Not allowed to change the id");
+      }
+   }
+ 
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      if (this.name == null)
+      {
+         this.name = name;
+      }
+      else
+      {
+         throw new IllegalStateException("Not allowed to change the name");
+      }
+   }
+ 
+   public LocalizedString getDisplayName()
+   {
+      return displayName;
+   }
+
+   public void setDisplayName(LocalizedString displayName)
+   {
+      this.displayName = displayName;
+   }
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/jcr/CategoryImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/jcr/CategoryImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/jcr/CategoryImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * 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.category.impl.jcr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.category.impl.AbstractCategory;
+import org.jboss.portletswap.jcr.JCRService;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CategoryImpl extends AbstractCategory
+{
+
+   private JCRService jcrService; 
+   
+   public CategoryImpl(JCRService jcrService, Node node)
+   {
+      this.jcrService = jcrService;
+      try
+      {
+         this.setId(node.getUUID());
+         this.setName(node.getName());
+      }
+      catch (UnsupportedRepositoryOperationException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (RepositoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+   }
+
+   @Override
+   public void addChild(Category category)
+   {
+      
+   }
+
+   @Override
+   public List<Category> getChildren()
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         Node node = session.getNodeByUUID((String) getId());
+         NodeIterator it = node.getNodes();
+         List<Category> list = new ArrayList<Category>();
+         while (it.hasNext())
+         {
+            Node tmpNode = it.nextNode();
+            if (tmpNode.isNodeType("ps:category"))
+            {
+               list.add(new CategoryImpl(jcrService, tmpNode));
+            }
+         }
+         return list;
+      }
+      catch (RepositoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+         return null;
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   @Override
+   public Category getParent()
+   {
+      Session session = null;
+      
+      if (getName().equals(ROOT_CATEGORY_NAME))
+      {
+         return null;
+      }
+      
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         Node node = session.getNodeByUUID((String) getId());
+         Node parent = node.getParent();
+         return new CategoryImpl(jcrService, parent);
+      }
+      catch (RepositoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+         return null;
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   
+   
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/memory/CategoryImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/memory/CategoryImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/category/impl/memory/CategoryImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.category.impl.memory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.category.impl.AbstractCategory;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CategoryImpl extends AbstractCategory
+{
+   public static final String ROOT_CATEGORY_NAME = "org.jboss.portletswap.RootCategoryNode";
+
+   private Category parent;
+
+   private LocalizedString displayName;
+
+   private List<Category> children;
+
+   public CategoryImpl(String name, Category parent)
+   {
+      setParent(parent);
+      setName(name);
+      if (parent != null)
+      {
+         parent.addChild(this);
+      }
+      children = new ArrayList<Category>();
+   }
+
+   public Category getParent()
+   {
+      return parent;
+   }
+
+   private void setParent(Category parent)
+   {
+      this.parent = parent;
+   }
+
+   public void addChild(Category category)
+   {
+      children.add(category);
+   }
+
+   public LocalizedString getDisplayName()
+   {
+      if (displayName != null)
+      {
+         return displayName;
+      }
+      else
+      {
+         return new LocalizedString((String)getName());
+      }
+   }
+
+   public List<Category> getChildren()
+   {
+      return children;
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,294 @@
+/******************************************************************************
+ * 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.jcr;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.Ordering;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.category.impl.jcr.CategoryImpl;
+import org.jboss.portletswap.filter.Filter;
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.module.impl.jcr.ModuleImpl;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+ at SuppressWarnings("serial")
+public class DirectoryServiceImpl implements DirectoryService, Serializable
+{
+
+
+   private JCRService jcrService;
+   
+   public JCRService getJcrService()
+   {
+      return jcrService;
+   }
+
+   public void setJcrService(JCRService jcrService)
+   {
+      this.jcrService = jcrService;
+   }
+   
+   public List<Module> getModules(boolean published)
+   {
+      String workspace = JCRService.MODULE_WORKSPACE_NAME;
+      if (published)
+      {
+         workspace = JCRService.PUBLISHED_MODULE_WORKSPACE_NAME;
+      }
+      
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(workspace);
+         NodeIterator it = session.getRootNode().getNodes();
+         List<Module> result = new ArrayList<Module>();
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (node.isNodeType("ps:module"))
+            {
+               result.add(new ModuleImpl(jcrService, node));
+            }
+         }
+         return result;
+      }
+      catch (ItemNotFoundException e)
+      {
+         return null;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+
+   public List<Module> getModules(boolean published, Ordering ordering)
+   {
+      String workspace = JCRService.MODULE_WORKSPACE_NAME;
+      if (published)
+      {
+         workspace = JCRService.PUBLISHED_MODULE_WORKSPACE_NAME;
+      }
+      
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(workspace);
+         QueryManager queryManager = session.getWorkspace().getQueryManager();
+         Query query = queryManager.createQuery("SELECT * from ps:module " + orderby(ordering), Query.SQL);
+         QueryResult queryResult = query.execute();
+         
+         NodeIterator it = queryResult.getNodes();
+         List<Module> result = new ArrayList<Module>();
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (node.isNodeType("ps:module"))
+            {
+               result.add(new ModuleImpl(jcrService, node));
+            }
+         }
+         return result;
+      }
+      catch (ItemNotFoundException e)
+      {
+         return null;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+
+   private String orderby(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)
+      {
+         workspace = JCRService.PUBLISHED_MODULE_WORKSPACE_NAME;
+      }
+      
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(workspace);
+         QueryManager queryManager = session.getWorkspace().getQueryManager();
+         Query query = queryManager.createQuery("SELECT * from ps:module where ps:categoryRef = '" + category.getId() + "'", Query.SQL);
+         QueryResult queryResult = query.execute();
+         
+         NodeIterator it = queryResult.getNodes();
+         List<Module> result = new ArrayList<Module>();
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (node.isNodeType("ps:module"))
+            {
+               result.add(new ModuleImpl(jcrService, node));
+            }
+         }
+         return result;
+      }
+      catch (ItemNotFoundException e)
+      {
+         return null;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+
+   public List<Module> getModules(boolean published, Category category, Ordering ordering)
+   {
+      // FIXME getModules
+      return null;
+   }
+
+   public List<Module> getModules(boolean published, Filter filter)
+   {
+      // FIXME getModules
+      return null;
+   }
+
+   public List<Module> getModules(boolean published, Filter filter, 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)
+      {
+         workspace = JCRService.PUBLISHED_MODULE_WORKSPACE_NAME;
+      }
+      
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(workspace);
+         QueryManager queryManager = session.getWorkspace().getQueryManager();
+         Query query = queryManager.createQuery("SELECT * from ps:category", Query.SQL);
+         QueryResult queryResult = query.execute();
+         
+         NodeIterator it = queryResult.getNodes();
+         List<Category> result = new ArrayList<Category>();
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (node.isNodeType("ps:category"))
+            {
+               result.add(new CategoryImpl(jcrService, node));
+            }
+         }
+         return result;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,172 @@
+/******************************************************************************
+ * 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.memory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.Ordering;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.filter.CategoryFilter;
+import org.jboss.portletswap.filter.Filter;
+import org.jboss.portletswap.filter.TypeFilter;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DirectoryServiceImpl implements DirectoryService
+{
+   private Map<Object, Module> modules;
+   
+   public void setStorage(Map<Object, Module> modules)
+   {
+      this.modules = modules;
+   }
+   
+   @SuppressWarnings("unchecked")
+   public List<Module> getModules(boolean published)
+   {
+      return getModules(published, Collections.EMPTY_LIST);
+   }
+
+   @SuppressWarnings("unchecked")
+   public List<Module> getModules(boolean published, Ordering ordering)
+   {
+      return getModules(published, Collections.EMPTY_LIST, ordering);
+   }
+
+   public List<Module> getModules(boolean published, Type type)
+   {
+      return getModules(published, type, Ordering.NO_SPECIAL_ORDER);
+   }
+
+   public List<Module> getModules(boolean published, Type type, Ordering ordering)
+   {
+      return getModules(published, new TypeFilter(type), ordering);
+   }
+
+   public List<Module> getModules(boolean published, Category category)
+   {
+      return getModules(published, category, Ordering.NO_SPECIAL_ORDER);
+   }
+
+   public List<Module> getModules(boolean published, Category category, Ordering ordering)
+   {
+      List<Filter> filters = new ArrayList<Filter>();
+      filters.add(new CategoryFilter(category));
+      return getModules(published, filters);
+   }
+
+   public List<Module> getModules(boolean published, Filter filter)
+   {
+      return getModules(published, filter, Ordering.NO_SPECIAL_ORDER);
+   }
+   
+
+   public List<Module> getModules(boolean published, Filter filter, Ordering ordering)
+   {
+      List<Filter> list = new ArrayList<Filter>();
+      list.add(filter);
+      return getModules(published, list, ordering);
+   }
+   
+   public List<Module> getModules(boolean published, List<Filter> filters, Ordering ordering)
+   {
+      Set<Module> result = null;
+      Comparator<Module> comparator = getComparator(ordering);
+      if (comparator != null)
+      {
+         result = new TreeSet<Module>(comparator);
+      }
+      else
+      {
+         result = new HashSet<Module>();
+      }
+      for(Module module: modules.values())
+      {
+         boolean accept = true;
+         for (Filter filter:filters)
+         {
+            if (!filter.accept(module))
+            {
+               accept = false;
+            }
+         }
+         if (accept)
+         {
+            result.add(module);
+         }
+      }
+      return Tools.toList(result.iterator());
+   }
+
+   public List<Module> getModules(boolean published, List<Filter> filters)
+   {
+      return getModules(published, filters, Ordering.NO_SPECIAL_ORDER);
+   }
+   
+   private Comparator<Module> getComparator(Ordering ordering)
+   {
+      if (ordering.equals(Ordering.NAME_ASC))
+      {
+         return new Comparator<Module>() {
+
+            public int compare(Module o1, Module o2)
+            {
+               return o1.getName().compareTo(o2.getName());
+            }
+         };
+      }
+      if (ordering.equals(Ordering.NAME_DESC))
+      {
+         return new Comparator<Module>() {
+
+            public int compare(Module o1, Module o2)
+            {
+               return o2.getName().compareTo(o1.getName());
+            }
+         };
+      }
+      
+      return null;
+   }
+
+   public List<Category> getCategories(boolean published)
+   {
+      // FIXME getCategories
+      return null;
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/CategoryFilter.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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;
+
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.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;
+      }
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/Filter.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.Module;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Filter
+{
+
+   public boolean accept(Module module);
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/filter/TypeFilter.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.Module;
+import org.jboss.portletswap.Type;
+
+/**
+ * @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;
+      }
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRService.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRService.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.jcr;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface JCRService
+{
+   public static String MODULE_WORKSPACE_NAME = "moduleWorkspace";
+   
+   public static String PUBLISHED_MODULE_WORKSPACE_NAME = "publishedModuleWorkspace";
+
+   public Session openSession(String workspaceName) throws RepositoryException;
+   
+   public void stop();
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRServiceImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRServiceImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRServiceImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,216 @@
+/******************************************************************************
+ * 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.jcr;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Workspace;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.WorkspaceImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
+import org.apache.jackrabbit.value.DateValue;
+import org.jboss.portletswap.Category;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JCRServiceImpl implements JCRService
+{
+   
+   private String settingsLocation;
+   
+   private String rootPath;
+   
+   private RepositoryImpl repository;
+   
+   public JCRServiceImpl()
+   {
+   }
+   
+   public void setSettingsLocation(String settingsLocation)
+   {
+      this.settingsLocation = settingsLocation;
+   }
+
+   public void setRootPath(String rootPath)
+   {
+      this.rootPath= rootPath;
+   }
+   
+   public void init()
+   {
+      Session session = null;
+      Credentials credentials = null;
+      try
+      {
+         Repository repository = getRepository();
+         credentials = new SimpleCredentials("userId", "".toCharArray());
+         session = repository.login(credentials);
+         WorkspaceImpl workspaceImpl = (WorkspaceImpl) session.getWorkspace();
+         
+        if (workspaceImpl.getAccessibleWorkspaceNames().length == 1)
+        {
+            workspaceImpl.getNamespaceRegistry().registerNamespace("ps", "http://www.portletswap.com");
+
+            workspaceImpl.createWorkspace(MODULE_WORKSPACE_NAME);
+            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("customNodes.cnd");
+            registerCustomNodeTypes(MODULE_WORKSPACE_NAME, is);
+
+            workspaceImpl.createWorkspace(PUBLISHED_MODULE_WORKSPACE_NAME);
+//         registerCustomNodeTypes(PUBLISHED_MODULE_WORKSPACE_NAME, new File("src/main/resources/customNodes.cnd"));
+        }   
+         session.save();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      
+      try
+      {
+         session = repository.login(credentials, MODULE_WORKSPACE_NAME);
+         createRootCategoryNode(session.getRootNode());
+         session.save();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+
+      try
+      {
+         session = repository.login(credentials, PUBLISHED_MODULE_WORKSPACE_NAME);
+         createRootCategoryNode(session.getRootNode());
+         session.save();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+}
+   
+   public void stop()
+   {
+      ((RepositoryImpl)repository).shutdown();
+   }
+
+   public Session openSession(String workspaceName) throws RepositoryException
+   {
+      Repository repository = getRepository();
+      Credentials credentials = new SimpleCredentials("userId", "".toCharArray());
+      return repository.login(credentials, workspaceName);
+   }
+   
+   private Repository getRepository() throws RepositoryException
+   {
+      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(settingsLocation);
+      if (repository == null)
+      {
+         RepositoryConfig cfg = RepositoryConfig.create(is, rootPath);
+         repository = RepositoryImpl.create(cfg);
+      }
+      return repository;
+   }
+   
+   @SuppressWarnings("unchecked")
+   private void registerCustomNodeTypes(String workspaceName, InputStream is) throws Exception
+   {
+      Session session = openSession(workspaceName);
+      Workspace ws = session.getWorkspace();
+      // Read in the CND file
+      try
+      {
+         Reader isReader = new InputStreamReader(is);
+   
+         // Create a CompactNodeTypeDefReader
+         CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(isReader, "cnd");
+         
+         // Get the List of NodeTypeDef objects
+         List<NodeTypeDef> ntdList = cndReader.getNodeTypeDefs();
+         
+         // Get the NodeTypeManager from the Workspace.
+         // Note that it must be cast from the generic JCR NodeTypeManager to the
+         // Jackrabbit-specific implementation.
+         NodeTypeManagerImpl ntmgr =(NodeTypeManagerImpl)ws.getNodeTypeManager();
+
+         // Acquire the NodeTypeRegistry
+         NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry();
+
+         // Loop through the prepared NodeTypeDefs
+         for (NodeTypeDef nodeTypeDef: ntdList) {
+
+            // ...and register it
+            ntreg.registerNodeType(nodeTypeDef);
+         }
+      }
+      finally
+      {
+         session.logout();
+      }
+
+   }
+   
+   private void createRootCategoryNode(Node rootNode)
+   {
+      try
+      {
+         Node node = rootNode.addNode(Category.ROOT_CATEGORY_NAME, "ps:category");
+         node.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+      }
+      catch (Exception e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/Author.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/Author.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/Author.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Author
+{
+   private String username;
+   
+   private String firstname;
+
+   private String lastname;
+
+   public Author(String username, String firstname, String lastname)
+   {
+      this.username = username;
+      this.firstname = firstname;
+      this.lastname = lastname;
+   }
+
+   public String getUsername()
+   {
+      return username;
+   }
+
+   public void setUsername(String username)
+   {
+      this.username = username;
+   }
+
+   public String getFirstname()
+   {
+      return firstname;
+   }
+
+   public void setFirstname(String firstname)
+   {
+      this.firstname = firstname;
+   }
+
+   public String getLastname()
+   {
+      return lastname;
+   }
+
+   public void setLastname(String lastname)
+   {
+      this.lastname = lastname;
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/CompatibilityList.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/CompatibilityList.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/CompatibilityList.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.metadata;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CompatibilityList
+{
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/License.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/License.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/metadata/License.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface License
+{
+   public String getName();
+   
+   public String getText();
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/AbstractModule.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/AbstractModule.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/AbstractModule.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,173 @@
+/******************************************************************************
+ * 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.module.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.metadata.Author;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractModule implements Module
+{
+   private List<Artifact> artifacts;
+   
+   private Object id;
+   
+   private String name;
+   
+   private Version version;
+   
+   private LocalizedString description;
+
+   private List<Author> authors;
+   
+   private List<Category> categories = new ArrayList<Category>();
+   
+   public AbstractModule(String name, Version version)
+   {
+      this.version = version;
+      this.name = name;
+      this.artifacts = new ArrayList<Artifact>();
+   }
+
+   public AbstractModule(String name)
+   {
+      this.name = name;
+      this.artifacts = new ArrayList<Artifact>();
+   }
+
+   public AbstractModule()
+   {
+      this.artifacts = new ArrayList<Artifact>();
+   }
+
+   public Object getId()
+   {
+      return id;
+   }
+
+   public Version getVersion()
+   {
+      return version;
+   }
+
+   public Type getType()
+   {
+      Type type = null;
+      for (Artifact artifact: artifacts)
+      {
+         if (type == null)
+         {
+            type = artifact.getType();
+         }
+         else if (type != artifact.getType())
+         {
+            type = Type.MIXED;
+         }
+      }
+      return type;
+   }
+
+   public List<Artifact> getArtifacts()
+   {
+      return artifacts;
+   }
+
+   public void setId(Object id)
+   {
+      if (this.id == null)
+      {
+         this.id = id;
+      }
+      else
+      {
+         throw new IllegalStateException("Not allowed to change the id");
+      }
+   }
+
+   public void setName(String name)
+   {
+      if (this.name == null)
+      {
+         this.name = name;
+      }
+      else
+      {
+         throw new IllegalStateException("Not allowed to change the name");
+      }
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setVersion(Version version)
+   {
+      this.version = version;
+   }
+   
+   public LocalizedString getDescription()
+   {
+      return description;
+   }
+
+   public void setDescription(LocalizedString description)
+   {
+      this.description = description;  
+   }
+
+   public List<Author> getAuthors()
+   {
+      return authors;
+   }
+
+   public void setAuthors(List<Author> authors)
+   {
+      this.authors = authors;
+   }
+   
+   public List<Category> getCategories()
+   {
+      return categories;
+   }
+
+   public void setCategories(List<Category> categories)
+   {
+      this.categories = categories;
+   }
+
+   public abstract void addCategory(Category category);
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/jcr/ModuleImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/jcr/ModuleImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/jcr/ModuleImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,244 @@
+/******************************************************************************
+ * 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.module.impl.jcr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.value.ReferenceValue;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.artifact.impl.jcr.FileArtifactImpl;
+import org.jboss.portletswap.category.impl.jcr.CategoryImpl;
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.metadata.Author;
+import org.jboss.portletswap.module.impl.AbstractModule;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ModuleImpl extends AbstractModule
+{
+
+   private List<Artifact> artifacts = new ArrayList<Artifact>();
+   
+   private JCRService jcrService;
+
+   public ModuleImpl(JCRService jcrService, Node node) throws RepositoryException
+   {
+      this.jcrService = jcrService;
+
+      setName(node.getProperty("ps:name").getString());
+      setId(node.getUUID());
+
+      Node versionNode = node.getNode("ps:version");
+      Version version = new Version(versionNode.getProperty("ps:name").getString(),
+            (int)versionNode.getProperty("ps:major").getValue().getLong(),
+            (int)versionNode.getProperty("ps:minor").getValue().getLong(), 
+            (int)versionNode.getProperty("ps:patch").getValue().getLong(),
+            new Version.Qualifier(
+                  Version.Qualifier.Prefix.valueOf(versionNode.getProperty("ps:prefix").getValue().getString()), 
+                  Version.Qualifier.Suffix.valueOf(versionNode.getProperty("ps:suffix").getValue().getString())),
+                  versionNode.getProperty("ps:codename").getValue().getString());
+      setVersion(version);
+      
+      NodeIterator it = node.getNodes("ps:description");
+      Map<Locale, String> values = new HashMap<Locale, String>();
+      while (it.hasNext())
+      {
+         Node tmpNode = it.nextNode();
+         Locale locale = new Locale(tmpNode.getProperty("jcr:language").getString());
+         String value = tmpNode.getProperty("ps:value").getString();
+         values.put(locale, value);
+      }
+      setDescription(new LocalizedString(values, Locale.ENGLISH));
+      
+      it = node.getNodes("ps:author");
+      List<Author> authors = new ArrayList<Author>();
+      while (it.hasNext())
+      {
+         Node tmpNode = it.nextNode();
+         Author author = new Author(tmpNode.getProperty("ps:username").getString(), 
+               tmpNode.getProperty("ps:firstname").getString(),
+               tmpNode.getProperty("ps:lastname").getString());
+         authors.add(author);
+      }
+      setAuthors(authors);
+      
+   }
+
+   public ModuleImpl(JCRService jcrService, String name, Version version)
+   {
+      this.jcrService = jcrService;
+      setName(name);
+      setVersion(version);
+   }
+
+   @Override
+   public Type getType()
+   {
+      Type type = null;
+      for (Artifact artifact: artifacts)
+      {
+         if (type == null)
+         {
+            type = artifact.getType();
+         }
+         else if (type != artifact.getType())
+         {
+            type = Type.MIXED;
+         }
+      }
+      return type;
+   }
+
+   @Override
+   public List<Artifact> getArtifacts()
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+
+         Node node = session.getNodeByUUID((String) getId());
+         
+         List<Artifact> result = new ArrayList<Artifact>();
+         NodeIterator it = node.getNodes();
+         while (it.hasNext())
+         {
+            Node tmpNode = it.nextNode();
+            if (tmpNode.isNodeType("ps:fileArtifact"))
+            {
+               result.add(new FileArtifactImpl(jcrService, tmpNode));
+            }
+         }
+         return result;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+
+   @Override
+   public void addCategory(Category category)
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+
+         Node node = session.getNodeByUUID((String) getId());
+
+         List<Value> valuesList;
+         try
+         {
+            Property property = node.getProperty("ps:categoryRef");
+            valuesList = new ArrayList<Value>(Arrays.asList(property.getValues()));
+         }
+         catch (PathNotFoundException e)
+         {
+            valuesList = new ArrayList<Value>();
+         }
+
+         valuesList.add(new ReferenceValue(session.getNodeByUUID((String)category.getId())));
+         Value[] values = valuesList.toArray(new Value[valuesList.size()]);
+         
+         node.setProperty("ps:categoryRef", values);
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+   
+   @Override
+   public List<Category> getCategories()
+   {
+      Session session = null;
+      List<Category> categories = new ArrayList<Category>();
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         Node node = session.getNodeByUUID((String) getId());
+         Property property;
+         try
+         {
+            property = node.getProperty("ps:categoryRef");
+         }
+         catch (PathNotFoundException e)
+         {
+            return categories;
+         }
+         
+         Value[] values = property.getValues();
+         for (Value value: values)
+         {
+            Node tmpNode = node.getSession().getNodeByUUID(value.getString());
+            Category category = new CategoryImpl(jcrService, tmpNode);
+            categories.add(category);
+         }
+         return categories;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public void addArtifact(Artifact artifact)
+   {
+      // repositoryService.storeArtifact(this, artifact);
+   }
+}

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/memory/ModuleImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/memory/ModuleImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/module/impl/memory/ModuleImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * 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.module.impl.memory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.common.util.Version;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.metadata.Author;
+import org.jboss.portletswap.module.impl.AbstractModule;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ModuleImpl extends AbstractModule
+{
+
+   private List<Artifact> artifacts;
+   
+   public ModuleImpl(String name, Version version)
+   {
+      super(name, version);
+      artifacts = new ArrayList<Artifact>();
+   }
+   
+   public Type getType()
+   {
+      Type type = null;
+      for (Artifact artifact: artifacts)
+      {
+         if (type == null)
+         {
+            type = artifact.getType();
+         }
+         else if (type != artifact.getType())
+         {
+            type = Type.MIXED;
+         }
+      }
+      return type;
+   }
+
+   public void addArtifact(Artifact artifact)
+   {
+      artifacts.add(artifact);
+   }
+
+   public List<Artifact> getArtifacts()
+   {
+      return artifacts;
+   }
+
+   public void setArtifacts(List<Artifact> artifacts)
+   {
+      this.artifacts = artifacts;
+   }
+
+   public void addCategory(Category category)
+   {
+      // FIXME addCategory
+      
+   }
+
+   public List<Author> getAuthors()
+   {
+      // FIXME getAuthors
+      return null;
+   }
+
+   public List<Category> getCategories()
+   {
+      // FIXME getCategories
+      return null;
+   }
+
+   public List<String> getKeywords()
+   {
+      // FIXME getKeywords
+      return null;
+   }
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteCategoryException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteCategoryException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteCategoryException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DeleteCategoryException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 9182835548026829570L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteModuleException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteModuleException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/DeleteModuleException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DeleteModuleException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 7650377766868991970L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/PublishModuleException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/PublishModuleException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/PublishModuleException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PublishModuleException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 7339595717707845495L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveCategoryException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveCategoryException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveCategoryException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RetrieveCategoryException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -3012658907801824817L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveModuleException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveModuleException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RetrieveModuleException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RetrieveModuleException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1073395550575404278L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreArtifactException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreArtifactException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreArtifactException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class StoreArtifactException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -1464464883984783905L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreCategoryException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreCategoryException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreCategoryException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class StoreCategoryException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -494227373485090213L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreLicenseException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreLicenseException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreLicenseException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class StoreLicenseException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 589991665204716100L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreModuleException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreModuleException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/StoreModuleException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class StoreModuleException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -8053828450478606547L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/UnpublishModuleException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/UnpublishModuleException.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/UnpublishModuleException.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.repository;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UnpublishModuleException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -6962744679265911299L;
+
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,530 @@
+/******************************************************************************
+ * 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.repository.impl.jcr;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.value.DateValue;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.ArtifactType;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.RepositoryService;
+import org.jboss.portletswap.artifact.FileArtifact;
+import org.jboss.portletswap.artifact.impl.jcr.FileArtifactImpl;
+import org.jboss.portletswap.artifact.impl.jcr.LicenseImpl;
+import org.jboss.portletswap.category.impl.AbstractCategory;
+import org.jboss.portletswap.category.impl.jcr.CategoryImpl;
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.metadata.Author;
+import org.jboss.portletswap.metadata.License;
+import org.jboss.portletswap.module.impl.jcr.ModuleImpl;
+import org.jboss.portletswap.repository.DeleteCategoryException;
+import org.jboss.portletswap.repository.DeleteModuleException;
+import org.jboss.portletswap.repository.PublishModuleException;
+import org.jboss.portletswap.repository.RetrieveCategoryException;
+import org.jboss.portletswap.repository.RetrieveModuleException;
+import org.jboss.portletswap.repository.StoreArtifactException;
+import org.jboss.portletswap.repository.StoreCategoryException;
+import org.jboss.portletswap.repository.StoreLicenseException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.UnpublishModuleException;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+ at SuppressWarnings("serial")
+public class RepositoryServiceImpl implements RepositoryService, Serializable
+{
+
+   private JCRService jcrService;
+   
+   private Category rootCategory;
+
+   public RepositoryServiceImpl()
+   {
+   }
+   
+   public JCRService getJcrService()
+   {
+      return jcrService;
+   }
+
+   public void setJcrService(JCRService jcrService)
+   {
+      this.jcrService = jcrService;
+   }
+
+   public void deleteModule(Module module) throws DeleteModuleException
+   {
+      try
+      {
+         unpublishModule(module);
+      }
+      catch (UnpublishModuleException e)
+      {
+         // ignore
+      }
+
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         Node node = session.getNodeByUUID((String)module.getId());
+         if (node != null)
+         {
+            node.remove();
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new DeleteModuleException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public Module getModule(Object id) throws RetrieveModuleException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         Node node = session.getNodeByUUID((String)id);
+         if (node != null)
+         {
+            return new ModuleImpl(jcrService, node);
+         }
+      }
+      catch (ItemNotFoundException e)
+      {
+         return null;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new RetrieveModuleException();
+      }
+      finally
+      {
+         session.logout();
+      }
+      return null;
+   }
+   
+   public Module publishModule(Module module) throws PublishModuleException
+   {
+      Session sessionUnpublished = null;
+      Session sessionPublished = null;
+      try
+      {
+         sessionUnpublished = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         Node node = sessionUnpublished.getNodeByUUID((String) module.getId());
+         
+         sessionPublished = jcrService.openSession(JCRService.PUBLISHED_MODULE_WORKSPACE_NAME);
+         
+         // Publish categories
+         List<Category> categories = module.getCategories();
+         for (Category category: categories)
+         {
+            try 
+            {
+               sessionPublished.getNodeByUUID((String) category.getId());
+            }
+            catch (ItemNotFoundException e)
+            {
+               Node categoryNode = sessionUnpublished.getNodeByUUID((String) category.getId());
+               sessionPublished.getWorkspace().clone(sessionUnpublished.getWorkspace().getName(), categoryNode.getPath(), categoryNode.getPath(), false);
+            }
+         }
+         
+         sessionPublished.getWorkspace().clone(sessionUnpublished.getWorkspace().getName(), node.getPath(), node.getPath(), false);
+         
+         sessionPublished.save();
+         return new ModuleImpl(jcrService, sessionPublished.getNodeByUUID((String) module.getId()));
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new PublishModuleException();
+      }
+      finally
+      {
+         sessionPublished.logout();
+         sessionUnpublished.logout();
+      }
+   }
+
+   public Category storeCategory(Category category) throws StoreCategoryException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         Node parentNode = null;
+         if (category.getName() == AbstractCategory.ROOT_CATEGORY_NAME)
+         {
+            parentNode = session.getRootNode();
+         }
+         else
+         {
+            parentNode = session.getNodeByUUID((String) category.getParent().getId());
+         }
+
+         Node node = parentNode.addNode(category.getName(), "ps:category");
+         node.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+         
+         // Store the displayName
+         LocalizedString displayName = category.getDisplayName();
+         if (displayName != null)
+         {
+            @SuppressWarnings("unchecked")
+            Map<Locale, LocalizedString.Value> values = displayName.getValues();
+
+            Set<Locale> set = values.keySet();
+            Iterator<Locale> it = set.iterator();
+            while (it.hasNext())
+            {
+               Locale locale = it.next();
+               {
+                  Node displayNameNode = node.addNode("ps:displayName", "ps:displayName");
+                  displayNameNode.setProperty("jcr:language", locale.toString());
+                  displayNameNode.setProperty("ps:value", (values.get(locale)).getString());
+               }
+            }
+         }
+
+         
+         session.save();
+         
+         return new CategoryImpl(jcrService, node);
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new StoreCategoryException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public Module storeModule(Module module) throws StoreModuleException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         // Store the module name
+         Node moduleNode = session.getRootNode().addNode("ps:module", "ps:module");
+         
+         moduleNode.setProperty("ps:name", module.getName());
+         
+         // Store the last modified date
+         moduleNode.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+         // Store the version
+         Version version = module.getVersion();
+         Node versionNode = moduleNode.addNode("ps:version", "ps:version");
+         {
+            versionNode.setProperty("ps:name", version.getName());
+            versionNode.setProperty("ps:major", version.getMajor());
+            versionNode.setProperty("ps:minor", version.getMinor());
+            versionNode.setProperty("ps:patch", version.getPatch());
+            versionNode.setProperty("ps:prefix", version.getQualifier().getPrefix().getName());
+            versionNode.setProperty("ps:suffix", version.getQualifier().getSuffix().name());
+            versionNode.setProperty("ps:codename", version.getCodeName());
+         }
+         
+         // Store the description
+         LocalizedString description = module.getDescription();
+         if (description != null)
+         {
+            @SuppressWarnings("unchecked")
+            Map<Locale, LocalizedString.Value> values = description.getValues();
+
+            Set<Locale> set = values.keySet();
+            Iterator<Locale> it = set.iterator();
+            while (it.hasNext())
+            {
+               Locale locale = it.next();
+               {
+                  Node descriptionNode = moduleNode.addNode("ps:description", "ps:description");
+                  descriptionNode.setProperty("jcr:language", locale.toString());
+                  descriptionNode.setProperty("ps:value", (values.get(locale)).getString());
+               }
+            }
+         }
+         
+         // Store the authors
+         List<Author> authors = module.getAuthors();
+         if (authors != null)
+         {
+            for (Author author: authors)
+            {
+               Node authorNode = moduleNode.addNode("ps:author", "ps:author");
+               authorNode.setProperty("ps:username", author.getUsername());
+               authorNode.setProperty("ps:firstname", author.getFirstname());
+               authorNode.setProperty("ps:lastname", author.getLastname());
+            }
+         }
+         
+         session.save();
+  
+         module.setId(moduleNode.getUUID());
+
+         return module;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new StoreModuleException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public void unpublishModule(Module module) throws UnpublishModuleException
+   {
+      Session sessionPublished = null;
+      try
+      {
+         sessionPublished = jcrService.openSession(JCRService.PUBLISHED_MODULE_WORKSPACE_NAME);
+         Node node = sessionPublished.getNodeByUUID((String) module.getId());
+
+         node.remove();
+
+         sessionPublished.save();
+      }
+      catch (RepositoryException e)
+      {
+         throw new UnpublishModuleException();
+      }
+      finally
+      {
+         sessionPublished.logout();
+      }
+   }
+
+   public Category getCategory(Object id) throws RetrieveCategoryException
+   {
+      try
+      {
+         Session session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         Node node = session.getNodeByUUID((String)id);
+         if (node != null)
+         {
+            return new CategoryImpl(jcrService, node);
+         }
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new RetrieveCategoryException();
+      }
+      return null;
+   }
+
+   public Category getRootCategory() throws RetrieveCategoryException
+   {
+      if (rootCategory == null)
+      {
+         Session session = null;
+         try
+         {
+            session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+                  
+            Node rootNode = session.getRootNode();
+            rootCategory = new CategoryImpl(jcrService, rootNode.getNode(Category.ROOT_CATEGORY_NAME));
+         }
+         catch (RepositoryException e)
+         {
+            e.printStackTrace();
+            throw new RetrieveCategoryException();
+         }
+         finally
+         {
+            session.logout();
+         }
+      }
+      return rootCategory;
+   }
+
+   public void deleteCategory(Category category) throws DeleteCategoryException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         Node node = session.getNodeByUUID((String)category.getId());
+         if (node != null)
+         {
+            node.remove();
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new DeleteCategoryException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public Artifact storeArtifact(Module module, Artifact artifact) throws StoreArtifactException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         Node node = session.getNodeByUUID((String) module.getId());
+         
+         Node artifactNode = null;
+         if (artifact.getArtifactType().equals(ArtifactType.FILE_ARTIFACT_TYPE))
+         {
+            artifactNode = node.addNode(artifact.getName(), "ps:fileArtifact");
+            artifactNode.setProperty("ps:file", ((FileArtifact)artifact).getInputStream());
+            artifactNode.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+            artifactNode.setProperty("ps:license", ((LicenseImpl)artifact.getLicense()).getId());
+            artifactNode.setProperty("ps:type", artifact.getType().name());
+            
+            // Store the description
+            LocalizedString description = module.getDescription();
+            if (description != null)
+            {
+               @SuppressWarnings("unchecked")
+               Map<Locale, LocalizedString.Value> values = description.getValues();
+
+               Set<Locale> set = values.keySet();
+               Iterator<Locale> it = set.iterator();
+               while (it.hasNext())
+               {
+                  Locale locale = it.next();
+                  {
+                     Node descriptionNode = artifactNode.addNode("ps:description", "ps:description");
+                     descriptionNode.setProperty("jcr:language", locale.toString());
+                     descriptionNode.setProperty("ps:value", (values.get(locale)).getString());
+                  }
+               }
+            }
+
+            // Store the displayName
+            LocalizedString displayName = artifact.getDisplayName();
+            if (displayName != null)
+            {
+               @SuppressWarnings("unchecked")
+               Map<Locale, LocalizedString.Value> values = displayName.getValues();
+
+               Set<Locale> set = values.keySet();
+               Iterator<Locale> it = set.iterator();
+               while (it.hasNext())
+               {
+                  Locale locale = it.next();
+                  {
+                     Node displayNameNode = artifactNode.addNode("ps:displayName", "ps:displayName");
+                     displayNameNode.setProperty("jcr:language", locale.toString());
+                     displayNameNode.setProperty("ps:value", (values.get(locale)).getString());
+                  }
+               }
+            }
+
+            
+            session.save();
+            ((FileArtifactImpl)artifact).setId(artifactNode.getUUID());
+            return artifact;
+         }
+         return null;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new StoreArtifactException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   public License storeLicense(License license) throws StoreLicenseException
+   {
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+               
+         // Store the license name
+         Node licenseNode = session.getRootNode().addNode("ps:license", "ps:license");
+         
+         // Store the license text
+         licenseNode.setProperty("ps:name", license.getName());
+         licenseNode.setProperty("ps:text", license.getText());
+         
+         session.save();
+  
+         ((LicenseImpl)license).setId(licenseNode.getUUID());
+
+         return license;
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+         throw new StoreLicenseException();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+}
+

Added: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceImpl.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceImpl.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * 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.repository.impl.memory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.RepositoryService;
+import org.jboss.portletswap.category.impl.memory.CategoryImpl;
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.portletswap.metadata.License;
+import org.jboss.portletswap.module.impl.AbstractModule;
+import org.jboss.portletswap.repository.DeleteCategoryException;
+import org.jboss.portletswap.repository.DeleteModuleException;
+import org.jboss.portletswap.repository.PublishModuleException;
+import org.jboss.portletswap.repository.StoreLicenseException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.UnpublishModuleException;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RepositoryServiceImpl implements RepositoryService
+{
+
+   public static final Category ROOT_CATEGORY = new CategoryImpl(Category.ROOT_CATEGORY_NAME, null);
+
+   private JCRServiceImpl jcrService;
+   
+   private Map<Object, Module> modules = new HashMap<Object, Module>();
+   
+   private List<Module> published = new java.util.ArrayList<Module>();
+   
+   public void deleteModule(Module module) throws DeleteModuleException
+   {
+      modules.remove(module.getId());
+   }
+
+   public Map<Object, Module> getModules()
+   {
+      return modules;
+   }
+   
+   public Module getModule(Object id)
+   {
+      return modules.get(id);
+   }
+
+   public Module storeModule(Module module) throws StoreModuleException
+   {
+      ((AbstractModule)module).setId(module.getName() + module.getVersion());
+      modules.put(module.getId(), module);
+      return module;
+   }
+
+   public Category storeCategory(Category category)
+   {
+      // FIXME getCategory
+      return null;
+   }
+
+   public Module publishModule(Module module) throws PublishModuleException
+   {
+      published.add(module);
+      return module;
+   }
+
+   public void unpublishModule(Module module) throws UnpublishModuleException
+   {
+      published.remove(module);
+   }
+
+   public JCRServiceImpl getJcrService()
+   {
+      return jcrService;
+   }
+
+   public void setJcrService(JCRServiceImpl jcrService)
+   {
+      this.jcrService = jcrService;
+   }
+
+   public Category getCategory(Object id)
+   {
+      // FIXME getCategory
+      return null;
+   }
+
+   public void deleteCategory(Category category) throws DeleteCategoryException
+   {
+      // FIXME deleteCategory
+      
+   }
+   
+   public Artifact storeArtifact(Module module, Artifact artifact)
+   {
+      return null;
+   }
+
+   public License storeLicense(License license) throws StoreLicenseException
+   {
+      // FIXME storeLicense
+      return null;
+   }
+
+   
+}
+

Added: server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,55 @@
+/** Categories node types */
+<mix = 'http://www.jcp.org/jcr/mix/1.0'>
+<nt  = 'http://www.jcp.org/jcr/nt/1.0'>
+<jcr = 'http://www.jcp.org/jcr/1.0'>
+<ps  = 'http://www.portletswap.com'>
+
+[ps:category] > nt:folder, mix:referenceable
+ - jcr:lastModified (date) mandatory ignore
+ + ps:description
+ + * (ps:category)
+ + ps:displayName
+ 
+[ps:localizedString] > nt:base
+ - jcr:language (string) mandatory
+ - ps:value
+ 
+[ps:description] > ps:localizedString
+
+[ps:displayName] > ps:localizedString
+
+[ps:license] > nt:base, mix:referenceable
+ - ps:text
+ - ps:name
+
+[ps:author] > nt:base
+ - ps:username
+ - ps:firstname
+ - ps:lastname
+ + ps:description
+ + ps:displayName
+
+[ps:fileArtifact] > nt:base, mix:referenceable
+ - jcr:lastModified (date) mandatory ignore
+ - ps:file (binary) 
+ - ps:type (string) mandatory
+ - ps:license (reference) mandatory
+ 
+[ps:module] > nt:base, mix:referenceable
+ - jcr:lastModified (date) mandatory ignore
+ - ps:categoryRef (reference) multiple copy
+ - ps:name (string)
+ + ps:author
+ + ps:description
+ + ps:version mandatory
+ + * (ps:fileArtifact)
+
+[ps:version] > nt:base
+ - ps:name
+ - ps:major mandatory
+ - ps:minor mandatory
+ - ps:patch mandatory
+ - ps:prefix mandatory
+ - ps:suffix
+ - ps:codename
+ 
\ No newline at end of file

Added: server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Naming" class="org.jnp.server.NamingServer"/>
+ 
+   <bean name="InitialContextProperties" class="java.util.Hashtable">
+      <constructor>
+      <parameter class="java.util.Map">
+            <map keyClass="java.lang.String" valueClass="java.lang.String">
+               <entry>
+                  <key>java.naming.factory.initial</key>
+                  <value>org.jnp.interfaces.NamingContextFactory</value>
+               </entry>
+               <entry>
+                   <key>java.naming.factory.url.pkgs</key>
+                   <value>org.jboss.naming:org.jnp.interfaces</value>
+               </entry>
+            </map>
+      </parameter>
+      </constructor>
+   </bean>
+   
+   
+   <!-- JCR IMPLEMENTATION -->
+
+   <bean name="JCRService" class="org.jboss.portletswap.jcr.JCRServiceImpl">
+      <property name="settingsLocation">settings.xml</property>
+      <property name="rootPath">/tmp/jcr</property>
+   </bean>
+
+   <bean name="RepositoryService"
+         class="org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl">
+      <property name="jcrService">
+         <inject bean="JCRService"/>
+      </property>
+      <property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
+      <property name="bindTo">java:/RespositoryService</property>
+   </bean>       
+   
+   <bean name="DirectoryService"
+         class="org.jboss.portletswap.directory.impl.jcr.DirectoryServiceImpl">
+      <property name="jcrService">
+         <inject bean="JCRService"/>
+      </property>
+   </bean>       
+
+   <!-- MEMORY IMPLEMENTATION
+
+   <bean name="RepositoryService"
+         class="org.jboss.portletswap.repository.impl.memory.RepositoryServiceImpl">
+   </bean>       
+   
+   <bean name="DirectoryService"
+         class="org.jboss.portletswap.directory.impl.memory.DirectoryServiceImpl">
+		<property name="storage">
+		   <inject bean="RepositoryService" property="modules"/>  
+		</property>
+   </bean>       
+   
+   -->
+   
+</deployment>
\ No newline at end of file

Added: server/trunk/server-service/server-lib/src/main/resources/log4j.properties
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/log4j.properties	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/resources/log4j.properties	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,5 @@
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
\ No newline at end of file

Added: server/trunk/server-service/server-lib/src/main/resources/settings.xml
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/settings.xml	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/main/resources/settings.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,40 @@
+<Repository>
+	<FileSystem
+		class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+		<param name="path" value="${rep.home}/repository" />
+	</FileSystem>
+	<Security appName="Jackrabbit">
+		<AccessManager
+			class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
+		<LoginModule
+			class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+			<param name="anonymousId" value="anonymous" />
+		</LoginModule>
+	</Security>
+	<Workspaces rootPath="${rep.home}/workspaces"
+		defaultWorkspace="default" />
+	<Workspace name="${wsp.name}">
+		<FileSystem
+			class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+			<param name="path" value="${wsp.home}" />
+		</FileSystem>
+		<PersistenceManager
+            class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+		<SearchIndex
+			class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+			<param name="path" value="${wsp.home}/index" />
+		</SearchIndex>
+	</Workspace>
+	<Versioning rootPath="${rep.home}/version">
+		<FileSystem
+			class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+			<param name="path" value="${rep.home}/version" />
+		</FileSystem>
+		<PersistenceManager
+            class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+	</Versioning>
+	<SearchIndex
+		class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+		<param name="path" value="${rep.home}/repository/index" />
+	</SearchIndex>
+</Repository>
\ No newline at end of file

Added: server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java
===================================================================
--- server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * 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.jcr;
+
+import static org.jboss.unit.api.Assert.*;
+import java.util.List;
+
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.jboss.portal.common.util.Version;
+import org.jboss.portal.common.util.Version.Qualifier;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.portletswap.module.impl.jcr.ModuleImpl;
+import org.jboss.portletswap.repository.PublishModuleException;
+import org.jboss.portletswap.repository.RetrieveCategoryException;
+import org.jboss.portletswap.repository.StoreCategoryException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DirectoryServiceTestCase
+{
+
+   private JCRServiceImpl jcrService;
+   
+   private RepositoryServiceImpl repositoryService;
+
+   private DirectoryServiceImpl directoryService;
+
+   private Module module;
+   
+   private Category category;
+   
+   @Create
+   public void setUp()
+   {
+      jcrService = new JCRServiceImpl();
+      jcrService.setSettingsLocation("settings.xml");
+      jcrService.setRootPath("/tmp/jcr");
+      jcrService.init();
+      
+      directoryService = new DirectoryServiceImpl();
+      directoryService.setJcrService(jcrService);
+      
+      repositoryService = new RepositoryServiceImpl();
+      repositoryService.setJcrService(jcrService);
+      
+      
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      module = new ModuleImpl(jcrService, "Foo", version);
+      
+
+      try
+      {
+         category = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Foo", repositoryService.getRootCategory());
+         category = repositoryService.storeCategory(category);
+      }
+      catch (RetrieveCategoryException e)
+      {
+         e.printStackTrace();
+      }
+      catch (StoreCategoryException e)
+      {
+         e.printStackTrace();
+      }
+      
+      assertNull(module.getId());
+      try
+      {
+         module = repositoryService.storeModule(module);
+         module.addCategory(category);
+      }
+      catch (StoreModuleException e)
+      {
+         e.printStackTrace();
+      }
+   }
+   
+   @Destroy
+   public void tearDown()
+   {
+
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         NodeIterator it = session.getRootNode().getNodes();
+         
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (!node.getName().equals("jcr:system"))
+            {
+               node.remove();
+            }
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      
+      try
+      {
+         session = jcrService.openSession(JCRService.PUBLISHED_MODULE_WORKSPACE_NAME);
+         NodeIterator it = session.getRootNode().getNodes();
+         
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (!node.getName().equals("jcr:system"))
+            {
+               node.remove();
+            }
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      jcrService.stop();
+   }
+   
+   
+   @Test
+   public void testGetModules() throws PublishModuleException
+   {
+      List<Module> modules = directoryService.getModules(false);
+      assertEquals(1, modules.size());
+      modules = directoryService.getModules(true);
+      assertEquals(0, modules.size());
+      repositoryService.publishModule(module);
+      modules = directoryService.getModules(true);
+      assertEquals(1, modules.size());
+   }
+
+   @Test
+   public void testGetCategories() throws PublishModuleException
+   {
+      List<Category> categories = directoryService.getCategories(false);
+      assertEquals(2, categories.size());
+   }
+
+   @Test
+   public void testGetModulesForOneCategory() throws PublishModuleException, StoreModuleException
+   {
+      Module module2 = new ModuleImpl(jcrService, "Bar", module.getVersion());
+      repositoryService.storeModule(module2);
+      List<Module> modules = directoryService.getModules(false);
+      assertEquals(2, modules.size());
+      modules = directoryService.getModules(false, category);
+      assertEquals(1, modules.size());
+      module2.addCategory(category);
+      modules = directoryService.getModules(false, category);
+      assertEquals(2, modules.size());
+      modules = directoryService.getModules(true, category);
+      assertEquals(0, modules.size());
+   }
+}
+

Added: server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceTestCase.java
===================================================================
--- server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceTestCase.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.memory;
+
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.portal.common.util.Version;
+import org.jboss.portal.common.util.Version.Qualifier;
+import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.module.impl.memory.ModuleImpl;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.impl.memory.RepositoryServiceImpl;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DirectoryServiceTestCase
+{
+
+   @Test
+   public void testRegister() throws StoreModuleException
+   {
+      RepositoryServiceImpl repositoryService = new RepositoryServiceImpl();
+      
+      Version version1 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module1 = new ModuleImpl("Foo", version1);
+      repositoryService.storeModule(module1);
+      
+      Version version2 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.CR), "");
+      Module module2 = new ModuleImpl("Foo", version2);
+      repositoryService.storeModule(module2);
+
+      DirectoryService directoryService = new DirectoryServiceImpl();
+      ((DirectoryServiceImpl)directoryService).setStorage(repositoryService.getModules());
+      
+      List<Module> modules = directoryService.getModules(false);
+      assertEquals(2, modules.size());
+      
+      Version version3 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.BETA), "");
+      Module module3 = new ModuleImpl("Foo", version3);
+      repositoryService.storeModule(module3);
+
+      modules = directoryService.getModules(false);
+      assertEquals(3, modules.size());
+      
+   }
+   
+}
+

Added: server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/jcr/JCRServiceTestCase.java
===================================================================
--- server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/jcr/JCRServiceTestCase.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/jcr/JCRServiceTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.jcr;
+
+//import static org.jboss.unit.api.Assert.*;
+
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.value.DateValue;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JCRServiceTestCase
+{
+   
+   @Test
+   public void testAddCustomNodes() throws Exception
+   {
+      JCRServiceImpl jcrService = new JCRServiceImpl();
+      jcrService.setSettingsLocation("settings.xml");
+      jcrService.setRootPath("/tmp/jcr");
+      jcrService.init();
+
+      Session session = jcrService.openSession(JCRServiceImpl.MODULE_WORKSPACE_NAME);
+      
+      Node node1 = session.getRootNode().addNode("Category1" , "ps:category");
+      node1.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+      Node node2 = session.getRootNode().addNode("Category2" , "ps:category");
+      node2.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+      Node node3 = session.getRootNode().addNode("Category3" , "ps:category");
+      node3.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+      Node node1_1 = node1.addNode("Category11" , "ps:category");
+      node1_1.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+      Node node1_2 = node1.addNode("Category12" , "ps:category");
+      node1_2.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
+
+      session.save();
+      
+      dumpSession(session.getRootNode(), 0);
+      
+      jcrService.stop();
+   }
+   
+   private void dumpSession(Node node, int index) throws RepositoryException
+   {
+      NodeIterator it = node.getNodes();
+      while (it.hasNext())
+      {
+         Node tmpNode = it.nextNode();
+         for (int i=0; i< index; i++)
+         {
+            System.out.print(" ");
+         }
+         System.out.println("* " + tmpNode.getName());
+         dumpSession(tmpNode, index+1);
+      }
+   }
+}
+

Added: server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
===================================================================
--- server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,356 @@
+/******************************************************************************
+ * 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.repository.impl.jcr;
+
+import static org.jboss.unit.api.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+import org.jboss.portal.common.util.Version.Qualifier;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.artifact.FileArtifact;
+import org.jboss.portletswap.artifact.impl.jcr.FileArtifactImpl;
+import org.jboss.portletswap.artifact.impl.jcr.LicenseImpl;
+import org.jboss.portletswap.jcr.JCRService;
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.portletswap.metadata.License;
+import org.jboss.portletswap.module.impl.jcr.ModuleImpl;
+import org.jboss.portletswap.repository.RetrieveModuleException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RepositoryServiceTestCase
+{
+
+   private JCRServiceImpl jcrService;
+   
+   private RepositoryServiceImpl repositoryService;
+   
+   @Create
+   public void setUp()
+   {
+      jcrService = new JCRServiceImpl();
+      jcrService.setSettingsLocation("settings.xml");
+      jcrService.setRootPath("/tmp/jcr");
+      jcrService.init();
+      
+      repositoryService = new RepositoryServiceImpl();
+      repositoryService.setJcrService(jcrService);
+      
+   }
+   
+   @Destroy
+   public void tearDown()
+   {
+
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
+         NodeIterator it = session.getRootNode().getNodes();
+         
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (!node.getName().equals("jcr:system"))
+            {
+               node.remove();
+            }
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+
+      try
+      {
+         session = jcrService.openSession(JCRService.PUBLISHED_MODULE_WORKSPACE_NAME);
+         NodeIterator it = session.getRootNode().getNodes();
+         
+         while (it.hasNext())
+         {
+            Node node = it.nextNode();
+            if (!node.getName().equals("jcr:system"))
+            {
+               node.remove();
+            }
+         }
+         session.save();
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+      jcrService.stop();
+      
+      jcrService.stop();
+   }
+   
+   @Test
+   public void testRegisterModule()
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Foo", version);
+      assertNull(module.getId());
+      try
+      {
+         module = repositoryService.storeModule(module);
+      }
+      catch (StoreModuleException e)
+      {
+         e.printStackTrace();
+      }
+      Object id = module.getId();
+      assertNotNull(id);
+      Module getModule = null;
+      try
+      {
+         getModule = repositoryService.getModule(id);
+      }
+      catch (RetrieveModuleException e)
+      {
+         e.printStackTrace();
+      }
+      assertNotNull(getModule);
+      assertEquals(id, getModule.getId());
+      assertEquals(version, module.getVersion());
+   }
+
+   @Test
+   public void testRegisterModuleWithDescription()
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Foo", version);
+      module.setDescription(new LocalizedString("Toto is bo"));
+      try
+      {
+         module = repositoryService.storeModule(module);
+         Module getModule = repositoryService.getModule(module.getId());
+         assertEquals("Toto is bo", getModule.getDescription().getDefaultString());
+      }
+      catch (StoreModuleException e)
+      {
+         e.printStackTrace();
+      }
+      catch (RetrieveModuleException e)
+      {
+         e.printStackTrace();
+      }
+   }
+   
+   @Test
+   public void testAddCategoryToModule() throws Exception
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Foo", version);
+      assertNull(module.getId());
+      try
+      {
+         module = repositoryService.storeModule(module);
+      }
+      catch (StoreModuleException e)
+      {
+         e.printStackTrace();
+      }
+      
+      Category rootCategory = repositoryService.getRootCategory();
+      
+      Category category1 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Foo", rootCategory);
+      category1 = repositoryService.storeCategory(category1);
+      
+      Category category2 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Bar", rootCategory);
+      category2 = repositoryService.storeCategory(category2);
+
+      List<Category> categories = module.getCategories();
+      assertEquals(0, categories.size());
+
+      module.addCategory(category1);
+      categories = module.getCategories();
+      assertEquals(1, categories.size());
+
+      assertEquals(category1.getId(), categories.get(0).getId());
+
+      module.addCategory(category2);
+      categories = module.getCategories();
+      assertEquals(2, categories.size());
+      
+   }
+
+   @Test
+   public void testRegisterCategory() throws Exception
+   {
+      Category rootCategory = repositoryService.getRootCategory();
+      
+      Category category1 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Foo", rootCategory);
+      category1 = repositoryService.storeCategory(category1);
+      Object id = category1.getId();
+      assertNotNull(id);
+
+      Category getCategory = repositoryService.getCategory(id);
+      assertNotNull(getCategory);
+      assertEquals(id, getCategory.getId());
+      
+   }
+   
+
+   @Test
+   public void testRegisterCategoryRecursive() throws Exception
+   {
+      Category rootCategory = repositoryService.getRootCategory();
+      
+      Category category1 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Bar", rootCategory);
+      category1 = repositoryService.storeCategory(category1);
+      Object id1 = category1.getId();
+      assertNotNull(id1);
+      
+      Category category2 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("Foo", category1);
+      category2 = repositoryService.storeCategory(category2);
+      Object id2 = category2.getId();
+      assertNotNull(id2);
+
+      Category getCategory1 = repositoryService.getCategory(id1);
+      assertNotNull(getCategory1);
+      assertEquals(id1, getCategory1.getId());
+
+      Category getCategory2 = repositoryService.getCategory(id2);
+      assertNotNull(getCategory2);
+      assertEquals(id2, getCategory2.getId());
+      
+      assertEquals(rootCategory.getId(), getCategory1.getParent().getId());
+      assertEquals(getCategory1.getId(), getCategory2.getParent().getId());
+      
+   }
+
+   @Test
+   public void testDeleteModule() throws Exception
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Test", version);
+      assertNull(module.getId());
+      module = repositoryService.storeModule(module);
+      Object id = module.getId();
+      assertNotNull(id);
+      Module getModule = repositoryService.getModule(id);
+      assertNotNull(getModule);
+      assertEquals(id, getModule.getId());
+      
+      repositoryService.deleteModule(module);
+      getModule = repositoryService.getModule(id);
+      assertNull(getModule);      
+   }
+
+   @Test
+   public void testPublishModule() throws Exception
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Test", version);
+      assertNull(module.getId());
+      module = repositoryService.storeModule(module);
+      Object id = module.getId();
+      assertNotNull(id);
+
+      repositoryService.publishModule(module);
+      
+      Session session = null;
+      try
+      {
+         session = jcrService.openSession(JCRService.PUBLISHED_MODULE_WORKSPACE_NAME);
+         Node node = session.getNodeByUUID((String)id);
+         assertNotNull(node);
+      }
+      catch (RepositoryException e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         session.logout();
+      }
+   }
+
+   @Test
+   public void testAddArtifact() throws Exception
+   {
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl(jcrService, "Test", version);
+      assertNull(module.getId());
+      Module retModule = repositoryService.storeModule(module);
+
+      InputStream is = new FileInputStream("/tmp/test");
+      Artifact artifact = new FileArtifactImpl(Type.JSR168PORTLET, new File("/tmp/test"), is);
+      ((FileArtifactImpl)artifact).setName("Bozo");
+      
+      License license = new LicenseImpl("LGPL", "blah");
+      license = repositoryService.storeLicense(license);
+
+      artifact.setLicense(license);
+      artifact = repositoryService.storeArtifact(retModule, artifact);
+      
+      List<Artifact> artifacts = retModule.getArtifacts();
+      assertEquals(1, artifacts.size());
+
+      FileArtifact getArtifact = (FileArtifact)artifacts.get(0);
+      assertNotNull(getArtifact);
+      assertNotNull(getArtifact.getInputStream());
+      
+//      FileOutputStream fos = new FileOutputStream("/tmp/foobarou");
+//      
+//      byte[] buf = new byte[256];
+//      int read = 0;
+//      while ((read = getArtifact.getInputStream().read(buf)) > 0) {
+//          fos.write(buf, 0, read);
+//      }
+//      
+      
+   }
+}
+

Added: server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceTestCase.java
===================================================================
--- server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceTestCase.java	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.repository.impl.memory;
+
+import org.jboss.portal.common.util.Version;
+import org.jboss.portal.common.util.Version.Qualifier;
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.RepositoryService;
+import org.jboss.portletswap.Type;
+import org.jboss.portletswap.artifact.impl.jcr.FileArtifactImpl;
+import org.jboss.portletswap.module.impl.memory.ModuleImpl;
+import org.jboss.portletswap.repository.StoreArtifactException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RepositoryServiceTestCase
+{
+   /*
+   public void testRegister() throws StoreModuleException
+   {
+      RepositoryService repositoryService = new RepositoryServiceImpl();
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new MemoryModuleImpl("Foo", version);
+      repositoryService.storeModule(module);
+      
+      assertEquals(1, repositoryService.getModules("Foo").size());
+      
+      assertNotNull(repositoryService.getModule("Foo", version));
+      
+      Version version2 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.BETA), "");
+      assertNull(repositoryService.getModule("Foo", version2));
+
+      Module module2 = new MemoryModuleImpl("Foo", version2);
+      repositoryService.storeModule(module2);
+
+      assertEquals(2, repositoryService.getModules("Foo").size());
+
+      assertNotNull(repositoryService.getModule("Foo", version2));
+   }
+   */
+ 
+   @Test
+   public void testAddArtifact() throws StoreModuleException, StoreArtifactException
+   {
+      RepositoryService repositoryService = new RepositoryServiceImpl();
+      Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
+      Module module = new ModuleImpl("Foo", version);
+      Artifact artifact = new FileArtifactImpl(Type.JSR168PORTLET, null, null);
+      module = repositoryService.storeModule(module);
+      repositoryService.storeArtifact(module, artifact);
+   }
+
+   /*
+   public void testAddCategory()
+   {
+      RepositoryService repositoryService = new RepositoryServiceImpl();
+      assertNull(repositoryService.findCategory("category1"));
+      assertNull(repositoryService.findCategory("category1_1"));
+      Category category1 = new CategoryImpl("category1", CategoryImpl.ROOT_CATEGORY);
+      assertNotNull(repositoryService.findCategory("category1"));
+      new CategoryImpl("category1_1", category1);
+      assertNotNull(repositoryService.findCategory("category1_1"));
+   }
+   */
+}
+

Added: server/trunk/server-service/server-lib/src/test/resources/jboss-unit.xml
===================================================================
--- server/trunk/server-service/server-lib/src/test/resources/jboss-unit.xml	                        (rev 0)
+++ server/trunk/server-service/server-lib/src/test/resources/jboss-unit.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+   xmlns="urn:jboss:jboss-unit:1.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+   <pojo>
+      <test>
+         <class name="org.jboss.portletswap.directory.impl.jcr.DirectoryServiceTestCase"/>
+      </test>
+      <test>
+         <class name="org.jboss.portletswap.directory.impl.memory.DirectoryServiceTestCase"/>
+      </test>
+      <test>
+         <class name="org.jboss.portletswap.jcr.JCRServiceTestCase"/>
+      </test>
+      <test>
+         <class name="org.jboss.portletswap.repository.impl.jcr.RepositoryServiceTestCase"/>
+      </test>
+      <test>
+         <class name="org.jboss.portletswap.repository.impl.memory.RepositoryServiceTestCase"/>
+      </test>
+   </pojo>
+</jboss-unit>
\ No newline at end of file

Added: server/trunk/server-service/server-service/.classpath
===================================================================
--- server/trunk/server-service/server-service/.classpath	                        (rev 0)
+++ server/trunk/server-service/server-service/.classpath	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="lib" path="target/server-service-1.0-CR1-sources.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/server-service-1.0-CR1"/>
+</classpath>

Added: server/trunk/server-service/server-service/.project
===================================================================
--- server/trunk/server-service/server-service/.project	                        (rev 0)
+++ server/trunk/server-service/server-service/.project	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>server-service</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: server/trunk/server-service/server-service/pom.xml
===================================================================
--- server/trunk/server-service/server-service/pom.xml	                        (rev 0)
+++ server/trunk/server-service/server-service/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,119 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>org.jboss.portletswap</groupId>
+		<artifactId>module-parent</artifactId>
+		<version>1.0-CR1</version>
+		<relativePath>../build/pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>server-service</artifactId>
+	<packaging>jboss-sar</packaging>
+	<name>JBoss PortletSwap Server Service</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>jboss</groupId>
+			<artifactId>jboss-system</artifactId>
+			<version>4.0.2</version>
+		</dependency>
+		<dependency>
+			<groupId>jboss</groupId>
+			<artifactId>jboss-jmx</artifactId>
+			<version>4.0.2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-api</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.portletswap</groupId>
+			<artifactId>server-lib</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+	</dependencies>
+
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>jboss-packaging-maven-plugin</artifactId>
+				<version>2.0-SNAPSHOT</version>
+				<extensions>true</extensions>
+				<configuration>
+					<excludes>
+						<exclude>jboss:jboss-jmx</exclude>
+						<exclude>
+							jboss:jboss-backport-concurrent
+						</exclude>
+						<exclude>
+							jboss:jboss-common-logging-spi
+						</exclude>
+						<exclude>
+							org.jboss.portal.common:common-common
+						</exclude>
+						<exclude>junit:junit</exclude>
+						<exclude>jboss:jboss-remoting</exclude>
+						<exclude>
+							jboss.jbossas.core-libs:jboss-local-jdbc
+						</exclude>
+						<exclude>javax.servlet:servlet-api</exclude>
+						<exclude>ant:ant</exclude>
+						<exclude>jboss.jbossas.core-libs:jboss</exclude>
+						<exclude>
+							jboss.jbossas.core-libs:jnpserver
+						</exclude>
+						<exclude>ant:ant-launcher</exclude>
+						<exclude>jboss:jboss-common-core</exclude>
+						<exclude>jboss:jboss-j2ee</exclude>
+						<exclude>jboss:jboss-system</exclude>
+						<exclude>ant:ant-nodeps</exclude>
+						<exclude>javax.activation:activation</exclude>
+						<exclude>
+							jboss.jbossas.core-libs:jboss-jca
+						</exclude>
+						<exclude>cargo:core</exclude>
+						<exclude>hibernate:hibernate3</exclude>
+						<exclude>apache-xerces:xml-apis</exclude>
+						<exclude>
+							jboss.jbossas.core-libs:jboss-transaction
+						</exclude>
+						<exclude>dom4j:dom4j</exclude>
+						<exclude>oswego-concurrent:concurrent</exclude>
+						<exclude>apache-slide:webdavlib</exclude>
+						<exclude>
+							apache-httpclient:commons-httpclient
+						</exclude>
+						<exclude>apache-log4j:log4j</exclude>
+						<exclude>
+							org.codehaus.cargo:cargo-core-uberjar
+						</exclude>
+						<exclude>xml-apis:xml-apis</exclude>
+						<exclude>ant:ant-junit</exclude>
+					</excludes>
+					<libDirectory>
+						${project.build.directory}/${project.build.finalName}
+					</libDirectory>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<pluginRepositories>
+		<pluginRepository>
+			<id>Codehaus Snapshots</id>
+			<url>http://snapshots.repository.codehaus.org/</url>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</pluginRepository>
+	</pluginRepositories>
+
+	<properties>
+		<maven.test.skip>true</maven.test.skip>
+	</properties>
+</project>
\ No newline at end of file

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapService.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapService.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * 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.service;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.portletswap.directory.impl.jcr.DirectoryServiceImpl;
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletSwapService extends ServiceMBeanSupport implements PortletSwapServiceMBean
+{
+   
+   public static final String REPOSITORY_JNDI_NAME = "repositoryService";
+   
+   public static final String DIRECTORY_JNDI_NAME = "directoryService";
+   
+   private String settingsLocation;
+   
+   private String rootPath;
+   
+   private JCRServiceImpl jcrService;
+
+   public String getSettingsLocation()
+   {
+      return settingsLocation;
+   }
+
+   public void setSettingsLocation(String settingsLocation)
+   {
+      this.settingsLocation = settingsLocation;
+   }
+
+   public String getRootPath()
+   {
+      return rootPath;
+   }
+
+   public void setRootPath(String rootPath)
+   {
+      this.rootPath = rootPath;
+   }
+
+   @Override
+   public void startService()
+   {
+      jcrService = new JCRServiceImpl();
+      jcrService.setRootPath(rootPath);
+      jcrService.setSettingsLocation(settingsLocation);
+      jcrService.init();
+
+      RepositoryServiceImpl repositoryService = new RepositoryServiceImpl();
+
+      try
+      {
+         InitialContext ic = new InitialContext();
+         ic.bind(REPOSITORY_JNDI_NAME, repositoryService);
+
+         DirectoryServiceImpl directoryService = new DirectoryServiceImpl();
+
+         ic.bind(DIRECTORY_JNDI_NAME, directoryService);
+         
+         repositoryService.setJcrService(jcrService);
+         directoryService.setJcrService(jcrService);
+
+      }
+      catch (NamingException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      
+      
+   }
+
+   @Override
+   public void stopService()
+   {
+      jcrService.stop();
+   }
+   
+   
+}
+

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapServiceMBean.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapServiceMBean.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/PortletSwapServiceMBean.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.service;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface PortletSwapServiceMBean extends ServiceMBean
+{
+   public void setSettingsLocation(String settingsLocation);
+   
+   public void setRootPath(String rootPath);
+
+
+}
+

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRService.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRService.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.service.crap;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.jboss.portletswap.jcr.JCRServiceImpl;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JCRService extends ServiceMBeanSupport implements JCRServiceMBean
+{
+   private JCRServiceImpl jcrServiceImpl;
+   
+   private String settingsLocation;
+   
+   private String rootPath;
+   
+   @Override
+   public void start()
+   {
+      jcrServiceImpl = new JCRServiceImpl();
+      jcrServiceImpl.setSettingsLocation(settingsLocation);
+      jcrServiceImpl.setRootPath(rootPath);
+      jcrServiceImpl.init();
+   }
+
+   @Override
+   public void stop()
+   {
+      jcrServiceImpl.stop();
+   }
+
+   public Session openSession(String workspace) throws RepositoryException
+   {
+      return jcrServiceImpl.openSession(workspace);
+   }
+
+   public String getSettingsLocation()
+   {
+      return settingsLocation;
+   }
+
+   public void setSettingsLocation(String settingsLocation)
+   {
+      this.settingsLocation = settingsLocation;
+   }
+
+   public String getRootPath()
+   {
+      return rootPath;
+   }
+
+   public void setRootPath(String rootPath)
+   {
+      this.rootPath = rootPath;
+   }
+}
+

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRServiceMBean.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRServiceMBean.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/JCRServiceMBean.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.service.crap;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface JCRServiceMBean extends org.jboss.portletswap.jcr.JCRService, ServiceMBean
+{
+   public void setSettingsLocation(String settingsLocation);
+
+   public void setRootPath(String rootPath);
+}
+

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryService.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryService.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryService.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * 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.service.crap;
+
+import org.jboss.portletswap.Artifact;
+import org.jboss.portletswap.Category;
+import org.jboss.portletswap.Module;
+import org.jboss.portletswap.metadata.License;
+import org.jboss.portletswap.repository.DeleteCategoryException;
+import org.jboss.portletswap.repository.DeleteModuleException;
+import org.jboss.portletswap.repository.PublishModuleException;
+import org.jboss.portletswap.repository.RetrieveCategoryException;
+import org.jboss.portletswap.repository.RetrieveModuleException;
+import org.jboss.portletswap.repository.StoreArtifactException;
+import org.jboss.portletswap.repository.StoreCategoryException;
+import org.jboss.portletswap.repository.StoreLicenseException;
+import org.jboss.portletswap.repository.StoreModuleException;
+import org.jboss.portletswap.repository.UnpublishModuleException;
+import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RepositoryService extends ServiceMBeanSupport implements RepositoryServiceMBean
+{
+   
+   private RepositoryServiceImpl repositoryService;
+   
+   private JCRService foo;
+   
+   public JCRService getFoo()
+   {
+      return foo;
+   }
+
+   public void setFoo(JCRService foo)
+   {
+      this.foo = foo;
+   }
+
+   @Override
+   public void start()
+   {
+      repositoryService = new RepositoryServiceImpl();
+      repositoryService.setJcrService(foo);
+   }
+
+   public void deleteCategory(Category category) throws DeleteCategoryException
+   {
+      repositoryService.deleteCategory(category);
+   }
+
+   public void deleteModule(Module module) throws DeleteModuleException
+   {
+      repositoryService.deleteModule(module);
+   }
+
+   public Category getCategory(Object id) throws RetrieveCategoryException
+   {
+      return repositoryService.getCategory(id);
+   }
+
+   public Module getModule(Object id) throws RetrieveModuleException
+   {
+      return repositoryService.getModule(id);
+   }
+
+   public Module publishModule(Module module) throws PublishModuleException
+   {
+      return repositoryService.publishModule(module);
+   }
+
+   public Artifact storeArtifact(Module module, Artifact artifact) throws StoreArtifactException
+   {
+      return repositoryService.storeArtifact(module, artifact);
+   }
+
+   public Category storeCategory(Category category) throws StoreCategoryException
+   {
+      return repositoryService.storeCategory(category);
+   }
+
+   public License storeLicense(License license) throws StoreLicenseException
+   {
+      return repositoryService.storeLicense(license);
+   }
+
+   public Module storeModule(Module module) throws StoreModuleException
+   {
+      return repositoryService.storeModule(module);
+   }
+
+   public void unpublishModule(Module module) throws UnpublishModuleException
+   {
+      repositoryService.unpublishModule(module);
+   }
+   
+
+}
+

Added: server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryServiceMBean.java
===================================================================
--- server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryServiceMBean.java	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/java/org/jboss/portletswap/service/crap/RepositoryServiceMBean.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -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.service.crap;
+
+import org.jboss.portletswap.RepositoryService;
+import org.jboss.system.ServiceMBean;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface RepositoryServiceMBean extends RepositoryService, ServiceMBean
+{
+   public void setFoo(JCRService jcrService);
+}
+

Added: server/trunk/server-service/server-service/src/main/resources/META-INF/jboss-service.xml
===================================================================
--- server/trunk/server-service/server-service/src/main/resources/META-INF/jboss-service.xml	                        (rev 0)
+++ server/trunk/server-service/server-service/src/main/resources/META-INF/jboss-service.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,9 @@
+<server>
+
+  <mbean code="org.jboss.portletswap.service.PortletSwapService"
+         name="portletswap:service=portletSwapService">
+         <attribute name="SettingsLocation">settings.xml</attribute>
+         <attribute name="RootPath">/tmp/jcr</attribute>
+  </mbean>
+
+</server>
\ No newline at end of file

Added: server/trunk/server-webapp/.classpath
===================================================================
--- server/trunk/server-webapp/.classpath	                        (rev 0)
+++ server/trunk/server-webapp/.classpath	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/modules"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: server/trunk/server-webapp/.project
===================================================================
--- server/trunk/server-webapp/.project	                        (rev 0)
+++ server/trunk/server-webapp/.project	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>server-webapp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: server/trunk/server-webapp/pom.xml
===================================================================
--- server/trunk/server-webapp/pom.xml	                        (rev 0)
+++ server/trunk/server-webapp/pom.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,42 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>org.jboss.portletswap</groupId>
+		<artifactId>module-parent</artifactId>
+		<version>1.0-CR1</version>
+		<relativePath>../build/pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>server-webapp</artifactId>
+	<packaging>war</packaging>
+	<name>JBoss PortletSwap Server Webapp for REST API</name>
+
+
+	<dependencies>
+	    <dependency>
+	        <groupId>org.jboss</groupId>
+	        <artifactId>jbossxb</artifactId>
+	        <version>2.0.0.CR5</version>
+	        <scope>provided</scope>
+	    </dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.5</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.portletswap</groupId>
+			<artifactId>server-lib</artifactId>
+			<scope>provided</scope>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>1.4.3</version>
+		</dependency>
+	</dependencies>
+
+</project>
\ No newline at end of file

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,55 @@
+package org.jboss.portletswap.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CategoryModel {
+
+   private String id;
+
+   private List<DisplayNameModel> displayNames;
+
+   private List<CategoryModel> childCategories;
+
+   public CategoryModel(String id)
+   {
+      this.id = id;
+      this.childCategories = new ArrayList<CategoryModel>();
+      this.displayNames = new ArrayList<DisplayNameModel>();
+   }
+
+   public String getId() {
+      return id;
+   }
+
+   public void setId(String id) {
+      this.id = id;
+   }
+
+   public List<DisplayNameModel> getDisplayNames() {
+      return displayNames;
+   }
+
+   public void setDisplayNames(List<DisplayNameModel> displayNames) {
+      this.displayNames = displayNames;
+   }
+
+   public List<CategoryModel> getChildCategories() {
+      return childCategories;
+   }
+
+   public void setChildCategories(List<CategoryModel> childCategories) {
+      this.childCategories = childCategories;
+   }
+
+   public void addChildCategory(CategoryModel category)
+   {
+      childCategories.add(category);
+   }
+
+   public void addDisplayName(DisplayNameModel displayName)
+   {
+      displayNames.add(displayName);
+   }
+
+}

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,35 @@
+package org.jboss.portletswap.metadata;
+
+public class DisplayNameModel {
+
+   private String lang;
+
+   private String text;
+
+   public DisplayNameModel(String lang, String text)
+   {
+      this.lang = lang;
+      this.text = text;
+   }
+
+   public DisplayNameModel(String lang)
+   {
+      this.lang = lang;
+   }
+
+   public String getLang() {
+      return lang;
+   }
+
+   public void setLang(String lang) {
+      this.lang = lang;
+   }
+
+   public String getText() {
+      return text;
+   }
+
+   public void setText(String text) {
+      this.text = text;
+   }
+}

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ResultModel
+{
+   private List<CategoryModel> categories;
+
+   public ResultModel()
+   {
+      categories = new ArrayList<CategoryModel>();
+   }
+   
+   public List<CategoryModel> getCategories()
+   {
+      return categories;
+   }
+
+   public void addCategory(CategoryModel category)
+   {
+      categories.add(category);
+   }
+
+}
+

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * 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 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 CategoryModel(attrs.getValue("id"));
+      }
+      return child;
+   }
+   
+   public Object newChild(CategoryModel result,
+         UnmarshallingContext context,
+         String namespaceURI,
+         String localName,
+         Attributes attrs)
+   {
+      Object child = null;
+      if("displayName".equals(localName))
+      {
+         child = new DisplayNameModel(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, CategoryModel category, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      result.addCategory(category);
+   }
+
+   /**
+    * Called when parsing character is complete.
+    */
+   public void addChild(CategoryModel category, CategoryModel childCategory, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      category.addChildCategory(childCategory);
+   }
+
+   /**
+    * Called when parsing character is complete.
+    */
+   public void addChild(CategoryModel category, DisplayNameModel displayName, UnmarshallingContext arg1, String arg2, String arg3)
+   {
+      category.addDisplayName(displayName);
+   }
+
+}
+

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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.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<CategoryModel> getChildren(ResultModel result, String namespaceUri, String localName)
+   {
+      if ("category".equals(localName))
+      {
+         return result.getCategories();
+      }
+      return null;
+   }
+
+   public List<Object> getChildren(CategoryModel category, String namespaceUri, String localName)
+   {
+      List<Object> children = new ArrayList<Object>();
+      if ("category".equals(localName))
+      {
+         children.addAll(category.getChildCategories());
+      }
+      else if ("displayName".equals(localName))
+      {
+         children.addAll(category.getDisplayNames());
+      }
+      return children;
+   }
+
+
+   public String getAttributeValue(CategoryModel category, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("id".equals(localName))
+      {
+         value = category.getId();
+      }
+      else
+      {
+         value = null;
+      }
+      return value;
+   }
+
+   public String getAttributeValue(DisplayNameModel displayName, String namespaceUri, String localName)
+   {
+      String value = null;
+      if("lang".equals(localName))
+      {
+         value = displayName.getLang();
+      }
+      else
+      {
+         value = null;
+      }
+      return value;
+   }
+
+}
+

Added: server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java
===================================================================
--- server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java	                        (rev 0)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,238 @@
+package org.jboss.portletswap.servlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Map.Entry;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString.Value;
+import org.jboss.portletswap.Category;
+//import org.jboss.portletswap.DirectoryService;
+import org.jboss.portletswap.RepositoryService;
+//import org.jboss.portletswap.directory.impl.jcr.DirectoryServiceImpl;
+import org.jboss.portletswap.metadata.DisplayNameModel;
+import org.jboss.portletswap.metadata.ResultModel;
+import org.jboss.portletswap.metadata.ResultModelProvider;
+import org.jboss.portletswap.repository.RetrieveCategoryException;
+import org.jboss.portletswap.repository.StoreCategoryException;
+import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.xml.sax.SAXException;
+
+public class DirectoryServlet extends HttpServlet {
+
+   /**
+    * 
+    */
+   private static final long serialVersionUID = 381691756034047451L;
+
+   private RepositoryService repositoryService;
+
+//   private DirectoryService directoryService;
+
+   @Override
+   public void destroy()
+   {
+   }
+   
+   @Override
+   public void init()
+   {
+      try
+      {
+         InitialContext ic = new InitialContext();
+         repositoryService = (RepositoryServiceImpl) ic.lookup("repositoryService");
+//         directoryService = (DirectoryServiceImpl) ic.lookup("directoryService");
+      }
+      catch (NamingException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      populate();
+   }
+
+   private void populate()
+   {
+      Category rootCategory;
+      Category category1;
+      Category category2;
+      Category category3;
+      try
+      {
+         rootCategory = ((RepositoryServiceImpl)repositoryService).getRootCategory();
+         category1 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("foo", rootCategory);
+         category1 = repositoryService.storeCategory(category1);
+         category2 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("bar", rootCategory);
+         category2 = repositoryService.storeCategory(category2);
+         category3 = new org.jboss.portletswap.category.impl.memory.CategoryImpl("child", category2);
+         category3.setDisplayName(new LocalizedString("foobar"));
+         category3 = repositoryService.storeCategory(category3);
+      }
+      catch (RetrieveCategoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (StoreCategoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      
+   }
+
+   @Override
+   public void doPost(HttpServletRequest request, HttpServletResponse response)
+   {
+      doGet(request, response);
+   }
+
+   @Override
+   public void doGet(HttpServletRequest request, HttpServletResponse response)
+   {
+      String uri = request.getRequestURI();
+      StringTokenizer tokenizer = new StringTokenizer(uri, "/");
+
+      // Probably the context path except if the context path is /
+      String firstToken = tokenizer.nextToken();
+
+      if (request.getContextPath().equals("/" + firstToken))
+      {
+         // Servlet path
+         tokenizer.nextToken();
+      }
+      String command = tokenizer.nextToken();
+
+      PrintWriter pw = null;
+      try
+      {
+         pw = response.getWriter();
+         pw.write("QueryString: " + request.getQueryString());
+         pw.write("RequestURI: " + request.getRequestURI());
+         pw.write("Command: " + command);
+      }
+      catch (IOException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      if ("categories".equals(command))
+      {
+         printCategories(pw, getCategoriesResult());
+      }
+      pw.flush();
+      pw.close();
+   }
+
+   private ResultModel getCategoriesResult()
+   {
+      try
+      {
+         Category rootCategory = ((RepositoryServiceImpl)repositoryService).getRootCategory();
+         ResultModel result = new ResultModel();
+         org.jboss.portletswap.metadata.CategoryModel rootCategoryModel = new org.jboss.portletswap.metadata.CategoryModel((String)rootCategory.getName());
+         addCategories(rootCategoryModel, rootCategory);
+         result.addCategory(rootCategoryModel);
+         return result;
+      }
+      catch (RetrieveCategoryException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      return null;
+   }
+
+   private void addCategories(org.jboss.portletswap.metadata.CategoryModel categoryModel, Category category)
+   {
+      List<Category> categories = category.getChildren();
+      for (Category tmpCategory: categories)
+      {
+         org.jboss.portletswap.metadata.CategoryModel tmpCategoryModel = new org.jboss.portletswap.metadata.CategoryModel((String)tmpCategory.getName());
+         
+         
+         tmpCategoryModel.setDisplayNames(convert(category.getDisplayName()));
+         
+         addCategories(tmpCategoryModel, tmpCategory);
+         categoryModel.addChildCategory(tmpCategoryModel);
+      }
+   }
+   
+   public List<DisplayNameModel> convert(LocalizedString lString)
+   {
+      List<DisplayNameModel> result = new ArrayList<DisplayNameModel>();
+      if (lString != null)
+      {
+      @SuppressWarnings("unchecked")
+      Map<Locale, Value> values = lString.getValues();
+      Set<Entry<Locale, Value>> valueSet = values.entrySet();
+      Iterator<Entry<Locale, Value>> it = valueSet.iterator();
+      
+      
+      while (it.hasNext())
+      {
+         Entry<Locale, Value> entry = it.next();
+         Value value = entry.getValue();
+         result.add(new DisplayNameModel(value.getLocale().toString(), value.getString()));
+      }
+      }
+      return result;
+      
+   }
+   
+
+   private void printCategories(Writer writer, ResultModel result)
+   {
+      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();
+
+      try
+      {
+         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("result.xsd");
+         marshaller.marshal(new InputStreamReader(is), provider, result, writer);
+      }
+      catch (IOException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (SAXException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (ParserConfigurationException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+
+   }
+
+
+}

Added: server/trunk/server-webapp/src/main/resources/result.xsd
===================================================================
--- server/trunk/server-webapp/src/main/resources/result.xsd	                        (rev 0)
+++ server/trunk/server-webapp/src/main/resources/result.xsd	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,38 @@
+<?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:attribute name="lang" type="xsd:string"></xsd:attribute>
+	</xsd:complexType>
+</xsd:schema>
\ No newline at end of file

Added: server/trunk/server-webapp/src/main/resources/settings.xml
===================================================================
--- server/trunk/server-webapp/src/main/resources/settings.xml	                        (rev 0)
+++ server/trunk/server-webapp/src/main/resources/settings.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,40 @@
+<Repository>
+	<FileSystem
+		class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+		<param name="path" value="${rep.home}/repository" />
+	</FileSystem>
+	<Security appName="Jackrabbit">
+		<AccessManager
+			class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
+		<LoginModule
+			class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+			<param name="anonymousId" value="anonymous" />
+		</LoginModule>
+	</Security>
+	<Workspaces rootPath="${rep.home}/workspaces"
+		defaultWorkspace="default" />
+	<Workspace name="${wsp.name}">
+		<FileSystem
+			class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+			<param name="path" value="${wsp.home}" />
+		</FileSystem>
+		<PersistenceManager
+            class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+		<SearchIndex
+			class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+			<param name="path" value="${wsp.home}/index" />
+		</SearchIndex>
+	</Workspace>
+	<Versioning rootPath="${rep.home}/version">
+		<FileSystem
+			class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+			<param name="path" value="${rep.home}/version" />
+		</FileSystem>
+		<PersistenceManager
+            class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+	</Versioning>
+	<SearchIndex
+		class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+		<param name="path" value="${rep.home}/repository/index" />
+	</SearchIndex>
+</Repository>
\ No newline at end of file

Added: server/trunk/server-webapp/src/main/webapp/WEB-INF/web.xml
===================================================================
--- server/trunk/server-webapp/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ server/trunk/server-webapp/src/main/webapp/WEB-INF/web.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,16 @@
+<!DOCTYPE web-app PUBLIC
+   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+   "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+	<servlet>
+		<servlet-name>DirectoryServlet</servlet-name>
+		<servlet-class>org.jboss.portletswap.servlet.DirectoryServlet</servlet-class>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>DirectoryServlet</servlet-name>
+		<url-pattern>/directory/*</url-pattern>
+	</servlet-mapping>
+
+</web-app>
\ No newline at end of file

Added: server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java
===================================================================
--- server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java	                        (rev 0)
+++ server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,66 @@
+package org.jboss.portletswap.metadata;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.xml.sax.SAXException;
+
+public class MarshallerTestCase extends TestCase
+{
+
+   public void testMarshallCategory()
+   {
+      
+      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 PrintWriter(System.out);
+      try
+      {
+         marshaller.marshal("src/main/resources/result.xsd", provider, getResult(), writer);
+         writer.flush();
+         writer.close();
+
+      }
+      catch (IOException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (SAXException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      
+      System.out.println("end");
+   }
+   
+   private ResultModel getResult()
+   {
+      ResultModel result = new ResultModel();
+      CategoryModel category1 = new CategoryModel("1111-2222-3333");
+      CategoryModel category2 = new CategoryModel("2222-3333-4444");
+      CategoryModel category3 = new CategoryModel("3333-4444-5555");
+      result.addCategory(category1);
+      category2.addChildCategory(category3);
+      List<DisplayNameModel> displayNames = new ArrayList<DisplayNameModel>();
+      displayNames.add(new DisplayNameModel("fr", "Mon display nom"));
+      displayNames.add(new DisplayNameModel("en", "My display name"));
+      category2.setDisplayNames(displayNames);
+      result.addCategory(category2);
+      return result;
+   }
+}

Added: server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java
===================================================================
--- server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java	                        (rev 0)
+++ server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UnMarshallerTestCase extends TestCase
+{
+
+   public void testUnmarshall()
+   {
+      // get the XML stream
+      InputStream is;
+      try
+      {
+         is = new FileInputStream("src/test/resources/test.xml");
+         // create unmarshaller
+         Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+         // create an instance of ObjectModelFactory
+         ObjectModelFactory factory = new ResultModelFactory();
+
+         // let the object model factory to create an instance of Book and populate it with data from XML
+         ResultModel result = (ResultModel)unmarshaller.unmarshal(is, factory, null);
+
+         assertEquals(3, result.getCategories().size());
+         
+         assertEquals(2, result.getCategories().get(0).getDisplayNames().size());
+         
+         for (DisplayNameModel dn: result.getCategories().get(0).getDisplayNames() )
+         {
+            System.out.println(dn.getLang() + ":" + dn.getText());
+         }
+         
+         // close the XML stream
+         is.close();
+      }
+      catch (FileNotFoundException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (IOException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+      catch (JBossXBException e)
+      {
+         // FIXME
+         e.printStackTrace();
+      }
+   }
+
+}
+

Added: server/trunk/server-webapp/src/test/resources/test.xml
===================================================================
--- server/trunk/server-webapp/src/test/resources/test.xml	                        (rev 0)
+++ server/trunk/server-webapp/src/test/resources/test.xml	2008-01-20 19:18:42 UTC (rev 202)
@@ -0,0 +1,10 @@
+<result>
+   <category id="1">
+      <displayName lang="fr">Coolos</displayName>
+      <displayName lang="en">Cool</displayName>
+   </category>
+   <category id="2">
+      <category id="4"/>
+   </category>
+   <category id="3"/>
+</result>
\ No newline at end of file




More information about the jboss-svn-commits mailing list