Skip to content

Instantly share code, notes, and snippets.

@s992
Created October 24, 2011 03:08
Show Gist options
  • Save s992/1308277 to your computer and use it in GitHub Desktop.
Save s992/1308277 to your computer and use it in GitHub Desktop.
MuraProxy plugin deployment
<!--- Instantiate the MuraProxy webservice --->
<cfset muraProxy = createObject( "webservice", "http://localhost/muraFork/MuraProxy.cfc?wsdl" ) />
<!--- Authenticate --->
<cfset authToken = muraProxy.login( 'admin', 'admin', 'default' ) />
<!--- Create our args struct and serialize it to place in the URL --->
<cfset args = structNew() />
<cfset args.siteID = 'default' />
<cfset args = serializeJSON( args ) />
<cfoutput>
<!---
This form contains everything else we need. For some reason, I had to specify args in the URL instead of as a hidden
input.
--->
<form action="http://localhost/muraFork/MuraProxy.cfc?args=#urlEncodedFormat(args)#" method="post" enctype="multipart/form-data">
<input type="hidden" name="method" value="call" />
<input type="hidden" name="serviceName" value="plugin" />
<input type="hidden" name="methodName" value="deploy" />
<input type="hidden" name="authToken" value="#authToken#" />
<input type="file" name="bundleFile" />
<input type="Submit" value="Submit" />
</form>
</cfoutput>
<cfcomponent output="false" extends="service">
<cffunction name="deploy" output="false">
<cfargument name="event">
<cfset var fileManager = getBean("fileManager")>
<cfset var tempfile = "">
<cfset var errors = structNew()>
<cftry>
<cffile action="upload" result="tempFile" filefield="bundleFile" nameconflict="makeunique" destination="#application.configBean.getTempDir()#">
<cfset application.pluginManager.announceEvent("onBeforeProxyBundleDeploy", event)>
<cfset application.pluginManager.deployPlugin(
siteID=arguments.event.getValue( 'siteID' ),
pluginFile="#tempfile.serverDirectory#/#tempfile.serverFilename#.#tempfile.serverFileExt#") />
<cffile action="delete" file="#tempfile.serverDirectory#/#tempfile.serverFilename#.#tempfile.serverFileExt#">
<cfset event.setValue("__response__", "success")>
<cfset application.pluginManager.announceEvent("onAfterProxyBundleDeploy", event)>
<cfcatch>
<cfset event.setValue("__response__", cfcatch.Message)>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment