Author: adrianc
Date: Thu Oct 24 02:44:45 2013
New Revision: 1535268

URL: http://svn.apache.org/r1535268
Log:
Added a helpful method to WebAppUtil.java.

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/WebAppUtil.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/WebAppUtil.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/WebAppUtil.java?rev=1535268&r1=1535267&r2=1535268&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/WebAppUtil.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/WebAppUtil.java Thu Oct 
24 02:44:45 2013
@@ -29,6 +29,7 @@ import org.apache.catalina.deploy.WebXml
 import org.apache.catalina.startup.DigesterFactory;
 import org.apache.catalina.startup.WebRuleSet;
 import org.apache.tomcat.util.digester.Digester;
+import org.ofbiz.base.component.ComponentConfig;
 import org.ofbiz.base.component.ComponentConfig.WebappInfo;
 import org.ofbiz.base.util.Assert;
 import org.ofbiz.base.util.Debug;
@@ -86,6 +87,24 @@ public final class WebAppUtil {
     }
 
     /**
+     * Returns the <code>WebappInfo</code> instance associated to the 
specified web site ID.
+     * Throws <code>IllegalArgumentException</code> if the web site ID was not 
found.
+     * 
+     * @param webSiteId
+     * @throws IOException
+     * @throws SAXException
+     */
+    public static WebappInfo getWebappInfoFromWebsiteId(String webSiteId) 
throws IOException, SAXException {
+        Assert.notNull("webSiteId", webSiteId);
+        for (WebappInfo webAppInfo : 
ComponentConfig.getAllWebappResourceInfos()) {
+            if (webSiteId.equals(WebAppUtil.getWebSiteId(webAppInfo))) {
+                return webAppInfo;
+            }
+        }
+        throw new IllegalArgumentException("Web site ID '" + webSiteId + "' 
not found.");
+    }
+
+    /**
      * Returns the web site ID - as configured in the web application's 
<code>web.xml</code> file,
      * or <code>null</code> if no web site ID was found.
      * 


Reply via email to