Example #1
0
        protected void init(CurlResource curl)

        {
            Proxy proxy = getProxy();

            if (proxy != null)
            {
                setConnection(_url.openConnection(proxy));
            }
            else
            {
                setConnection(_url.openConnection());
            }
        }
Example #2
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        //ORIGINAL LINE: private static String httpPut(String paramString1, String paramString2) throws java.io.UnsupportedEncodingException, java.io.IOException
        private static string httpPut(string paramString1, string paramString2)
        {
            URL uRL = new URL(paramString1);
            HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();

            httpURLConnection.RequestMethod = "PUT";
            httpURLConnection.DoOutput      = true;
            httpURLConnection.setRequestProperty("Content-Type", "application/json");
            StreamWriter outputStreamWriter = new StreamWriter(httpURLConnection.OutputStream, Encoding.UTF8);

            outputStreamWriter.Write(paramString2);
            outputStreamWriter.Close();
            if (httpURLConnection.ResponseCode != 200)
            {
                throw new IOException(httpURLConnection.ResponseMessage);
            }
            StreamReader  bufferedReader = new StreamReader(httpURLConnection.InputStream, Encoding.UTF8);
            StringBuilder stringBuilder  = new StringBuilder();
            string        str;

            while (!string.ReferenceEquals((str = bufferedReader.ReadLine()), null))
            {
                stringBuilder.Append(str);
            }
            bufferedReader.Close();
            httpURLConnection.disconnect();
            return(stringBuilder.ToString());
        }
Example #3
0
            private string downloadUrl(string strUrl)
            {
                string            data          = "";
                Stream            iStream       = null;
                HttpURLConnection urlConnection = null;

                try
                {
                    URL url = new URL(strUrl);
                    urlConnection = (HttpURLConnection)url.openConnection();
                    urlConnection.connect();
                    iStream = urlConnection.getInputStream();
                    StreamReader  br   = new StreamReader(iStream);
                    StringBuilder sb   = new StringBuilder();
                    string        line = "";
                    while (!string.ReferenceEquals((line = br.ReadLine()), null))
                    {
                        sb.Append(line);
                    }

                    data = sb.ToString();

                    br.Close();
                }
                catch (Exception e)
                {
                    Log.d("Exception", e.ToString());
                }
                finally
                {
                    iStream.Close();
                    urlConnection.disconnect();
                }
                return(data);
            }
