From fop-users-return-35274-apmail-xmlgraphics-fop-users-archive=xmlgraphics.apache.org@xmlgraphics.apache.org Wed Apr 18 18:11:48 2012 Return-Path: X-Original-To: apmail-xmlgraphics-fop-users-archive@www.apache.org Delivered-To: apmail-xmlgraphics-fop-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 46EF8900B for ; Wed, 18 Apr 2012 18:11:48 +0000 (UTC) Received: (qmail 74864 invoked by uid 500); 18 Apr 2012 18:11:47 -0000 Delivered-To: apmail-xmlgraphics-fop-users-archive@xmlgraphics.apache.org Received: (qmail 74848 invoked by uid 500); 18 Apr 2012 18:11:47 -0000 Mailing-List: contact fop-users-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-users@xmlgraphics.apache.org Delivered-To: mailing list fop-users@xmlgraphics.apache.org Received: (qmail 74841 invoked by uid 99); 18 Apr 2012 18:11:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 18:11:47 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rsargent@xmission.com designates 166.70.13.231 as permitted sender) Received: from [166.70.13.231] (HELO out01.mta.xmission.com) (166.70.13.231) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Apr 2012 18:11:37 +0000 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1SKZLX-00085D-4u for fop-users@xmlgraphics.apache.org; Wed, 18 Apr 2012 12:11:15 -0600 Received: from [208.187.158.94] (helo=[172.16.1.88]) by in02.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1SKZLS-0000aA-MK for fop-users@xmlgraphics.apache.org; Wed, 18 Apr 2012 12:11:14 -0600 Message-ID: <4F8F041F.6090200@xmission.com> Date: Wed, 18 Apr 2012 12:12:47 -0600 From: Rob Sargent User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: fop-users@xmlgraphics.apache.org References: <4F8DF57F.9010103@xmission.com> <4F8ED211.90600@xmission.com> <4F8EE2AB.1090300@xmission.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------080706010503050703090004" X-XM-SPF: eid=;;;mid=;;;hst=in02.mta.xmission.com;;;ip=208.187.158.94;;;frm=rsargent@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+UAQii3Bc7lNOTg3eKHCpkeTqR2KFEfd4= X-SA-Exim-Connect-IP: 208.187.158.94 X-SA-Exim-Mail-From: rsargent@xmission.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sa04.xmission.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.1 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: T_TM2_M_HEADER_IN_MSG * 0.0 HTML_MESSAGE BODY: HTML included in message * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_XMDrugObfuBody_08 obfuscated drug references * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;fop-users@xmlgraphics.apache.org X-Spam-Relay-Country: Subject: Re: Trouble with setting font base url which include space character X-SA-Exim-Version: 4.2.1 (built Fri, 06 Aug 2010 16:31:04 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) X-Old-Spam-Flag: No X-Old-Spam-Status: No, score=0.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,HTML_MESSAGE,T_TM2_M_HEADER_IN_MSG,T_XMDrugObfuBody_08, XMSolicitRefs_0,XMSubLong autolearn=disabled version=3.3.1 --------------080706010503050703090004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Stop me if you've heard this one before: I'm an idiot. You know how it goes. Add a log message; fix the code. Well of course one more recompile of everything and a restart of IDE /et viola/ it all works as expected. My apologies to all, rjs Still looking forward to an API the doesn't use String for UR[IL] but what we have does work. rj. On 04/18/2012 09:54 AM, mehdi houshmand wrote: > Oh no, I wasn't suggesting you change to the > FontManager.setFontBaseURL(), I was just noting that the method is > overridden. Could you provide a full stack trace, it might be > interesting to note where that exception is coming from? > > Also, just to expedite the process, try the same thing with trunk, see > what happens. From testing the method call, it should accept spaces in > the String, the FOURIResolver does a lot of URI correction. > > Mehdi > > On 18 April 2012 16:50, Rob Sargent > wrote: > > And my bad too: FOP-1.0 compiled from source of official release > circa 2012-03-01. > > You are correct in that I'm working off of FopFactory, but my > debugger takes me to the same setFontBaseURL(String) you list so > I'm not sure switching to FontManager would change anything. (It > will take a moderate effort to switch this: the "long story" is > that we still use older versions of fop (including to 0.20-5 I'm > sorry to say) so that's why I'm using reflection (and classloader > shenanigans to boot). > > I have not looked at recent releases for any fixes in this area. > I actually expected a flood of "your doing it wrong, do this > instead".... > > rjs > > > > > On 04/18/2012 09:19 AM, mehdi houshmand wrote: >> Hi Rob, >> >> Ooohh, my bad. I must have misunderstood your concern. This is an >> interesting little problem, the only thing I can think if is that >> the FopFactory overrides the FontManager.setFontBaseURL(...) method: >> >> this.fontManager = new FontManager() { >> >> /** {@inheritDoc} */ >> @Override >> public void setFontBaseURL(String fontBase) throws MalformedURLException { >> super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase)); >> } >> >> }; >> But then, you're calling the "setFontBaseURL(...)" method on >> FopFactory and not FontManager, so I don't know, maybe someone >> else may have an idea. But could you give us all the usuals, what >> version of FOP you're using? Have you tried seeing if trunk has >> the same issue etc... >> >> Mehdi >> >> On 18 April 2012 15:39, Rob Sargent > > wrote: >> >> Thanks Mehdi, looking forward to the API change. >> >> But I'm not sending ".../acres install/...", rather (I >> believe) I'm sending ".../acres%20install/..." as the string >> URL. Is that not the correct format? >> >> rjs >> >> >> On 04/18/2012 01:43 AM, mehdi houshmand wrote: >>> Hi Rob, >>> >>> Firstly, we are working to change how fop handles file >>> access and I/O in general. I should note, that we're >>> unifying all resource acquisition to resolving URIs, not >>> URLs. The two concepts differ, and it's non-trivial. >>> >>> See http://wiki.apache.org/xmlgraphics-fop/URIResolution and >>> http://wiki.apache.org/xmlgraphics-fop/FopFactoryConfiguration. >>> >>> Secondly, there are some misnomers in the names of these >>> resource finders. The issue you're seeing is that >>> "/d1/rework/acres install/ac47/eclipe/plugins" while it is a >>> valid URL, it is not a valid URI. The >>> FopFactory.setFontBaseURL(...) method delegates to the >>> FOURIResolver to validate the String given and parses it as >>> a URL NOT a URL. That is why you're seeing this problem. >>> >>> Mehdi >>> >>> On 17 April 2012 23:58, Rob Sargent >> > wrote: >>> >>> Seems to me FopFactory.setFontBaseURL(String s) is broken? >>> >>> Forgive the reflection calls (long story). >>> >>> File fontsdir = new File(bundlePath + fopHome + >>> "/fonts"); >>> >>> URL fontsURL = fontsdir.toURI().toURL(); >>> setFontBaseURLMethod.invoke(fopFactory, >>> fontsURL.toExternalForm()); >>> >>> works fine when the directory is, shall we say, normal, >>> but if the directory has a space the method appears to >>> eat the "%20". >>> >>> Caused by: java.net.MalformedURLException: Illegal >>> character in path at index 23: file:///d1/rework/acres >>> install/ac47/eclipse/plugins/com.amirsys.console_4.6.0/fop/fop100/fop/fonts/ >>> >>> >>> bundlePath=/d1/rework/acres install/ac47/eclipe/plugins >>> fopHome=com.amirsys.console_4.6.0/fop/fop100/fop >>> >>> I've written a test jig to see what File.toURI().toURL() >>> does: >>> >>> import java.net.URL; >>> import java.io.File; >>> >>> public class FileURL { >>> >>> public static void main(String[] args) { >>> try { >>> File f = new File(args[0]); >>> URL furl = f.toURI().toURL(); >>> System.out.println(furl.toString()); >>> System.out.println(furl.toExternalForm()); >>> } >>> catch (java.net.MalformedURLException mue) { >>> mue.printStackTrace(); >>> } >>> } >>> } >>> >>> And that reports what I expected, an encoded path: >>> >>> java -cp . FileURL /d1/rework/acres\ install/ac47 >>> file:/d1/rework/acres%20install/ac47/ >>> file:/d1/rework/acres%20install/ac47/ >>> >>> >>> I hope someone has a better plan. >>> >>> I do think that the FOP api should be changed to take a >>> URL rather than a string, but that's for another day. >>> >>> >>> >> >> > > --------------080706010503050703090004 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Stop me if you've heard this one before:  I'm an idiot. 

