[jboss-svn-commits] JBoss PortletSwap SVN: r222 - in src/server/trunk/server-service: server-lib/src/main/resources and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 25 09:07:01 EST 2008


Author: thomas.heute at jboss.com
Date: 2008-01-25 09:07:01 -0500 (Fri, 25 Jan 2008)
New Revision: 222

Added:
   src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Version.java
Modified:
   src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java
   src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
   src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
   src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
Log:
Use a fork of Version

Modified: src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java	2008-01-25 13:57:39 UTC (rev 221)
+++ src/server/trunk/server-service/server-lib/src/main/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceImpl.java	2008-01-25 14:07:01 UTC (rev 222)
@@ -37,7 +37,6 @@
 
 import org.apache.jackrabbit.value.DateValue;
 import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.Version;
 import org.jboss.portletswap.model.ArtifactType;
 import org.jboss.portletswap.PortletswapException;
 import org.jboss.portletswap.RepositoryService;
@@ -48,6 +47,7 @@
 import org.jboss.portletswap.model.FileArtifact;
 import org.jboss.portletswap.model.License;
 import org.jboss.portletswap.model.Module;
+import org.jboss.portletswap.model.Version;
 import org.jboss.portletswap.model.impl.jcr.JCRCategoryImpl;
 import org.jboss.portletswap.model.impl.jcr.JCRModuleImpl;
 import org.jboss.portletswap.repository.NotFoundException;
@@ -447,13 +447,11 @@
             Version version = artifact.getVersion();
             Node versionNode = artifactNode.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

