Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: deleteFiles Javascript

  1. #1

    Default deleteFiles Javascript

    I'd like to use the deleteFiles Transformation Funtion (Special Functions) to delete files from a directory.
    I tried deleteFile(PATH_FILE) where PATH_FILE is the full path and filename derived from a Get File Names and Database lookup steps. My syntax isn't right because I'm erroring out.

    2009/04/15 11:52:48 - org.pentaho.di.ui.spoon.trans.TransGraph - Transformation opened.
    2009/04/15 11:52:48 - Spoon - Launching transformation [Transformation 1]...
    2009/04/15 11:52:48 - Spoon - Started the transformation execution.
    2009/04/15 11:52:48 - Transformation 1 - Dispatching started for transformation [Transformation 1]
    2009/04/15 11:52:48 - Transformation 1 - This transformation can be replayed with replay date: 2009/04/15 11:52:48
    2009/04/15 11:52:48 - Get File Names.0 - Finished processing (I=0, O=0, R=0, W=2, U=2, E=0)
    2009/04/15 11:52:48 - Database lookup.0 - Finished processing (I=0, O=0, R=2, W=2, U=2, E=0)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : Unexpected error :
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : org.pentaho.di.core.exception.KettleValueException:
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : Javascript error:
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : org.mozilla.javascript.EvaluatorException: The function call deleteFile is not valid. (script#3) (script#3)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) :
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMod.addValues(ScriptValuesMod.java:409)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMod.processRow(ScriptValuesMod.java:640)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.step.BaseStep.runStepThread(BaseStep.java:2664)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMod.run(ScriptValuesMod.java:703)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : Caused by: org.mozilla.javascript.EvaluatorException: org.mozilla.javascript.EvaluatorException: The function call deleteFile is not valid. (script#3) (script#3)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.Context.reportRuntimeError(Context.java:922)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.Context.reportRuntimeError(Context.java:978)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.deleteFile(ScriptValuesAddedFunctions.java:1760)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at java.lang.reflect.Method.invoke(Unknown Source)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.gen.c2._c0(script:3)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.gen.c2.call(script)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.gen.c2.call(script)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.mozilla.javascript.gen.c2.exec(script)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : at org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMod.addValues(ScriptValuesMod.java:332)
    2009/04/15 11:52:48 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : ... 3 more
    2009/04/15 11:52:48 - Modified Java Script Value.0 - Finished processing (I=0, O=0, R=1, W=0, U=0, E=1)
    2009/04/15 11:52:48 - Spoon - The transformation has finished!!
    2009/04/15 11:52:48 - Transformation 1 - Transformation detected one or more steps with errors.
    2009/04/15 11:52:48 - Transformation 1 - Transformation is killing the other steps!


    What's the correct way to do this?

    Thanks,
    David
    Attached Images Attached Images  

  2. #2
    Join Date
    Mar 2006
    Posts
    114

    Post

    Uses try/cacth ...

    try{
    deleteFiles(fileName);
    }cacth(err){
    var teste = "Warning";
    }

    regards

    Conca

  3. #3

    Thumbs up

    Excellent! So the try/catch takes care of the error I was getting which prevented the step from finishing successfully. Thank you for your insight!

    David

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.