Example #4
0
        public static string getInternalParserModelName(URL mcoUrl)
        {
            string internalParserModelName = null;

            try
            {
                JarEntry       je;
                JarInputStream jis = new JarInputStream(mcoUrl.openConnection().InputStream);

                while ((je = jis.NextJarEntry) != null)
                {
                    string fileName = je.Name;
                    jis.closeEntry();
                    int index = fileName.IndexOf('/');
                    if (index == -1)
                    {
                        index = fileName.IndexOf('\\');
                    }
                    if (ReferenceEquals(internalParserModelName, null))
                    {
                        internalParserModelName = fileName.Substring(0, index);
                        break;
                    }
                }
                jis.close();
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            return(internalParserModelName);
        }
Example #5
0
        /// <summary>
        /// Makes initial contact with the signed URL we got back when talking to the Neo4j cloud console. This will create yet another URL
        /// which will be used to upload the source to, potentially resumed if it gets interrupted in the middle.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.net.URL initiateResumableUpload(boolean verbose, java.net.URL signedURL) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private URL InitiateResumableUpload(bool verbose, URL signedURL)
        {
            HttpURLConnection connection = ( HttpURLConnection )signedURL.openConnection();

            try
            {
                connection.RequestMethod = "POST";
                connection.setRequestProperty("Content-Length", "0");
                connection.FixedLengthStreamingMode = 0;
                connection.setRequestProperty("x-goog-resumable", "start");
                // We don't want to have any Content-Type set really, but there's this issue with the standard HttpURLConnection
                // implementation where it defaults Content-Type to application/x-www-form-urlencoded for POSTs for some reason
                connection.setRequestProperty("Content-Type", "");
                connection.DoOutput = true;
                int responseCode = connection.ResponseCode;
                if (responseCode != HTTP_CREATED)
                {
                    throw UnexpectedResponse(verbose, connection, "Initiating database upload");
                }
                return(SafeUrl(connection.getHeaderField("Location")));
            }
            finally
            {
                connection.disconnect();
            }
        }
Example #6
0
        private void sendGET(string GET_URL)
        {
            var url = new URL(GET_URL);
            HttpURLConnection con = (HttpURLConnection)url.openConnection();

            con.setRequestMethod("GET");
            con.setRequestProperty("User-Agent", USER_AGENT);

            int responseCode = con.getResponseCode();

            if (responseCode == HttpURLConnection.HTTP_OK)
            {
                BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
                string         inputLine;
                StringBuffer   response = new StringBuffer();

                while ((inputLine = br.readLine()) != null)
                {
                    response.append(inputLine);
                }
                br.close();
            }
            else
            {
                Console.WriteLine("GET request not worked");
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private java.io.InputStream openConnection(android.net.Uri uri) throws java.io.IOException
        private System.IO.Stream openConnection(Uri uri)
        {
            URL           url  = new URL(uri.ToString());
            URLConnection conn = url.openConnection();

            return(conn.InputStream);
        }
Example #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void ping() throws java.io.IOException
        internal virtual void Ping()
        {
            _pingCount++;

            IDictionary <string, string> usageDataMap = _collector.UdcParams;

            StringBuilder uri = new StringBuilder("http://" + _address + "/" + "?");

            foreach (KeyValuePair <string, string> entry in usageDataMap.SetOfKeyValuePairs())
            {
                uri.Append(entry.Key);
                uri.Append("=");
                uri.Append(URLEncoder.encode(entry.Value, StandardCharsets.UTF_8.name()));
                uri.Append("+");
            }

            uri.Append(PING + "=").Append(_pingCount);

            URL           url = new URL(uri.ToString());
            URLConnection con = url.openConnection();

            con.DoInput   = true;
            con.DoOutput  = false;
            con.UseCaches = false;
            con.connect();

            con.InputStream.close();
        }
Example #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private String getDatabaseStatus(boolean verbose, java.net.URL statusURL, String bearerToken) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private string GetDatabaseStatus(bool verbose, URL statusURL, string bearerToken)
        {
            HttpURLConnection connection = ( HttpURLConnection )statusURL.openConnection();

            try
            {
                connection.RequestMethod = "GET";
                connection.setRequestProperty("Authorization", bearerToken);
                connection.DoOutput = true;

                int responseCode = connection.ResponseCode;
                switch (responseCode)
                {
                case HTTP_NOT_FOUND:
                // fallthrough
                case HTTP_MOVED_PERM:
                    throw UpdatePluginErrorResponse(connection);

                case HTTP_OK:
                    using (Stream responseData = connection.InputStream)
                    {
                        string json = new string( toByteArray(responseData), UTF_8 );
                        return(ParseJsonUsingJacksonParser(json, typeof(StatusBody)).Status);
                    }

                default:
                    throw UnexpectedResponse(verbose, connection, "Trigger import/restore after successful upload");
                }
            }
            finally
            {
                connection.disconnect();
            }
        }
Example #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public String authenticate(boolean verbose, String consoleUrl, String username, char[] password, boolean consentConfirmed) throws org.neo4j.commandline.admin.CommandFailed
        public override string Authenticate(bool verbose, string consoleUrl, string username, char[] password, bool consentConfirmed)
        {
            try
            {
                URL url = SafeUrl(consoleUrl + "/import/auth");
                HttpURLConnection connection = ( HttpURLConnection )url.openConnection();
                try
                {
                    connection.RequestMethod = "POST";
                    connection.setRequestProperty("Authorization", "Basic " + Base64Encode(username, password));
                    connection.setRequestProperty("Accept", "application/json");
                    connection.setRequestProperty("Confirmed", consentConfirmed.ToString());
                    int responseCode = connection.ResponseCode;
                    switch (responseCode)
                    {
                    case HTTP_NOT_FOUND:
                    // fallthrough
                    case HTTP_MOVED_PERM:
                        throw UpdatePluginErrorResponse(connection);

                    case HTTP_UNAUTHORIZED:
                        throw ErrorResponse(verbose, connection, "Invalid username/password credentials");

                    case HTTP_FORBIDDEN:
                        throw ErrorResponse(verbose, connection, "The given credentials do not give administrative access to the target database");

                    case HTTP_CONFLICT:
                        // the cloud target database has already been populated with data, and importing the dump file would overwrite it.
                        bool consent = AskForBooleanConsent("A non-empty database already exists at the given location, would you like to overwrite that database?");
                        if (consent)
                        {
                            return(Authenticate(verbose, consoleUrl, username, password, true));
                        }
                        else
                        {
                            throw ErrorResponse(verbose, connection, "No consent to overwrite database, aborting upload");
                        }

                    case HTTP_OK:
                        using (Stream responseData = connection.InputStream)
                        {
                            string json = new string( toByteArray(responseData), UTF_8 );
                            return(ParseJsonUsingJacksonParser(json, typeof(TokenBody)).Token);
                        }

                    default:
                        throw UnexpectedResponse(verbose, connection, "Authorization");
                    }
                }
                finally
                {
                    connection.disconnect();
                }
            }
            catch (IOException e)
            {
                throw new CommandFailed(e.Message, e);
            }
        }
Example #11
0
            public override HttpURLConnection createConnection(URL arg0)
            {
                URL               url               = new URL("https://developer.huawei.com");
                URLConnection     rulConnection     = url.openConnection();
                HttpURLConnection httpUrlConnection = rulConnection.toType <HttpURLConnection>();

                return(httpUrlConnection);
            }
Example #12
0
 public static Node GetInstanceFromURL(string url)
 {
     try
     {
         var _url = new URL(url);
         return(InputStreamParser.Parse(_url.openConnection().InputStream));
     }
     catch (IOException)
     {
         throw new Indeterminate(Indeterminate.IndeterminateProcessingError);
     }
 }
Example #13
0
            public Reader resolve(URI absoluteURI, string encoding, Configuration config)
            {
                if (encoding == null)
                {
                    encodings.TryGetValue(new Uri(absoluteURI.ToString()), out encoding);
                }
                if (encoding == null)
                {
                    encoding = "utf-8";
                }
                try
                {
                    // The following is necessary to ensure that encoding errors are not recovered.
                    java.nio.charset.Charset        charset = java.nio.charset.Charset.forName(encoding);
                    java.nio.charset.CharsetDecoder decoder = charset.newDecoder();
                    decoder = decoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPORT);
                    decoder = decoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPORT);
                    Object obj;
                    resources.TryGetValue(new Uri(absoluteURI.ToString()), out obj);
                    if (obj is java.io.File)
                    {
                        return(new BufferedReader(new InputStreamReader(new FileInputStream((java.io.File)obj), decoder)));
                    }
                    else
                    {
                        resources.TryGetValue(new Uri(absoluteURI.ToString()), out obj);
                        URL resource = (URL)obj;
                        if (resource == null)
                        {
                            resource = absoluteURI.toURL();
                            //throw new XPathException("Unparsed text resource " + absoluteURI + " not registered in catalog", "FOUT1170");
                        }
                        java.io.InputStream in1 = resource.openConnection().getInputStream();
                        return(new BufferedReader(new InputStreamReader(in1, decoder)));
                    }
                    //   return new InputStreamReader(new FileInputStream(resources.get(absoluteURI)), encoding);
                }
                catch (java.lang.Exception ioe)
                {
                    throw new Exception(ioe.getMessage() + "FOUT1170");
                }

                /*catch (IllegalCharsetNameException icne)
                 * {
                 *  throw new XPathException("Invalid encoding name: " + encoding, "FOUT1190");
                 * }
                 * catch (UnsupportedCharsetException uce)
                 * {
                 *  throw new XPathException("Invalid encoding name: " + encoding, "FOUT1190");
                 * }*/
            }
Example #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static java.io.InputStream getInputStreamFromURL(String paramString1, String paramString2, String paramString3) throws Exception
        public static Stream getInputStreamFromURL(string paramString1, string paramString2, string paramString3)
        {
            URL           uRL           = new URL(paramString1);
            URLConnection uRLConnection = uRL.openConnection();

            uRLConnection.ConnectTimeout = 4000;
            uRLConnection.ReadTimeout    = 30000;
            uRLConnection.setRequestProperty("User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
            if (!string.ReferenceEquals(paramString2, null))
            {
                uRLConnection.setRequestProperty("Authorization", "Basic " + encode(paramString2 + ":" + paramString3));
            }
            return(uRLConnection.InputStream);
        }
Example #15
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        //ORIGINAL LINE: private java.io.InputStream getInputStream(String paramString, java.util.Map<String, String> paramMap) throws Exception
        private Stream getInputStream(string paramString, IDictionary <string, string> paramMap)
        {
            URL uRL = constructURL(paramString, paramMap);
            HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();

            httpURLConnection.ConnectTimeout = 4000;
            httpURLConnection.ReadTimeout    = 30000;
            if (((!string.ReferenceEquals(this.username, null)) ? 1 : 0) & ((!string.ReferenceEquals(this.password, null)) ? 1 : 0))
            {
                httpURLConnection.setRequestProperty("Authorization", "Basic " + HTTPUtil.encode(this.username + ":" + this.password));
            }
            httpURLConnection.setRequestProperty("Content-Type", "application/json");
            return(httpURLConnection.InputStream);
        }
Example #16
0
		/// <summary>
		/// PING指定URL是否可用
		/// </summary>
		/// <param name="address">
		/// @return </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public static boolean pingUrl(final String address)
		public static bool pingUrl(string address)
		{

			try
			{

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.net.URL url = new java.net.URL("http://" + address);
				URL url = new URL("http://" + address);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.net.HttpURLConnection urlConn = (java.net.HttpURLConnection) url.openConnection();
				HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();

				urlConn.ConnectTimeout = 1000 * 10; // mTimeout is in seconds

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long startTime = System.currentTimeMillis();
				long startTime = DateTimeHelperClass.CurrentUnixTimeMillis();

				urlConn.connect();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long endTime = System.currentTimeMillis();
				long endTime = DateTimeHelperClass.CurrentUnixTimeMillis();

				if (urlConn.ResponseCode == HttpURLConnection.HTTP_OK)
				{
					LOGGER.info("Time (ms) : " + (endTime - startTime));
					LOGGER.info("Ping to " + address + " was success");
					return true;
				}

			}
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final java.net.MalformedURLException e1)
			catch (MalformedURLException e1)
			{
				Console.WriteLine(e1.ToString());
				Console.Write(e1.StackTrace);
			}
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final java.io.IOException e)
			catch (IOException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}
			return false;
		}
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public MessageList paymentRequest(DirectPaymentRequest directPaymentRequest, EasypayConfig config) throws java.net.MalformedURLException
		public virtual MessageList paymentRequest(DirectPaymentRequest directPaymentRequest, EasypayConfig config)
		{

			URL url = new URL("https://" + config.Host);
			string httpRequestMethod = "POST";
			string contentHash = "xxx";
			string contentType = "??";
			string date = "";
			string path = "";

			HttpURLConnection urlConnection = null;
			try
			{
				urlConnection = (HttpURLConnection) url.openConnection();

				urlConnection.RequestMethod = httpRequestMethod;
				urlConnection.setRequestProperty("Content-Type", contentType);
				// urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(postData.getBytes().length));

				urlConnection.UseCaches = false;
				urlConnection.DoInput = true;
				urlConnection.DoOutput = true;

				System.IO.Stream @out = new BufferedOutputStream(urlConnection.OutputStream);
				// writeStream(out);

				System.IO.Stream @in = new BufferedInputStream(urlConnection.InputStream);
				// readStream(in);


			}
			catch (IOException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}
			finally
			{
				if (urlConnection != null)
				{
					urlConnection.disconnect();
				}
			}
			return new MessageList();
		}
