OSDN Git Service

BUG 2041701: Release notes content/link in SDK Updater schema
authorRaphael <raphael@google.com>
Tue, 11 Aug 2009 20:46:21 +0000 (13:46 -0700)
committerRaphael <raphael@google.com>
Tue, 11 Aug 2009 20:53:16 +0000 (13:53 -0700)
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd
tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml

index 8d19c0f..5afe73c 100755 (executable)
@@ -42,16 +42,20 @@ import java.util.Properties;
  */\r
 public abstract class Package implements IDescription {\r
 \r
-    private static final String PROP_REVISION    = "Pkg.Revision";     //$NON-NLS-1$\r
-    private static final String PROP_LICENSE     = "Pkg.License";      //$NON-NLS-1$\r
-    private static final String PROP_DESC        = "Pkg.Desc";         //$NON-NLS-1$\r
-    private static final String PROP_DESC_URL    = "Pkg.DescUrl";      //$NON-NLS-1$\r
-    private static final String PROP_SOURCE_URL  = "Pkg.SourceUrl";    //$NON-NLS-1$\r
-    private static final String PROP_USER_SOURCE = "Pkg.UserSrc";      //$NON-NLS-1$\r
+    private static final String PROP_REVISION     = "Pkg.Revision";     //$NON-NLS-1$\r
+    private static final String PROP_LICENSE      = "Pkg.License";      //$NON-NLS-1$\r
+    private static final String PROP_DESC         = "Pkg.Desc";         //$NON-NLS-1$\r
+    private static final String PROP_DESC_URL     = "Pkg.DescUrl";      //$NON-NLS-1$\r
+    private static final String PROP_RELEASE_NOTE = "Pkg.RelNote";      //$NON-NLS-1$\r
+    private static final String PROP_RELEASE_URL  = "Pkg.RelNoteUrl";   //$NON-NLS-1$\r
+    private static final String PROP_SOURCE_URL   = "Pkg.SourceUrl";    //$NON-NLS-1$\r
+    private static final String PROP_USER_SOURCE  = "Pkg.UserSrc";      //$NON-NLS-1$\r
     private final int mRevision;\r
     private final String mLicense;\r
     private final String mDescription;\r
     private final String mDescUrl;\r
+    private final String mReleaseNote;\r
+    private final String mReleaseUrl;\r
     private final Archive[] mArchives;\r
     private final RepoSource mSource;\r
 \r
@@ -80,6 +84,8 @@ public abstract class Package implements IDescription {
         mRevision    = XmlParserUtils.getXmlInt   (packageNode, SdkRepository.NODE_REVISION, 0);\r
         mDescription = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_DESCRIPTION);\r
         mDescUrl     = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_DESC_URL);\r
