Skip to content

Commit

Permalink
Release 4.1.1 (#444)
Browse files Browse the repository at this point in the history
* fix: Fix for ERM-1777 (#442)

StringTemplateService will now fire if a StringTemplate has been deleted since the last run

* updated NEWS.md and gradle.properties

* tweak to APITenantSpec

* fix: ERM-1781 (#443)

Error on adding coverage to PCI which overlaps with existing coverage on PTI/TI, validate now uses existing session

* updated NEWS.md
  • Loading branch information
EthanFreestone authored Aug 3, 2021
1 parent ed2c5ed commit e4aea58
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.1.1 2021-07-28
* ERM-1781 Error on adding coverage to PCI which overlaps with existing coverage on PTI/TI
* ERM-1777 Templated URL not updating on deletion of Proxy

## 4.1.0 2021-06-15
* ERM-1730 Add renewalPriority to agreement widget definition
* ERM-1724 Reduce running time for StringTemplateBulkSpec integration test
Expand Down
2 changes: 1 addition & 1 deletion service/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ gradleWrapperVersion=5.4

# Application
appName=mod-agreements
appVersion=4.1.0
appVersion=4.1.1
dockerTagSuffix=
dockerRepo=folioci
5 changes: 4 additions & 1 deletion service/grails-app/domain/org/olf/kb/ErmResource.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public class ErmResource extends ErmTitleList implements MultiTenant<ErmResource
def beforeValidate() {
if (!validating) {
validating = true
CoverageService.changeListener(this)
// Attempt to avoid session locking
ErmResource.withSession {
CoverageService.changeListener(this)
}
validating = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.k_int.web.toolkit.settings.AppSetting
@CompileStatic
@Transactional
public class StringTemplatingService {

/*
* This method will take in an id of the form f311d130-8024-47c4-8a86-58f817dbefde
* It will return a Map of StringTemplates grouped by context, that are relevant for this id
Expand Down Expand Up @@ -159,9 +158,14 @@ public class StringTemplatingService {
// Also create container for the current cursor value
Date last_refreshed
AppSetting url_refresh_cursor
AppSetting previous_sts_count
Long previousStsCount

Tenants.withId(tenantId) {
// One transaction for fetching the initial value/creating AppSetting
// Start by grabbing the count of StringTemplates currently in the system
Long currentStsCount = StringTemplate.executeQuery("select count(*) from StringTemplate")[0]

// One transaction for fetching the initial values/creating AppSettings
AppSetting.withNewTransaction {
// Need to flush this initially so it exists for first instance
// Set initial cursor to 0 so everything currently in system gets updated
Expand All @@ -172,8 +176,16 @@ public class StringTemplatingService {
value: 0
).save(flush: true, failOnError: true)

// Parse setting String to Date
previous_sts_count = AppSetting.findByKey('sts_count') ?: new AppSetting(
section:'registry',
settingType:'Number',
key: 'sts_count',
value: 0
).save(flush: true, failOnError: true)

// Parse setting Strings to Date/Long
last_refreshed = new Date(Long.parseLong(url_refresh_cursor.value))
previousStsCount = Long.parseLong(previous_sts_count.value)
}

// Fetch stringTemplates that have changed since the last refresh
Expand All @@ -185,7 +197,15 @@ public class StringTemplatingService {
}
}

if (sts.size() > 0) {
/*
* If sts.size is not zero, or the counts differ,
* then string templates have been created, deleted or updated
* so run refresh for all.
*/
if (
currentStsCount != previousStsCount ||
sts.size() > 0
) {
// StringTemplates have changed, ignore more granular changes and just refresh everything
generateTemplatedUrlsForErmResources(tenantId)
} else {
Expand Down Expand Up @@ -235,10 +255,13 @@ public class StringTemplatingService {
}
}

//One transaction for updating value with new refresh time
//One transaction for updating value with new refresh time and new count (count taken from beginning of refresh task)
AppSetting.withNewTransaction {
url_refresh_cursor.value = new_cursor_value
url_refresh_cursor.save(failOnError: true)

previous_sts_count.value = currentStsCount
previous_sts_count.save(failOnError: true)
}
}

Expand Down
11 changes: 1 addition & 10 deletions service/src/integration-test/groovy/org/olf/TenantAPISpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import spock.util.concurrent.PollingConditions

@Integration
@Stepwise
class TenantAPISpec extends HttpSpec {
class TenantAPISpec extends BaseSpec {

static final String tenantName = 'tenant_api_tests'
static final Closure booleanResponder = {
Expand All @@ -22,15 +22,6 @@ class TenantAPISpec extends HttpSpec {
}
}

def setupSpec() {
httpClientConfig = {
client.clientCustomizer { HttpURLConnection conn ->
conn.connectTimeout = 2000
conn.readTimeout = 10000 // Need this for activating tenants
}
}
}

def setup() {
setHeaders((OkapiHeaders.TENANT): tenantName)
}
Expand Down

0 comments on commit e4aea58

Please sign in to comment.