2 Replies Latest reply on May 10, 2006 6:28 AM by

    Extending SimpleFileDeployer Service help

      Have CPS installed on a local staging server and have "tweaked" the SimpleFileDeployer to use FTP,production server is in a DMZ so no direct smb. It works really well to my test site on my production server, but I need to extend further to include file changes by things other than Contribute....ie Dreamweaver. Would like to automate the process also, but that can wait. I read a little bit about DirectoryWatcher Event Gateway, but I don't have Enterprise Edition, and I can only assume Developer won't work as I have many Contribute users connect. Looking for advice as my current copying software like to stop with out explaination and I am getting sick of having to restart it all the time.
        • 1. Re: Extending SimpleFileDeployer Service help
          Steph06
          I don't have an answer to your question but I was wondering how you got the CPS to use FTP as I cannot find any help anywhere and all our sites production sites must use this. Any help would be appreciated and any code.

          Thanks a lot Stephanie
          1 person found this helpful
          • 2. Re: Extending SimpleFileDeployer Service help
            The file you want to work with is deployfile.cfc. Here are the two functions for copying files and deleting them(have not tested deleting yet). One odd thing I couldn't get working was in settings.xml I couldn't use just an IP address for the remote server, had to manually define it in the CFFTP tag. All I basically did was comment out some CFFILE tags and replace them with CFFTP tags. Hope this helps you out in some way.

            <cffunction name="pushCopyFileBased">
            <cfargument name="settings" type="struct" required="true">
            <cfargument name="siteRelative" type="string" required="true">

            <!-- Do nothing if nil is defined for the live server file path... This is so you can use this as a change tracker -->
            <cfif settings.liveFileSystemPath eq "nil/">
            <cfreturn>
            </cfif>

            <cfif not FileExists( settings.stagingFileSystemPath & siteRelative )>

            <!-- Check if they've trying to put in a web path where they need a file path. -->
            <cfif Left( settings.stagingFileSystemPath, 7 ) eq " http://"
            or Left( settings.stagingFileSystemPath, 8 ) eq "https://" >

            <cfthrow errorcode="File Doesn't Exist"
            message="File to copy, #settings.stagingFileSystemPath & siteRelative#, doesn't exist or can not be accessed. You have supplied a web path ( http://...) where we were expecting a file system path.">

            <!-- Check if they've used a windows path on a linux or unix machine. -->
            <cfelseif ( Left( settings.stagingFileSystemPath, 2 ) eq "\\"
            or Left( settings.stagingFileSystemPath, 2 ) eq "//"
            or Mid( settings.stagingFileSystemPath, 2, 1 ) eq ":" )
            and
            ( FindNoCase( "linux", SERVER.OS.Name ) gt 0
            or FindNoCase( "unix", SERVER.OS.Name ) gt 0 ) >

            <cfthrow errorcode="File Doesn't Exist"
            message="File to copy, #settings.stagingFileSystemPath & siteRelative#, doesn't exist or can not be accessed. You seem to be using a Windows path on a UNIX-like file system.">

            <cfelse>
            <!-- Generic Error. -->

            <cfthrow errorcode="File Doesn't Exist"
            message="File to copy, #settings.stagingFileSystemPath & siteRelative#, doesn't exist or can not be accessed.">
            </cfif>
            </cfif>

            <cftry>
            <cfinvoke method="MakeSurePathExists" path="#settings.liveFileSystemPath & siteRelative#">
            <cfcatch type="any">
            <cfthrow errorcode="NoLiveServerAccess" message="Can not access or do not have sufficient permissions to write to: #settings.liveFileSystemPath & siteRelative#">
            </cfcatch>
            </cftry>
            <!--- this looks to be the spot to change to ftp to copy--->
            <!---<cffile action="copy" source="#settings.stagingFileSystemPath & siteRelative#" destination="#settings.liveFileSystemPath & siteRelative#">--->
            <cfftp action="putfile" server="********" username="*******" password="******" localfile="#settings.stagingFileSystemPath & siteRelative#" remotefile="#siteRelative#" transfermode="BINARY">
            <!-- touch the file so it gets the current date, so the browser will pull down the new one when previewed -->
            <!---<cffile action="append" file="#settings.liveFileSystemPath & siteRelative#" output="">--->
            </cffunction>

            <cffunction name="pushDeleteFileBased">
            <cfargument name="settings" type="struct" required="true">
            <cfargument name="siteRelative" type="string" required="true">

            <!-- Do nothing if nil is defined for the live server file path... This is so you can use this as a change tracker -->
            <cfif settings.liveFileSystemPath eq "nil/">
            <cfreturn>
            </cfif>

            <cfif not FileExists( settings.liveFileSystemPath & siteRelative )>
            <cfreturn>
            </cfif>
            <!--- this looks to be the spot to change to ftp to delete--->
            <cfftp action="remove" server="******" stoponerror="yes" username="******" password="******" item="#siteRelative#">
            <!---<cffile action="delete" file="#settings.liveFileSystemPath & siteRelative#">--->
            </cffunction>