[jboss-svn-commits] JBoss PortletSwap SVN: r211 - in server/trunk: server-service/server-lib/src/main/java/org/jboss/portletswap/jcr and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 23 16:25:18 EST 2008
Author: thomas.heute at jboss.com
Date: 2008-01-23 16:25:18 -0500 (Wed, 23 Jan 2008)
New Revision: 211
Added:
server/trunk/server-service/server-lib/src/test/resources/log4j.properties
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java
Removed:
server/trunk/server-service/server-lib/src/main/resources/log4j.properties
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java
server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/impl/
server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java
Modified:
server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/PortletswapException.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/model/impl/jcr/JCRCategoryImpl.java
server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRFileArtifactImpl.java
server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRLicenseImpl.java
server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java
server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RepositoryException.java
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/RepositoryServiceImpl.java
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/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/DirectoryServiceTestCase.java
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/RepositoryServiceTestCase.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/DirectoryServlet.java
server/trunk/server-webapp/src/main/resources/result.xsd
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
Log:
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/PortletswapException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/PortletswapException.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/PortletswapException.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -28,7 +28,15 @@
*/
public class PortletswapException extends Exception
{
+ public PortletswapException()
+ {
+ }
+ public PortletswapException(Throwable e)
+ {
+ super(e);
+ }
+
/** The serialVersionUID */
private static final long serialVersionUID = -8508224315279934537L;
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/jcr/JCRServiceImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -202,7 +202,8 @@
{
try
{
- Node node = rootNode.addNode(Category.ROOT_CATEGORY_NAME, "ps:category");
+ Node node = rootNode.addNode("ps:category", "ps:category");
+ node.setProperty("ps:name", Category.ROOT_CATEGORY_NAME);
node.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
}
catch (Exception e)
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRCategoryImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRCategoryImpl.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRCategoryImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -33,13 +33,12 @@
import org.jboss.portletswap.jcr.JCRService;
import org.jboss.portletswap.model.Category;
-import org.jboss.portletswap.model.impl.CategoryImpl;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class JCRCategoryImpl extends CategoryImpl
+public class JCRCategoryImpl extends Category
{
private JCRService jcrService;
@@ -51,7 +50,6 @@
try
{
this.setId(node.getUUID());
- this.setName(node.getName());
}
catch (UnsupportedRepositoryOperationException e)
{
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRFileArtifactImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRFileArtifactImpl.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRFileArtifactImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -36,16 +36,15 @@
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portletswap.model.ArtifactType;
+import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.Type;
import org.jboss.portletswap.jcr.JCRService;
-import org.jboss.portletswap.model.FileArtifact;
-import org.jboss.portletswap.model.impl.FileArtifactImpl;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class JCRFileArtifactImpl extends FileArtifactImpl implements FileArtifact
+public class JCRFileArtifactImpl extends FileArtifact
{
private InputStream inputStream;
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRLicenseImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRLicenseImpl.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRLicenseImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -26,13 +26,13 @@
import javax.jcr.RepositoryException;
import org.jboss.portletswap.jcr.JCRService;
-import org.jboss.portletswap.model.impl.LicenseImpl;
+import org.jboss.portletswap.model.License;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class JCRLicenseImpl extends LicenseImpl
+public class JCRLicenseImpl extends License
{
private String id;
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/model/impl/jcr/JCRModuleImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -45,13 +45,13 @@
import org.jboss.portletswap.model.Artifact;
import org.jboss.portletswap.model.Author;
import org.jboss.portletswap.model.Category;
-import org.jboss.portletswap.model.impl.ModuleImpl;
+import org.jboss.portletswap.model.Module;
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class JCRModuleImpl extends ModuleImpl
+public class JCRModuleImpl extends Module
{
private List<Artifact> artifacts = new ArrayList<Artifact>();
Modified: server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RepositoryException.java
===================================================================
--- server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RepositoryException.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/RepositoryException.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -31,6 +31,11 @@
public class RepositoryException extends PortletswapException
{
+ public RepositoryException(Throwable e)
+ {
+ super(e);
+ }
+
/** The serialVersionUID */
private static final long serialVersionUID = 2813107030784559784L;
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -47,8 +47,6 @@
import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.License;
import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.impl.FileArtifactImpl;
-import org.jboss.portletswap.model.impl.LicenseImpl;
import org.jboss.portletswap.model.impl.jcr.JCRCategoryImpl;
import org.jboss.portletswap.model.impl.jcr.JCRModuleImpl;
import org.jboss.portletswap.repository.NotFoundException;
@@ -109,7 +107,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -136,7 +134,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -182,7 +180,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -208,7 +206,8 @@
parentNode = session.getNodeByUUID((String) category.getParent().getId());
}
- Node node = parentNode.addNode(category.getName(), "ps:category");
+ Node node = parentNode.addNode("ps:category", "ps:category");
+ node.setProperty("ps:name", node.getName());
node.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
// Store the displayName
@@ -238,7 +237,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -313,7 +312,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -339,7 +338,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -365,7 +364,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
return null;
}
@@ -380,7 +379,7 @@
session = jcrService.openSession(JCRService.MODULE_WORKSPACE_NAME);
Node rootNode = session.getRootNode();
- rootCategory = new JCRCategoryImpl(jcrService, rootNode.getNode(Category.ROOT_CATEGORY_NAME));
+ rootCategory = new JCRCategoryImpl(jcrService, rootNode.getNode("ps:category"));
}
catch (ItemNotFoundException e)
{
@@ -388,7 +387,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -418,7 +417,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -442,7 +441,7 @@
artifactNode.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
if (artifact.getLicense() != null)
{
- artifactNode.setProperty("ps:license", ((LicenseImpl)artifact.getLicense()).getId());
+ artifactNode.setProperty("ps:license", ((License)artifact.getLicense()).getId());
}
artifactNode.setProperty("ps:type", artifact.getType().name());
@@ -488,7 +487,7 @@
session.save();
- ((FileArtifactImpl)artifact).setId(artifactNode.getUUID());
+ ((FileArtifact)artifact).setId(artifactNode.getUUID());
return artifact;
}
return null;
@@ -499,7 +498,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -525,7 +524,7 @@
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
@@ -551,13 +550,13 @@
session.save();
- ((LicenseImpl)license).setId(licenseNode.getUUID());
+ ((License)license).setId(licenseNode.getUUID());
return license;
}
catch (javax.jcr.RepositoryException e)
{
- throw new RepositoryException();
+ throw new RepositoryException(e);
}
finally
{
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceImpl.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -32,8 +32,6 @@
import org.jboss.portletswap.model.Category;
import org.jboss.portletswap.model.License;
import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.impl.CategoryImpl;
-import org.jboss.portletswap.model.impl.ModuleImpl;
import org.jboss.portletswap.repository.NotFoundException;
import org.jboss.portletswap.repository.RepositoryException;
@@ -44,7 +42,7 @@
public class RepositoryServiceImpl implements RepositoryService
{
- public static final Category ROOT_CATEGORY = new CategoryImpl(Category.ROOT_CATEGORY_NAME, null);
+ public static final Category ROOT_CATEGORY = new Category(Category.ROOT_CATEGORY_NAME);
private JCRServiceImpl jcrService;
@@ -69,7 +67,7 @@
public Module storeModule(Module module) throws RepositoryException
{
- ((ModuleImpl)module).setId(module.getName() + module.getVersion());
+ ((Module)module).setId(module.getName() + module.getVersion());
modules.put(module.getId(), module);
return module;
}
Modified: server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd 2008-01-23 21:25:18 UTC (rev 211)
@@ -6,8 +6,9 @@
[ps:category] > nt:folder, mix:referenceable
- jcr:lastModified (date) mandatory ignore
+ - ps:name
+ ps:description
- + * (ps:category)
+ + ps:category multiple
+ ps:displayName
[ps:localizedString] > nt:base
@@ -26,10 +27,7 @@
- ps:username
- ps:firstname
- ps:lastname
- + ps:description
- + ps:displayName
-
[ps:artifact] > nt:base, mix:referenceable
[ps:fileArtifact] > ps:artifact
@@ -45,7 +43,7 @@
+ ps:author
+ ps:description
+ ps:version mandatory
- + ps:artifact
+ + ps:artifact multiple
[ps:version] > nt:base
- ps:name
Modified: server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/resources/jboss-beans.xml 2008-01-23 21:25:18 UTC (rev 211)
@@ -36,8 +36,10 @@
<property name="jcrService">
<inject bean="JCRService"/>
</property>
+ <!--
<property name="jndiProperties"><inject bean="InitialContextProperties"/></property>
<property name="bindTo">java:/RespositoryService</property>
+ -->
</bean>
<bean name="DirectoryService"
Deleted: server/trunk/server-service/server-lib/src/main/resources/log4j.properties
===================================================================
--- server/trunk/server-service/server-lib/src/main/resources/log4j.properties 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/main/resources/log4j.properties 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,5 +0,0 @@
-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
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/jcr/DirectoryServiceTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -39,8 +39,6 @@
import org.jboss.portletswap.jcr.JCRServiceImpl;
import org.jboss.portletswap.model.Category;
import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.impl.CategoryImpl;
-import org.jboss.portletswap.model.impl.ModuleImpl;
import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
@@ -79,12 +77,12 @@
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- module = new ModuleImpl("Foo", version);
+ module = new Module("Foo", version);
try
{
- category = new CategoryImpl("Foo", repositoryService.getRootCategory());
+ category = new Category("Foo", repositoryService.getRootCategory());
category = repositoryService.storeCategory(category);
}
catch (PortletswapException e)
@@ -182,7 +180,7 @@
@Test
public void testGetModulesForOneCategory() throws PortletswapException
{
- Module module2 = new ModuleImpl("Bar", module.getVersion());
+ Module module2 = new Module("Bar", module.getVersion());
module2 = repositoryService.storeModule(module2);
List<Module> modules = directoryService.getModules(false);
assertEquals(2, modules.size());
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/directory/impl/memory/DirectoryServiceTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -31,7 +31,6 @@
import org.jboss.portletswap.DirectoryService;
import org.jboss.portletswap.PortletswapException;
import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.impl.ModuleImpl;
import org.jboss.portletswap.repository.impl.memory.RepositoryServiceImpl;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -48,11 +47,11 @@
RepositoryServiceImpl repositoryService = new RepositoryServiceImpl();
Version version1 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module1 = new ModuleImpl("Foo", version1);
+ Module module1 = new Module("Foo", version1);
repositoryService.storeModule(module1);
Version version2 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.CR), "");
- Module module2 = new ModuleImpl("Foo", version2);
+ Module module2 = new Module("Foo", version2);
repositoryService.storeModule(module2);
DirectoryService directoryService = new DirectoryServiceImpl();
@@ -62,7 +61,7 @@
assertEquals(2, modules.size());
Version version3 = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.BETA), "");
- Module module3 = new ModuleImpl("Foo", version3);
+ Module module3 = new Module("Foo", version3);
repositoryService.storeModule(module3);
modules = directoryService.getModules(false);
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -48,10 +48,6 @@
import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.License;
import org.jboss.portletswap.model.Module;
-import org.jboss.portletswap.model.impl.CategoryImpl;
-import org.jboss.portletswap.model.impl.FileArtifactImpl;
-import org.jboss.portletswap.model.impl.LicenseImpl;
-import org.jboss.portletswap.model.impl.ModuleImpl;
import org.jboss.portletswap.repository.NotFoundException;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
@@ -142,7 +138,7 @@
public void testRegisterModule()
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Foo", version);
+ Module module = new Module("Foo", version);
assertNull(module.getId());
try
{
@@ -172,7 +168,7 @@
public void testRegisterModuleWithDescription()
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Foo", version);
+ Module module = new Module("Foo", version);
module.setDescription(new LocalizedString("Toto is bo"));
try
{
@@ -190,7 +186,7 @@
public void testAddCategoryToModule() throws Exception
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Foo", version);
+ Module module = new Module("Foo", version);
assertNull(module.getId());
try
{
@@ -203,10 +199,10 @@
Category rootCategory = repositoryService.getRootCategory();
- Category category1 = new CategoryImpl("Foo", rootCategory);
+ Category category1 = new Category("Foo", rootCategory);
category1 = repositoryService.storeCategory(category1);
- Category category2 = new CategoryImpl("Bar", rootCategory);
+ Category category2 = new Category("Bar", rootCategory);
category2 = repositoryService.storeCategory(category2);
List<Category> categories = module.getCategories();
@@ -229,7 +225,7 @@
{
Category rootCategory = repositoryService.getRootCategory();
- Category category1 = new CategoryImpl("Foo", rootCategory);
+ Category category1 = new Category("Foo", rootCategory);
category1 = repositoryService.storeCategory(category1);
Object id = category1.getId();
assertNotNull(id);
@@ -246,12 +242,12 @@
{
Category rootCategory = repositoryService.getRootCategory();
- Category category1 = new CategoryImpl("Bar", rootCategory);
+ Category category1 = new Category("Bar", rootCategory);
category1 = repositoryService.storeCategory(category1);
Object id1 = category1.getId();
assertNotNull(id1);
- Category category2 = new CategoryImpl("Foo", category1);
+ Category category2 = new Category("Foo", category1);
category2 = repositoryService.storeCategory(category2);
Object id2 = category2.getId();
assertNotNull(id2);
@@ -273,7 +269,7 @@
public void testDeleteModule() throws Exception
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Test", version);
+ Module module = new Module("Test", version);
assertNull(module.getId());
module = repositoryService.storeModule(module);
Object id = module.getId();
@@ -299,7 +295,7 @@
public void testPublishModule() throws Exception
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Test", version);
+ Module module = new Module("Test", version);
assertNull(module.getId());
module = repositoryService.storeModule(module);
Object id = module.getId();
@@ -328,15 +324,15 @@
public void testAddArtifact() throws Exception
{
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Test", version);
+ Module module = new Module("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");
+ Artifact artifact = new FileArtifact(Type.JSR168PORTLET, new File("/tmp/test"), is);
+ ((FileArtifact)artifact).setName("Bozo");
- License license = new LicenseImpl("LGPL", "blah");
+ License license = new License("LGPL", "blah");
license = repositoryService.storeLicense(license);
artifact.setLicense(license);
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/memory/RepositoryServiceTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -29,10 +29,9 @@
import org.jboss.portletswap.PortletswapException;
import org.jboss.portletswap.RepositoryService;
import org.jboss.portletswap.model.Artifact;
+import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.Module;
import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.model.impl.FileArtifactImpl;
-import org.jboss.portletswap.model.impl.ModuleImpl;
import org.jboss.unit.api.pojo.annotations.Test;
/**
@@ -46,7 +45,7 @@
{
RepositoryService repositoryService = new RepositoryServiceImpl();
Version version = new Version("", 1, 0, 0, new Qualifier(Qualifier.Prefix.ALPHA), "");
- Module module = new ModuleImpl("Foo", version);
+ Module module = new Module("Foo", version);
repositoryService.storeModule(module);
assertNotNull(module.getId());
@@ -67,8 +66,8 @@
{
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 module = new Module("Foo", version);
+ Artifact artifact = new FileArtifact(Type.JSR168PORTLET, null, null);
module = repositoryService.storeModule(module);
repositoryService.storeArtifact(module, artifact);
}
Copied: server/trunk/server-service/server-lib/src/test/resources/log4j.properties (from rev 204, server/trunk/server-service/server-lib/src/main/resources/log4j.properties)
===================================================================
--- server/trunk/server-service/server-lib/src/test/resources/log4j.properties (rev 0)
+++ server/trunk/server-service/server-lib/src/test/resources/log4j.properties 2008-01-23 21:25:18 UTC (rev 211)
@@ -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
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-import org.jboss.portal.common.i18n.LocalizedString;
-
-/**
- * @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-model/src/main/java/org/jboss/portletswap/model/Artifact.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class 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;
+ }
+
+
+}
+
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,54 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-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-model/src/main/java/org/jboss/portletswap/model/Category.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Category.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+import java.util.ArrayList;
+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 class Category
+{
+
+ public static final String ROOT_CATEGORY_NAME = "org.jboss.portletswap.root_category";
+
+ private Object id;
+
+ private LocalizedString displayName;
+
+ private String name;
+
+ private List<Category> children = new ArrayList<Category>();
+
+ private Category parent;
+
+ public Category()
+ {
+ }
+
+ public Category(String name)
+ {
+ this.name = name;
+ }
+
+ public Category(String name, Category parent)
+ {
+ this.name = name;
+ this.parent = parent;
+ parent.addChild(this);
+ }
+
+ public Category getParent()
+ {
+ return parent;
+ }
+
+ protected void getParent(Category parent)
+ {
+ this.parent = parent;
+ }
+
+ public void addChild(Category category)
+ {
+ children.add(category);
+ }
+
+ public List<Category> getChildren()
+ {
+ return children;
+ }
+
+ 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;
+ }
+}
+
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,40 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.jboss.portletswap.model.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-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/FileArtifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+import java.io.File;
+import java.io.InputStream;
+
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FileArtifact extends Artifact
+{
+
+ private InputStream inputStream;
+
+ private File file;
+
+ protected FileArtifact()
+ {
+
+ }
+
+ public FileArtifact(Type type, File file, InputStream inputStream)
+ {
+ setType(type);
+ this.inputStream = inputStream;
+ this.file = file;
+ }
+
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public ArtifactType getArtifactType()
+ {
+ return ArtifactType.FILE_ARTIFACT_TYPE;
+ }
+
+}
+
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,35 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-/**
- * @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-model/src/main/java/org/jboss/portletswap/model/License.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/License.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class License
+{
+ private String id;
+
+ private String name;
+
+ private String text;
+
+ protected License()
+ {
+
+ }
+
+ public License(String name, String text)
+ {
+ this.name = name;
+ this.text = text;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+
+ }
+
+}
+
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,65 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-import java.util.List;
-
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.Version;
-import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.model.Author;
-import org.jboss.portletswap.model.Artifact;
-
-/**
- * @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-model/src/main/java/org/jboss/portletswap/model/Module.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Module.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.Version;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class 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 Module(String name, Version version)
+ {
+ this.version = version;
+ this.name = name;
+ this.artifacts = new ArrayList<Artifact>();
+ }
+
+ public Module(String name)
+ {
+ this.name = name;
+ this.artifacts = new ArrayList<Artifact>();
+ }
+
+ public Module()
+ {
+ 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 void addCategory(Category category)
+ {
+ categories.add(category);
+ }
+
+ public void addArtifact(Artifact artifact)
+ {
+ artifacts.add(artifact);
+ }
+
+}
+
Deleted: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portletswap.model;
-
-import java.net.URL;
-
-import org.jboss.portletswap.model.Artifact;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public interface ReferencedArtifact extends Artifact
-{
- public URL getUrl();
-}
-
Copied: server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java (from rev 209, server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/impl/ReferencedArtifact.java)
===================================================================
--- server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java (rev 0)
+++ server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/ReferencedArtifact.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portletswap.model;
+
+import java.net.URL;
+
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ReferencedArtifact extends Artifact
+{
+ private URL url;
+
+ public URL getUrl()
+ {
+ return url;
+ }
+}
+
Deleted: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/CategoryModel.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,55 +0,0 @@
-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);
- }
-
-}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/DisplayNameModel.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -1,27 +1,29 @@
package org.jboss.portletswap.metadata;
+import java.util.Locale;
+
public class DisplayNameModel {
- private String lang;
+ private Locale lang;
private String text;
- public DisplayNameModel(String lang, String text)
+ public DisplayNameModel(Locale lang, String text)
{
this.lang = lang;
this.text = text;
}
- public DisplayNameModel(String lang)
+ public DisplayNameModel(Locale lang)
{
this.lang = lang;
}
- public String getLang() {
+ public Locale getLang() {
return lang;
}
- public void setLang(String lang) {
+ public void setLang(Locale lang) {
this.lang = lang;
}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModel.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -25,25 +25,27 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.portletswap.model.Category;
+
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @version $Revision$
*/
public class ResultModel
{
- private List<CategoryModel> categories;
+ private List<Category> categories;
public ResultModel()
{
- categories = new ArrayList<CategoryModel>();
+ categories = new ArrayList<Category>();
}
- public List<CategoryModel> getCategories()
+ public List<Category> getCategories()
{
return categories;
}
- public void addCategory(CategoryModel category)
+ public void addCategory(Category category)
{
categories.add(category);
}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelFactory.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -22,6 +22,14 @@
******************************************************************************/
package org.jboss.portletswap.metadata;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString.Value;
+import org.jboss.portletswap.model.Category;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -52,12 +60,12 @@
Object child = null;
if("category".equals(localName))
{
- child = new CategoryModel(attrs.getValue("id"));
+ child = new Category();
}
return child;
}
- public Object newChild(CategoryModel result,
+ public Object newChild(Category result,
UnmarshallingContext context,
String namespaceURI,
String localName,
@@ -66,7 +74,7 @@
Object child = null;
if("displayName".equals(localName))
{
- child = new DisplayNameModel(attrs.getValue("lang"));
+ child = new DisplayNameModel(new Locale(attrs.getValue("lang")));
}
return child;
}
@@ -80,7 +88,7 @@
/**
* Called when parsing character is complete.
*/
- public void addChild(ResultModel result, CategoryModel category, UnmarshallingContext arg1, String arg2, String arg3)
+ public void addChild(ResultModel result, Category category, UnmarshallingContext arg1, String arg2, String arg3)
{
result.addCategory(category);
}
@@ -88,17 +96,28 @@
/**
* Called when parsing character is complete.
*/
- public void addChild(CategoryModel category, CategoryModel childCategory, UnmarshallingContext arg1, String arg2, String arg3)
+ public void addChild(Category category, Category childCategory, UnmarshallingContext arg1, String arg2, String arg3)
{
- category.addChildCategory(childCategory);
+ category.addChild(childCategory);
}
/**
* Called when parsing character is complete.
*/
- public void addChild(CategoryModel category, DisplayNameModel displayName, UnmarshallingContext arg1, String arg2, String arg3)
+ public void addChild(Category category, DisplayNameModel displayName, UnmarshallingContext arg1, String arg2, String arg3)
{
- category.addDisplayName(displayName);
+ LocalizedString lString = category.getDisplayName();
+ @SuppressWarnings("unchecked")
+ Map<Locale, Value> values = lString.getValues();
+ Map<Locale, String> result = new HashMap<Locale, String>();
+ Iterator<Value> it = values.values().iterator();
+ while (it.hasNext())
+ {
+ Value value = it.next();
+ result.put(value.getLocale(), value.getString());
+ }
+ result.put(displayName.getLang(), displayName.getText());
+ category.setDisplayName(new LocalizedString(result, lString.getDefaultLocale()));
}
}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/metadata/ResultModelProvider.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -23,8 +23,13 @@
package org.jboss.portletswap.metadata;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import org.jboss.portal.common.i18n.LocalizedString.Value;
+import org.jboss.portletswap.model.Category;
import org.jboss.xb.binding.MarshallingContext;
/**
@@ -39,7 +44,7 @@
return (ResultModel)object;
}
- public List<CategoryModel> getChildren(ResultModel result, String namespaceUri, String localName)
+ public List<Category> getChildren(ResultModel result, String namespaceUri, String localName)
{
if ("category".equals(localName))
{
@@ -48,27 +53,40 @@
return null;
}
- public List<Object> getChildren(CategoryModel category, String namespaceUri, String localName)
+ public Object getChildren(Category category, String namespaceUri, String localName)
{
- List<Object> children = new ArrayList<Object>();
if ("category".equals(localName))
{
- children.addAll(category.getChildCategories());
+ List<Category> children = new ArrayList<Category>();
+ children.addAll(category.getChildren());
+ return children;
}
else if ("displayName".equals(localName))
{
- children.addAll(category.getDisplayNames());
+ List<DisplayNameModel> children = new ArrayList<DisplayNameModel>();
+ if (category.getDisplayName() != null)
+ {
+ @SuppressWarnings("unchecked")
+ Map<Locale, Value> map = category.getDisplayName().getValues();
+ Iterator<Value> it = map.values().iterator();
+ while (it.hasNext())
+ {
+ Value value = it.next();
+ children.add(new DisplayNameModel(value.getLocale(), value.getString()));
+ }
+ }
+ return children;
}
- return children;
+ return null;
}
- public String getAttributeValue(CategoryModel category, String namespaceUri, String localName)
+ public String getAttributeValue(Category category, String namespaceUri, String localName)
{
String value = null;
if("id".equals(localName))
{
- value = category.getId();
+ value = category.getId().toString();
}
else
{
@@ -82,7 +100,7 @@
String value = null;
if("lang".equals(localName))
{
- value = displayName.getLang();
+ value = displayName.getLang().toString();
}
else
{
@@ -90,6 +108,10 @@
}
return value;
}
-
+
+ public Object getElementValue(DisplayNameModel displayName, String namespaceUri, String localName)
+ {
+ return displayName.getText();
+ }
}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/java/org/jboss/portletswap/servlet/DirectoryServlet.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -7,38 +7,26 @@
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.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.portal.common.util.Version;
-import org.jboss.portletswap.PortletswapException;
-import org.jboss.portletswap.RepositoryService;
-import org.jboss.portletswap.metadata.DisplayNameModel;
+//import org.jboss.portletswap.RepositoryService;
import org.jboss.portletswap.metadata.ResultModel;
import org.jboss.portletswap.metadata.ResultModelProvider;
import org.jboss.portletswap.model.Artifact;
import org.jboss.portletswap.model.Category;
+import org.jboss.portletswap.model.FileArtifact;
import org.jboss.portletswap.model.Module;
import org.jboss.portletswap.model.Type;
-import org.jboss.portletswap.model.impl.CategoryImpl;
-import org.jboss.portletswap.model.impl.FileArtifactImpl;
-import org.jboss.portletswap.model.impl.ModuleImpl;
-import org.jboss.portletswap.repository.impl.jcr.RepositoryServiceImpl;
+//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;
@@ -50,59 +38,53 @@
*/
private static final long serialVersionUID = 381691756034047451L;
- private RepositoryService repositoryService;
+// private RepositoryService repositoryService;
-// private DirectoryService directoryService;
+// private DirectoryService directoryService;
+ private Category rootCategory;
+
@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();
- }
+// 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 CategoryImpl("foo", rootCategory);
- category1 = repositoryService.storeCategory(category1);
- category2 = new CategoryImpl("bar", rootCategory);
- category2 = repositoryService.storeCategory(category2);
- category3 = new CategoryImpl("child", category2);
- category3.setDisplayName(new LocalizedString("foobar"));
- category3 = repositoryService.storeCategory(category3);
-
- Module module = new ModuleImpl("Toto", new Version("", 1, 0, 0, new Version.Qualifier(Version.Qualifier.Prefix.ALPHA, Version.Qualifier.Suffix.SUFFIX_1), ""));
- module = repositoryService.storeModule(module);
- Artifact artifact = new FileArtifactImpl(Type.JSR168PORTLET, new File("/tmp"), new ByteArrayInputStream(new byte[0]));
- artifact = repositoryService.storeArtifact(module, artifact);
- System.out.println(artifact.getId());
- }
- catch (PortletswapException e)
- {
- e.printStackTrace();
- }
+
+ rootCategory = new Category(Category.ROOT_CATEGORY_NAME);
+ ((Category)rootCategory).setId("0");
+ category1 = new Category("foo", rootCategory);
+ ((Category)category1).setId("1");
+ category2 = new Category("bar", rootCategory);
+ ((Category)category2).setId("2");
+ category3 = new Category("child", category2);
+ ((Category)category3).setId("3");
+ category3.setDisplayName(new LocalizedString("foobar"));
+
+ Module module = new Module("Toto", new Version("", 1, 0, 0, new Version.Qualifier(Version.Qualifier.Prefix.ALPHA, Version.Qualifier.Suffix.SUFFIX_1), ""));
+ Artifact artifact = new FileArtifact(Type.JSR168PORTLET, new File("/tmp"), new ByteArrayInputStream(new byte[0]));
+ module.addArtifact(artifact);
}
@Override
@@ -148,60 +130,10 @@
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 (PortletswapException 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()));
- }
- }
+ ResultModel result = new ResultModel();
+ result.addCategory(rootCategory);
return result;
-
}
-
private void printCategories(Writer writer, ResultModel result)
{
Modified: server/trunk/server-webapp/src/main/resources/result.xsd
===================================================================
--- server/trunk/server-webapp/src/main/resources/result.xsd 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/main/resources/result.xsd 2008-01-23 21:25:18 UTC (rev 211)
@@ -17,11 +17,11 @@
<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"
@@ -33,6 +33,17 @@
</xsd:complexType>
<xsd:complexType name="displayName">
- <xsd:attribute name="lang" type="xsd:string"></xsd:attribute>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="lang" type="xsd:string">
+ </xsd:attribute>
+ </xsd:extension>
+ </xsd:simpleContent>
</xsd:complexType>
+
+
+
+ <xsd:simpleType name="test">
+ <xsd:restriction base="xsd:string"></xsd:restriction>
+ </xsd:simpleType>
</xsd:schema>
\ No newline at end of file
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/MarshallerTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -3,11 +3,14 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portletswap.model.Category;
import org.jboss.xb.binding.ObjectModelProvider;
import org.jboss.xb.binding.XercesXsMarshaller;
import org.xml.sax.SAXException;
@@ -44,23 +47,28 @@
// 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");
+ Category category1 = new Category(Category.ROOT_CATEGORY_NAME);
+ ((Category)category1).setId("id");
+/*
+ Category category2 = new CategoryImpl("2222-3333-4444");
+ Category category3 = new CategoryImpl("3333-4444-5555");
+*/
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);
+/*
+ category2.addChild(category3);
+*/
+ Map<Locale, String> map = new HashMap<Locale, String>();
+ map.put(new Locale("fr"), "Mon display nom");
+ map.put(new Locale("en"), "My display name");
+ category1.setDisplayName(new LocalizedString(map, Locale.ENGLISH));
+/*
result.addCategory(category2);
+*/
return result;
}
}
Modified: 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 2008-01-21 20:04:55 UTC (rev 210)
+++ server/trunk/server-webapp/src/test/java/org/jboss/portletswap/metadata/UnMarshallerTestCase.java 2008-01-23 21:25:18 UTC (rev 211)
@@ -59,13 +59,8 @@
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());
- }
-
+ assertEquals(2, result.getCategories().get(0).getDisplayName().getValues().size());
+
// close the XML stream
is.close();
}
More information about the jboss-svn-commits
mailing list