Skip to content

Commit

Permalink
completed deleteApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Risberg committed Sep 17, 2009
1 parent 3eb8f30 commit 8984b17
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions hqu/hqapi1/app/ApplicationController.groovy
Expand Up @@ -5,7 +5,7 @@ import org.hyperic.hq.appdef.shared.ApplicationManagerLocal

class ApplicationController extends ApiController {

ApplicationManagerLocal applicationManager = null;
ApplicationManagerLocal applicationManager = ApplicationManagerEJBImpl.getOne()

private Closure getApplicationXML(a) {
{ doc ->
Expand All @@ -17,23 +17,17 @@ class ApplicationController extends ApiController {
opsContact : a.opsContact,
bizContact : a.businessContact)
// TODO: include ApplicationServices and ApplicationGroups
// a.getAppServiceValues().each { asv ->
// print "Resource: " + asv
a.getAppServiceValues().each { asv ->
print "Resource: " + asv
// if (!asv.isCluster) {
// Resource(id : asv.service.id,
// name : asv.service.name,
// description : asv.service.description)
// }
// }
}
}
}

protected void init() {
applicationManager = ApplicationManagerEJBImpl.getOne()
// TODO: remove next debugging line
print "Number of Applications: " + applicationManager.getApplicationCount()
}

def list(params) {
def failureXml = null

Expand Down Expand Up @@ -91,19 +85,47 @@ class ApplicationController extends ApiController {
return
}

def app = getApplication(id)
def failureXml = null

// TODO: remove next debugging line
print "ID: " + id
if (!app) {
renderXml() {
out << StatusResponse() {
out << getFailureXML(ErrorCode.OBJECT_NOT_FOUND)
}
}
return
}

try {
removeApplication(id)
} catch (Exception e) {
renderXml() {
log.error("Error removing application", e)
StatusResponse() {
out << getFailureXML(ErrorCode.UNEXPECTED_ERROR)
}
}
return
}

renderXml() {
StatusResponse() {
if (failureXml) {
out << failureXml
} else {
out << getSuccessXML()
}
out << getSuccessXML()
}
}
}
}

private getApplication(id) {
try {
return applicationManager.findApplicationById(user, id)
}
catch (Exception e) {
return null
}
}

private removeApplication(id) {
applicationManager.removeApplication(user, id)
}
}

0 comments on commit 8984b17

Please sign in to comment.