1 16 package org.apache.cocoon.acting; 17 18 import org.apache.avalon.framework.parameters.Parameters; 19 import org.apache.avalon.framework.thread.ThreadSafe; 20 import org.apache.cocoon.environment.Redirector; 21 import org.apache.cocoon.environment.SourceResolver; 22 import org.apache.excalibur.source.Source; 23 import org.apache.excalibur.source.SourceNotFoundException; 24 25 import java.util.Map ; 26 27 42 public class ResourceExistsAction extends ServiceableAction implements ThreadSafe { 43 44 public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws Exception { 45 String resourceURI = parameters.getParameter("url", src); 46 Source source = null; 47 try { 48 source = resolver.resolveURI(resourceURI); 49 if (source.exists()) { 50 return EMPTY_MAP; 51 } 52 } catch (SourceNotFoundException e) { 53 } catch (Exception e) { 55 getLogger().warn("Exception resolving resource " + resourceURI, e); 56 } finally { 57 if (source != null) { 58 resolver.release(source); 59 } 60 } 61 return null; 62 } 63 } 64 | Popular Tags |