Skip to content

Commit 8e80698

Browse files
committed
Release 0.0.27
Bugfix for StaleObjectStateException
1 parent 57b50d3 commit 8e80698

File tree

9 files changed

+72
-11
lines changed

9 files changed

+72
-11
lines changed

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>access</artifactId>
7-
<version>0.0.27-SNAPSHOT</version>
7+
<version>0.0.27</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-client</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.openconext</groupId>
55
<artifactId>access</artifactId>
6-
<version>0.0.27-SNAPSHOT</version>
6+
<version>0.0.27</version>
77
<packaging>pom</packaging>
88
<name>access</name>
99
<description>SURFconext Invite</description>

provisioning-mock/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>access</artifactId>
7-
<version>0.0.27-SNAPSHOT</version>
7+
<version>0.0.27</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>provisioning-mock</artifactId>

server/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>access</artifactId>
7-
<version>0.0.27-SNAPSHOT</version>
7+
<version>0.0.27</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-server</artifactId>
@@ -23,10 +23,11 @@
2323
<groupId>org.springframework.session</groupId>
2424
<artifactId>spring-session-jdbc</artifactId>
2525
</dependency>
26+
<!-- https://mvnrepository.com/artifact/io.hypersistence/hypersistence-utils-hibernate-63 -->
2627
<dependency>
2728
<groupId>io.hypersistence</groupId>
28-
<artifactId>hypersistence-utils-hibernate-60</artifactId>
29-
<version>3.8.2</version>
29+
<artifactId>hypersistence-utils-hibernate-63</artifactId>
30+
<version>3.9.1</version>
3031
</dependency>
3132
<dependency>
3233
<groupId>org.springframework.boot</groupId>

server/src/main/java/access/teams/TeamsController.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,14 @@ public ResponseEntity<Map<String, Integer>> migrateTeam(@RequestBody Team team)
9494
//This is the disadvantage of having to save references from Manage
9595
Set<ApplicationUsage> applicationUsages = team.getApplications().stream()
9696
.map(applicationFromTeams -> {
97-
Application applicationFromDB = applicationRepository
98-
.findByManageIdAndManageType(applicationFromTeams.getManageId(), applicationFromTeams.getManageType())
99-
.orElseGet(() -> applicationRepository.save(applicationFromTeams));
97+
Optional<Application> optionalApplication = applicationRepository
98+
.findByManageIdAndManageType(applicationFromTeams.getManageId(), applicationFromTeams.getManageType());
99+
Application applicationFromDB = optionalApplication
100+
.orElseGet(() -> {
101+
// ID is also serialized from database teams object, need to prevent StaleObjectStateException
102+
applicationFromTeams.setId(null);
103+
return applicationRepository.save(applicationFromTeams);
104+
});
100105
return new ApplicationUsage(applicationFromDB, applicationFromTeams.getLandingPage());
101106
})
102107
.collect(Collectors.toSet());

server/src/main/resources/manage/oidc10_rp.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
"coin:application_url": "https://default-url-cloud.org"
3030
}
3131
}
32+
},
33+
{
34+
"_id": "7",
35+
"version": 1,
36+
"type": "oidc10_rp",
37+
"data": {
38+
"entityid": "https://unused",
39+
"metaDataFields": {
40+
"name:en": "Unused EN",
41+
"name:nl": "Unused NL",
42+
"OrganizationName:en": "SURF bv",
43+
"logo:0:url": "https://static.surfconext.nl/media/idp/surfconext.png",
44+
"coin:application_url": "https://default-url-unused.org"
45+
}
46+
}
3247
}
48+
3349
]

server/src/test/java/access/api/ManageControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void providers() throws Exception {
7878
.get("/api/v1/manage/providers")
7979
.as(new TypeRef<>() {
8080
});
81-
assertEquals(6, result.size());
81+
assertEquals(7, result.size());
8282
}
8383

8484
@Test

server/src/test/java/access/teams/TeamsControllerTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
import java.time.temporal.ChronoUnit;
1717
import java.util.List;
1818
import java.util.Map;
19+
import java.util.UUID;
1920
import java.util.stream.Collectors;
2021

2122
import static access.teams.TeamsController.mapAuthority;
23+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
24+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
2225
import static io.restassured.RestAssured.given;
2326
import static org.junit.jupiter.api.Assertions.*;
2427

@@ -102,6 +105,42 @@ void migrateTeam() throws JsonProcessingException {
102105
assertEquals(team.getName(), group.get("name"));
103106
}
104107

108+
@Test
109+
void migrateTeamObjectOptimisticLockingFailureException() throws JsonProcessingException {
110+
List<Membership> memberships = getMemberships();
111+
String manageId = UUID.randomUUID().toString();
112+
Application application = new Application(manageId, EntityType.OIDC10_RP);
113+
application.setId(Long.MAX_VALUE - 1);
114+
115+
List<Application> applications = List.of(application);
116+
Team team = new Team(
117+
"nl:surfnet:diensten:test",
118+
"test migration",
119+
"test migration",
120+
memberships,
121+
applications
122+
);
123+
String path = String.format("/manage/api/internal/metadata/%s/%s",
124+
application.getManageType().name().toLowerCase(), manageId);
125+
String body = objectMapper.writeValueAsString(localManage.providerById(application.getManageType(), "7"));
126+
stubFor(get(urlPathMatching(path)).willReturn(aResponse()
127+
.withHeader("Content-Type", "application/json")
128+
.withBody(body)));
129+
130+
super.stubForManageProvisioning(List.of());
131+
132+
given()
133+
.when()
134+
.auth().preemptive().basic("teams", "secret")
135+
.accept(ContentType.JSON)
136+
.contentType(ContentType.JSON)
137+
.body(team)
138+
.put("/api/external/v1/teams")
139+
.then()
140+
.statusCode(201);
141+
142+
}
143+
105144
private List<Membership> getMemberships() {
106145
return userRoles.entrySet().stream()
107146
.map(entry -> new Membership(

welcome/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>access</artifactId>
7-
<version>0.0.27-SNAPSHOT</version>
7+
<version>0.0.27</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-welcome</artifactId>

0 commit comments

Comments
 (0)