Modified: src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd
===================================================================
--- src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd	2008-01-25 13:57:39 UTC (rev 221)
+++ src/server/trunk/server-service/server-lib/src/main/resources/customNodes.cnd	2008-01-25 14:07:01 UTC (rev 222)
@@ -53,11 +53,9 @@
  - ps:author (reference) multiple
 
 [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

Modified: src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java
===================================================================
--- src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java	2008-01-25 13:57:39 UTC (rev 221)
+++ src/server/trunk/server-service/server-lib/src/test/java/org/jboss/portletswap/repository/impl/jcr/RepositoryServiceTestCase.java	2008-01-25 14:07:01 UTC (rev 222)
@@ -37,7 +37,6 @@
 import javax.jcr.Session;
 
 import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.Version;
 import org.jboss.portletswap.PortletswapException;
 import org.jboss.portletswap.jcr.JCRService;
 import org.jboss.portletswap.jcr.JCRServiceImpl;
@@ -47,6 +46,7 @@
 import org.jboss.portletswap.model.License;
 import org.jboss.portletswap.model.Module;
 import org.jboss.portletswap.model.Type;
+import org.jboss.portletswap.model.Version;
 import org.jboss.portletswap.repository.NotFoundException;
 import org.jboss.unit.api.pojo.annotations.Create;
 import org.jboss.unit.api.pojo.annotations.Destroy;
@@ -320,7 +320,7 @@
       assertNull(module.getId());
       Module retModule = repositoryService.storeModule(module);
 
-      Version version = new Version("", 1, 0, 0, new Version.Qualifier(Version.Qualifier.Prefix.GA), "");
+      Version version = new Version(1, 0, 0, new Version.Qualifier(Version.Qualifier.Prefix.GA));
       
       InputStream is = new FileInputStream("/tmp/test");
       Artifact artifact = new FileArtifact(Type.JSR168PORTLET, new File("/tmp/test"), is);

Modified: src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java
===================================================================
--- src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java	2008-01-25 13:57:39 UTC (rev 221)
+++ src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Artifact.java	2008-01-25 14:07:01 UTC (rev 222)
@@ -23,7 +23,6 @@
 package org.jboss.portletswap.model;
 
 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>

Added: src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Version.java
===================================================================
--- src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Version.java	                        (rev 0)
+++ src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Version.java	2008-01-25 14:07:01 UTC (rev 222)
@@ -0,0 +1,284 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * Version class conforming to JBoss Product Version Conventions post 2006-03-01. See
+ * http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 7165 $
+ */
+public class Version implements Comparable<Version>
+{
+
+   /** . */
+   private final String toString;
+
+   /** . */
+   private final int major;
+
+   /** . */
+   private final int minor;
+
+   /** . */
+   private final int patch;
+
+   /** . */
+   private final Qualifier qualifier;
+
+   public Version(int major, int minor, int patch, Qualifier qualifier)
+   {
+      if (major < 0)
+      {
+         throw new IllegalArgumentException("Major cannot be negative");
+      }
+      if (minor < 0)
+      {
+         throw new IllegalArgumentException("Minor cannot be negative");
+      }
+      if (patch < 0)
+      {
+         throw new IllegalArgumentException("Patch cannot be negative");
+      }
+      if (qualifier == null)
+      {
+         throw new IllegalArgumentException("Qualifier cannot be null");
+      }
+      this.major = major;
+      this.minor = minor;
+      this.patch = patch;
+      this.qualifier = qualifier;
+      this.toString = Format.JBOSS_PRODUCT_CONVENTION.toString(this);
+   }
+
+   /** Return the major. */
+   public int getMajor()
+   {
+      return major;
+   }
+
+   /** Return the minor. */
+   public int getMinor()
+   {
+      return minor;
+   }
+
+   /** Return the patch. */
+   public int getPatch()
+   {
+      return patch;
+   }
+
+   /** Return the intermediate major. */
+   public Qualifier getQualifier()
+   {
+      return qualifier;
+   }
+
+   public String toString()
+   {
+      return toString;
+   }
+
+   public String toString(Format format) throws IllegalArgumentException
+   {
+      if (format == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      return format.toString(this);
+   }
+
+   /** Type safe enum for intermediate major. */
+   public static class Qualifier
+   {
+
+      public enum Prefix
+      {
+
+         SNAPSHOT("SNAPSHOT", false, "Snapshot"),
+         ALPHA("ALPHA", true, "Alpha"),
+         BETA("BETA", true, "Beta"),
+         CR("CR", true, "Candidate for release"),
+         GA("GA", false, "General Availability"),
+         SP("SP", true, "Service pack");
+
+         /** . */
+         private final String name;
+
+         /** . */
+         private final String description;
+
+         /** . */
+         private final boolean suffixable;
+
+         private Prefix(String name, boolean suffixable, String description)
+         {
+            this.name = name;
+            this.suffixable = suffixable;
+            this.description = description;
+         }
+
+         public String getName()
+         {
+            return name;
+         }
+
+         public boolean isSuffixable()
+         {
+            return suffixable;
+         }
+
+         public String getDescription()
+         {
+            return description;
+         }
+
+         public String toString()
+         {
+            return name;
+         }
+      }
+
+      public enum Suffix
+      {
+
+         EMPTY(""),
+         SUFFIX_1("1"),
+         SUFFIX_2("2"),
+         SUFFIX_3("3"),
+         SUFFIX_4("4"),
+         SUFFIX_5("5"),
+         SUFFIX_6("6");
+
+         /** . */
+         private final String value;
+
+         private Suffix(String value)
+         {
+            this.value = value;
+         }
+
+         public String toString()
+         {
+            return value;
+         }
+      }
+
+      /** . */
+      private final String toString;
+
+      /** . */
+      private final Prefix prefix;
+
+      /** . */
+      private final Suffix suffix;
+
+      public Qualifier(Prefix prefix)
+      {
+         this(prefix, Suffix.EMPTY);
+      }
+
+      public Qualifier(Prefix prefix, Suffix suffix)
+      {
+         if (prefix == null)
+         {
+            throw new IllegalArgumentException("No prefix provided");
+         }
+         if (suffix == null)
+         {
+            suffix = Suffix.EMPTY;
+         }
+         if (prefix.isSuffixable() == false && suffix.value.length() > 0)
+         {
+            throw new IllegalArgumentException("The prefix " + prefix + " is not suffixable");
+         }
+         this.toString = "" + prefix + suffix;
+         this.prefix = prefix;
+         this.suffix = suffix;
+      }
+
+      public Prefix getPrefix()
+      {
+         return prefix;
+      }
+
+      public Suffix getSuffix()
+      {
+         return suffix;
+      }
+
+      public String toString()
+      {
+         return toString;
+      }
+   }
+
+   public interface Format
+   {
+
+      /**
+       * Implement formatting as defined <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning">here</a>
+       */
+      Format JBOSS_PRODUCT_CONVENTION = new Format()
+      {
+         public String toString(Version version)
+         {
+            StringBuffer buffer = new StringBuffer()
+               .append(version.getMajor()).append('.')
+               .append(version.getMinor()).append('.')
+               .append(version.getPatch()).append('-')
+               .append(version.getQualifier());
+            return buffer.toString();
+         }
+      };
+
+      String toString(Version version);
+   }
+
+   public int compareTo(Version other)
+   {
+      if (major != other.major)
+      {
+         return major - other.major;
+      }
+      if (minor != other.minor)
+      {
+         return minor - other.minor;
+      }
+      if (patch != other.patch)
+      {
+         return patch - other.patch;
+      }
+      if (qualifier.prefix != other.qualifier.prefix)
+      {
+         return qualifier.prefix.compareTo(other.qualifier.prefix);
+      }
+      if (qualifier.suffix != other.qualifier.suffix)
+      {
+         return qualifier.suffix.compareTo(other.qualifier.suffix);
+      }
+      return 0;
+   }
+}


Property changes on: src/server/trunk/server-service/server-model/src/main/java/org/jboss/portletswap/model/Version.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-svn-commits mailing list