+        mReleaseNote = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_RELEASE_NOTE);\r
+        mReleaseUrl  = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_RELEASE_URL);\r
 \r
         mLicense  = parseLicense(packageNode, licenses);\r
         mArchives = parseArchives(XmlParserUtils.getFirstChild(\r
@@ -104,10 +110,19 @@ public abstract class Package implements IDescription {
             Arch archiveArch,\r
             String archiveOsPath) {\r
 \r
+        if (description == null) {\r
+            description = "";\r
+        }\r
+        if (descUrl == null) {\r
+            descUrl = "";\r
+        }\r
+\r
         mRevision = Integer.parseInt(getProperty(props, PROP_REVISION, Integer.toString(revision)));\r
-        mLicense     = getProperty(props, PROP_LICENSE,  license);\r
-        mDescription = getProperty(props, PROP_DESC,     description);\r
-        mDescUrl     = getProperty(props, PROP_DESC_URL, descUrl);\r
+        mLicense     = getProperty(props, PROP_LICENSE,      license);\r
+        mDescription = getProperty(props, PROP_DESC,         description);\r
+        mDescUrl     = getProperty(props, PROP_DESC_URL,     descUrl);\r
+        mReleaseNote = getProperty(props, PROP_RELEASE_NOTE, "");\r
+        mReleaseUrl  = getProperty(props, PROP_RELEASE_URL,  "");\r
 \r
         // If source is null and we can find a source URL in the properties, generate\r
         // a dummy source just to store the URL. This allows us to easily remember where\r
@@ -145,16 +160,24 @@ public abstract class Package implements IDescription {
      */\r
     void saveProperties(Properties props) {\r
         props.setProperty(PROP_REVISION, Integer.toString(mRevision));\r
-        if (mLicense != null) {\r
+        if (mLicense != null && mLicense.length() > 0) {\r
             props.setProperty(PROP_LICENSE, mLicense);\r
         }\r
-        if (mDescription != null) {\r
+\r
+        if (mDescription != null && mDescription.length() > 0) {\r
             props.setProperty(PROP_DESC, mDescription);\r
         }\r
-        if (mDescUrl != null) {\r
+        if (mDescUrl != null && mDescUrl.length() > 0) {\r
             props.setProperty(PROP_DESC_URL, mDescUrl);\r
         }\r
 \r
+        if (mReleaseNote != null && mReleaseNote.length() > 0) {\r
+            props.setProperty(PROP_RELEASE_NOTE, mReleaseNote);\r
+        }\r
+        if (mReleaseUrl != null && mReleaseUrl.length() > 0) {\r
+            props.setProperty(PROP_RELEASE_URL, mReleaseUrl);\r
+        }\r
+\r
         if (mSource != null) {\r
             props.setProperty(PROP_SOURCE_URL,  mSource.getUrl());\r
             props.setProperty(PROP_USER_SOURCE, Boolean.toString(mSource.isUserSource()));\r
@@ -259,6 +282,22 @@ public abstract class Package implements IDescription {
     }\r
 \r
     /**\r
+     * Returns the optional release note for all packages (platform, add-on, tool, doc) or\r
+     * for a lib. Can be empty but not null.\r
+     */\r
+    public String getReleaseNote() {\r
+        return mReleaseNote;\r
+    }\r
+\r
+    /**\r
+     * Returns the optional release note URL for all packages (platform, add-on, tool, doc).\r
+     * Can be empty but not null.\r
+     */\r
+    public String getReleaseNoteUrl() {\r
+        return mReleaseUrl;\r
+    }\r
+\r
+    /**\r
      * Returns the archives defined in this package.\r
      * Can be an empty array but not null.\r
      */\r
@@ -291,7 +330,31 @@ public abstract class Package implements IDescription {
      * Can be empty but not null.\r
      */\r
     public String getLongDescription() {\r
-        return String.format("%1$s\nRevision %2$d", getDescription(), getRevision());\r
+        StringBuilder sb = new StringBuilder();\r
+\r
+        String s = getDescription();\r
+        if (s != null) {\r
+            sb.append(s);\r
+        }\r
+\r
+        sb.append(String.format("\nRevision %1$d", getRevision()));\r
+\r
+        s = getDescUrl();\r
+        if (s != null && s.length() > 0) {\r
+            sb.append(String.format("\n\nMore information at %1$s", s));\r
+        }\r
+\r
+        s = getReleaseNote();\r
+        if (s != null && s.length() > 0) {\r
+            sb.append("\n\nRelease note:\n").append(s);\r
+        }\r
+\r
+        s = getReleaseNoteUrl();\r
+        if (s != null && s.length() > 0) {\r
+            sb.append("\nRelease note URL: ").append(s);\r
+        }\r
+\r
+        return sb.toString();\r
     }\r
 \r
     /**\r
index 88d18db..4b12d59 100755 (executable)
@@ -53,11 +53,15 @@ public class SdkRepository {
     /** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */\r
     public static final String NODE_USES_LICENSE = "uses-license";              //$NON-NLS-1$\r
     /** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */\r
-    public static final String NODE_REVISION    = "revision";                   //$NON-NLS-1$\r
+    public static final String NODE_REVISION     = "revision";                  //$NON-NLS-1$\r
     /** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */\r
-    public static final String NODE_DESCRIPTION = "description";                //$NON-NLS-1$\r
+    public static final String NODE_DESCRIPTION  = "description";               //$NON-NLS-1$\r
     /** The optional description URL for all packages (platform, add-on, tool, doc). */\r
-    public static final String NODE_DESC_URL    = "desc-url";                   //$NON-NLS-1$\r
+    public static final String NODE_DESC_URL     = "desc-url";                  //$NON-NLS-1$\r
+    /** The optional release note for all packages (platform, add-on, tool, doc). */\r
+    public static final String NODE_RELEASE_NOTE = "release-note";              //$NON-NLS-1$\r
+    /** The optional release note URL for all packages (platform, add-on, tool, doc). */\r
+    public static final String NODE_RELEASE_URL  = "release-url";               //$NON-NLS-1$\r
 \r
     /** The version, a string, for platform packages. */\r
     public static final String NODE_VERSION   = "version";                      //$NON-NLS-1$\r
index a697c83..7ca0892 100755 (executable)
                             <xsd:element name="description"  type="xsd:string"      minOccurs="0" />
                             <!-- The optional description URL of this package -->
                             <xsd:element name="desc-url"     type="xsd:token"       minOccurs="0" />
+                            <!-- The optional release note for this package. -->
+                            <xsd:element name="release-note" type="xsd:string"      minOccurs="0" />
+                            <!-- The optional release note URL of this package -->
+                            <xsd:element name="release-url"  type="xsd:token"       minOccurs="0" />
                             <!-- A list of file archives for this package. -->
                             <xsd:element name="archives"     type="sdk:archivesType" />
                         </xsd:all>
                             <xsd:element name="description"  type="xsd:string"      minOccurs="0" />
                             <!-- The optional description URL of this package -->
                             <xsd:element name="desc-url"     type="xsd:token"       minOccurs="0" />
+                            <!-- The optional release note for this package. -->
+                            <xsd:element name="release-note" type="xsd:string"      minOccurs="0" />
+                            <!-- The optional release note URL of this package -->
+                            <xsd:element name="release-url"  type="xsd:token"       minOccurs="0" />
                             <!-- A list of file archives for this package. -->
                             <xsd:element name="archives"     type="sdk:archivesType" />
 
                             <xsd:element name="description"  type="xsd:string"      minOccurs="0" />
                             <!-- The optional description URL of this package -->
                             <xsd:element name="desc-url"     type="xsd:token"       minOccurs="0" />
+                            <!-- The optional release note for this package. -->
+                            <xsd:element name="release-note" type="xsd:string"      minOccurs="0" />
+                            <!-- The optional release note URL of this package -->
+                            <xsd:element name="release-url"  type="xsd:token"       minOccurs="0" />
                             <!-- A list of file archives for this package. -->
                             <xsd:element name="archives"     type="sdk:archivesType" />
                         </xsd:all>
                             <xsd:element name="description"  type="xsd:string"      minOccurs="0" />
                             <!-- The optional description URL of this package -->
                             <xsd:element name="desc-url"     type="xsd:token"       minOccurs="0" />
+                            <!-- The optional release note for this package. -->
+                            <xsd:element name="release-note" type="xsd:string"      minOccurs="0" />
+                            <!-- The optional release note URL of this package -->
+                            <xsd:element name="release-url"  type="xsd:token"       minOccurs="0" />
                             <!-- A list of file archives for this package. -->
                             <xsd:element name="archives"     type="sdk:archivesType" />
                         </xsd:all>
                             <xsd:element name="description"  type="xsd:string"      minOccurs="0" />
                             <!-- The optional description URL of this package -->
                             <xsd:element name="desc-url"     type="xsd:token"       minOccurs="0" />
+                            <!-- The optional release note for this package. -->
+                            <xsd:element name="release-note" type="xsd:string"      minOccurs="0" />
+                            <!-- The optional release note URL of this package -->
+                            <xsd:element name="release-url"  type="xsd:token"       minOccurs="0" />
                             <!-- A list of file archives for this package. -->
                             <xsd:element name="archives"     type="sdk:archivesType" />
                         </xsd:all>
index 7340549..20b8571 100755 (executable)
         <sdk:uses-license ref="license1" />\r
         <sdk:description>Some optional description</sdk:description>\r
         <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url>\r
+        <sdk:release-note>This is an optional release note\r
+            for this package. It's a free multi-line text.\r
+        </sdk:release-note>\r
+        <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url>\r
         <!-- The archives node is mandatory and it cannot be empty. -->\r
         <sdk:archives>\r
             <sdk:archive os="any">\r