openBlueDragon cfzip issue - coldfusion

I'm trying to zip a directory using cfzip with no success. The newly created directory contains PDFs. The code:
<cfset tempDir = getTempDirectory() />
<cfset userDirName = CreateUUID() />
<cfset userTempDir = #tempDir# & #userDirName# />
<cfloop query="data">
Create PDFs...[cfdocument]
<cffile action="write" file="#userTempDir#\#name#.pdf" output="#pdf_output#" addnewline="no" nameconflict="makeunique" />
</cfloop>
<cfzip action="zip" source="#userTempDir#" file="#tempDir#/testZIP.zip" recurse="yes" />
Everything executed nicely but cfzip. When the cfzip line tries to execute the following error comes up:
The page you were executing caused an internal server error
Request /applications/useritems/resources-cors/cfScripts/Print/Print.cfc
File Trace E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc
Type Internal
Tag Context CFZIP (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=1018, Column=13)
|
+-- CFIF (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=818, Column=9)
|
+-- CFFUNCTION (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=814, Column=5)
Stack Trace
java.lang.NullPointerException
at com.naryx.tagfusion.expression.function.file.Zip.execute(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.createZip(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.realRender(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.render(Unknown Source)
What am i missing here?

Related

How to remove ROOT directory from FTP using CFFTP

I need to remove the Directory(folder) from FTP server using coldfusion. My server folders looks like below,
/jawa/notes/test.cfm
/jawa/notes/test1.cfm
/jawa/notes/test2.cfm
/jawa/notes/test3.cfm
/jawa/test1.cfm
/jawa/test2.cfm
/jawa/test3.cfm
My question is, how to remove the 'jawa' folder. Because all files and notes folder is under 'jawa' folder. So, If we delete the root folder ( jawa ) then the whole directory and files.
Are these possible guys?
Here's a function I wrote many years ago to accomplish this task. It uses <cfdirectory> with the recurse="yes" option. This creates a query object in which I loop through and first delete files only. Then I run a second loop in reverse which then deletes the folders. This method has worked well with no issues over many years.
<!---
Private function that will clear a specified directory of all files, folders,
subfolders and files contained in subfolders.
--->
<cffunction name="clearFolder" access="private" returntype="string" output="no">
<cfargument name="dirPath" type="string" required="yes">
<!---
Step 1: Loop through all the files in the specified directory/subdirectories
and delete the files only.
--->
<cfdirectory action="list" name="qDirListing" directory="#dirPath#" recurse="yes">
<cfloop query="qDirListing">
<cfif qDirListing.type eq "file">
<cftry>
<cffile action="delete" file="#qDirListing.directory#\#qDirListing.name#">
<cfcatch type="any">
<cfreturn "failure: Error deleting file #qDirListing.directory#\#qDirListing.name#">
</cfcatch>
</cftry>
</cfif>
</cfloop>
<!---
Step 2: Now that the files are cleared from all the directories, loop through all
the directories and delete them. Note that you need to loop backwards through
the result set since the subdirectories need to be deleted before the parent
directories can be deleted.
--->
<cfdirectory action="list" name="qDirListing" directory="#dirPath#" recurse="yes">
<cfloop from="#qDirListing.recordCount#" to="1" step="-1" index="i">
<cftry>
<cffile action="delete" file="#qDirListing['directory'][i]#\#qDirListing['name'][i]#">
<cfcatch type="any">
<cfreturn "failure: Error deleting file #qDirListing['directory'][i]#\#qDirListing['name'][i]#">
</cfcatch>
</cftry>
</cfloop>
<cfreturn "">
</cffunction>

ColdFusion file operation rejected with an exception error

I'm still using coldfusion 8 and the file operation I wrote works for one application but when I reuse the codes for another application I got an exception error.
I'm just simply need to copy, rename and move uploaded file from one directory to another.That's all I need. And this is for Oracle bcp from csv file.
All the permissions have been checked and allowed, all of the paths have been checked and correct. Both application reside at the same coldfusion server (unix based).
Here is what I'm trying to do:
I'm calling my comp:
<CFSET DestinationLoc = "/space/users/www/data/temp/Archives/#Trim(session.usergroup)#/">
<CFSET SourceLoc = "/space/users/www/data/temp/#Trim(session.usergroup)#">
<CFSET FileName = "#Trim(CFFILE.ServerFile)#">
<CFSET CopyRenameObjObj = createObject("component", "cfcomponents.ParentComp.Copy_and_Rename").init()>
<CFSET CopyRenameObjObj.Copy_and_Rename(DestinationLoc,SourceLoc,FileName)>
I created a copy and rename cfc:
<CFCOMPONENT>
<CFFUNCTION name="Init" access="public" returntype="any" output="false" hint="Returns an initialized component instance.">
<cfreturn THIS />
</CFFUNCTION>
<CFFUNCTION name="Copy_and_Rename">
<cfargument name="destinationPath" type="String" required="TRUE">
<cfargument name="SourcePath" type="String" required="TRUE">
<cfargument name="FileName" type="String" required="TRUE">
<!--- First copy the file from source location to destination location --->
<cffile action = "copy" destination = "#Trim(arguments.destinationPath)#"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>
<!--- Then move the file from the source to detination 2 --->
<cffile action = "move" destination = "/opt/coldfusion8/runtime/bin/"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>
<cffile action = "rename" destination = "/opt/coldfusion8/runtime/bin/#Trim(session.usergroup)#_PARENTLOADFeed.txt"
source = "/opt/coldfusion8/runtime/bin/#Trim(arguments.FileName)#"/>
</CFFUNCTION>
</CFCOMPONENT>
The error I'm getting is:
Despite of this error, the directory is there, the file is renamed, moved successfully but the process stop due to this error!
An exception occurred when performing a file operation copy on files
/space/users/www/data/temp/BC/BC_Smallfile.TXT and
/space/users/www/data /temp/Archives/BC/.
The cause of this
exception was: java.io.FileNotFoundException: /space
/users/www/data/temp/BC/BC_Smallfile.TXT (No such file or directory).
The error occurred in /space/users/www/webdocsec/cfcomponents /ParentComp/Copy_and_Rename.cfc: line 23
Problem code:
<!--- Source : /space/users/www/data/temp/BC/BC_testfile.TXT --->
<cffile action = "copy" destination =
"#Trim(arguments.destinationPath)#"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>

Error while Running a .exe file using coldfusion schedule task

I need to run a exe file on app server using coldfusion schedule task. I wrote code inside cfm file with cfexecute command below.
But the executable doesn't run with/without timeout clause in cfexecute. Can anyone point out what I'm doing wrong.
<cfsetting enableCFOutputOnly="false" requestTimeout="9600" />
<!--- Call executable --->
<cftry>
**<cfexecute name= "C:\npp.exe" />**
<cfcatch type="Any">
<cfoutput>(Cal): Error - #cfcatch.message#</cfoutput>
<!--- TO DO:Log error --->
<cflog application="true" log="application" type="Error"
text=" Error - #cfcatch.message#" />
</cfcatch>
</cftry>
<cflog application="true" log="application" type="Information" text=" executable called" />

Using binary data as a source in Railo's cfpdf tag

So I am saving PDF blob in a database and trying to retrieve it and display it on a page. When i run the code on Coldfusion 10 it runs as expected. However, when i move the same exact code over to Railo 4.2.1.0 I get an error.
I'm curious if it is possible to pass binary data into CFPDF Source tag in Railo. If not does anyone know of a good workaround?
When i run a dump the pdfBinary data does have the correct binary information inside of it.
Thanks
Code:
<cfset tcpInformation = dataPopulatorController.getTCPInformation(session.requestID, session.personID) />
<cfset pdfBinary = tcpInformation.file_content[1]>
<cfpdf action="read" source="pdfBinary" name="TCPDocument">
<cfheader name="Content-Disposition" value="filename=TCP.pdf" />
<cfcontent type="application/pdf" variable="#toBinary(TCPDocument)#" />
Error I get on Railo:
The Error Occurred in
/****/tcpviewer.cfm: line 7
5:
6:
7:
8:
9:
Java Stacktrace file or directory pdfBinary not exist
at railo.commons.io.res.util.ResourceUtil.toResourceExisting(ResourceUtil.java:199):199
at railo.commons.io.res.util.ResourceUtil.toResourceExisting(ResourceUtil.java:164):164
at railo.runtime.tag.PDF.toPDFDocument(PDF.java:1207):1207
at railo.runtime.tag.PDF.doActionRead(PDF.java:1033):1033
at railo.runtime.tag.PDF.doEndTag(PDF.java:568):568
at onboarding.views.tcpviewer_cfm$cf.call(/onboarding/views/tcpviewer.cfm:7):7
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:913):913
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:865):865
at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:206):206
at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2218):2218
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2185):2185
at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:332):332
at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947):947
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408):408
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589):589
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source):-1
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1
at java.lang.Thread.run(Unknown Source):-1
When reading from a binary variable source in Railo it seems you need to wrap it with #s:
<cfpdf action="read" source="#pdfBinary#" name="TCPDocument">
But as Leigh says, there's no need to re-read the variable using CFPDF to output the content to the browser:
<cfset tcpInformation = dataPopulatorController.getTCPInformation(session.requestID, session.personID) />
<cfset pdfBinary = tcpInformation.file_content[1]>
<cfheader name="Content-Disposition" value="filename=TCP.pdf" />
<cfcontent type="application/pdf" variable="#pdfBinary#" />

