|
From: Qin D. <qd...@cs...> - 2003-10-02 16:13:35
|
David:
I see what you did. However, what I try to achieve is different. After the
scanner picks up the file, I believe that original file is wrapped up into
babeldoc's internal document. Now all I want to do is to get that file out
from the document wrapper so that I can pass it to my validation routine.
The question I have is:
Do you have a method like this:
document.getFile("file_name") which should return java.io.File
I saw babeldoc has a method: document.getInputStream(). Does this
inputStream represent the original file?
Why when I do the following (pass the file name and file's Inputstream to
my validation routine), I got TestManager not defined error? The class is
in %babeldoc_home%/lib directory?
initialize.script=\
longlegs.core.filevalidation.TestManager.validate(document.get
("file_name"),\ document.getInputStream());\
May I give you a call? I guess I am not very good to make myself
understood in writing. I appreciated it very much.
Qin
----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------
David Glick
<dglick To: "Qin Ding" <qd...@cs...>
@cox.net> cc: bab...@li...
Subject: Re: [Babeldoc-devel] Re: [Babeldoc-user]
10/02/03 10:59 Questions. Please Help
AM
Oops! I told an untruth. You CAN use imports in Javascript, as you've
done.
Remember this when you trust what I say... :-)
David
On Thursday 02 October 2003 8:50 am, David Glick wrote:
> Hi Qin,
>
> Here's a stage that I use to load values from a properties file. You
> should be able to do something similar in your case:
>
> ######
> # Get the next document ID
> ######
> get-next-doc-id.stageType=Scripting
> get-next-doc-id.nextStage=perl-post-doc
> get-next-doc-id.failOnError=true
> get-next-doc-id.language=javascript
> get-next-doc-id.script=\
> var document_id;\
> var propertiesFile = new
> java.io.File(${document.get("merchant_properties")});\
> var properties = new java.util.Properties();\
> if (propertiesFile.exists()) {properties.load(new
> java.io.FileInputStream(propertiesFile));}\
> document_id = properties.getProperty("next_document_id", "10001");\
> document_id++;\
> properties.setProperty("next_document_id", document_id);\
> properties.store(new java.io.FileOutputStream(propertiesFile),null);\
> document.put("document_id", document_id);
>
> Note that you cannot import in Javascript. This is why you have to use
the
> fully-qualified class name.
>
>
> Hope this helps,
>
> David
>
> On Thursday 02 October 2003 8:19 am, Qin Ding wrote:
> > David, Good morning:
> >
> > I checked the scripting examples. I did not see any examples that
shows
> > how I can extract the original file as type java.io.File. The closest
one
> > is md5 example, which shows how to get Inputstream out of the document.
I
> > assume this is the inputstream of the original file. So, I changed my
> > script like this:
> > initialize.script=\
> > importClass(Packages.longlegs.core.filevalidation.TestManager);\
> > TestManager.validate(document.get("file_name"),
> > document.getInputStream());\
> >
> > I deployed my file validation jar into babeldoc/lib directory, of
course.
> >
> > When I ran the pipeline, I got this error stating my TestManager is not
> > defined.
> >
> > <2003-10-02 09:57:37,517> INFO [main] : PipelineStage name:
initialize
> > <2003-10-02 09:57:37,978> ERROR [main] :
> > [DefaultPipelineStageErrorHandler.handlePipelineStageError]
PipelineStage
> > name: initialize Error: com.babeldoc.core.pipeline.PipelineException:
> > Script processing failed
> > <2003-10-02 09:57:37,978> ERROR [main] : [PipelineFeeder.process]
> > com.babeldoc.core.pipeline.PipelineException: Script processing failed
> > at
> > com.babeldoc.core.pipeline.stage.ScriptingPipelineStage.process(Unknown
> > Source)
> > at com.babeldoc.core.pipeline.PipelineStage.processStage(Unknown
> > Source)
> > at
> >
com.babeldoc.core.pipeline.processor.SyncPipelineStageProcessor.processPi
> >pe lineStage(Unknown Source)
> > at
> >
com.babeldoc.core.pipeline.processor.SyncPipelineStageProcessor.process(U
> >nk nown Source)
> > at
com.babeldoc.core.pipeline.PipelineStageFactory.process(Unknown
> > Source)
> > at com.babeldoc.core.pipeline.PipelineFactory.process(Unknown
> > Source) at
> > com.babeldoc.core.pipeline.PipelineFactoryFactory.process(Unknown
Source)
> > at
> > com.babeldoc.core.pipeline.feeder.SynchronousFeeder.process(Unknown
> > Source) at
> > com.babeldoc.core.pipeline.feeder.FeederFactory.process(Unknown Source)
> > at
> > com.babeldoc.core.pipeline.command.PipelineFeeder.process(Unknown
Source)
> > at
> > com.babeldoc.core.pipeline.command.PipelineFeeder.execute(Unknown
Source)
> > at com.babeldoc.core.BabeldocCommand.executeCommand(Unknown
Source)
> > at com.babeldoc.core.BabeldocCommand.<init>(Unknown Source)
> > at
com.babeldoc.core.pipeline.command.PipelineFeeder.<init>(Unknown
> > Source)
> > at com.babeldoc.core.pipeline.command.PipelineFeeder.main(Unknown
> > Source)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> >:3 9) at
> >
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> >mp l.java:25) at java.lang.reflect.Method.invoke(Method.java:324)
> > at com.babeldoc.core.Main.handleCommand(Unknown Source)
> > at com.babeldoc.core.Main.main(Unknown Source)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> >:3 9) at
> >
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> >mp l.java:25) at java.lang.reflect.Method.invoke(Method.java:324)
> > at com.babeldoc.init.Main.runBabeldocMain(Unknown Source)
> > at com.babeldoc.init.Main.main(Unknown Source)
> > Caused by: org.apache.bsf.BSFException: JavaScript Error: Internal
Error:
> > ReferenceError: "TestManager" is not defined.
> > at
> > org.apache.bsf.engines.javascript.JavaScriptEngine.handleError(Unknown
> > Source)
> > at
org.apache.bsf.engines.javascript.JavaScriptEngine.eval(Unknown
> > Source)
> > at org.apache.bsf.util.BSFEngineImpl.exec(Unknown Source)
> > at org.apache.bsf.BSFManager$6.run(Unknown Source)
> > at java.security.AccessController.doPrivileged(Native Method)
> > at org.apache.bsf.BSFManager.exec(Unknown Source)
> > ... 27 more
> >
> >
> >
-------------------------------------------------------------------------
> >-- -------------
> >
> > This is a PRIVATE message. If you are not the intended recipient,
please
> > delete without copying and kindly advise us by e-mail of the mistake in
> > delivery. NOTE: Regardless of content, this e-mail shall not operate to
> > bind CSC to any order or other contract unless pursuant to explicit
> > written agreement or government initiative expressly permitting the use
> > of e-mail for such purpose.
> >
-------------------------------------------------------------------------
> >-- -------------
--
David Glick
Transmit Consulting, Inc
619-475-4052
dg...@tr...
|