You know how it goes.  Add a log message; fix the code.  Well of course one more recompile of everything and a restart of IDE et viola it all works as expected.

My apologies to all,

rjs

Still looking forward to an API the doesn't use String for UR[IL] but what we have does work.
rj.

On 04/18/2012 09:54 AM, mehdi houshmand wrote:
Oh no, I wasn't suggesting you change to the FontManager.setFontBaseURL(), I was just noting that the method is overridden. Could you provide a full stack trace, it might be interesting to note where that exception is coming from?

Also, just to expedite the process, try the same thing with trunk, see what happens. From testing the method call, it should accept spaces in the String, the FOURIResolver does a lot of URI correction.

Mehdi

On 18 April 2012 16:50, Rob Sargent <rsargent@xmission.com> wrote:
And my bad too: FOP-1.0 compiled from source of official release circa 2012-03-01.

You are correct in that I'm working off of FopFactory, but my debugger takes me to the same setFontBaseURL(String) you list so I'm not sure switching to FontManager would change anything.  (It will take a moderate effort to switch this:  the "long story" is that we still use older versions of fop (including to 0.20-5 I'm sorry to say) so that's why I'm using reflection (and classloader shenanigans to boot).

I have not looked at recent releases for any fixes in this area.  I actually expected a flood of "your doing it wrong, do this instead"....

rjs




On 04/18/2012 09:19 AM, mehdi houshmand wrote:
Hi Rob,

Ooohh, my bad. I must have misunderstood your concern. This is an interesting little problem, the only thing I can think if is that the FopFactory overrides the FontManager.setFontBaseURL(...) method:

        this.fontManager = new FontManager() {

            /** {@inheritDoc} */
            @Override
            public void setFontBaseURL(String fontBase) throws MalformedURLException {
                super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase));
            }

        };