Example #18
0
                protected internal override Bitmap doInBackground(params Uri[] @params)
                {
                    System.IO.Stream @in = null;
                    try
                    {
                        URL           url  = new URL(@params[0].ToString());
                        URLConnection conn = url.openConnection();
                        @in = conn.InputStream;
                        Bitmap bitmap = BitmapFactory.decodeStream(@in);

                        // Add the bitmap to cache.
                        if (outerInstance.mIconsCache != null)
                        {
                            outerInstance.mIconsCache.put(@params[0], bitmap);
                        }
                        //return the bitmap only if target image view is still valid
                        if (@params[0].Equals(mImageView.Tag))
                        {
                            return(bitmap);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    catch (IOException)
                    {
                        // Failed to retrieve icon, ignore it
                        return(null);
                    }
                    finally
                    {
                        if (@in != null)
                        {
                            try
                            {
                                @in.Close();
                            }
                            catch (IOException)
                            {
                            }
                        }
                    }
                }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public MessageList paymentRequest(DirectPaymentRequest directPaymentRequest, EasypayConfig config) throws java.net.MalformedURLException
        public virtual MessageList paymentRequest(DirectPaymentRequest directPaymentRequest, EasypayConfig config)
        {
            URL    url = new URL("https://" + config.Host);
            string httpRequestMethod = "POST";
            string contentHash       = "xxx";
            string contentType       = "??";
            string date = "";
            string path = "";

            HttpURLConnection urlConnection = null;

            try
            {
                urlConnection = (HttpURLConnection)url.openConnection();

                urlConnection.RequestMethod = httpRequestMethod;
                urlConnection.setRequestProperty("Content-Type", contentType);
                // urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(postData.getBytes().length));

                urlConnection.UseCaches = false;
                urlConnection.DoInput   = true;
                urlConnection.DoOutput  = true;

                System.IO.Stream @out = new BufferedOutputStream(urlConnection.OutputStream);
                // writeStream(out);

                System.IO.Stream @in = new BufferedInputStream(urlConnection.InputStream);
                // readStream(in);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            finally
            {
                if (urlConnection != null)
                {
                    urlConnection.disconnect();
                }
            }
            return(new MessageList());
        }
Example #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static java.util.Properties getPropertiesURL(String paramString1, String paramString2, String paramString3) throws Exception
        public static Properties getPropertiesURL(string paramString1, string paramString2, string paramString3)
        {
            Properties    properties    = new Properties();
            URL           uRL           = new URL(paramString1);
            URLConnection uRLConnection = uRL.openConnection();

            uRLConnection.ConnectTimeout = 5000;
            uRLConnection.ReadTimeout    = 5000;
            uRLConnection.setRequestProperty("User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
            if (!string.ReferenceEquals(paramString2, null))
            {
                uRLConnection.setRequestProperty("Authorization", "Basic " + encode(paramString2 + ":" + paramString3));
            }
            Stream inputStream = uRLConnection.InputStream;

            properties.load(inputStream);
            inputStream.Close();
            return(properties);
        }
Example #21
0
        /// <summary>
        /// Communication with Neo4j's cloud console, resulting in some signed URI to do the actual upload to.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.net.URL initiateCopy(boolean verbose, java.net.URL importURL, long crc32Sum, String bearerToken) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private URL InitiateCopy(bool verbose, URL importURL, long crc32Sum, string bearerToken)
        {
            HttpURLConnection connection = ( HttpURLConnection )importURL.openConnection();

            try
            {
                // POST the request
                connection.RequestMethod = "POST";
                connection.setRequestProperty("Content-Type", "application/json");
                connection.setRequestProperty("Authorization", bearerToken);
                connection.setRequestProperty("Accept", "application/json");
                connection.DoOutput = true;
                using (Stream postData = connection.OutputStream)
                {
                    postData.WriteByte(BuildCrc32WithConsentJson(crc32Sum).GetBytes(UTF_8));
                }

                // Read the response
                int responseCode = connection.ResponseCode;
                switch (responseCode)
                {
                case HTTP_NOT_FOUND:
                // fallthrough
                case HTTP_MOVED_PERM:
                    throw UpdatePluginErrorResponse(connection);

                case HTTP_UNAUTHORIZED:
                    throw ErrorResponse(verbose, connection, "The given authorization token is invalid or has expired");

                case HTTP_ACCEPTED:
                    // the import request was accepted, and the server has not seen this dump file, meaning the import request is a new operation.
                    return(SafeUrl(ExtractSignedURIFromResponse(verbose, connection)));

                default:
                    throw UnexpectedResponse(verbose, connection, "Initiating upload target");
                }
            }
            finally
            {
                connection.disconnect();
            }
        }
Example #22
0
        /// <summary>
        /// Uploads source from the given position to the upload location.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private boolean resumeUpload(boolean verbose, java.nio.file.Path source, long sourceLength, long position, java.net.URL uploadLocation, ProgressTrackingOutputStream.Progress uploadProgress) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private bool ResumeUpload(bool verbose, Path source, long sourceLength, long position, URL uploadLocation, ProgressTrackingOutputStream.Progress uploadProgress)
        {
            HttpURLConnection connection = ( HttpURLConnection )uploadLocation.openConnection();

            try
            {
                connection.RequestMethod = "PUT";
                long contentLength = sourceLength - position;
                connection.setRequestProperty("Content-Length", contentLength.ToString());
                connection.FixedLengthStreamingMode = contentLength;
                if (position > 0)
                {
                    // If we're not starting from the beginning we need to specify what range we're uploading in this format
                    connection.setRequestProperty("Content-Range", format("bytes %d-%d/%d", position, sourceLength - 1, sourceLength));
                }
                connection.DoOutput = true;
                uploadProgress.RewindTo(position);
                using (Stream sourceStream = new FileStream(source.toFile(), FileMode.Open, FileAccess.Read), Stream targetStream = connection.OutputStream)
                {
                    SafeSkip(sourceStream, position);
                    IOUtils.copy(new BufferedInputStream(sourceStream), new ProgressTrackingOutputStream(targetStream, uploadProgress));
                }
                int responseCode = connection.ResponseCode;
                switch (responseCode)
                {
                case HTTP_OK:
                    return(true);                             // the file is now uploaded, all good

                case HTTP_INTERNAL_ERROR:
                case HTTP_UNAVAILABLE:
                    DebugErrorResponse(verbose, connection);
                    return(false);

                default:
                    throw UnexpectedResponse(verbose, connection, "Resumable database upload");
                }
            }
            finally
            {
                connection.disconnect();
            }
        }
Example #23
0
        /// <summary>
        /// Extract jar that is stored ad resource in a parent jar into temporary file </summary>
        /// <param name="resourceUrl"> resource jar resourceUrl </param>
        /// <param name="jar"> jar resource path </param>
        /// <returns> jar temporary file </returns>
        /// <exception cref="IOException"> on exception during jar extractions </exception>
        /// <exception cref="EmbeddedJarNotFoundException"> if jar not found or can't be extracted. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.io.File extractJar(java.net.URL resourceUrl, String jar) throws java.io.IOException
        private File ExtractJar(URL resourceUrl, string jar)
        {
            URLConnection connection = resourceUrl.openConnection();

            if (connection is JarURLConnection)
            {
                JarURLConnection urlConnection = ( JarURLConnection )connection;
                JarFile          jarFile       = urlConnection.JarFile;
                JarEntry         jarEntry      = urlConnection.JarEntry;
                if (jarEntry == null)
                {
                    throw new EmbeddedJarNotFoundException("Jar file '" + jar + "' not found.");
                }
                return(Extract(jarFile, jarEntry));
            }
            else
            {
                throw new EmbeddedJarNotFoundException("Jar file '" + jar + "' not found.");
            }
        }
Example #24
0
        public static string getURL(string paramString1, string paramString2, string paramString3, int paramInt1, int paramInt2)
        {
            string str = "";

            try
            {
                URL uRL = new URL(paramString1);
                try
                {
                    URLConnection uRLConnection = uRL.openConnection();
                    uRLConnection.ConnectTimeout = paramInt1;
                    uRLConnection.ReadTimeout    = paramInt2;
                    uRLConnection.setRequestProperty("User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
                    if (!string.ReferenceEquals(paramString2, null))
                    {
                        uRLConnection.setRequestProperty("Authorization", "Basic " + encode(paramString2 + ":" + paramString3));
                    }
                    Stream       inputStream    = uRLConnection.InputStream;
                    StreamReader bufferedReader = new StreamReader(inputStream);
                    string       str1;
                    while (!string.ReferenceEquals((str1 = bufferedReader.ReadLine()), null))
                    {
                        str = str + str1;
                    }
                    bufferedReader.Close();
                    inputStream.Close();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    Console.Write(exception.StackTrace);
                    return("");
                }
            }
            catch (MalformedURLException)
            {
                return(paramString1 + " is not a parseable URL");
            }
            return(str);
        }
Example #25
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void triggerImportProtocol(boolean verbose, java.net.URL importURL, long crc32Sum, String bearerToken) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private void TriggerImportProtocol(bool verbose, URL importURL, long crc32Sum, string bearerToken)
        {
            HttpURLConnection connection = ( HttpURLConnection )importURL.openConnection();

            try
            {
                connection.RequestMethod = "POST";
                connection.setRequestProperty("Content-Type", "application/json");
                connection.setRequestProperty("Authorization", bearerToken);
                connection.DoOutput = true;
                using (Stream postData = connection.OutputStream)
                {
                    postData.WriteByte(BuildCrc32WithConsentJson(crc32Sum).GetBytes(UTF_8));
                }

                int responseCode = connection.ResponseCode;
                switch (responseCode)
                {
                case HTTP_NOT_FOUND:
                // fallthrough
                case HTTP_MOVED_PERM:
                    throw UpdatePluginErrorResponse(connection);

                case HTTP_CONFLICT:
                    throw ErrorResponse(verbose, connection, "A non-empty database already exists at the given location and overwrite consent not given, aborting");

                case HTTP_OK:
                    // All good, we managed to trigger the import protocol after our completed upload
                    break;

                default:
                    throw UnexpectedResponse(verbose, connection, "Trigger import/restore after successful upload");
                }
            }
            finally
            {
                connection.disconnect();
            }
        }
Example #26
0
        /// <summary>
        /// Asks about how far the upload has gone so far, typically after being interrupted one way or another. The result of this method
        /// can be fed into <seealso cref="resumeUpload(bool, Path, long, long, URL, ProgressTrackingOutputStream.Progress)"/> to resume an upload.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long getResumablePosition(boolean verbose, long sourceLength, java.net.URL uploadLocation) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        private long GetResumablePosition(bool verbose, long sourceLength, URL uploadLocation)
        {
            Debug(verbose, "Asking about resumable position for the upload");
            HttpURLConnection connection = ( HttpURLConnection )uploadLocation.openConnection();

            try
            {
                connection.RequestMethod = "PUT";
                connection.setRequestProperty("Content-Length", "0");
                connection.FixedLengthStreamingMode = 0;
                connection.setRequestProperty("Content-Range", "bytes */" + sourceLength);
                connection.DoOutput = true;
                int responseCode = connection.ResponseCode;
                switch (responseCode)
                {
                case HTTP_OK:
                case HTTP_CREATED:
                    Debug(verbose, "Upload seems to be completed got " + responseCode);
                    return(POSITION_UPLOAD_COMPLETED);

                case HTTP_RESUME_INCOMPLETE:
                    string range = connection.getHeaderField("Range");
                    Debug(verbose, "Upload not completed got " + range);
                    long position = string.ReferenceEquals(range, null) ? 0 : ParseResumablePosition(range);
                    Debug(verbose, "Parsed that as position " + position);
                    return(position);

                default:
                    throw UnexpectedResponse(verbose, connection, "Acquire resumable upload position");
                }
            }
            finally
            {
                connection.disconnect();
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static LocationSearchResult reverseSearch(org.jdesktop.swingx.mapviewer.GeoPosition paramGeoPosition, int paramInt1, int paramInt2) throws Exception
        public static LocationSearchResult reverseSearch(GeoPosition paramGeoPosition, int paramInt1, int paramInt2)
        {
            LocationSearchResult locationSearchResult = new LocationSearchResult();

            locationSearchResult.PlaceList = new List <object>();
            string str = StringUtils.replace("http://nominatim.openstreetmap.org/reverse?format=xml&lat={A}&lon={B}&zoom={C}&addressdetails=1", "{A}", "" + paramGeoPosition.Latitude);

            str = StringUtils.replace(str, "{B}", "" + paramGeoPosition.Longitude);
            double d = paramInt1 * 19.0D / paramInt2;

            paramInt1 = (int)(19.0D - d - 0.5D);
            if (paramInt1 == 0)
            {
                paramInt1 = 1;
            }
            else if (paramInt1 >= 19)
            {
                paramInt1 = 18;
            }
            str = StringUtils.replace(str, "{C}", "" + paramInt1);
            URL           uRL           = new URL(str);
            URLConnection uRLConnection = uRL.openConnection();

            uRLConnection.setRequestProperty("User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
            uRLConnection.ConnectTimeout = 4000;
            uRLConnection.ReadTimeout    = 30000;
            Stream    inputStream = uRLConnection.InputStream;
            SAXReader sAXReader   = new SAXReader();
            Document  document    = sAXReader.read(inputStream);
            Element   element     = document.RootElement;

            locationSearchResult.Query_string = element.attributeValue("query_string");
            locationSearchResult.Polygon      = (new bool?(element.attributeValue("polygon")));
            LocationPlace locationPlace = new LocationPlace();

            locationPlace.Lat = "" + paramGeoPosition.Latitude;
            locationPlace.Lon = "" + paramGeoPosition.Longitude;
            System.Collections.IEnumerator iterator = element.elementIterator();
            while (iterator.MoveNext())
            {
                Element element1 = (Element)iterator.Current;
                if (element1.Name.Equals("result"))
                {
                    locationPlace.Place_id     = element1.attributeValue("place_id");
                    locationPlace.Osm_type     = element1.attributeValue("osm_type");
                    locationPlace.Osm_id       = element1.attributeValue("osm_type");
                    locationPlace.Display_name = element1.StringValue;
                    continue;
                }
                if (element1.Name.Equals("addressparts"))
                {
                    System.Collections.IEnumerator iterator1 = element1.elementIterator();
                    while (iterator1.MoveNext())
                    {
                        Element element2 = (Element)iterator1.Current;
                        if (element2.Name.Equals("station"))
                        {
                            locationPlace.Station = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("road"))
                        {
                            locationPlace.Road = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("suburb"))
                        {
                            locationPlace.Suburb = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("village"))
                        {
                            locationPlace.Village = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("city"))
                        {
                            locationPlace.City = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("postcode"))
                        {
                            locationPlace.Postcode = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("country"))
                        {
                            locationPlace.Country = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("country_code"))
                        {
                            locationPlace.Country_code = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("county"))
                        {
                            locationPlace.County = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("state"))
                        {
                            locationPlace.State = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("hamlet"))
                        {
                            locationPlace.Hamlet = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("town"))
                        {
                            locationPlace.Town = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("residential"))
                        {
                            locationPlace.Residential = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("house"))
                        {
                            locationPlace.House = element2.StringValue;
                            continue;
                        }
                        if (element2.Name.Equals("place"))
                        {
                            locationPlace.Place = element2.StringValue;
                        }
                    }
                }
            }
            locationSearchResult.PlaceList.Add(locationPlace);
            return(locationSearchResult);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static LocationSearchResult search(String paramString, boolean paramBoolean) throws Exception
        public static LocationSearchResult search(string paramString, bool paramBoolean)
        {
            paramString = StringUtils.replaceAll(paramString, " ", "+");
            string str = StringUtils.replace("http://nominatim.openstreetmap.org/search?format=xml&q={A}&polygon={B}&addressdetails=1", "{A}", paramString);

            str = StringUtils.replace(str, "{B}", paramBoolean ? "1" : "0");
            URL           uRL           = new URL(str);
            URLConnection uRLConnection = uRL.openConnection();

            uRLConnection.setRequestProperty("User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
            uRLConnection.ConnectTimeout = 4000;
            uRLConnection.ReadTimeout    = 30000;
            Stream               inputStream          = uRLConnection.InputStream;
            SAXReader            sAXReader            = new SAXReader();
            Document             document             = sAXReader.read(inputStream);
            LocationSearchResult locationSearchResult = new LocationSearchResult();
            Element              element = document.RootElement;

            locationSearchResult.Query_string      = element.attributeValue("query_string");
            locationSearchResult.Polygon           = (new bool?(element.attributeValue("polygon")));
            locationSearchResult.Exclude_place_ids = element.attributeValue("exclude_place_ids");
            locationSearchResult.More_url          = element.attributeValue("more_url");
            locationSearchResult.Attribution       = element.attributeValue("attribution");
            locationSearchResult.PlaceList         = new List <object>();
            System.Collections.IEnumerator iterator = element.elementIterator();
            while (iterator.MoveNext())
            {
                Element       element1      = (Element)iterator.Current;
                LocationPlace locationPlace = new LocationPlace();
                locationPlace.Place_id     = element1.attributeValue("place_id");
                locationPlace.Osm_type     = element1.attributeValue("osm_type");
                locationPlace.Osm_id       = element1.attributeValue("osm_id");
                locationPlace.Lat          = element1.attributeValue("lat");
                locationPlace.Lon          = element1.attributeValue("lon");
                locationPlace.Place_class  = element1.attributeValue("class");
                locationPlace.Type         = element1.attributeValue("type");
                locationPlace.Display_name = element1.attributeValue("display_name");
                locationPlace.Icon         = element1.attributeValue("icon");
                locationPlace.Boundingbox  = element1.attributeValue("boundingbox");
                if (paramBoolean)
                {
                    locationPlace.calculatePolygonPoints(element1.attributeValue("polygonpoints"));
                }
                System.Collections.IEnumerator iterator1 = element1.elementIterator();
                while (iterator1.MoveNext())
                {
                    Element element2 = (Element)iterator1.Current;
                    if (element2.Name.Equals("station"))
                    {
                        locationPlace.Station = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("road"))
                    {
                        locationPlace.Road = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("suburb"))
                    {
                        locationPlace.Suburb = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("village"))
                    {
                        locationPlace.Village = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("city"))
                    {
                        locationPlace.City = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("postcode"))
                    {
                        locationPlace.Postcode = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("country"))
                    {
                        locationPlace.Country = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("country_code"))
                    {
                        locationPlace.Country_code = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("county"))
                    {
                        locationPlace.County = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("state"))
                    {
                        locationPlace.State = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("hamlet"))
                    {
                        locationPlace.Hamlet = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("town"))
                    {
                        locationPlace.Town = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("residential"))
                    {
                        locationPlace.Residential = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("house"))
                    {
                        locationPlace.House = element2.StringValue;
                        continue;
                    }
                    if (element2.Name.Equals("place"))
                    {
                        locationPlace.Place = element2.StringValue;
                    }
                }
                locationSearchResult.PlaceList.Add(locationPlace);
            }
            return(locationSearchResult);
        }
        /**
         * Determine if a host is reachable by attempting to resolve the host name, and then attempting to open a
         * connection.
         *
         * @param hostName Name of the host to connect to.
         *
         * @return {@code true} if a the host is reachable, {@code false} if the host name cannot be resolved, or if opening
         *         a connection to the host fails.
         */
        protected static bool isHostReachable(String hostName)
        {
            try
            {
                // Assume host is unreachable if we can't get its dns entry without getting an exception
                //noinspection ResultOfMethodCallIgnored
                InetAddress.getByName(hostName);
            }
            catch (UnknownHostException e)
            {
                String message = Logging.getMessage("NetworkStatus.UnreachableTestHost", hostName);
                Logging.logger().fine(message);
                return(false);
            }
            catch (Exception e)
            {
                String message = Logging.getMessage("NetworkStatus.ExceptionTestingHost", hostName);
                Logging.logger().info(message);
                return(false);
            }

            // Was able to get internet address, but host still might not be reachable because the address might have been
            // cached earlier when it was available. So need to try something else.

            URLConnection connection = null;

            try
            {
                URL   url   = new URL("http://" + hostName);
                Proxy proxy = WWIO.configureProxy();
                if (proxy != null)
                {
                    connection = url.openConnection(proxy);
                }
                else
                {
                    connection = url.openConnection();
                }

                connection.setConnectTimeout(2000);
                connection.setReadTimeout(2000);
                String ct = connection.getContentType();
                if (ct != null)
                {
                    return(true);
                }
            }
            catch (IOException e)
            {
                String message = Logging.getMessage("NetworkStatus.ExceptionTestingHost", hostName);
                Logging.logger().info(message);
            }
            finally
            {
                if (connection != null && connection is HttpURLConnection)
                {
                    ((HttpURLConnection)connection).disconnect();
                }
            }

            return(false);
        }
Example #30
0
        protected internal virtual Dictionary <string, string> executeSimpleUPnPcommand(string controlUrl, string serviceType, string action, Dictionary <string, string> arguments)
        {
            Dictionary <string, string> result = null;

            StringBuilder body = new StringBuilder();

            body.Append(string.Format("<?xml version=\"1.0\"?>\r\n"));
            body.Append(string.Format("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"));
            body.Append(string.Format("<s:Body>\r\n"));
            body.Append(string.Format("  <u:{0} xmlns:u=\"{1}\">\r\n", action, serviceType));
            if (arguments != null)
            {
                foreach (string name in arguments.Keys)
                {
                    string value = arguments[name];
                    if (string.ReferenceEquals(value, null) || value.Length == 0)
                    {
                        body.Append(string.Format("    <{0} />\r\n", name));
                    }
                    else
                    {
                        body.Append(string.Format("    <{0}>{1}</{2}>\r\n", name, value, name));
                    }
                }
            }
            body.Append(string.Format("  </u:{0}>\r\n", action));
            body.Append(string.Format("</s:Body>\r\n"));
            body.Append(string.Format("</s:Envelope>\r\n"));

            if (log.TraceEnabled)
            {
                log.trace(string.Format("Sending UPnP command: {0}", body.ToString()));
            }

            sbyte[] bodyBytes = body.ToString().GetBytes();

            try
            {
                URL           url        = new URL(controlUrl);
                URLConnection connection = url.openConnection();
                if (connection is HttpURLConnection)
                {
                    HttpURLConnection httpURLConnection = (HttpURLConnection)connection;
                    httpURLConnection.RequestMethod = "POST";
                }
                connection.setRequestProperty("SOAPAction", string.Format("{0}#{1}", serviceType, action));
                connection.setRequestProperty("Content-Type", "text/xml");
                connection.setRequestProperty("Content-Length", Convert.ToString(bodyBytes.Length));
                connection.DoOutput = true;
                System.IO.Stream output = connection.OutputStream;
                output.Write(bodyBytes, 0, bodyBytes.Length);
                output.Flush();
                output.Close();

                connection.connect();

                System.IO.Stream response = connection.InputStream;
                StringBuilder    content  = new StringBuilder();
                sbyte[]          buffer   = new sbyte[1024];
                int n;
                do
                {
                    n = response.Read(buffer, 0, buffer.Length);
                    if (n > 0)
                    {
                        content.Append(StringHelper.NewString(buffer, 0, n));
                    }
                } while (n >= 0);
                response.Close();

                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("UPnP command serviceType {0}, action {1}, result: {2}", serviceType, action, content.ToString()));
                }

                result = parseSimpleCommandResponse(content.ToString());

                //if (log.DebugEnabled)
                {
                    string errorCode = result["errorCode"];
                    if (!string.ReferenceEquals(errorCode, null))
                    {
                        Console.WriteLine(string.Format("UPnP command {0}: errorCode = {1}", action, errorCode));
                    }
                }
            }
            catch (MalformedURLException e)
            {
                Console.WriteLine("executeUPnPcommand", e);
            }
            catch (IOException e)
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine("executeUPnPcommand", e);
                }
            }

            return(result);
        }
Example #31
0
        /// <summary>
        /// Loads the content of a jar file that comply with a MaltParser Plugin
        /// </summary>
        /// <param name="jarUrl"> The URL to the jar file </param>
        /// <exception cref="PluginException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean readJarFile(java.net.URL jarUrl) throws org.maltparser.core.exception.MaltChainedException
        public virtual bool readJarFile(URL jarUrl)
        {
            JarInputStream jis;
            JarEntry       je;
            ISet <URL>     pluginXMLs = new Helper.HashSet <URL>();

            /*if (logger.isDebugEnabled()) {
             *      logger.debug("Loading jar " + jarUrl+"\n");
             * }*/
            JarFile jarFile;

            try
            {
                jarFile = new JarFile(jarUrl.File);
            }
            catch (IOException e)
            {
                throw new PluginException("Could not open jar file " + jarUrl + ". ", e);
            }
            try
            {
                Manifest manifest = jarFile.Manifest;
                if (manifest != null)
                {
                    Attributes manifestAttributes = manifest.MainAttributes;
                    if (!(manifestAttributes.getValue("MaltParser-Plugin") != null && manifestAttributes.getValue("MaltParser-Plugin").Equals("true")))
                    {
                        return(false);
                    }
                    if (manifestAttributes.getValue("Class-Path") != null)
                    {
                        string[] classPathItems = manifestAttributes.getValue("Class-Path").Split(" ");
                        for (int i = 0; i < classPathItems.Length; i++)
                        {
                            URL u;
                            try
                            {
                                u = new URL(jarUrl.Protocol + ":" + (new File(jarFile.Name)).ParentFile.Path + "/" + classPathItems[i]);
                            }
                            catch (MalformedURLException e)
                            {
                                throw new PluginException("The URL to the plugin jar-class-path '" + jarUrl.Protocol + ":" + (new File(jarFile.Name)).ParentFile.Path + "/" + classPathItems[i] + "' is wrong. ", e);
                            }
                            URLClassLoader sysloader            = (URLClassLoader)ClassLoader.SystemClassLoader;
                            Type           sysclass             = typeof(URLClassLoader);
                            System.Reflection.MethodInfo method = sysclass.getDeclaredMethod("addURL", new Type[] { typeof(URL) });
                            method.Accessible = true;
                            method.invoke(sysloader, new object[] { u });
                        }
                    }
                }
            }
            catch (PatternSyntaxException e)
            {
                throw new PluginException("Could not split jar-class-path entries in the jar-file '" + jarFile.Name + "'. ", e);
            }
            catch (IOException e)
            {
                throw new PluginException("Could not read the manifest file in the jar-file '" + jarFile.Name + "'. ", e);
            }
            catch (NoSuchMethodException e)
            {
                throw new PluginException("", e);
            }
            catch (IllegalAccessException e)
            {
                throw new PluginException("", e);
            }
            catch (InvocationTargetException e)
            {
                throw new PluginException("", e);
            }

            try
            {
                jis = new JarInputStream(jarUrl.openConnection().InputStream);

                while ((je = jis.NextJarEntry) != null)
                {
                    string jarName = je.Name;
                    if (jarName.EndsWith(".class", StringComparison.Ordinal))
                    {
                        /* if (logger.isDebugEnabled()) {
                         *      logger.debug("  Loading class: " + jarName+"\n");
                         * }*/
                        loadClassBytes(jis, jarName);
                        Type clazz = findClass(jarName.Substring(0, jarName.Length - 6));
                        classes[jarName.Substring(0, jarName.Length - 6).Replace('/', '.')] = clazz;
                        loadClass(jarName.Substring(0, jarName.Length - 6).Replace('/', '.'));
                    }
                    if (jarName.EndsWith("plugin.xml", StringComparison.Ordinal))
                    {
                        pluginXMLs.Add(new URL("jar:" + jarUrl.Protocol + ":" + jarUrl.Path + "!/" + jarName));
                    }
                    jis.closeEntry();
                }
                foreach (URL url in pluginXMLs)
                {
                    /* if (logger.isDebugEnabled()) {
                     *      logger.debug("  Loading "+url+"\n");
                     * }*/
                    OptionManager.instance().loadOptionDescriptionFile(url);
                }
            }
            catch (MalformedURLException e)
            {
                throw new PluginException("The URL to the plugin.xml is wrong. ", e);
            }
            catch (IOException e)
            {
                throw new PluginException("cannot open jar file " + jarUrl + ". ", e);
            }
            catch (ClassNotFoundException e)
            {
                throw new PluginException("The class " + e.Message + " can't be found. ", e);
            }
            return(true);
        }