Skip to content

Commit

Permalink
Added the ability to view the change information and to be able to re…
Browse files Browse the repository at this point in the history
…fresh the page to see the current status from the web service.

Closes #4
  • Loading branch information
Zoramite committed Dec 24, 2010
1 parent 325cd62 commit 81f657c
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 23 deletions.
@@ -0,0 +1,5 @@
<cfset viewRoute53 = views.get('amazon-aws', 'route53') />

<cfoutput>
#viewRoute53.detailChange(change)#
</cfoutput>
Expand Up @@ -9,13 +9,14 @@
// Process the form submission
modelSerial.deserialize(form, hostedZone);
servRoute53.setHostedZone(user, hostedZone);
change = servRoute53.setHostedZone(user, hostedZone);
// Add a success message
transport.theSession.managers.singleton.getSuccess().addMessages('The hosted zone ''' & hostedZone.getName() & ''' was successfully saved.');
// Redirect
theURL.setRedirect('_base', '/admin/aws/route53/hostedZone/list');
theURL.setRedirect('_base', '/admin/aws/route53/change');
theURL.setRedirect('change', change.getChangeID());
theURL.removeRedirect('hostedZone');
theURL.redirectRedirect();
Expand Down
Expand Up @@ -5,13 +5,14 @@
hostedZone = servRoute53.getHostedZone(user, theUrl.search('hostedZoneID'));
servRoute53.deleteHostedZone(user, hostedZone);
change = servRoute53.deleteHostedZone(user, hostedZone);
// Add a success message
transport.theSession.managers.singleton.getSuccess().addMessages('The hosted zone ''' & hostedZone.getName() & ''' was successfully submitted for deletion.');
// Redirect
theURL.setRedirect('_base', '/admin/aws/route53/hostedZone/list');
theURL.setRedirect('_base', '/admin/aws/route53/change');
theURL.setRedirect('change', change.getChangeID());
theURL.removeRedirect('hostedZone');
theURL.redirectRedirect();
Expand Down
@@ -0,0 +1,7 @@
<cfscript>
servRoute53 = services.get('amazon-aws', 'route53');
user = transport.theSession.managers.singleton.getUser();
change = servRoute53.getChange(user, theUrl.search('changeID'));
</cfscript>
Empty file.
2 changes: 2 additions & 0 deletions amazon-aws/extend/admin/navigation/structure.xml.cfm
Expand Up @@ -2,6 +2,8 @@
<admin>
<aws position="main">
<route53 position="main">
<change position="main"/>

<hostedZone position="main">
<add position="action"/>
<delete position="action"/>
Expand Down
4 changes: 4 additions & 0 deletions amazon-aws/i18n/extend/admin/navigation/structure.properties
Expand Up @@ -8,6 +8,10 @@ admin/aws/route53=Route 53
admin/aws/route53-nav=Route 53
admin/aws/route53-desc=AWS Route 53 DNS Hosting

admin/aws/route53/change=Route 53 Change
admin/aws/route53/change-nav=
admin/aws/route53/change-desc=AWS Route 53 change status

admin/aws/route53/hostedZone=Hosted Zone
admin/aws/route53/hostedZone-nav=
admin/aws/route53/hostedZone-desc=Route 53 Hosted Zone
Expand Down
8 changes: 8 additions & 0 deletions amazon-aws/i18n/inc/model/modChange.properties
@@ -0,0 +1,8 @@
# Change Model

# Change ID
changeID=change ID
# Status
status=status
# Submitted At
submittedAt=submitted at
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion amazon-aws/i18n/inc/model/modHostedZone.properties
Expand Up @@ -5,7 +5,7 @@ hostedZoneID=hosted zone ID
# Caller Reference
callerReference=caller reference
# Change Information
changeInfo=change information
change=change information
# Comment
comment=comment
# Delegation Set
Expand Down
25 changes: 25 additions & 0 deletions amazon-aws/inc/model/modChange.cfc
@@ -0,0 +1,25 @@
component extends="algid.inc.resource.base.model" {
public component function init(required component i18n, string locale = 'en_US') {
super.init(arguments.i18n, arguments.locale);

// Change ID
addAttribute(
attribute = 'changeID'
);

// Status
addAttribute(
attribute = 'status'
);

// Submitted At
addAttribute(
attribute = 'submittedAt'
);

// Set the bundle information for translation
addBundle('plugins/amazon-aws/i18n/inc/model', 'modChange');

return this;
}
}
5 changes: 2 additions & 3 deletions amazon-aws/inc/model/modHostedZone.cfc
Expand Up @@ -13,10 +13,9 @@ component extends="algid.inc.resource.base.model" {
defaultValue = createUUID()
);

// ChangeInformation
// Change Information
addAttribute(
attribute = 'changeInfo',
defaultValue = {}
attribute = 'change'
);

// Comment
Expand Down
76 changes: 61 additions & 15 deletions amazon-aws/inc/service/servRoute53.cfc
Expand Up @@ -20,6 +20,7 @@
<cfargument name="currUser" type="component" required="true" />
<cfargument name="hostedZone" type="component" required="true" />

<cfset var change = '' />
<cfset var delegationSet = '' />
<cfset var hostedZone = '' />
<cfset var modelSerial = '' />
Expand Down Expand Up @@ -50,16 +51,61 @@
<!--- Pull the data in from the response --->
<cfset parsed = xmlParse(results.filecontent).xmlroot />

<cfset changeInfo = {
'changeInfoID': parsed.changeInfo.id.xmlText,
'status': parsed.changeInfo.status.xmlText,
'submittedAt': parsed.changeInfo.submittedAt.xmlText
} />
<cfset change = getModel('amazon-aws', 'change') />

<cfset change.setChangeInfoID(parsed.changeInfo.id.xmlText) />
<cfset change.setStatus(parsed.status.id.xmlText) />
<cfset change.setSubmittedAt(parsed.submittedAt.id.xmlText) />

<!--- After Delete Event --->
<cfset observer.afterHostedZoneDelete(variables.transport, arguments.currUser, arguments.hostedZone) />

<cfreturn changeInfo />
<cfreturn change />
</cffunction>

<cffunction name="getChange" access="public" returntype="component" output="false">
<cfargument name="currUser" type="component" required="true" />
<cfargument name="changeID" type="string" required="true" />

<cfset var delegationSet = '' />
<cfset var change = '' />
<cfset var modelSerial = '' />
<cfset var nameServer = '' />
<cfset var observer = '' />
<cfset var parsed = '' />
<cfset var requestDate = '' />
<cfset var results = '' />

<cfset requestDate = getDate() />

<!--- Get the event observer --->
<cfset observer = getPluginObserver('amazon-aws', 'route53') />

<cfset change = getModel('amazon-aws', 'change') />

<!--- Before Get Event --->
<cfset observer.beforeChangeGet(variables.transport, arguments.currUser, arguments.changeID) />

<!--- Retrieve the change --->
<cfhttp method="get" url="https://#variables.service.hostname#/#variables.service.version#/change/#listLast(arguments.changeID, '/')#" result="results">
<cfhttpparam type="header" name="Date" value="#requestDate#" />
<cfhttpparam type="header" name="X-Amzn-Authorization" value="AWS3-HTTPS AWSAccessKeyId=#variables.awsKeys.accessKeyID#,Algorithm=HmacSHA256,Signature=#variables.hmac.getSignatureAsBase64(requestDate, variables.awsKeys.secretKey, 'hmacSHA256')#" />
</cfhttp>

<cfif results.status_code neq 200>
<cfthrow message="Unable to complete web service call" detail="Server responded with a #results.status_code# status" extendedinfo="#results.filecontent#" />
</cfif>

<cfset parsed = xmlParse(results.filecontent).xmlroot />

<cfset change.setChangeInfoID(parsed.changeInfo.id.xmlText) />
<cfset change.setStatus(parsed.status.id.xmlText) />
<cfset change.setSubmittedAt(parsed.submittedAt.id.xmlText) />

<!--- After Get Event --->
<cfset observer.afterChangeGet(variables.transport, arguments.currUser, arguments.changeID) />

<cfreturn change />
</cffunction>

<cffunction name="getDate" access="public" returntype="string" output="false">
Expand Down Expand Up @@ -173,11 +219,11 @@
<cfreturn hostedZones />
</cffunction>

<cffunction name="setHostedZone" access="public" returntype="struct" output="false">
<cffunction name="setHostedZone" access="public" returntype="component" output="false">
<cfargument name="currUser" type="component" required="true" />
<cfargument name="hostedZone" type="component" required="true" />

<cfset var changeInfo = '' />
<cfset var change = '' />
<cfset var delegationSet = '' />
<cfset var nameServer = '' />
<cfset var observer = '' />
Expand Down Expand Up @@ -232,13 +278,13 @@
<cfset hostedZone.setCallerReference(parsed.hostedZone.callerReference.xmlText) />
<cfset hostedZone.setComment(parsed.hostedZone.config.comment.xmlText) />

<cfset changeInfo = {
'changeInfoID': parsed.changeInfo.id.xmlText,
'status': parsed.changeInfo.status.xmlText,
'submittedAt': parsed.changeInfo.submittedAt.xmlText
} />
<cfset change = getModel('amazon-aws', 'change') />

<cfset change.setChangeInfoID(parsed.changeInfo.id.xmlText) />
<cfset change.setStatus(parsed.status.id.xmlText) />
<cfset change.setSubmittedAt(parsed.submittedAt.id.xmlText) />

<cfset hostedZone.setChangeInfo(changeInfo) />
<cfset hostedZone.setChange(change) />

<cfset delegationSet = {
'nameServers': []
Expand All @@ -256,6 +302,6 @@
<!--- After Save Event --->
<cfset observer.afterHostedZoneSave(variables.transport, arguments.currUser, arguments.hostedZone) />

<cfreturn changeInfo />
<cfreturn change />
</cffunction>
</cfcomponent>
13 changes: 13 additions & 0 deletions amazon-aws/inc/view/viewRoute53.cfc
Expand Up @@ -29,6 +29,19 @@
<cfreturn theForm.toHTML(theURL.get()) />
</cffunction>

<cffunction name="detailChange" access="public" returntype="string" output="false">
<cfargument name="change" type="component" required="true" />

<cfset var html = '' />

<!--- TODO Make a nice display of the information for the change --->
<cfsavecontent variable="html">
<cfset arguments.change.print() />
</cfsavecontent>

<cfreturn html />
</cffunction>

<cffunction name="detailHostedZone" access="public" returntype="string" output="false">
<cfargument name="hostedZone" type="component" required="true" />

Expand Down

0 comments on commit 81f657c

Please sign in to comment.