From 18ca733f595ed11aa717e49b3d7693cc44985222 Mon Sep 17 00:00:00 2001 From: Ryan Morgan Date: Tue, 12 Jan 2010 15:27:02 -0800 Subject: [PATCH 1/3] Bump to 1.8. --- hqu/hqapi1/plugin.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hqu/hqapi1/plugin.properties b/hqu/hqapi1/plugin.properties index c9cf4702..bbffc5f6 100644 --- a/hqu/hqapi1/plugin.properties +++ b/hqu/hqapi1/plugin.properties @@ -1,6 +1,6 @@ plugin.name=hqapi1 plugin.helpTag=hqapi -plugin.version=1.7 +plugin.version=1.8 plugin.apiMajor=1 -plugin.apiMinor=7 +plugin.apiMinor=8 From f8382d4eb04764698e5a68ae28f5f79ca23a57b0 Mon Sep 17 00:00:00 2001 From: Ryan Morgan Date: Tue, 12 Jan 2010 15:55:47 -0800 Subject: [PATCH 2/3] [HHQ-3664] Increase application update/create by not using Groovy's Collection.minus() and pre-fetch the application inventory prior to the session being marked read-write. --- hqu/hqapi1/app/ApplicationController.groovy | 48 ++++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/hqu/hqapi1/app/ApplicationController.groovy b/hqu/hqapi1/app/ApplicationController.groovy index fe32a2ea..f9894cc7 100644 --- a/hqu/hqapi1/app/ApplicationController.groovy +++ b/hqu/hqapi1/app/ApplicationController.groovy @@ -90,6 +90,22 @@ class ApplicationController extends ApiController { return true } + private buildServiceList(resources) { + def svcList = [] // List of AppdefEntityID's to add to the application + + if (resources) { + resources.each { res -> + def rid = res.'@id'?.toInteger() + def sid = resMan.findResourceById(rid)?.instanceId + def entId = AppdefEntityID.newServiceID(sid) + if (!svcList.contains(entId)) { + svcList.add(entId) + } + } + } + svcList + } + /** * Create an Application via XML. * @@ -117,6 +133,10 @@ class ApplicationController extends ApiController { applicationValue.opsContact = appOps applicationValue.businessContact = appBiz + // Build resource list prior to update to avoid dirty checking of + // all Resource objects. + def resources = buildServiceList(xmlApplication['Resource']) + def newApp try { applicationValue.applicationType = appMan.findApplicationType(1) @@ -135,7 +155,6 @@ class ApplicationController extends ApiController { return null } - def resources = xmlApplication['Resource'] updateAppServices(newApp, resources) return newApp } @@ -209,6 +228,10 @@ class ApplicationController extends ApiController { applicationValue.opsContact = appOps applicationValue.businessContact = appBiz + // Build resource list prior to update to avoid dirty checking of + // all Resource objects. + def resources = buildServiceList(xmlApplication['Resource']) + try { appMan.updateApplication(user, applicationValue) } catch (AppdefDuplicateNameException e) { @@ -222,7 +245,6 @@ class ApplicationController extends ApiController { return null } - def resources = xmlApplication['Resource'] updateAppServices(updateApp, resources) return getApplication(appId) } @@ -324,19 +346,7 @@ class ApplicationController extends ApiController { } } - private updateAppServices(app, resources) { - def svcList = [] // List of AppdefEntityID's to add to the application - - if (resources) { - resources.each { res -> - def rid = res.'@id'?.toInteger() - def sid = resMan.findResourceById(rid)?.instanceId - def entId = AppdefEntityID.newServiceID(sid) - if (!svcList.contains(entId)) { - svcList.add(entId) - } - } - } + private updateAppServices(app, svcList) { // Setting the application services does not remove any app services // that may have been removed from the application. It will also add @@ -358,7 +368,13 @@ class ApplicationController extends ApiController { } } - def toAdd = svcList - svcListExisting + def toAdd = [] + for (svc in svcList) { + if (!svcListExisting.contains(svc)) { + toAdd << svc + } + } + appMan.setApplicationServices(user, app.id, toAdd) // Remove all deleted services From 2f100f3b7a65f2ece973556cc305eb7777612859 Mon Sep 17 00:00:00 2001 From: Ryan Morgan Date: Tue, 12 Jan 2010 15:58:04 -0800 Subject: [PATCH 3/3] Add ChangeLog entry for HHQ-3664 --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 05bbbe0c..e9097955 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ Changes in HQApi 2.4 + *) [HHQ-3664] Increase application update/create by not using Groovy's + Collection.minus() and pre-fetch the application inventory prior to the + session being marked read-write. + *) [HHQ-3624] For resource type alert definitions, update the "basic" information in a separate call so that the instance alert definitions are also updated