You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/07/31 16:14:06 UTC

svn commit: r427122 - /lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java

Author: andreas
Date: Mon Jul 31 07:14:05 2006
New Revision: 427122

URL: http://svn.apache.org/viewvc?rev=427122&view=rev
Log:
SiteUtil: check if URL points to a document before trying to resolve the locator

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java?rev=427122&r1=427121&r2=427122&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java Mon Jul 31 07:14:05 2006
@@ -554,8 +554,33 @@
     
     public static boolean isDocument(ServiceManager manager, DocumentFactory factory,
             String webappUrl) throws SiteException {
-        DocumentLocator locator = getLocator(manager, webappUrl);
-        return contains(manager, factory, locator);
+        
+        URLInformation info = new URLInformation(webappUrl);
+        DocumentBuilder builder = null;
+        ServiceSelector selector = null;
+        try {
+            Publication pub = PublicationUtil.getPublication(manager, info.getPublicationId());
+            selector = (ServiceSelector) manager.lookup(DocumentBuilder.ROLE + "Selector");
+            builder = (DocumentBuilder) selector.select(pub.getDocumentBuilderHint());
+            if (builder.isDocument(webappUrl)) {
+                DocumentLocator locator = builder.getLocator(webappUrl);
+                return contains(manager, factory, locator);
+            }
+            else {
+                return false;
+            }
+        } catch (SiteException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SiteException(e);
+        } finally {
+            if (selector != null) {
+                if (builder != null) {
+                    selector.release(builder);
+                }
+                manager.release(selector);
+            }
+        }
     }
 
     public static Document getDocument(ServiceManager manager, DocumentFactory factory,



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org