Author: julien(a)jboss.com
Date: 2007-06-03 15:44:21 -0400 (Sun, 03 Jun 2007)
New Revision: 7379
Added:
trunk/common/src/main/org/jboss/portal/common/net/URLStreamOpeningThread.java
trunk/common/src/main/org/jboss/portal/common/net/URLTools.java
trunk/common/src/main/org/jboss/portal/test/common/net/
trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/net/URLToolsTestCase.java
Removed:
trunk/common/src/main/org/jboss/portal/common/util/URLStreamOpeningThread.java
trunk/common/src/main/org/jboss/portal/common/util/URLTools.java
trunk/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java
Modified:
trunk/common/build.xml
trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java
trunk/common/src/main/org/jboss/portal/common/util/CLResourceLoader.java
trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
trunk/jems/src/main/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java
trunk/portlet-server/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java
trunk/server/src/main/org/jboss/portal/server/deployment/jboss/ServerDeployer.java
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
move URL related utils to the
common.net package
Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml 2007-06-03 19:40:18 UTC (rev 7378)
+++ trunk/common/build.xml 2007-06-03 19:44:21 UTC (rev 7379)
@@ -210,6 +210,8 @@
</x-sysproperty>
<x-test>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.net.URLNavigatorTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.net.URLToolsTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.io.IOToolsTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.reflect.ReflectionTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.reflect.ModifierTestCase"/>
@@ -235,7 +237,6 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.common.HexTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.StringTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.JarTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.common.URLNavigatorTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.PathTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.JavaBeanModelMBeanBuilderTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.ParameterMapTestCase"/>
@@ -244,7 +245,6 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.common.BufferedStreamTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.CharBufferTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.CopyOnWriteRegistryTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.common.URLToolsTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.ToolsTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.IteratorStatusTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.PathMapperTestCase"/>
Modified: trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/common/src/main/org/jboss/portal/common/http/QueryStringParser.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.common.http;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import java.util.Collections;
import java.util.HashMap;
Copied: trunk/common/src/main/org/jboss/portal/common/net/URLStreamOpeningThread.java
(from rev 7378,
trunk/common/src/main/org/jboss/portal/common/util/URLStreamOpeningThread.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/URLStreamOpeningThread.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/net/URLStreamOpeningThread.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -0,0 +1,99 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package
org.jboss.portal.common.net;
+
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * A class that opens an InputStream to a URL in a thread so that it doesn't block
normal operations and can be timed
+ * out if needed.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4.2
+ */
+public class URLStreamOpeningThread extends Thread
+{
+
+ /** . */
+ private final URL url;
+
+ /** . */
+ private volatile InputStream inputStream;
+
+ /** Exception in the event a connection error occurs */
+ private volatile IOException exception;
+
+ public URLStreamOpeningThread(URL url)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(url, "URL");
+
+ //
+ this.url = url;
+ this.inputStream = null;
+ this.exception = null;
+ }
+
+ public void run()
+ {
+ try
+ {
+ InputStream in = url.openStream();
+ if (in == null)
+ {
+ throw new IllegalArgumentException("Cannot open stream from [" +
url + "]");
+ }
+
+ //
+ inputStream = in;
+ }
+ catch (IOException e)
+ {
+ exception = e;
+ }
+ }
+
+ public boolean isConnected()
+ {
+ return inputStream != null;
+ }
+
+ public boolean isError()
+ {
+ return exception != null;
+ }
+
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ public IOException getException()
+ {
+ return exception;
+ }
+}
Property changes on:
trunk/common/src/main/org/jboss/portal/common/net/URLStreamOpeningThread.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/net/URLTools.java (from rev 7374,
trunk/common/src/main/org/jboss/portal/common/util/URLTools.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/URLTools.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/net/URLTools.java 2007-06-03 19:44:21
UTC (rev 7379)
@@ -0,0 +1,430 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package
org.jboss.portal.common.net;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4 (May 26, 2006)
+ */
+public class URLTools
+{
+ public static final String RE_EMAIL_VALIDATION =
"^([a-zA-Z0-9]+(([\\.\\-\\_]?[a-zA-Z0-9]+)+)?)\\(a)(([a-zA-Z0-9]+[\\.\\-\\_])+[a-zA-Z]{2,4})$";
+ private static final Pattern LINK =
Pattern.compile("(?:href|action|src|location)\\s*=\\s*('|\")\\s*([^'\"]*)\\s*('|\")",
+ Pattern.CASE_INSENSITIVE);
+
+ public static final String HTTP_PREFIX = "http://";
+ public static final String HTTPS_PREFIX = "https://";
+ public static final String FTP_PREFIX = "ftp://";
+ public static final String FILE_PREFIX = "/";
+
+ public static boolean isURLAbsolute(String url)
+ {
+ return isNetworkURL(url) || url.startsWith(FILE_PREFIX);
+ }
+
+ /**
+ * Fetches content from an HTTP server performing a GET operation. If the status code
is 200
+ * then it will return a byte array of the body otherwise returns null. The timeout
values
+ * must not be negative integers, when it is equals to zero it means that it does not
setup
+ * a timeout and use the default values.
+ *
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
+ * @param connTimeoutMillis the connection timeout in millis
+ * @return
+ */
+ public static byte[] performGET(URL url, int soTimeoutMillis, int connTimeoutMillis)
throws IllegalArgumentException, IOException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (soTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative socket timeout");
+ }
+ if (connTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative connection timeout");
+ }
+ if ("http".equals(url.getProtocol()) ||
"https".equals(url.getProtocol()))
+ {
+ HttpClient client = new HttpClient();
+
+ // Yes deprecated but advocated way to do will not for with 2.0.2 which is what
today JBoss AS ships
+ if (connTimeoutMillis > 0)
+ {
+ client.setConnectionTimeout(connTimeoutMillis);
+ }
+ if (soTimeoutMillis > 0)
+ {
+ client.setTimeout(soTimeoutMillis);
+ }
+
+ //
+ HttpMethod method = null;
+ try
+ {
+ method = new GetMethod(url.toString());
+ int statusCode = client.executeMethod(method);
+ if (statusCode == 200)
+ {
+ return method.getResponseBody();
+ }
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.releaseConnection();
+ }
+ }
+ }
+ throw new IllegalArgumentException("Protocol " + url.getProtocol() +
" not accepted");
+ }
+
+ /**
+ * @param url
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isNetworkURL(String url)
+ {
+ if (url == null || url.length() == 0)
+ {
+ return false;
+ }
+
+ return url.startsWith(HTTP_PREFIX) || url.startsWith(HTTPS_PREFIX) ||
url.startsWith(FTP_PREFIX);
+ }
+
+ /**
+ * Enforces that the given URL is absolute
+ *
+ * @param url the String representation of the URL to be checked
+ * @throws IllegalArgumentException if the given URL is not absolute
+ */
+ public static void enforceAbsoluteURL(String url) throws IllegalArgumentException
+ {
+ if (!isURLAbsolute(url))
+ {
+ throw new IllegalArgumentException("URL must be absolute. Was: " +
url);
+ }
+ }
+
+ public static String encodeXWWWFormURL(String s)
+ {
+ try
+ {
+ return URLEncoder.encode(s, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Error("UTF-8 encoding missing");
+ }
+ }
+
+ public static String decodeXWWWFormURL(String s)
+ {
+ try
+ {
+ return URLDecoder.decode(s, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Error("UTF-8 encoding missing");
+ }
+ }
+
+ /** Return true is the address is not null and matches the email validation regular
expression. */
+ public static boolean isEmailValid(String address)
+ {
+ return address != null && Pattern.matches(RE_EMAIL_VALIDATION, address);
+ }
+
+ /**
+ * Determines that the specified URL corresponds to an existing resource by trying to
open a stream from it. Same as
+ * <code>exists(url, 1000)</code>
+ *
+ * @param url
+ * @return
+ */
+ public static boolean exists(URL url)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(url, "URL");
+
+ return exists(url, 1000);
+ }
+
+ /**
+ * Determines if the specified URL corresponds to an existing resource by trying to
open a stream from it. The
+ * connection attempt is made from a different thread on which we wait for the
specified amount of time before timing
+ * out.
+ *
+ * @param url the URL to be tested
+ * @param waitForMillis the number of milliseconds to wait before timing out, 0
meaning never timing out.
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean exists(URL url, long waitForMillis)
+ {
+ URLStreamOpeningThread thread = new URLStreamOpeningThread(url);
+ thread.start();
+
+ try
+ {
+ // Wait for the thread to finish but don't wait longer than the specified
time
+ thread.join(waitForMillis);
+
+ if (thread.isAlive())
+ {
+ // Timeout occurred; thread has not finished
+ throw new RuntimeException("Couldn't connect to " + url +
" within " + waitForMillis / 1000
+ + " seconds. Check your connection parameters or the URL.");
+ }
+ else
+ {
+ // Finished
+ return thread.isConnected() && !thread.isError();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ // Thread was interrupted
+ throw new RuntimeException("Connection thread to " + url + " was
interrupted!", e);
+ }
+ finally
+ {
+ IOTools.safeClose(thread.getInputStream());
+ }
+ }
+
+ /**
+ * @param urlAsString
+ * @param allowNull <code>true</code> if passing
<code>null</code> will be ignored and just return
+ * <code>false</code>, <code>false</code>
to throw an {@link IllegalArgumentException} is the
+ * given URL is <code>null</code>.
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean exists(String urlAsString, boolean allowNull)
+ {
+ if (!allowNull)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(urlAsString,
"URL", null);
+ }
+
+ try
+ {
+ URL url = new URL(urlAsString);
+ return exists(url);
+ }
+ catch (MalformedURLException e)
+ {
+ return false;
+ }
+ }
+
+ public static URLMatch[] extractURLsFrom(String markup)
+ {
+ // todo: will need to re-write without regex after 2.4
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int currentIndex = 0;
+ List links = new ArrayList();
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ links.add(new URLMatch(matcher.start(2), matcher.end(2), matcher.group(2)));
+ currentIndex = matcher.end();
+ }
+
+ return (URLMatch[])links.toArray(new URLMatch[0]);
+ }
+ throw new IllegalArgumentException("Cannot extract URLs from a null or empty
markup string!");
+ }
+
+ public static int getURLCountIn(String markup)
+ {
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int count = 0;
+ int currentIndex = 0;
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ count++;
+ currentIndex = matcher.end();
+ }
+ return count;
+ }
+ return 0;
+ }
+
+ public static String replaceURLsBy(String markup, final String[] replacements)
+ {
+ if (replacements == null || replacements.length == 0)
+ {
+ return markup;
+ }
+
+ int urlCount = getURLCountIn(markup);
+ if (replacements.length != urlCount)
+ {
+ throw new IllegalArgumentException("Trying to replace " + urlCount +
" URLs by " + replacements.length + " replacement(s).");
+ }
+
+ return replaceURLsBy(markup, new URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replacements[currentIndex];
+ }
+ });
+ }
+
+ public static String replaceURLsBy(String markup, URLReplacementGenerator generator)
+ {
+
+ URLMatch[] urls = extractURLsFrom(markup);
+ if (urls.length > 0)
+ {
+ StringBuffer newMarkup = new StringBuffer(markup.length());
+ int currentIndex = 0;
+ for (int i = 0; i < urls.length; i++)
+ {
+ URLMatch url = urls[i];
+ newMarkup.append(markup.substring(currentIndex,
url.getStart())).append(generator.getReplacementFor(i, url));
+ currentIndex = url.getEnd();
+ }
+ newMarkup.append(markup.substring(currentIndex));
+ markup = newMarkup.toString();
+ }
+ return markup;
+ }
+
+ public static class URLMatch
+ {
+ private int start;
+ private int end;
+ private String urlAsString;
+
+ private URLMatch(int start, int end, String urlAsString)
+ {
+ this.start = start;
+ this.end = end;
+ this.urlAsString = urlAsString;
+ }
+
+ public int getStart()
+ {
+ return start;
+ }
+
+ public int getEnd()
+ {
+ return end;
+ }
+
+ public String getURLAsString()
+ {
+ return urlAsString;
+ }
+ }
+
+ /** @since 2.4.2 */
+ public abstract static class URLReplacementGenerator
+ {
+ public abstract String getReplacementFor(int currentIndex, URLMatch currentMatch);
+ }
+
+ public static class PortReplacementGenerator extends URLReplacementGenerator
+ {
+ private int replacementPort;
+
+ public PortReplacementGenerator(int replacementPort)
+ {
+ this.replacementPort = replacementPort;
+ }
+
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replaceServerPortInURL(currentMatch.getURLAsString(), replacementPort);
+ }
+ }
+
+ /**
+ * @param url
+ * @param newPort
+ * @return
+ * @since 2.4.2
+ */
+ public static String replaceServerPortInURL(String url, int newPort)
+ {
+ if (!isNetworkURL(url))
+ {
+ return url;
+ }
+
+ StringBuffer buf = new StringBuffer(url);
+ int afterProtocol = url.indexOf("://") + 3;
+ int beforePort = url.indexOf(':', afterProtocol);
+ int afterPort;
+
+ if (beforePort != -1)
+ {
+ afterPort = url.indexOf('/', beforePort);
+ buf.delete(beforePort + 1, afterPort);
+ buf.insert(beforePort + 1, newPort);
+ }
+ else
+ {
+ // port number was not present
+ afterPort = url.indexOf('/', afterProtocol);
+ buf.insert(afterPort, ":" + newPort);
+ }
+
+ return buf.toString();
+ }
+
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/net/URLTools.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/common/src/main/org/jboss/portal/common/util/CLResourceLoader.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CLResourceLoader.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/common/src/main/org/jboss/portal/common/util/CLResourceLoader.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.common.util;
+import org.jboss.portal.common.net.URLTools;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Deleted: trunk/common/src/main/org/jboss/portal/common/util/URLStreamOpeningThread.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/util/URLStreamOpeningThread.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/common/src/main/org/jboss/portal/common/util/URLStreamOpeningThread.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -1,97 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.portal.common.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * A class that opens an InputStream to a URL in a thread so that it doesn't block
normal operations and can be timed
- * out if needed.
- *
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4.2
- */
-public class URLStreamOpeningThread extends Thread
-{
-
- /** . */
- private final URL url;
-
- /** . */
- private volatile InputStream inputStream;
-
- /** Exception in the event a connection error occurs */
- private volatile IOException exception;
-
- public URLStreamOpeningThread(URL url)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(url, "URL");
-
- //
- this.url = url;
- this.inputStream = null;
- this.exception = null;
- }
-
- public void run()
- {
- try
- {
- InputStream in = url.openStream();
- if (in == null)
- {
- throw new IllegalArgumentException("Cannot open stream from [" +
url + "]");
- }
-
- //
- inputStream = in;
- }
- catch (IOException e)
- {
- exception = e;
- }
- }
-
- public boolean isConnected()
- {
- return inputStream != null;
- }
-
- public boolean isError()
- {
- return exception != null;
- }
-
- public InputStream getInputStream()
- {
- return inputStream;
- }
-
- public IOException getException()
- {
- return exception;
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/URLTools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/URLTools.java 2007-06-03 19:40:18
UTC (rev 7378)
+++ trunk/common/src/main/org/jboss/portal/common/util/URLTools.java 2007-06-03 19:44:21
UTC (rev 7379)
@@ -1,429 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.util;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.portal.common.io.IOTools;
-
-import java.io.UnsupportedEncodingException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4 (May 26, 2006)
- */
-public class URLTools
-{
- public static final String RE_EMAIL_VALIDATION =
"^([a-zA-Z0-9]+(([\\.\\-\\_]?[a-zA-Z0-9]+)+)?)\\(a)(([a-zA-Z0-9]+[\\.\\-\\_])+[a-zA-Z]{2,4})$";
- private static final Pattern LINK =
Pattern.compile("(?:href|action|src|location)\\s*=\\s*('|\")\\s*([^'\"]*)\\s*('|\")",
- Pattern.CASE_INSENSITIVE);
-
- public static final String HTTP_PREFIX = "http://";
- public static final String HTTPS_PREFIX = "https://";
- public static final String FTP_PREFIX = "ftp://";
- public static final String FILE_PREFIX = "/";
-
- public static boolean isURLAbsolute(String url)
- {
- return isNetworkURL(url) || url.startsWith(FILE_PREFIX);
- }
-
- /**
- * Fetches content from an HTTP server performing a GET operation. If the status code
is 200
- * then it will return a byte array of the body otherwise returns null. The timeout
values
- * must not be negative integers, when it is equals to zero it means that it does not
setup
- * a timeout and use the default values.
- *
- * @param url the URL the URL of the resource
- * @param soTimeoutMillis the socket connection timeout in millis
- * @param connTimeoutMillis the connection timeout in millis
- * @return
- */
- public static byte[] performGET(URL url, int soTimeoutMillis, int connTimeoutMillis)
throws IllegalArgumentException, IOException
- {
- if (url == null)
- {
- throw new IllegalArgumentException();
- }
- if (soTimeoutMillis < 0)
- {
- throw new IllegalArgumentException("No negative socket timeout");
- }
- if (connTimeoutMillis < 0)
- {
- throw new IllegalArgumentException("No negative connection timeout");
- }
- if ("http".equals(url.getProtocol()) ||
"https".equals(url.getProtocol()))
- {
- HttpClient client = new HttpClient();
-
- // Yes deprecated but advocated way to do will not for with 2.0.2 which is what
today JBoss AS ships
- if (connTimeoutMillis > 0)
- {
- client.setConnectionTimeout(connTimeoutMillis);
- }
- if (soTimeoutMillis > 0)
- {
- client.setTimeout(soTimeoutMillis);
- }
-
- //
- HttpMethod method = null;
- try
- {
- method = new GetMethod(url.toString());
- int statusCode = client.executeMethod(method);
- if (statusCode == 200)
- {
- return method.getResponseBody();
- }
- }
- finally
- {
- if (method != null)
- {
- method.releaseConnection();
- }
- }
- }
- throw new IllegalArgumentException("Protocol " + url.getProtocol() +
" not accepted");
- }
-
- /**
- * @param url
- * @return
- * @since 2.4.2
- */
- public static boolean isNetworkURL(String url)
- {
- if (url == null || url.length() == 0)
- {
- return false;
- }
-
- return url.startsWith(HTTP_PREFIX) || url.startsWith(HTTPS_PREFIX) ||
url.startsWith(FTP_PREFIX);
- }
-
- /**
- * Enforces that the given URL is absolute
- *
- * @param url the String representation of the URL to be checked
- * @throws IllegalArgumentException if the given URL is not absolute
- */
- public static void enforceAbsoluteURL(String url) throws IllegalArgumentException
- {
- if (!isURLAbsolute(url))
- {
- throw new IllegalArgumentException("URL must be absolute. Was: " +
url);
- }
- }
-
- public static String encodeXWWWFormURL(String s)
- {
- try
- {
- return URLEncoder.encode(s, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new Error("UTF-8 encoding missing");
- }
- }
-
- public static String decodeXWWWFormURL(String s)
- {
- try
- {
- return URLDecoder.decode(s, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new Error("UTF-8 encoding missing");
- }
- }
-
- /** Return true is the address is not null and matches the email validation regular
expression. */
- public static boolean isEmailValid(String address)
- {
- return address != null && Pattern.matches(RE_EMAIL_VALIDATION, address);
- }
-
- /**
- * Determines that the specified URL corresponds to an existing resource by trying to
open a stream from it. Same as
- * <code>exists(url, 1000)</code>
- *
- * @param url
- * @return
- */
- public static boolean exists(URL url)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(url, "URL");
-
- return exists(url, 1000);
- }
-
- /**
- * Determines if the specified URL corresponds to an existing resource by trying to
open a stream from it. The
- * connection attempt is made from a different thread on which we wait for the
specified amount of time before timing
- * out.
- *
- * @param url the URL to be tested
- * @param waitForMillis the number of milliseconds to wait before timing out, 0
meaning never timing out.
- * @return
- * @since 2.4.2
- */
- public static boolean exists(URL url, long waitForMillis)
- {
- URLStreamOpeningThread thread = new URLStreamOpeningThread(url);
- thread.start();
-
- try
- {
- // Wait for the thread to finish but don't wait longer than the specified
time
- thread.join(waitForMillis);
-
- if (thread.isAlive())
- {
- // Timeout occurred; thread has not finished
- throw new RuntimeException("Couldn't connect to " + url +
" within " + waitForMillis / 1000
- + " seconds. Check your connection parameters or the URL.");
- }
- else
- {
- // Finished
- return thread.isConnected() && !thread.isError();
- }
- }
- catch (InterruptedException e)
- {
- // Thread was interrupted
- throw new RuntimeException("Connection thread to " + url + " was
interrupted!", e);
- }
- finally
- {
- IOTools.safeClose(thread.getInputStream());
- }
- }
-
- /**
- * @param urlAsString
- * @param allowNull <code>true</code> if passing
<code>null</code> will be ignored and just return
- * <code>false</code>, <code>false</code>
to throw an {@link IllegalArgumentException} is the
- * given URL is <code>null</code>.
- * @return
- * @since 2.4.2
- */
- public static boolean exists(String urlAsString, boolean allowNull)
- {
- if (!allowNull)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(urlAsString,
"URL", null);
- }
-
- try
- {
- URL url = new URL(urlAsString);
- return exists(url);
- }
- catch (MalformedURLException e)
- {
- return false;
- }
- }
-
- public static URLMatch[] extractURLsFrom(String markup)
- {
- // todo: will need to re-write without regex after 2.4
- int length;
- if (markup != null && (length = markup.length()) != 0)
- {
- Matcher matcher = LINK.matcher(markup);
- int currentIndex = 0;
- List links = new ArrayList();
- while (matcher.find(currentIndex) && currentIndex < length)
- {
- links.add(new URLMatch(matcher.start(2), matcher.end(2), matcher.group(2)));
- currentIndex = matcher.end();
- }
-
- return (URLMatch[])links.toArray(new URLMatch[0]);
- }
- throw new IllegalArgumentException("Cannot extract URLs from a null or empty
markup string!");
- }
-
- public static int getURLCountIn(String markup)
- {
- int length;
- if (markup != null && (length = markup.length()) != 0)
- {
- Matcher matcher = LINK.matcher(markup);
- int count = 0;
- int currentIndex = 0;
- while (matcher.find(currentIndex) && currentIndex < length)
- {
- count++;
- currentIndex = matcher.end();
- }
- return count;
- }
- return 0;
- }
-
- public static String replaceURLsBy(String markup, final String[] replacements)
- {
- if (replacements == null || replacements.length == 0)
- {
- return markup;
- }
-
- int urlCount = getURLCountIn(markup);
- if (replacements.length != urlCount)
- {
- throw new IllegalArgumentException("Trying to replace " + urlCount +
" URLs by " + replacements.length + " replacement(s).");
- }
-
- return replaceURLsBy(markup, new URLReplacementGenerator()
- {
- public String getReplacementFor(int currentIndex, URLMatch currentMatch)
- {
- return replacements[currentIndex];
- }
- });
- }
-
- public static String replaceURLsBy(String markup, URLReplacementGenerator generator)
- {
-
- URLMatch[] urls = extractURLsFrom(markup);
- if (urls.length > 0)
- {
- StringBuffer newMarkup = new StringBuffer(markup.length());
- int currentIndex = 0;
- for (int i = 0; i < urls.length; i++)
- {
- URLMatch url = urls[i];
- newMarkup.append(markup.substring(currentIndex,
url.getStart())).append(generator.getReplacementFor(i, url));
- currentIndex = url.getEnd();
- }
- newMarkup.append(markup.substring(currentIndex));
- markup = newMarkup.toString();
- }
- return markup;
- }
-
- public static class URLMatch
- {
- private int start;
- private int end;
- private String urlAsString;
-
- private URLMatch(int start, int end, String urlAsString)
- {
- this.start = start;
- this.end = end;
- this.urlAsString = urlAsString;
- }
-
- public int getStart()
- {
- return start;
- }
-
- public int getEnd()
- {
- return end;
- }
-
- public String getURLAsString()
- {
- return urlAsString;
- }
- }
-
- /** @since 2.4.2 */
- public abstract static class URLReplacementGenerator
- {
- public abstract String getReplacementFor(int currentIndex, URLMatch currentMatch);
- }
-
- public static class PortReplacementGenerator extends URLReplacementGenerator
- {
- private int replacementPort;
-
- public PortReplacementGenerator(int replacementPort)
- {
- this.replacementPort = replacementPort;
- }
-
- public String getReplacementFor(int currentIndex, URLMatch currentMatch)
- {
- return replaceServerPortInURL(currentMatch.getURLAsString(), replacementPort);
- }
- }
-
- /**
- * @param url
- * @param newPort
- * @return
- * @since 2.4.2
- */
- public static String replaceServerPortInURL(String url, int newPort)
- {
- if (!isNetworkURL(url))
- {
- return url;
- }
-
- StringBuffer buf = new StringBuffer(url);
- int afterProtocol = url.indexOf("://") + 3;
- int beforePort = url.indexOf(':', afterProtocol);
- int afterPort;
-
- if (beforePort != -1)
- {
- afterPort = url.indexOf('/', beforePort);
- buf.delete(beforePort + 1, afterPort);
- buf.insert(beforePort + 1, newPort);
- }
- else
- {
- // port number was not present
- afterPort = url.indexOf('/', afterProtocol);
- buf.insert(afterPort, ":" + newPort);
- }
-
- return buf.toString();
- }
-
-}
Deleted: trunk/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -1,322 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.common;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.jboss.portal.common.net.URLVisitor;
-import org.jboss.portal.common.net.URLNavigator;
-import org.jboss.portal.common.net.URLFilter;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class URLNavigatorTestCase extends TestCase
-{
-
- public URLNavigatorTestCase(String name)
- {
- super(name);
- }
-
- private List expectedAtoms1;
- private List expectedAtoms2;
- private List expectedAtoms3;
- private List expectedAtoms4;
- private List expectedAtoms5;
- private List expectedAtoms6;
- private List expectedAtoms7;
-
- private List expectedURLs1;
- private List expectedURLs2;
- private List expectedURLs3;
- private List expectedURLs4;
- private List expectedURLs5;
- private List expectedURLs6;
- private List expectedURLs7;
-
- private List filterValues1;
- private List filterValues2;
- private List filterValues3;
- private List filterValues4;
- private List filterValues5;
- private List filterValues6;
- private List filterValues7;
-
- protected void setUp() throws Exception
- {
- expectedAtoms1 = new ArrayList();
- expectedAtoms1.add("<b1>");
- expectedAtoms1.add("<c1>");
- expectedAtoms1.add("d1.txt");
- expectedAtoms1.add("</c1>");
- expectedAtoms1.add("c1.txt");
- expectedAtoms1.add("</b1>");
- expectedURLs1 = new ArrayList();
- expectedURLs1.add("/a1/b1/");
- expectedURLs1.add("/a1/b1/c1/");
- expectedURLs1.add("/a1/b1/c1/d1.txt");
- expectedURLs1.add("/a1/b1/c1/");
- expectedURLs1.add("/a1/b1/c1.txt");
- expectedURLs1.add("/a1/b1/");
- filterValues1 = new ArrayList();
- filterValues1.add(Boolean.TRUE);
- filterValues1.add(Boolean.TRUE);
-
- //
- expectedAtoms2 = new ArrayList();
- expectedAtoms2.add("<a1>");
- expectedAtoms2.add("<b1>");
- expectedAtoms2.add("<c1>");
- expectedAtoms2.add("d1.txt");
- expectedAtoms2.add("</c1>");
- expectedAtoms2.add("c1.txt");
- expectedAtoms2.add("</b1>");
- expectedAtoms2.add("<b1->");
- expectedAtoms2.add("</b1->");
- expectedAtoms2.add("b1.txt");
- expectedAtoms2.add("b2.txt");
- expectedAtoms2.add("</a1>");
- expectedURLs2 = new ArrayList();
- expectedURLs2.add("/a1/");
- expectedURLs2.add("/a1/b1/");
- expectedURLs2.add("/a1/b1/c1/");
- expectedURLs2.add("/a1/b1/c1/d1.txt");
- expectedURLs2.add("/a1/b1/c1/");
- expectedURLs2.add("/a1/b1/c1.txt");
- expectedURLs2.add("/a1/b1/");
- expectedURLs2.add("/a1/b1-/");
- expectedURLs2.add("/a1/b1-/");
- expectedURLs2.add("/a1/b1.txt");
- expectedURLs2.add("/a1/b2.txt");
- expectedURLs2.add("/a1/");
- filterValues2 = new ArrayList();
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
- filterValues2.add(Boolean.TRUE);
-
- //
- expectedAtoms3 = new ArrayList();
- expectedAtoms3.add("d1.txt");
- expectedURLs3 = new ArrayList();
- expectedURLs3.add("/a1/b1/c1/d1.txt");
- filterValues3 = new ArrayList();
-
- //
- expectedAtoms4 = new ArrayList();
- expectedAtoms4.add("<b1>");
- expectedAtoms4.add("c1.txt");
- expectedAtoms4.add("</b1>");
- expectedURLs4 = new ArrayList();
- expectedURLs4.add("/a1/b1/");
- expectedURLs4.add("/a1/b1/c1.txt");
- expectedURLs4.add("/a1/b1/");
- filterValues4 = new ArrayList();
- filterValues4.add(Boolean.TRUE);
- filterValues4.add(Boolean.FALSE);
-
- //
- expectedAtoms5 = new ArrayList();
- expectedURLs5 = new ArrayList();
- filterValues5 = new ArrayList();
- filterValues5.add(Boolean.FALSE);
-
- //
- expectedAtoms6 = new ArrayList();
- expectedAtoms6.add("<a1>");
- expectedAtoms6.add("<b1>");
- expectedAtoms6.add("c1.txt");
- expectedAtoms6.add("</b1>");
- expectedAtoms6.add("<b1->");
- expectedAtoms6.add("</b1->");
- expectedAtoms6.add("b1.txt");
- expectedAtoms6.add("b2.txt");
- expectedAtoms6.add("</a1>");
- expectedURLs6 = new ArrayList();
- expectedURLs6.add("/a1/");
- expectedURLs6.add("/a1/b1/");
- expectedURLs6.add("/a1/b1/c1.txt");
- expectedURLs6.add("/a1/b1/");
- expectedURLs6.add("/a1/b1-/");
- expectedURLs6.add("/a1/b1-/");
- expectedURLs6.add("/a1/b1.txt");
- expectedURLs6.add("/a1/b2.txt");
- expectedURLs6.add("/a1/");
- filterValues6 = new ArrayList();
- filterValues6.add(Boolean.TRUE);
- filterValues6.add(Boolean.TRUE);
- filterValues6.add(Boolean.FALSE);
- filterValues6.add(Boolean.TRUE);
-
- //
- expectedAtoms7 = new ArrayList();
- expectedAtoms7.add("<a1>");
- expectedAtoms7.add("<b1->");
- expectedAtoms7.add("</b1->");
- expectedAtoms7.add("b1.txt");
- expectedAtoms7.add("b2.txt");
- expectedAtoms7.add("</a1>");
- expectedURLs7 = new ArrayList();
- expectedURLs7.add("/a1/");
- expectedURLs7.add("/a1/b1-/");
- expectedURLs7.add("/a1/b1-/");
- expectedURLs7.add("/a1/b1.txt");
- expectedURLs7.add("/a1/b2.txt");
- expectedURLs7.add("/a1/");
- filterValues7 = new ArrayList();
- filterValues7.add(Boolean.TRUE);
- filterValues7.add(Boolean.FALSE);
- filterValues7.add(Boolean.TRUE);
- }
-
- protected void tearDown() throws Exception
- {
- }
-
- public void testJar() throws Exception
- {
- String libPath = System.getProperty("build.lib");
- assertNotNull(libPath);
- File libDir = new File(libPath);
- assertTrue(libDir.exists());
- assertTrue(libDir.isDirectory());
- File jarFile = new File(libDir, "test.jar");
- assertTrue(jarFile.exists());
- jarFile.deleteOnExit();
- assertFalse(jarFile.isDirectory());
-
- //
- URL jarURL1 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/b1/");
- doTest(jarURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
- doTest(jarURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
- doTest(jarURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
-
- //
- URL jarURL2 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/");
- doTest(jarURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
- doTest(jarURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
- doTest(jarURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
-
- //
- URL jarURL3 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/b1/c1/d1.txt");
- doTest(jarURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
- }
-
- public void testFile() throws Exception
- {
- String resourcePath = System.getProperty("build.resources");
- File resourcesDir = new File(resourcePath);
- assertTrue(resourcesDir.exists());
- assertTrue(resourcesDir.isDirectory());
-
- //
- File f1 = new File(resourcesDir, "test/test-jar/a1/b1/");
- assertTrue(f1.exists());
- assertTrue(f1.isDirectory());
- URL dirURL1 = f1.toURL();
- doTest(dirURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
- doTest(dirURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
- doTest(dirURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
-
- //
- File f2 = new File(resourcesDir, "test/test-jar/a1/");
- assertTrue(f2.exists());
- assertTrue(f2.isDirectory());
- URL dirURL2 = f2.toURL();
- doTest(dirURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
- doTest(dirURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
- doTest(dirURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
-
- //
- File f3 = new File(resourcesDir, "test/test-jar/a1/b1/c1/d1.txt");
- assertTrue(f3.exists());
- assertFalse(f3.isDirectory());
- URL dirURL3 = f3.toURL();
- doTest(dirURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
- }
-
- private void doTest(URL url, List expectedAtoms, List expectedURLs, final Iterator
filterBehavior) throws Exception
- {
- final List atoms = new ArrayList();
- final List urls = new ArrayList();
- URLNavigator.visit(url, new URLVisitor()
- {
- public void startDir(URL url, String name)
- {
- atoms.add("<" + name + ">");
- urls.add(url);
- }
- public void endDir(URL url, String name)
- {
- atoms.add("</" + name + ">");
- urls.add(url);
- }
- public void file(URL url, String name)
- {
- atoms.add(name);
- urls.add(url);
- }
- }, new URLFilter()
- {
- public boolean acceptFile(URL url)
- {
- throw new UnsupportedOperationException();
- }
- public boolean acceptDir(URL url)
- {
- return Boolean.TRUE.equals(filterBehavior.next());
- }
- });
-
- //
- if (urls.size() != expectedURLs.size())
- {
- fail("URLs size does not match " + urls.size() + "!=" +
expectedURLs.size());
- }
-
- //
- assertEquals(expectedAtoms, atoms);
-
- //
- for (int i = 0;i < urls.size();i++)
- {
- URL entryURL = (URL)urls.get(i);
- String suffix = (String)expectedURLs.get(i);
- if (!entryURL.getPath().endsWith(suffix))
- {
- fail("URL " + entryURL + " does not end with the suffix "
+ suffix + " at index " + i);
- }
- }
-
- //
- assertFalse(filterBehavior.hasNext());
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -1,172 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.common;
-
-import junit.framework.TestCase;
-import org.jboss.portal.common.util.URLTools;
-import org.apache.log4j.net.SocketServer;
-
-import java.net.URL;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4 (May 29, 2006)
- */
-public class URLToolsTestCase extends TestCase
-{
- private static final String MARKUP = "Hello, Anonymous!\n" +
- "Counter: 0<a
href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmc"
+
-
"uamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphd"
+
-
"mEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXI"
+
-
"AE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite'>My
name is Julien</a><a hr" +
-
"ef='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci"
+
-
"51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMW"
+
-
"YNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0cmluZz"
+
- "ut0lbn6R17RwIAAHhwAAAAAXQAA1JveXg*/wsrp_rewrite'>My name is
Roy</a><action='wsrp_rewrite?wsrp-urlType=bloc" +
-
"kingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQ"
+
-
"ZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQA"
+
-
"JdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK"
+
- "3g*/wsrp_rewrite'>counter++</a><a
href='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState" +
-
"=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvT"
+
-
"WFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAA"
+
-
"AAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAItLXg*/wsrp_rewrite'>counter--</a>";
-
- public void testExtractURLs()
- {
- String markup = MARKUP;
-
- URLTools.URLMatch[] links = URLTools.extractURLsFrom(markup);
- assertEquals(4, links.length);
- URLTools.URLMatch link = links[0];
-
assertEquals("wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNl"
+
-
"cnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQ"
+
-
"fawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0"
+
- "cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite",
link.getURLAsString());
-
assertEquals("wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9yd"
+
-
"GFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXN"
+
-
"oTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZ"
+
- "y5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK3g*/wsrp_rewrite",
links[2].getURLAsString());
-
- String url =
"wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite";
- markup = "12345href='" + url + "'76";
- links = URLTools.extractURLsFrom(markup);
- link = links[0];
- int startIndex = 11;
- assertEquals(startIndex, link.getStart());
- assertEquals(url.length() + startIndex, link.getEnd());
- assertEquals(url, markup.substring(link.getStart(), link.getEnd()));
- assertEquals(url, link.getURLAsString());
- }
-
- public void testReplaceURLs()
- {
- String markup = URLTools.replaceURLsBy(MARKUP, new String[]{"foo",
"bar", "baz", "buz"});
- String replaced = "Hello, Anonymous!\nCounter: 0<a href='foo'>My
name is Julien</a><a href='bar'>My name is Roy</a>" +
- "<action='baz'>counter++</a><a
href='buz'>counter--</a>";
- assertEquals(replaced, markup);
- assertEquals(replaced, URLTools.replaceURLsBy(replaced, (String[])null));
-
- String mixed = "<a
href='wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite'>My
name is Julien</a>" +
- "<a href='bar'>My name is Roy</a>";
- assertEquals("<a href='foo'>My name is Julien</a><a
href='bar'>My name is Roy</a>",
- URLTools.replaceURLsBy(mixed, new URLTools.URLReplacementGenerator()
- {
- public String getReplacementFor(int currentIndex, URLTools.URLMatch
currentMatch)
- {
- String urlAsString = currentMatch.getURLAsString();
- if (urlAsString.startsWith("wsrp_rewrite"))
- {
- return "foo";
- }
- return urlAsString;
- }
- }));
- }
-
- public void testReplaceAllPorts()
- {
- String original = "<wsdl:definitions
targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
- "
xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
- "
xmlns='http://schemas.xmlsoap.org/wsdl/'\n"
+
- "
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
- "
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
- "
xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
- "
xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
- " <import namespace='urn:oasis:names:tc:wsrp:v1:bind'
location='wsrp_v1_bindings.wsdl'/>\n" +
- " <wsdl:service name='WSRPService'>\n" +
- " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP'
name='WSRPBaseService'>\n" +
- " <soap:address
location='http://localhost/portal-wsrp/ServiceDescriptionService'/>\n" +
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP'
name='WSRPServiceDescriptionService'>\n" +
- " <soap:address
location='http://localhost/portal-wsrp/MarkupService'/>\n" +
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_Registration_Binding_SOAP'
name='WSRPRegistrationService'>\n" +
- " <soap:address
location='http://localhost/portal-wsrp/RegistrationService'/>\n" +
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_PortletManagement_Binding_SOAP'
name='WSRPPortletManagementService'>\n" +
- " <soap:address
location='http://localhost/portal-wsrp/PortletManagementService'/>\n" +
- " </wsdl:port>\n" +
- " </wsdl:service>\n" +
- "</wsdl:definitions>";
- String result = "<wsdl:definitions
targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
- "
xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
- "
xmlns='http://schemas.xmlsoap.org/wsdl/'\n"
+
- "
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
- "
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
- "
xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
- "
xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
- " <import namespace='urn:oasis:names:tc:wsrp:v1:bind'
location='wsrp_v1_bindings.wsdl'/>\n" +
- " <wsdl:service name='WSRPService'>\n" +
- " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP'
name='WSRPBaseService'>\n" +
- " <soap:address
location='http://localhost:8888/portal-wsrp/ServiceDescriptionService'/>\n"
+
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP'
name='WSRPServiceDescriptionService'>\n" +
- " <soap:address
location='http://localhost:8888/portal-wsrp/MarkupService'/>\n" +
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_Registration_Binding_SOAP'
name='WSRPRegistrationService'>\n" +
- " <soap:address
location='http://localhost:8888/portal-wsrp/RegistrationService'/>\n" +
- " </wsdl:port>\n" +
- " <wsdl:port
binding='bind:WSRP_v1_PortletManagement_Binding_SOAP'
name='WSRPPortletManagementService'>\n" +
- " <soap:address
location='http://localhost:8888/portal-wsrp/PortletManagementService'/>\n"
+
- " </wsdl:port>\n" +
- " </wsdl:service>\n" +
- "</wsdl:definitions>";
-
- assertEquals(result, URLTools.replaceURLsBy(original, new
URLTools.PortReplacementGenerator(8888)));
- }
-
- public void testReplaceServerPort()
- {
- assertEquals("http://hostname:8088/some/path",
URLTools.replaceServerPortInURL("http://hostname:8080/some/path", 8088));
- assertEquals("https://hostname:8088/some/path",
URLTools.replaceServerPortInURL("https://hostname:8080/some/path", 8088));
- assertEquals("http://hostname:8088/some/path",
URLTools.replaceServerPortInURL("http://hostname/some/path", 8088));
- assertEquals("https://hostname:8088/some/path",
URLTools.replaceServerPortInURL("https://hostname/some/path", 8088));
- }
-
- public void testExistsURL()
- {
- // todo: add more tests
- assertFalse(URLTools.exists(null, true));
- }
-}
Copied: trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
(from rev 7371,
trunk/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -0,0 +1,322 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package
org.jboss.portal.test.common.net;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLNavigator;
+import org.jboss.portal.common.net.URLFilter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class URLNavigatorTestCase extends TestCase
+{
+
+ public URLNavigatorTestCase(String name)
+ {
+ super(name);
+ }
+
+ private List expectedAtoms1;
+ private List expectedAtoms2;
+ private List expectedAtoms3;
+ private List expectedAtoms4;
+ private List expectedAtoms5;
+ private List expectedAtoms6;
+ private List expectedAtoms7;
+
+ private List expectedURLs1;
+ private List expectedURLs2;
+ private List expectedURLs3;
+ private List expectedURLs4;
+ private List expectedURLs5;
+ private List expectedURLs6;
+ private List expectedURLs7;
+
+ private List filterValues1;
+ private List filterValues2;
+ private List filterValues3;
+ private List filterValues4;
+ private List filterValues5;
+ private List filterValues6;
+ private List filterValues7;
+
+ protected void setUp() throws Exception
+ {
+ expectedAtoms1 = new ArrayList();
+ expectedAtoms1.add("<b1>");
+ expectedAtoms1.add("<c1>");
+ expectedAtoms1.add("d1.txt");
+ expectedAtoms1.add("</c1>");
+ expectedAtoms1.add("c1.txt");
+ expectedAtoms1.add("</b1>");
+ expectedURLs1 = new ArrayList();
+ expectedURLs1.add("/a1/b1/");
+ expectedURLs1.add("/a1/b1/c1/");
+ expectedURLs1.add("/a1/b1/c1/d1.txt");
+ expectedURLs1.add("/a1/b1/c1/");
+ expectedURLs1.add("/a1/b1/c1.txt");
+ expectedURLs1.add("/a1/b1/");
+ filterValues1 = new ArrayList();
+ filterValues1.add(Boolean.TRUE);
+ filterValues1.add(Boolean.TRUE);
+
+ //
+ expectedAtoms2 = new ArrayList();
+ expectedAtoms2.add("<a1>");
+ expectedAtoms2.add("<b1>");
+ expectedAtoms2.add("<c1>");
+ expectedAtoms2.add("d1.txt");
+ expectedAtoms2.add("</c1>");
+ expectedAtoms2.add("c1.txt");
+ expectedAtoms2.add("</b1>");
+ expectedAtoms2.add("<b1->");
+ expectedAtoms2.add("</b1->");
+ expectedAtoms2.add("b1.txt");
+ expectedAtoms2.add("b2.txt");
+ expectedAtoms2.add("</a1>");
+ expectedURLs2 = new ArrayList();
+ expectedURLs2.add("/a1/");
+ expectedURLs2.add("/a1/b1/");
+ expectedURLs2.add("/a1/b1/c1/");
+ expectedURLs2.add("/a1/b1/c1/d1.txt");
+ expectedURLs2.add("/a1/b1/c1/");
+ expectedURLs2.add("/a1/b1/c1.txt");
+ expectedURLs2.add("/a1/b1/");
+ expectedURLs2.add("/a1/b1-/");
+ expectedURLs2.add("/a1/b1-/");
+ expectedURLs2.add("/a1/b1.txt");
+ expectedURLs2.add("/a1/b2.txt");
+ expectedURLs2.add("/a1/");
+ filterValues2 = new ArrayList();
+ filterValues2.add(Boolean.TRUE);
+ filterValues2.add(Boolean.TRUE);
+ filterValues2.add(Boolean.TRUE);
+ filterValues2.add(Boolean.TRUE);
+
+ //
+ expectedAtoms3 = new ArrayList();
+ expectedAtoms3.add("d1.txt");
+ expectedURLs3 = new ArrayList();
+ expectedURLs3.add("/a1/b1/c1/d1.txt");
+ filterValues3 = new ArrayList();
+
+ //
+ expectedAtoms4 = new ArrayList();
+ expectedAtoms4.add("<b1>");
+ expectedAtoms4.add("c1.txt");
+ expectedAtoms4.add("</b1>");
+ expectedURLs4 = new ArrayList();
+ expectedURLs4.add("/a1/b1/");
+ expectedURLs4.add("/a1/b1/c1.txt");
+ expectedURLs4.add("/a1/b1/");
+ filterValues4 = new ArrayList();
+ filterValues4.add(Boolean.TRUE);
+ filterValues4.add(Boolean.FALSE);
+
+ //
+ expectedAtoms5 = new ArrayList();
+ expectedURLs5 = new ArrayList();
+ filterValues5 = new ArrayList();
+ filterValues5.add(Boolean.FALSE);
+
+ //
+ expectedAtoms6 = new ArrayList();
+ expectedAtoms6.add("<a1>");
+ expectedAtoms6.add("<b1>");
+ expectedAtoms6.add("c1.txt");
+ expectedAtoms6.add("</b1>");
+ expectedAtoms6.add("<b1->");
+ expectedAtoms6.add("</b1->");
+ expectedAtoms6.add("b1.txt");
+ expectedAtoms6.add("b2.txt");
+ expectedAtoms6.add("</a1>");
+ expectedURLs6 = new ArrayList();
+ expectedURLs6.add("/a1/");
+ expectedURLs6.add("/a1/b1/");
+ expectedURLs6.add("/a1/b1/c1.txt");
+ expectedURLs6.add("/a1/b1/");
+ expectedURLs6.add("/a1/b1-/");
+ expectedURLs6.add("/a1/b1-/");
+ expectedURLs6.add("/a1/b1.txt");
+ expectedURLs6.add("/a1/b2.txt");
+ expectedURLs6.add("/a1/");
+ filterValues6 = new ArrayList();
+ filterValues6.add(Boolean.TRUE);
+ filterValues6.add(Boolean.TRUE);
+ filterValues6.add(Boolean.FALSE);
+ filterValues6.add(Boolean.TRUE);
+
+ //
+ expectedAtoms7 = new ArrayList();
+ expectedAtoms7.add("<a1>");
+ expectedAtoms7.add("<b1->");
+ expectedAtoms7.add("</b1->");
+ expectedAtoms7.add("b1.txt");
+ expectedAtoms7.add("b2.txt");
+ expectedAtoms7.add("</a1>");
+ expectedURLs7 = new ArrayList();
+ expectedURLs7.add("/a1/");
+ expectedURLs7.add("/a1/b1-/");
+ expectedURLs7.add("/a1/b1-/");
+ expectedURLs7.add("/a1/b1.txt");
+ expectedURLs7.add("/a1/b2.txt");
+ expectedURLs7.add("/a1/");
+ filterValues7 = new ArrayList();
+ filterValues7.add(Boolean.TRUE);
+ filterValues7.add(Boolean.FALSE);
+ filterValues7.add(Boolean.TRUE);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ }
+
+ public void testJar() throws Exception
+ {
+ String libPath = System.getProperty("build.lib");
+ assertNotNull(libPath);
+ File libDir = new File(libPath);
+ assertTrue(libDir.exists());
+ assertTrue(libDir.isDirectory());
+ File jarFile = new File(libDir, "test.jar");
+ assertTrue(jarFile.exists());
+ jarFile.deleteOnExit();
+ assertFalse(jarFile.isDirectory());
+
+ //
+ URL jarURL1 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/b1/");
+ doTest(jarURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
+ doTest(jarURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
+ doTest(jarURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
+
+ //
+ URL jarURL2 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/");
+ doTest(jarURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
+ doTest(jarURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
+ doTest(jarURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
+
+ //
+ URL jarURL3 = new URL("jar", "", jarFile.toURL() +
"!" + "/a1/b1/c1/d1.txt");
+ doTest(jarURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
+ }
+
+ public void testFile() throws Exception
+ {
+ String resourcePath = System.getProperty("build.resources");
+ File resourcesDir = new File(resourcePath);
+ assertTrue(resourcesDir.exists());
+ assertTrue(resourcesDir.isDirectory());
+
+ //
+ File f1 = new File(resourcesDir, "test/test-jar/a1/b1/");
+ assertTrue(f1.exists());
+ assertTrue(f1.isDirectory());
+ URL dirURL1 = f1.toURL();
+ doTest(dirURL1, expectedAtoms1, expectedURLs1, filterValues1.iterator());
+ doTest(dirURL1, expectedAtoms4, expectedURLs4, filterValues4.iterator());
+ doTest(dirURL1, expectedAtoms5, expectedURLs5, filterValues5.iterator());
+
+ //
+ File f2 = new File(resourcesDir, "test/test-jar/a1/");
+ assertTrue(f2.exists());
+ assertTrue(f2.isDirectory());
+ URL dirURL2 = f2.toURL();
+ doTest(dirURL2, expectedAtoms2, expectedURLs2, filterValues2.iterator());
+ doTest(dirURL2, expectedAtoms6, expectedURLs6, filterValues6.iterator());
+ doTest(dirURL2, expectedAtoms7, expectedURLs7, filterValues7.iterator());
+
+ //
+ File f3 = new File(resourcesDir, "test/test-jar/a1/b1/c1/d1.txt");
+ assertTrue(f3.exists());
+ assertFalse(f3.isDirectory());
+ URL dirURL3 = f3.toURL();
+ doTest(dirURL3, expectedAtoms3, expectedURLs3, filterValues3.iterator());
+ }
+
+ private void doTest(URL url, List expectedAtoms, List expectedURLs, final Iterator
filterBehavior) throws Exception
+ {
+ final List atoms = new ArrayList();
+ final List urls = new ArrayList();
+ URLNavigator.visit(url, new URLVisitor()
+ {
+ public void startDir(URL url, String name)
+ {
+ atoms.add("<" + name + ">");
+ urls.add(url);
+ }
+ public void endDir(URL url, String name)
+ {
+ atoms.add("</" + name + ">");
+ urls.add(url);
+ }
+ public void file(URL url, String name)
+ {
+ atoms.add(name);
+ urls.add(url);
+ }
+ }, new URLFilter()
+ {
+ public boolean acceptFile(URL url)
+ {
+ throw new UnsupportedOperationException();
+ }
+ public boolean acceptDir(URL url)
+ {
+ return Boolean.TRUE.equals(filterBehavior.next());
+ }
+ });
+
+ //
+ if (urls.size() != expectedURLs.size())
+ {
+ fail("URLs size does not match " + urls.size() + "!=" +
expectedURLs.size());
+ }
+
+ //
+ assertEquals(expectedAtoms, atoms);
+
+ //
+ for (int i = 0;i < urls.size();i++)
+ {
+ URL entryURL = (URL)urls.get(i);
+ String suffix = (String)expectedURLs.get(i);
+ if (!entryURL.getPath().endsWith(suffix))
+ {
+ fail("URL " + entryURL + " does not end with the suffix "
+ suffix + " at index " + i);
+ }
+ }
+
+ //
+ assertFalse(filterBehavior.hasNext());
+ }
+}
Property changes on:
trunk/common/src/main/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/test/common/net/URLToolsTestCase.java (from
rev 7371, trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/net/URLToolsTestCase.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/test/common/net/URLToolsTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -0,0 +1,169 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package
org.jboss.portal.test.common.net;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.net.URLTools;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4 (May 29, 2006)
+ */
+public class URLToolsTestCase extends TestCase
+{
+ private static final String MARKUP = "Hello, Anonymous!\n" +
+ "Counter: 0<a
href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmc"
+
+
"uamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphd"
+
+
"mEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXI"
+
+
"AE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite'>My
name is Julien</a><a hr" +
+
"ef='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci"
+
+
"51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMW"
+
+
"YNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0cmluZz"
+
+ "ut0lbn6R17RwIAAHhwAAAAAXQAA1JveXg*/wsrp_rewrite'>My name is
Roy</a><action='wsrp_rewrite?wsrp-urlType=bloc" +
+
"kingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQ"
+
+
"ZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQA"
+
+
"JdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK"
+
+ "3g*/wsrp_rewrite'>counter++</a><a
href='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState" +
+
"=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvT"
+
+
"WFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAA"
+
+
"AAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAItLXg*/wsrp_rewrite'>counter--</a>";
+
+ public void testExtractURLs()
+ {
+ String markup = MARKUP;
+
+ URLTools.URLMatch[] links = URLTools.extractURLsFrom(markup);
+ assertEquals(4, links.length);
+ URLTools.URLMatch link = links[0];
+
assertEquals("wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNl"
+
+
"cnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQ"
+
+
"fawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0"
+
+ "cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite",
link.getURLAsString());
+
assertEquals("wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9yd"
+
+
"GFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXN"
+
+
"oTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZ"
+
+ "y5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK3g*/wsrp_rewrite",
links[2].getURLAsString());
+
+ String url =
"wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite";
+ markup = "12345href='" + url + "'76";
+ links = URLTools.extractURLsFrom(markup);
+ link = links[0];
+ int startIndex = 11;
+ assertEquals(startIndex, link.getStart());
+ assertEquals(url.length() + startIndex, link.getEnd());
+ assertEquals(url, markup.substring(link.getStart(), link.getEnd()));
+ assertEquals(url, link.getURLAsString());
+ }
+
+ public void testReplaceURLs()
+ {
+ String markup = URLTools.replaceURLsBy(MARKUP, new String[]{"foo",
"bar", "baz", "buz"});
+ String replaced = "Hello, Anonymous!\nCounter: 0<a href='foo'>My
name is Julien</a><a href='bar'>My name is Roy</a>" +
+ "<action='baz'>counter++</a><a
href='buz'>counter--</a>";
+ assertEquals(replaced, markup);
+ assertEquals(replaced, URLTools.replaceURLsBy(replaced, (String[])null));
+
+ String mixed = "<a
href='wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite'>My
name is Julien</a>" +
+ "<a href='bar'>My name is Roy</a>";
+ assertEquals("<a href='foo'>My name is Julien</a><a
href='bar'>My name is Roy</a>",
+ URLTools.replaceURLsBy(mixed, new URLTools.URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLTools.URLMatch
currentMatch)
+ {
+ String urlAsString = currentMatch.getURLAsString();
+ if (urlAsString.startsWith("wsrp_rewrite"))
+ {
+ return "foo";
+ }
+ return urlAsString;
+ }
+ }));
+ }
+
+ public void testReplaceAllPorts()
+ {
+ String original = "<wsdl:definitions
targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ "
xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ "
xmlns='http://schemas.xmlsoap.org/wsdl/'\n"
+
+ "
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ "
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ "
xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ "
xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind'
location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP'
name='WSRPBaseService'>\n" +
+ " <soap:address
location='http://localhost/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP'
name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address
location='http://localhost/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_Registration_Binding_SOAP'
name='WSRPRegistrationService'>\n" +
+ " <soap:address
location='http://localhost/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_PortletManagement_Binding_SOAP'
name='WSRPPortletManagementService'>\n" +
+ " <soap:address
location='http://localhost/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+ String result = "<wsdl:definitions
targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ "
xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ "
xmlns='http://schemas.xmlsoap.org/wsdl/'\n"
+
+ "
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ "
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ "
xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ "
xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind'
location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP'
name='WSRPBaseService'>\n" +
+ " <soap:address
location='http://localhost:8888/portal-wsrp/ServiceDescriptionService'/>\n"
+
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP'
name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address
location='http://localhost:8888/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_Registration_Binding_SOAP'
name='WSRPRegistrationService'>\n" +
+ " <soap:address
location='http://localhost:8888/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port
binding='bind:WSRP_v1_PortletManagement_Binding_SOAP'
name='WSRPPortletManagementService'>\n" +
+ " <soap:address
location='http://localhost:8888/portal-wsrp/PortletManagementService'/>\n"
+
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+
+ assertEquals(result, URLTools.replaceURLsBy(original, new
URLTools.PortReplacementGenerator(8888)));
+ }
+
+ public void testReplaceServerPort()
+ {
+ assertEquals("http://hostname:8088/some/path",
URLTools.replaceServerPortInURL("http://hostname:8080/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path",
URLTools.replaceServerPortInURL("https://hostname:8080/some/path", 8088));
+ assertEquals("http://hostname:8088/some/path",
URLTools.replaceServerPortInURL("http://hostname/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path",
URLTools.replaceServerPortInURL("https://hostname/some/path", 8088));
+ }
+
+ public void testExistsURL()
+ {
+ // todo: add more tests
+ assertFalse(URLTools.exists(null, true));
+ }
+}
Property changes on:
trunk/common/src/main/org/jboss/portal/test/common/net/URLToolsTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -30,7 +30,6 @@
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@@ -56,7 +55,7 @@
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.common.p3p.P3PConstants;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.common.i18n.LocaleFormat;
import org.jboss.portal.common.i18n.LocaleManager;
Modified:
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,7 +24,7 @@
package org.jboss.portal.test.core.deployment;
import junit.framework.TestCase;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.core.deployment.JBossApplicationMetaDataFactory;
import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-06-03 19:40:18 UTC
(rev 7378)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-06-03 19:44:21 UTC
(rev 7379)
@@ -25,7 +25,7 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.api.PortalRuntimeContext;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.portlet.SignOutResponse;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
Modified: trunk/jems/src/main/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java
===================================================================
---
trunk/jems/src/main/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/jems/src/main/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -35,7 +35,7 @@
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.jboss.portal.common.util.CLResourceLoader;
import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.jems.as.system.AbstractJBossService;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,7 +24,7 @@
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.invocation.ActionInvocation;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.impl.spi;
import org.jboss.portal.common.invocation.AbstractInvocationContext;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.StateString;
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/deployment/UnmarshallerTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,8 +24,7 @@
import junit.framework.TestCase;
import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.common.util.CollectionBuilder;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.portlet.TransportGuarantee;
import org.jboss.portal.portlet.deployment.JBossApplicationMetaDataFactory;
import org.jboss.portal.portlet.deployment.PortletApplicationMetaDataFactory;
@@ -37,7 +36,6 @@
import org.jboss.portal.portlet.impl.jsr168.metadata.UserAttributeMetaData;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import org.jboss.portal.portlet.metadata.PolicyPermissionMetaData;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
Modified:
trunk/portlet-server/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
---
trunk/portlet-server/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/portlet-server/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -31,7 +31,7 @@
import org.jboss.portal.common.invocation.Scope;
import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.PortletParameters;
Modified:
trunk/server/src/main/org/jboss/portal/server/deployment/jboss/ServerDeployer.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/deployment/jboss/ServerDeployer.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/server/src/main/org/jboss/portal/server/deployment/jboss/ServerDeployer.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -27,7 +27,7 @@
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployerSupport;
import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.net.URLFilter;
import org.jboss.portal.server.Server;
import org.jboss.portal.server.deployment.PortalWebApp;
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -28,7 +28,7 @@
import org.jboss.portal.common.invocation.InterceptorStackFactory;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.RequestControllerDispatcher;
Modified:
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
===================================================================
---
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget.google.provider;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.HTML;
Modified:
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
===================================================================
---
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.concurrent.loader.ObjectLoader;
import org.jboss.portal.widget.google.type.DataType;
import org.jboss.portal.widget.google.type.StringType;
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,7 +24,7 @@
package org.jboss.portal.test.wsrp.consumer;
import junit.framework.TestCase;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.wsrp.consumer.RenderHandler;
/**
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2007-06-03 19:40:18 UTC
(rev 7378)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2007-06-03 19:44:21 UTC
(rev 7379)
@@ -27,7 +27,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import javax.activation.MimeTypeParseException;
import java.net.MalformedURLException;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-06-03
19:40:18 UTC (rev 7378)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -24,7 +24,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -25,7 +25,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.invocation.EmptyAttributeResolver;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp.producer.config.impl;
-import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.net.URLTools;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerConfigurationFactory;
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-06-03
19:40:18 UTC (rev 7378)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-06-03
19:44:21 UTC (rev 7379)
@@ -25,7 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.common.util.URLStreamOpeningThread;
+import org.jboss.portal.common.net.URLStreamOpeningThread;
import org.jboss.portal.common.io.IOTools;
import org.xml.sax.InputSource;