[Yanel-commits] rev 27415 - public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources

jon at wyona.com jon at wyona.com
Tue Sep 18 15:41:03 CEST 2007


Author: jon
Date: 2007-09-18 15:41:03 +0200 (Tue, 18 Sep 2007)
New Revision: 27415

Removed:
   public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/YanelURIResolver.java
Modified:
   public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/PDFResource.java
Log:
use new YanelRepositoryResolver instead of YanelURIResolver for pdf resource.

Modified: public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/PDFResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/PDFResource.java	2007-09-18 13:40:30 UTC (rev 27414)
+++ public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/PDFResource.java	2007-09-18 13:41:03 UTC (rev 27415)
@@ -21,6 +21,7 @@
 import org.wyona.yanel.core.api.attributes.ViewableV2;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.yanel.core.source.YanelRepositoryResolver;
 
 import org.wyona.yarep.core.RepositoryException;
 import org.wyona.yarep.core.Repository;
@@ -88,8 +89,8 @@
             // Step 2: Construct fop with desired output format
             Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, getResponse().getOutputStream());
 
-            YanelURIResolver yanelURIResolver = new YanelURIResolver(this);
-            fopFactory.setURIResolver(yanelURIResolver); // yanelURIResolver is a javax.xml.transform.URIResolver
+            YanelRepositoryResolver yanelRepoResolver = new YanelRepositoryResolver(this);
+            fopFactory.setURIResolver(yanelRepoResolver);
             
             /* Only for debugging ...
             java.io.FileOutputStream fout = new java.io.FileOutputStream("/home/michi/Desktop/yanel.pdf");

Deleted: public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/YanelURIResolver.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/YanelURIResolver.java	2007-09-18 13:40:30 UTC (rev 27414)
+++ public/yanel/trunk/src/contributions/resources/pdf/src/java/org/wyona/yanel/impl/resources/YanelURIResolver.java	2007-09-18 13:41:03 UTC (rev 27415)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2007 Wyona
- *
- *  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.wyona.org/licenses/APACHE-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.wyona.yanel.impl.resources;
-
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import java.net.URL;
-import java.io.InputStream;
-import java.util.StringTokenizer;
-
-import org.apache.log4j.Category;
-
-import org.wyona.yanel.core.Resource;
-
-import org.wyona.yarep.core.RepositoryException;
-import org.wyona.yarep.core.Repository;
-
-/**
- * URI resolver for the scheme "yanel"
- */
-public class YanelURIResolver implements URIResolver {
-    private static Category log = Category.getInstance(YanelURIResolver.class);
-    
-    private static final String SCHEME = "yanel";
-    
-    private Resource resource;
-    
-    public YanelURIResolver(Resource resource) {
-        this.resource = resource;
-    }
-
-    public Source resolve(String href, String base) {
-        if (log.isDebugEnabled()) {
-            log.debug("resolving: " + href);
-        }
-    	
-        String prefix = SCHEME + ":/";
-    	
-        // only accept 'yanel:/' URIs
-        if (href == null || !href.startsWith(prefix)){
-            return null;
-        }
-
-        // we can't resolve to a Collection (indicated by a trailing '/')
-        if (href.charAt(href.length() - 1) == '/'){
-            return null;
-        }
-
-        StringTokenizer tokens = new StringTokenizer(href.substring(7), "/");
-        if (!tokens.hasMoreTokens()){
-            return null; // nothing after the 'yanel:/'
-        }
-	    
-        try {
-            String path = href.substring(7); // truncate yanel:/
-            Repository repo = resource.getRealm().getRepository();
-            InputStream in = repo.getNode(path).getInputStream();
-            return new StreamSource(in);
-        } catch (Exception e) {
-        	String errorMsg = "Could not resolve URI: " + href + ": " + e.toString();
-            log.error(errorMsg, e);
-        }
-        return null;
-    }
-}



More information about the Yanel-commits mailing list