CFExecute not working for imagemagick's command

I am running the following command using ColdFusion's cfexecute: composite -geometry +2+2 "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\316\resized.png" "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\templateImages\isubscribe\blank.png" "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\316\part1.png"
<cffunction name="executeWrap" returntype="string">
<cfargument name="commandToRun" type="string" required="Yes">
<cfargument name="cmdArg" type="string" required="Yes">
<cfset var result = "">
<cfexecute name="#arguments.commandToRun#" arguments="#arguments.cmdArg#"
variable="result" timeout="15" />
<!--- <cfdump var="#arguments#">
<cfdump var="#result#"> --->
<cfreturn result>
</cffunction>
For some reason the above thing does not work. Though when I run the command directly onto the command prompt then it works.
Any ideas please?
CFExecute ignores anything sent to standard error by the called process. To be able to see if there is any error output generated, add the "errorVariable" argument to your cfexecute call, then check if there is anything there and let your script react accordingly.
<cfexecute name="..command to run..."
arguments='.. your arguments...'
variable="results"
errorVariable="errorOuptut"
></cfexecute>
<cfif len(errorOuptut)>
<cfthrow message="#errorOuptut#" />
</cfif>
More info here:
http://www.raymondcamden.com/index.cfm/2008/4/9/ColdFusion-801-change-to-CFEXECUTE