diff options
author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-11-06 11:32:31 +0000 |
---|---|---|
committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-11-06 11:32:31 +0000 |
commit | 88f7e4891055e88e79871345f4bc7f6d4f37480e (patch) | |
tree | acd526a36b197d63469299ec76d96044e1d1be9f | |
parent | 8d49ae975c9dbf726a1b95eccc12907676f57ba9 (diff) | |
download | classpath-88f7e4891055e88e79871345f4bc7f6d4f37480e.tar.gz |
2005-11-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/CORBA/Minor.java (IOR_missing): New minor code.
* gnu/CORBA/NamingService/NameParser.java (corbaloc): Implemented
file//, ftp:// and http:// support.
* gnu/javax/rmi/CORBA/UtilDelegateImpl.java (mapSystemException):
Set the cause directly.
* org/omg/CORBA/DATA_CONVERSION.java,
org/omg/CORBA/ORB.java (string_to_object): Documentation update.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | gnu/CORBA/Minor.java | 6 | ||||
-rw-r--r-- | gnu/CORBA/NamingService/NameParser.java | 111 | ||||
-rw-r--r-- | gnu/javax/rmi/CORBA/UtilDelegateImpl.java | 10 | ||||
-rw-r--r-- | org/omg/CORBA/DATA_CONVERSION.java | 20 | ||||
-rw-r--r-- | org/omg/CORBA/ORB.java | 6 |
6 files changed, 158 insertions, 5 deletions
@@ -1,3 +1,13 @@ +2005-11-06 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * gnu/CORBA/Minor.java (IOR_missing): New minor code. + * gnu/CORBA/NamingService/NameParser.java (corbaloc): Implemented + file//, ftp:// and http:// support. + * gnu/javax/rmi/CORBA/UtilDelegateImpl.java (mapSystemException): + Set the cause directly. + * org/omg/CORBA/DATA_CONVERSION.java, + org/omg/CORBA/ORB.java (string_to_object): Documentation update. + 2005-11-06 Chris Burdess <dog@gnu.org> * javax/xml/stream/XMLStreamWriterImpl.java: Fixed handling of diff --git a/gnu/CORBA/Minor.java b/gnu/CORBA/Minor.java index fb5991dc9..511a34d55 100644 --- a/gnu/CORBA/Minor.java +++ b/gnu/CORBA/Minor.java @@ -272,5 +272,11 @@ public interface Minor * submitting large number of requests. */ int Threads = 21 | vendor; + + /** + * The IOR starts with file://, http:// or ftp://, but this local or remote + * resource is not accessible. + */ + int Missing_IOR = 22 | vendor; } diff --git a/gnu/CORBA/NamingService/NameParser.java b/gnu/CORBA/NamingService/NameParser.java index 8fc75c6a5..422db1c58 100644 --- a/gnu/CORBA/NamingService/NameParser.java +++ b/gnu/CORBA/NamingService/NameParser.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.CORBA.NamingService; +import gnu.CORBA.Minor; import gnu.CORBA.OrbFunctional; import gnu.CORBA.IOR; import gnu.CORBA.Unexpected; @@ -53,7 +54,13 @@ import org.omg.CORBA.portable.ObjectImpl; import org.omg.CosNaming.NamingContext; import org.omg.CosNaming._NamingContextStub; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; import java.util.StringTokenizer; @@ -88,6 +95,21 @@ public class NameParser * The IOR prefix. */ public static final String pxIOR = "ior"; + + /** + * The file:// prefix. + */ + public static final String pxFILE = "file://"; + + /** + * The ftp:// prefix. + */ + public static final String pxFTP = "ftp://"; + + /** + * The http:// prefix. + */ + public static final String pxHTTP = "http://"; /** * Marks iiop protocol. @@ -132,6 +154,9 @@ public class NameParser * 2. corbaloc:rir:[/key] <br> * 3. corbaname:[iiop][version.subversion@]:host[:port]/key <br> * 4. corbaname:rir:[/key] <br> + * 5. file://[file name]<br> + * 6. http://[url]<br> + * 7. ftp://[url]<br> * * Protocol defaults to IOP, the object key defaults to the NameService. * @@ -144,6 +169,28 @@ public class NameParser OrbFunctional orb) throws BAD_PARAM { + return corbaloc(corbaloc, orb, 0); + } + + /** + * Parse controlling against the infinite recursion loop. + */ + private org.omg.CORBA.Object corbaloc(String corbaloc, + OrbFunctional orb, int recursion) + { + // The used CORBA specification does not state how many times we should to + //redirect, but the infinite loop may be used to knock out the system. + // by malicious attempt. + if (recursion > 10) + throw new DATA_CONVERSION("More than 10 redirections"); + + if (corbaloc.startsWith(pxFILE)) + return corbaloc(readFile(corbaloc.substring(pxFILE.length())), orb, recursion+1); + else if (corbaloc.startsWith(pxHTTP)) + return corbaloc(readUrl(corbaloc), orb, recursion+1); + else if (corbaloc.startsWith(pxFTP)) + return corbaloc(readUrl(corbaloc), orb, recursion+1); + boolean corbaname; // The alternative addresses, if given. @@ -302,6 +349,70 @@ public class NameParser else throw new DATA_CONVERSION("Unsupported protocol '" + t[p] + "'"); } + + /** + * Read IOR from the file in the local file system. + */ + String readFile(String file) + { + File f = new File(file); + if (!f.exists()) + { + DATA_CONVERSION err = new DATA_CONVERSION(f.getAbsolutePath() + + " does not exist."); + err.minor = Minor.Missing_IOR; + } + try + { + char[] c = new char[(int) f.length()]; + FileReader fr = new FileReader(f); + fr.read(c); + fr.close(); + return new String(c).trim(); + } + catch (IOException ex) + { + DATA_CONVERSION d = new DATA_CONVERSION(); + d.initCause(ex); + d.minor = Minor.Missing_IOR; + throw (d); + } + } + + /** + * Read IOR from the remote URL. + */ + String readUrl(String url) + { + URL u; + try + { + u = new URL(url); + } + catch (MalformedURLException mex) + { + throw new BAD_PARAM("Malformed URL: '" + url + "'"); + } + + try + { + InputStreamReader r = new InputStreamReader(u.openStream()); + + StringBuffer b = new StringBuffer(); + int c; + + while ((c = r.read()) > 0) + b.append((char) c); + + return b.toString().trim(); + } + catch (Exception exc) + { + DATA_CONVERSION d = new DATA_CONVERSION("Reading " + url + " failed."); + d.minor = Minor.Missing_IOR; + throw d; + } + } private org.omg.CORBA.Object resolve(org.omg.CORBA.Object object) { diff --git a/gnu/javax/rmi/CORBA/UtilDelegateImpl.java b/gnu/javax/rmi/CORBA/UtilDelegateImpl.java index f37f18c24..66a4e24ff 100644 --- a/gnu/javax/rmi/CORBA/UtilDelegateImpl.java +++ b/gnu/javax/rmi/CORBA/UtilDelegateImpl.java @@ -518,7 +518,7 @@ public class UtilDelegateImpl else if (ex instanceof INV_OBJREF) { rex = new NoSuchObjectException(message); - rex.initCause(ex); + rex.detail = ex; } else if (ex instanceof NO_PERMISSION) rex = new AccessException(message, ex); @@ -529,22 +529,22 @@ public class UtilDelegateImpl else if (ex instanceof OBJECT_NOT_EXIST) { rex = new NoSuchObjectException(message); - rex.initCause(ex); + rex.detail = ex; } else if (ex instanceof TRANSACTION_REQUIRED) { rex = new TransactionRequiredException(message); - rex.initCause(ex); + rex.detail = ex; } else if (ex instanceof TRANSACTION_ROLLEDBACK) { rex = new TransactionRolledbackException(message); - rex.initCause(ex); + rex.detail = ex; } else if (ex instanceof INVALID_TRANSACTION) { rex = new InvalidTransactionException(message); - rex.initCause(ex); + rex.detail = ex; } else if (ex instanceof UNKNOWN) rex = wrapException(ex.getCause()); diff --git a/org/omg/CORBA/DATA_CONVERSION.java b/org/omg/CORBA/DATA_CONVERSION.java index 3faacdcb2..7261aae46 100644 --- a/org/omg/CORBA/DATA_CONVERSION.java +++ b/org/omg/CORBA/DATA_CONVERSION.java @@ -44,6 +44,26 @@ import java.io.Serializable; * Means that the ORB cannot convert between the marshalled and * native data representation. * + * In GNU Classpath, this exception may have the following minor codes: + * + * <table border="1"> + * <tr> + * <td>Hex</td> + * <td>Dec</td> + * <td>Minor</td> + * <td>Name</td> + * <td>Case</td> + * </tr> + * <td>47430016</td> + * <td>1195573270</td> + * <td>22</td> + * <td>Missing_IOR</td> + * <td>The object URL is such that the IOR string must be read from some + * local or remote resource (file or network), but this resource is not + * reacheable.</td> + * </tr> + * </table> + * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class DATA_CONVERSION diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java index 98120ac16..52c0ad621 100644 --- a/org/omg/CORBA/ORB.java +++ b/org/omg/CORBA/ORB.java @@ -1024,6 +1024,12 @@ public abstract class ORB * that runs on the given host at the given port. The ORB expects to find * there the {@link org.omg.CosNaming.NamingContext} under the key * "NameService.<br> + * 7. file://[file name] Read the object definition string from the + * file system<br> + * 8. http://[url] Read the object definition string from the provided + * url.<br> + * 9. ftp://[url] Read the object definition string from the provided + * url.<br> * * <p>The default port is always 2809. The default iiop version is 1.0 * that now may not always be supported, so we would recommend to specify |