felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r629378 - in /felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository: ObrCommandImpl.java ResourceImpl.java
Date Wed, 20 Feb 2008 07:18:41 GMT
Author: mcculls
Date: Tue Feb 19 23:18:38 2008
New Revision: 629378

URL: http://svn.apache.org/viewvc?rev=629378&view=rev
Log:
FELIX-498: add 'obr javadoc' command to bundlerepository

Modified:
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ObrCommandImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ObrCommandImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ObrCommandImpl.java?rev=629378&r1=629377&r2=629378&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ObrCommandImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ObrCommandImpl.java
Tue Feb 19 23:18:38 2008
@@ -38,6 +38,7 @@
     private static final String DEPLOY_CMD = "deploy";
     private static final String START_CMD = "start";
     private static final String SOURCE_CMD = "source";
+    private static final String JAVADOC_CMD = "javadoc";
 
     private static final String EXTRACT_SWITCH = "-x";
 
@@ -113,6 +114,10 @@
                 {
                     source(commandLine, command, out, err);
                 }
+                else if (command.equals(JAVADOC_CMD))
+                {
+                    javadoc(commandLine, command, out, err);
+                }
                 else
                 {
                     err.println("Unknown command: " + command);
@@ -419,6 +424,37 @@
         }
     }
 
+    private void javadoc(
+        String commandLine, String command, PrintStream out, PrintStream err)
+        throws IOException, InvalidSyntaxException
+    {
+        // Parse the command line to get all local targets to update.
+        ParsedCommand pc = parseSource(commandLine);
+        for (int i = 0; i < pc.getTargetCount(); i++)
+        {
+            Resource resource = selectNewestVersion(
+                searchRepository(pc.getTargetId(i), pc.getTargetVersion(i)));
+            if (resource == null)
+            {
+                err.println("Unknown bundle and/or version: "
+                    + pc.getTargetId(i));
+            }
+            else
+            {
+                URL docURL = (URL) resource.getProperties().get("javadoc");
+                if (docURL != null)
+                {
+                    FileUtil.downloadSource(
+                        out, err, docURL, pc.getDirectory(), pc.isExtract());
+                }
+                else
+                {
+                    err.println("Missing javadoc URL: " + pc.getTargetId(i));
+                }
+            }
+        }
+    }
+
     private Resource[] searchRepository(String targetId, String targetVersion)
     {
         // Try to see if the targetId is a bundle ID.
@@ -978,6 +1014,27 @@
                 "specified local directory.");
             out.println("");
         }
+        else if (command.equals(JAVADOC_CMD))
+        {
+            out.println("");
+            out.println("obr " + JAVADOC_CMD
+                + " [" + EXTRACT_SWITCH
+                + "] <local-dir> <bundle-name>[;<version>] ...");
+            out.println("");
+            out.println(
+                "This command retrieves the javadoc archives of the specified\n" +
+                "bundles and saves them to the specified local directory; use\n" +
+                "the \"" + EXTRACT_SWITCH + "\" switch to automatically extract the javadoc
archives.\n" +
+                "If a bundle name contains spaces, then it must be surrounded\n" +
+                "by quotes. It is also possible to specify a precise version if\n" +    
           "more than one version exists, such as:\n" +
+                "\n" +
+                "    obr javadoc /home/rickhall/tmp \"Bundle Repository\";1.0.0\n" +
+                "\n" +
+                "The above example retrieves the javadoc archive of version \"1.0.0\"\n"
+
+                "of the bundle named \"Bundle Repository\" and saves it to the\n" +
+                "specified local directory.");
+            out.println("");
+        }
         else
         {
             out.println("obr " + HELP_CMD
@@ -987,7 +1044,7 @@
                 + " | " + LIST_CMD
                 + " | " + INFO_CMD
                 + " | " + DEPLOY_CMD + " | " + START_CMD
-                + " | " + SOURCE_CMD + "]");
+                + " | " + SOURCE_CMD + " | " + JAVADOC_CMD + "]");
             out.println("obr " + ADDURL_CMD + " [<repository-file-url> ...]");
             out.println("obr " + REMOVEURL_CMD + " [<repository-file-url> ...]");
             out.println("obr " + LISTURL_CMD);
@@ -999,6 +1056,9 @@
             out.println("obr " + START_CMD
                 + " <bundle-name>|<bundle-symbolic-name>|<bundle-id>[;<version>]
...");
             out.println("obr " + SOURCE_CMD
+                + " [" + EXTRACT_SWITCH
+                + "] <local-dir> <bundle-name>[;<version>] ...");
+            out.println("obr " + JAVADOC_CMD
                 + " [" + EXTRACT_SWITCH
                 + "] <local-dir> <bundle-name>[;<version>] ...");
         }

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java?rev=629378&r1=629377&r2=629378&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/ResourceImpl.java
Tue Feb 19 23:18:38 2008
@@ -39,6 +39,7 @@
     private String m_docURI = null;
     private String m_licenseURI = null;
     private String m_sourceURI = null;
+    private String m_javadocURI = null;
     private boolean m_converted = false;
 
     public ResourceImpl()
@@ -178,6 +179,10 @@
         {
             m_sourceURI = (String) value;
         }
+        else if (key.equals("javadoc"))
+        {
+            m_javadocURI = (String) value;
+        }
         else if (key.equals(URI))
         {
             m_resourceURI = (String) value;
@@ -221,6 +226,10 @@
                 if (m_sourceURI != null)
                 {
                     m_map.put(SOURCE_URL, new URL(base, m_sourceURI));
+                }
+                if (m_javadocURI != null)
+                {
+                    m_map.put("javadoc", new URL(base, m_javadocURI));
                 }
                 m_converted = true;
             }



Mime
View raw message