cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r446958 - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms: DefaultFormManager.java FormsException.java
Date Sat, 16 Sep 2006 21:38:13 GMT
Author: vgritsenko
Date: Sat Sep 16 14:38:12 2006
New Revision: 446958

URL: http://svn.apache.org/viewvc?view=rev&rev=446958
Log:
Add located forms exception. Use in form manager.

Added:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/DefaultFormManager.java

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/DefaultFormManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/DefaultFormManager.java?view=diff&rev=446958&r1=446957&r2=446958
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/DefaultFormManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/DefaultFormManager.java
Sat Sep 16 14:38:12 2006
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms;
 
-import org.apache.avalon.framework.CascadingException;
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.component.Component;
@@ -42,6 +41,7 @@
 import org.apache.cocoon.forms.formmodel.library.LibraryManagerImpl;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.forms.util.SimpleServiceSelector;
+import org.apache.cocoon.util.location.LocationImpl;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -131,8 +131,13 @@
         SourceResolver resolver = null;
         Source source = null;
         try {
-            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
-            source = resolver.resolveURI(uri);
+            try {
+                resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+                source = resolver.resolveURI(uri);
+            } catch (Exception e) {
+                throw new FormsException("Could not resolve form definition URI.",
+                                         e, new LocationImpl("[FormManager]", uri));
+            }
             return createForm(source);
         } finally {
             if (source != null) {
@@ -161,8 +166,13 @@
         SourceResolver sourceResolver = null;
         Source source = null;
         try {
-            sourceResolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
-            source = sourceResolver.resolveURI(uri);
+            try {
+                sourceResolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+                source = sourceResolver.resolveURI(uri);
+            } catch (Exception e) {
+                throw new FormsException("Could not resolve form definition.",
+                                         e, new LocationImpl("[FormManager]", uri));
+            }
             return createFormDefinition(source);
         } finally {
             if (source != null) {
@@ -191,8 +201,8 @@
                 inputSource.setSystemId(source.getURI());
                 formDocument = DomHelper.parse(inputSource, this.manager);
             } catch (Exception e) {
-                throw new CascadingException("Could not parse form definition from " +
-                                             source.getURI(), e);
+                throw new FormsException("Could not parse form definition.",
+                                         e, new LocationImpl("[FormManager]", source.getURI()));
             }
 
             Element formElement = formDocument.getDocumentElement();
@@ -205,7 +215,8 @@
     public FormDefinition createFormDefinition(Element formElement) throws Exception {
         // check that the root element is a fd:form element
         if (!FormsConstants.DEFINITION_NS.equals(formElement.getNamespaceURI()) || !formElement.getLocalName().equals("form"))
{
-            throw new Exception("Expected a Cocoon Forms form element at " + DomHelper.getLocation(formElement));
+            throw new FormsException("Expected forms definition <fd:form> element.",
+                                     DomHelper.getLocationObject(formElement));
         }
 
         FormDefinitionBuilder builder = (FormDefinitionBuilder) widgetDefinitionBuilderSelector.select("form");

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java?view=auto&rev=446958
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
Sat Sep 16 14:38:12 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.util.location.Location;
+
+/**
+ * An exception raised when an error occurs during form handling. This is a
+ * located exception, which points to the relevant element declaration.
+ *
+ * @version $Id$
+ */
+public class FormsException extends ProcessingException {
+
+    public FormsException(String message) {
+        super(message);
+    }
+
+    public FormsException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public FormsException(String message, Location location) {
+        super(message, location);
+    }
+
+    public FormsException(String message, Throwable cause, Location location) {
+        super(message, cause, location);
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/FormsException.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message