You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/12/12 15:33:09 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/acting ResourceExistsAction.java
vgritsenko 2003/12/12 06:33:09
Modified: src/java/org/apache/cocoon/acting ResourceExistsAction.java
Log:
Cleanup
Revision Changes Path
1.4 +20 -11 cocoon-2.1/src/java/org/apache/cocoon/acting/ResourceExistsAction.java
Index: ResourceExistsAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/acting/ResourceExistsAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResourceExistsAction.java 15 Oct 2003 20:47:14 -0000 1.3
+++ ResourceExistsAction.java 12 Dec 2003 14:33:09 -0000 1.4
@@ -55,6 +55,7 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
import java.util.Map;
@@ -62,29 +63,37 @@
* This action simply checks to see if a given resource exists. It checks
* whether the specified in the src attribute source exists or not.
* The action returns empty <code>Map</code> if it exists, null otherwise.
- * <p>Instead of src attribute, source can be specified using
+ *
+ * <p>
+ * Instead of src attribute, source can be specified using
* parameter named 'url' (this is old syntax).
+ *
* <p>
* <b>Note:</b> {@link org.apache.cocoon.selection.ResourceExistsSelector}
* should be preferred to this component, as the semantics of a Selector better
- * match the supplied functionality.
+ * matches the supplied functionality.
*
* @author <a href="mailto:balld@apache.org">Donald Ball</a>
* @version CVS $Id$
*/
public class ResourceExistsAction extends ServiceableAction implements ThreadSafe {
- public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
- String urlstring = parameters.getParameter("url", source);
- Source src = null;
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws Exception {
+ String resourceURI = parameters.getParameter("url", src);
+ Source source = null;
try {
- src = resolver.resolveURI(urlstring);
- if (src.exists())
- return EMPTY_MAP;
+ source = resolver.resolveURI(resourceURI);
+ if (source.exists()) {
+ return EMPTY_MAP;
+ }
+ } catch (SourceNotFoundException e) {
+ // Do not log
} catch (Exception e) {
- getLogger().warn("Exception", e);
+ getLogger().warn("Exception resolving resource " + resourceURI, e);
} finally {
- resolver.release(src);
+ if (source != null) {
+ resolver.release(source);
+ }
}
return null;
}