But then, you're calling the "setFontBaseURL(...)" method on FopFactory and not FontManager, so I don't know, maybe someone else may have an idea. But could you give us all the usuals, what version of FOP you're using? Have you tried seeing if trunk has the same issue etc...

Mehdi

On 18 April 2012 15:39, Rob Sargent <rsargent@xmission.com> wrote:
Thanks Mehdi, looking forward to the API change.

But I'm not sending ".../acres install/...", rather (I believe) I'm sending ".../acres%20install/..." as the string URL.  Is that not the correct format?

rjs


On 04/18/2012 01:43 AM, mehdi houshmand wrote:
Hi Rob,

Firstly, we are working to change how fop handles file access and I/O in general. I should note, that we're unifying all resource acquisition to resolving URIs, not URLs. The two concepts differ, and it's non-trivial.


Secondly, there are some misnomers in the names of these resource finders. The issue you're seeing is that "/d1/rework/acres install/ac47/eclipe/plugins" while it is a valid URL, it is not a valid URI. The FopFactory.setFontBaseURL(...) method delegates to the FOURIResolver to validate the String given and parses it as a URL NOT a URL. That is why you're seeing this problem.

Mehdi

On 17 April 2012 23:58, Rob Sargent <rsargent@xmission.com> wrote:
Seems to me FopFactory.setFontBaseURL(String s) is broken?

Forgive the reflection calls (long story).

    File fontsdir = new File(bundlePath + fopHome + "/fonts");
           
    URL fontsURL = fontsdir.toURI().toURL();
    setFontBaseURLMethod.invoke(fopFactory, fontsURL.toExternalForm());

works fine when the directory is, shall we say, normal, but if the directory has a space the method appears to eat the "%20".

Caused by: java.net.MalformedURLException: Illegal character in path at index 23: file:///d1/rework/acres install/ac47/eclipse/plugins/com.amirsys.console_4.6.0/fop/fop100/fop/fonts/


bundlePath=/d1/rework/acres install/ac47/eclipe/plugins
fopHome=
com.amirsys.console_4.6.0/fop/fop100/fop

I've written a test jig to see what File.toURI().toURL() does:
import java.net.URL;
import java.io.File;

public class FileURL {

    public static void main(String[] args) {
        try {
            File f = new File(args[0]);
            URL furl = f.toURI().toURL();
            System.out.println(furl.toString());
            System.out.println(furl.toExternalForm());
        }
        catch (java.net.MalformedURLException mue) {
            mue.printStackTrace();
        }
    }
}

And that reports what I expected, an encoded path:
java -cp . FileURL /d1/rework/acres\ install/ac47
file:/d1/rework/acres%20install/ac47/
file:/d1/rework/acres%20install/ac47/

I hope someone has a better plan.

I do think that the FOP api should be changed to take a URL rather than a string, but that's for another day.








--------------080706010503050703090004--