felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r380806 [2/2] - in /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix: framework/ framework/cache/ framework/searchpolicy/ framework/util/ shell/impl/
Date Fri, 24 Feb 2006 20:09:30 GMT
Added: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java?rev=380806&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
(added)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
Fri Feb 24 12:09:28 2006
@@ -0,0 +1,443 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.felix.framework.cache;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.PrivilegedActionException;
+import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.apache.felix.framework.Logger;
+import org.apache.felix.framework.util.*;
+import org.apache.felix.moduleloader.*;
+
+/**
+ * <p>
+ * This class implements a bundle archive revision for a standard bundle
+ * JAR file. The specified location is the URL of the JAR file. By default,
+ * the associated JAR file is copied into the revision's directory on the
+ * file system, but it is possible to mark the JAR as 'by reference', which
+ * will result in the bundle JAR be used 'in place' and not being copied. In
+ * either case, some of the contents may be extracted into the revision
+ * directory, such as embedded JAR files and native libraries.
+ * </p>
+**/
+class JarRevision extends BundleRevision
+{
+    private static final transient String BUNDLE_JAR_FILE = "bundle.jar";
+    private static final transient String EMBEDDED_DIRECTORY = "embedded";
+    private static final transient String LIBRARY_DIRECTORY = "lib";
+
+    private File m_bundleFile = null;
+    private Map m_header = null;
+
+    public JarRevision(
+        Logger logger, File revisionRootDir, String location, boolean byReference)    
+        throws Exception
+    {
+        this(logger, revisionRootDir, location, byReference, null);
+    }
+
+    public JarRevision(
+        Logger logger, File revisionRootDir, String location,
+        boolean byReference, InputStream is)    
+        throws Exception
+    {
+        super(logger, revisionRootDir, location);
+
+        if (byReference)
+        {
+            m_bundleFile = new File(location.substring(
+                location.indexOf(DefaultBundleArchive.FILE_PROTOCOL)
+                    + DefaultBundleArchive.FILE_PROTOCOL.length()));
+        }
+        else
+        {
+            m_bundleFile = new File(getRevisionRootDir(), BUNDLE_JAR_FILE);
+        }
+
+        // Save and process the bundle JAR.
+        initialize(byReference, is);
+    }
+
+    public synchronized Map getManifestHeader() throws Exception
+    {
+        if (m_header != null)
+        {
+            return m_header;
+        }
+
+        // Get the embedded resource.
+        JarFile jarFile = null;
+
+        try
+        {
+            // Open bundle JAR file.
+            jarFile = DefaultBundleCache.getSecureAction().openJAR(m_bundleFile);
+            // Error if no jar file.
+            if (jarFile == null)
+            {
+                throw new IOException("No JAR file found.");
+            }
+            // Get manifest.
+            Manifest mf = jarFile.getManifest();
+            // Create a case insensitive map of manifest attributes.
+            m_header = new StringMap(mf.getMainAttributes(), false);
+            return m_header;
+
+        }
+        finally
+        {
+            if (jarFile != null) jarFile.close();
+        }
+    }
+
+    public IContent getContent() throws Exception
+    {
+        return new JarContent(m_bundleFile);
+    }
+
+    public synchronized IContent[] getContentPath() throws Exception
+    {
+        // Creating the content path entails examining the bundle's
+        // class path to determine whether the bundle JAR file itself
+        // is on the bundle's class path and then creating content
+        // objects for everything on the class path.
+
+        File embedDir = new File(getRevisionRootDir(), EMBEDDED_DIRECTORY);
+
+        // Get the bundle's manifest header.
+        Map map = getManifestHeader();
+
+        // Find class path meta-data.
+        String classPath = (map == null)
+            ? null : (String) map.get(FelixConstants.BUNDLE_CLASSPATH);
+
+        // Parse the class path into strings.
+        String[] classPathStrings = Util.parseDelimitedString(
+            classPath, FelixConstants.CLASS_PATH_SEPARATOR);
+
+        if (classPathStrings == null)
+        {
+            classPathStrings = new String[0];
+        }
+
+        // Create the bundles class path.
+        JarFile bundleJar = null;
+        try
+        {
+            bundleJar = DefaultBundleCache.getSecureAction().openJAR(m_bundleFile);
+            IContent self = new JarContent(m_bundleFile);
+            IContent[] contentPath = new IContent[classPathStrings.length];
+            for (int i = 0; i < classPathStrings.length; i++)
+            {
+                if (classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
+                {
+                    contentPath[i] = self;
+                }
+                else
+                {
+                    // Determine if the class path entry is a file or directory
+                    // in the bundle JAR file.
+                    ZipEntry entry = bundleJar.getEntry(classPathStrings[i]);
+                    if ((entry != null) && entry.isDirectory())
+                    {
+                        contentPath[i] = new ContentDirectoryContent(self, classPathStrings[i]);
+                    }
+                    else
+                    {
+                        contentPath[i] = new JarContent(new File(embedDir, classPathStrings[i]));
+                    }
+                }
+            }
+    
+            // If there is nothing on the class path, then include
+            // "." by default, as per the spec.
+            if (contentPath.length == 0)
+            {
+                contentPath = new IContent[] { self };
+            }
+
+            return contentPath;
+        }
+        finally
+        {
+            if (bundleJar != null) bundleJar.close();
+        }
+    }
+
+// TODO: This will need to consider security.
+    public synchronized String findLibrary(String libName) throws Exception
+    {
+        // Get bundle lib directory.
+        File libDir = new File(getRevisionRootDir(), LIBRARY_DIRECTORY);
+        // Get lib file.
+        File libFile = new File(libDir, File.separatorChar + libName);
+        // Make sure that the library's parent directory exists;
+        // it may be in a sub-directory.
+        libDir = libFile.getParentFile();
+        if (!DefaultBundleCache.getSecureAction().fileExists(libDir))
+        {
+            if (!DefaultBundleCache.getSecureAction().mkdirs(libDir))
+            {
+                throw new IOException("Unable to create library directory.");
+            }
+        }
+        // Extract the library from the JAR file if it does not
+        // already exist.
+        if (!DefaultBundleCache.getSecureAction().fileExists(libFile))
+        {
+            JarFile bundleJar = null;
+            InputStream is = null;
+
+            try
+            {
+                bundleJar = DefaultBundleCache.getSecureAction().openJAR(m_bundleFile);
+                ZipEntry ze = bundleJar.getEntry(libName);
+                if (ze == null)
+                {
+                    throw new IOException("No JAR entry: " + libName);
+                }
+                is = new BufferedInputStream(
+                    bundleJar.getInputStream(ze), DefaultBundleCache.BUFSIZE);
+                if (is == null)
+                {
+                    throw new IOException("No input stream: " + libName);
+                }
+
+                // Create the file.
+                DefaultBundleCache.copyStreamToFile(is, libFile);
+            }
+            finally
+            {
+                if (bundleJar != null) bundleJar.close();
+                if (is != null) is.close();
+            }
+        }
+
+        return libFile.toString();
+    }
+
+    public void dispose() throws Exception
+    {
+        // Nothing to dispose of, since we don't maintain any state outside
+        // of the revision directory, which will be automatically deleted
+        // by the parent bundle archive.
+    }
+
+    //
+    // Private methods.
+    //
+
+    private void initialize(boolean byReference, InputStream is)
+        throws Exception
+    {
+        try
+        {
+            // If the revision directory exists, then we don't
+            // need to initialize since it has already been done.
+            if (DefaultBundleCache.getSecureAction().fileExists(getRevisionRootDir()))
+            {
+                return;
+            }
+
+            // Create revision directory, if it does not exist.
+            if (!DefaultBundleCache.getSecureAction().mkdir(getRevisionRootDir()))
+            {
+                getLogger().log(
+                    Logger.LOG_ERROR,
+                    getClass().getName() + ": Unable to create revision directory.");
+                throw new IOException("Unable to create archive directory.");
+            }
+
+            if (!byReference)
+            {
+                if (is == null)
+                {
+                    // Do it the manual way to have a chance to 
+                    // set request properties such as proxy auth.
+                    URL url = new URL(getLocation());
+                    URLConnection conn = url.openConnection(); 
+        
+                    // Support for http proxy authentication.
+                    String auth = DefaultBundleCache.getSecureAction()
+                        .getSystemProperty("http.proxyAuth", null);
+                    if ((auth != null) && (auth.length() > 0))
+                    {
+                        if ("http".equals(url.getProtocol()) ||
+                            "https".equals(url.getProtocol()))
+                        {
+                            String base64 = Util.base64Encode(auth);
+                            conn.setRequestProperty(
+                                "Proxy-Authorization", "Basic " + base64);
+                        }
+                    }
+                    is = conn.getInputStream();
+                }
+    
+                // Save the bundle jar file.
+                DefaultBundleCache.copyStreamToFile(is, m_bundleFile);
+            }
+
+            // This will always be revision zero.
+            preprocessBundleJar();
+        }
+        finally
+        {
+            if (is != null) is.close();
+        }
+    }
+
+    /**
+     * This method pre-processes a bundle JAR file making it ready
+     * for use. This entails extracting all embedded JAR files and
+     * all native libraries.
+     * @throws java.lang.Exception if any error occurs while processing JAR file.
+    **/
+    private void preprocessBundleJar() throws Exception
+    {
+        //
+        // Create special directories so that we can avoid checking
+        // for their existence all the time.
+        //
+
+        File embedDir = new File(getRevisionRootDir(), EMBEDDED_DIRECTORY);
+        if (!DefaultBundleCache.getSecureAction().fileExists(embedDir))
+        {
+            if (!DefaultBundleCache.getSecureAction().mkdir(embedDir))
+            {
+                throw new IOException("Could not create embedded JAR directory.");
+            }
+        }
+
+        File libDir = new File(getRevisionRootDir(), LIBRARY_DIRECTORY);
+        if (!DefaultBundleCache.getSecureAction().fileExists(libDir))
+        {
+            if (!DefaultBundleCache.getSecureAction().mkdir(libDir))
+            {
+                throw new IOException("Unable to create native library directory.");
+            }
+        }
+
+        //
+        // This block extracts all embedded JAR files.
+        //
+
+        try
+        {
+            // Get the bundle's manifest header.
+            Map map = getManifestHeader();
+
+            // Find class path meta-data.
+            String classPath = (map == null)
+                ? null : (String) map.get(FelixConstants.BUNDLE_CLASSPATH);
+
+            // Parse the class path into strings.
+            String[] classPathStrings = Util.parseDelimitedString(
+                classPath, FelixConstants.CLASS_PATH_SEPARATOR);
+
+            if (classPathStrings == null)
+            {
+                classPathStrings = new String[0];
+            }
+
+            for (int i = 0; i < classPathStrings.length; i++)
+            {
+                if (!classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
+                {
+                    extractEmbeddedJar(classPathStrings[i]);
+                }
+            }
+
+        }
+        catch (PrivilegedActionException ex)
+        {
+            throw ((PrivilegedActionException) ex).getException();
+        }
+    }
+
+    /**
+     * This method extracts an embedded JAR file from the bundle's
+     * JAR file.
+     * <p>
+     * Security: This method must be called from within a <tt>doPrivileged()</tt>
+     * block since it accesses the disk.
+     * @param id the identifier of the bundle that owns the embedded JAR file.
+     * @param jarPath the path to the embedded JAR file inside the bundle JAR file.
+    **/
+    private void extractEmbeddedJar(String jarPath)
+        throws Exception
+    {
+        // Remove leading slash if present.
+        jarPath = (jarPath.length() > 0) && (jarPath.charAt(0) == '/')
+            ? jarPath.substring(1) : jarPath;
+
+        // If JAR is already extracted, then don't re-extract it...
+        File jarFile = new File(
+            getRevisionRootDir(), EMBEDDED_DIRECTORY + File.separatorChar + jarPath);
+
+        if (!DefaultBundleCache.getSecureAction().fileExists(jarFile))
+        {
+            JarFile bundleJar = null;
+            InputStream is = null;
+            try
+            {
+                // Make sure class path entry is a JAR file.
+                bundleJar = DefaultBundleCache.getSecureAction().openJAR(m_bundleFile);
+                ZipEntry ze = bundleJar.getEntry(jarPath);
+                if (ze == null)
+                {
+                    throw new IOException("No JAR entry: " + jarPath);
+                }
+                // If the zip entry is a directory, then ignore it since
+                // we don't need to extact it; otherwise, it points to an
+                // embedded JAR file, so extract it.
+                else if (!ze.isDirectory())
+                {
+                    // Make sure that the embedded JAR's parent directory exists;
+                    // it may be in a sub-directory.
+                    File jarDir = jarFile.getParentFile();
+                    if (!DefaultBundleCache.getSecureAction().fileExists(jarDir))
+                    {
+                        if (!DefaultBundleCache.getSecureAction().mkdirs(jarDir))
+                        {
+                            throw new IOException("Unable to create embedded JAR directory.");
+                        }
+                    }
+    
+                    // Extract embedded JAR into its directory.
+                    is = new BufferedInputStream(bundleJar.getInputStream(ze), DefaultBundleCache.BUFSIZE);
+                    if (is == null)
+                    {
+                        throw new IOException("No input stream: " + jarPath);
+                    }
+                    // Copy the file.
+                    DefaultBundleCache.copyStreamToFile(is, jarFile);
+                }
+            }
+            finally
+            {
+                if (bundleJar != null) bundleJar.close();
+                if (is != null) is.close();
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/SystemBundleArchive.java
(from r377666, incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java)
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/SystemBundleArchive.java?p2=incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/SystemBundleArchive.java&p1=incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java&r1=377666&r2=380806&rev=380806&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/SystemBundleArchive.java
Fri Feb 24 12:09:28 2006
@@ -14,57 +14,98 @@
  *   limitations under the License.
  *
  */
-package org.apache.felix.framework;
+package org.apache.felix.framework.cache;
 
 import java.io.File;
+import java.io.InputStream;
 import java.util.Map;
 
-import org.apache.felix.framework.cache.BundleArchive;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.moduleloader.IContent;
 import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 
-public class SystemBundleArchive implements BundleArchive
+/**
+ * <p>
+ * This class represents the bundle archive of the system bundle. It is a
+ * special case that is mostly just an empty implementation, since the system
+ * bundle is not a real archive.
+ * </p>
+**/
+public class SystemBundleArchive extends DefaultBundleArchive
 {
     private Map m_headerMap = null;
+    private BundleRevision m_revision = null;
+
+    public SystemBundleArchive()
+    {
+        m_revision = new BundleRevision() {
+
+            public Map getManifestHeader() throws Exception
+            {
+                return m_headerMap;
+            }
+
+            public IContent getContent() throws Exception
+            {
+                return null;
+            }
+
+            public IContent[] getContentPath() throws Exception
+            {
+                return null;
+            }
+
+            public String findLibrary(String libName) throws Exception
+            {
+                return null;
+            }
+
+            public void dispose() throws Exception
+            {
+            }
+        };
+    }
 
     public long getId()
     {
         return 0;
     }
-    
-    public String getLocation()
-        throws Exception
+
+    public String getLocation() throws Exception
     {
         return FelixConstants.SYSTEM_BUNDLE_LOCATION;
     }
 
-    public int getPersistentState()
-        throws Exception
+    public String getCurrentLocation() throws Exception
+    {
+        return null;
+    }
+
+    public void setCurrentLocation(String location) throws Exception
+    {
+    }
+
+    public int getPersistentState() throws Exception
     {
         return Bundle.ACTIVE;
     }
 
-    public void setPersistentState(int state)
-        throws Exception
+    public void setPersistentState(int state) throws Exception
     {
     }
 
-    public int getStartLevel()
-        throws Exception
+    public int getStartLevel() throws Exception
     {
         return FelixConstants.SYSTEMBUNDLE_DEFAULT_STARTLEVEL;
     }
 
-    public void setStartLevel(int level)
-        throws Exception
+    public void setStartLevel(int level) throws Exception
     {
     }
 
-    public File getDataFile(String fileName)
-        throws Exception
+    public File getDataFile(String fileName) throws Exception
     {
         return null;
     }
@@ -75,43 +116,41 @@
         return null;
     }
 
-    public void setActivator(Object obj)
-        throws Exception
+    public void setActivator(Object obj) throws Exception
     {
     }
 
     public int getRevisionCount()
-        throws Exception
     {
         return 1;
     }
 
-    public Map getManifestHeader(int revision)
-        throws Exception
+    public BundleRevision getRevision(int i)
     {
-        return m_headerMap;
+        return m_revision;
     }
-    
-    protected void setManifestHeader(Map headerMap)
+
+    public void revise(String location, InputStream is)
+        throws Exception
     {
-        m_headerMap = headerMap;
     }
 
-    public IContent getContent(int revision)
-        throws Exception
+    public  void purge() throws Exception
     {
-        return null;
     }
 
-    public IContent[] getContentPath(int revision)
-        throws Exception
+    public void dispose() throws Exception
     {
-        return null;
     }
 
-    public String findLibrary(int revision, String libName)
+    public Map getManifestHeader(int revision)
         throws Exception
     {
-        return null;
+        return m_headerMap;
+    }
+    
+    public void setManifestHeader(Map headerMap)
+    {
+        m_headerMap = headerMap;
     }
 }

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Library.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Library.java?rev=380806&r1=380805&r2=380806&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Library.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Library.java
Fri Feb 24 12:09:28 2006
@@ -17,13 +17,13 @@
 package org.apache.felix.framework.searchpolicy;
 
 import org.apache.felix.framework.Logger;
-import org.apache.felix.framework.cache.BundleCache;
+import org.apache.felix.framework.cache.DefaultBundleCache;
 import org.osgi.framework.Constants;
 
 public class R4Library
 {
     private Logger m_logger = null;
-    private BundleCache m_cache = null;
+    private DefaultBundleCache m_cache = null;
     private long m_bundleId = -1;
     private int m_revision = -1;
     private String m_os = null;
@@ -31,7 +31,7 @@
     private R4LibraryHeader m_header = null;
 
     public R4Library(
-        Logger logger, BundleCache cache, long bundleId, int revision,
+        Logger logger, DefaultBundleCache cache, long bundleId, int revision,
         String os, String processor, R4LibraryHeader header)
     {
         m_logger = logger;
@@ -63,7 +63,7 @@
             {
                 try {
                     return m_cache.getArchive(m_bundleId)
-                        .findLibrary(m_revision, m_header.getName());
+                        .getRevision(m_revision).findLibrary(m_header.getName());
                 } catch (Exception ex) {
                     m_logger.log(Logger.LOG_ERROR, "R4Library: Error finding library.", ex);
                 }

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java?rev=380806&r1=380805&r2=380806&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
Fri Feb 24 12:09:28 2006
@@ -43,7 +43,6 @@
     public static final String AUTO_START_PROP = "felix.auto.start";
     public static final String EMBEDDED_EXECUTION_PROP = "felix.embedded.execution";
     public static final String STRICT_OSGI_PROP = "felix.strict.osgi";
-    public static final String CACHE_CLASS_PROP = "felix.cache.class";
     public static final String FRAMEWORK_STARTLEVEL_PROP
         = "felix.startlevel.framework";
     public static final String BUNDLE_STARTLEVEL_PROP

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/shell/impl/InstallCommandImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/shell/impl/InstallCommandImpl.java?rev=380806&r1=380805&r2=380806&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/shell/impl/InstallCommandImpl.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/shell/impl/InstallCommandImpl.java
Fri Feb 24 12:09:28 2006
@@ -17,7 +17,6 @@
 package org.apache.felix.shell.impl;
 
 import java.io.PrintStream;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.StringTokenizer;
 
@@ -109,15 +108,10 @@
 
     private String absoluteLocation(String location)
     {
-        if (!location.endsWith(".jar"))
-        {
-            location = location + ".jar";
-        }
-        try
-        {
-            new URL(location);
-        }
-        catch (MalformedURLException ex)
+        String guess = location;
+        // If the location does not contain a ":", then try to
+        // add the base URL from the 'cd' command service.
+        if (location.indexOf(':') < 0)
         {
             // Try to create a valid URL using the base URL
             // contained in the "cd" command service.
@@ -137,16 +131,16 @@
                     m_context.ungetService(ref);
                 }
 
-                String theURL = baseURL + location;
+                String theURL = baseURL + guess;
                 new URL(theURL);
-
             }
             catch (Exception ex2)
             {
-                return null;
+                // If that fails, then just return the original.
+                return location;
             }
-            location = baseURL + location;
+            guess = baseURL + guess;
         }
-        return location;
+        return guess;
     }
 }



Mime
View raw message