Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db migration #49

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.1</version>
<version>42.4.4</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.10.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.javers/javers-core -->
<dependency>
<groupId>org.javers</groupId>
Expand Down Expand Up @@ -65,37 +71,37 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>

<dependency>
Expand All @@ -122,12 +128,12 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.71</version>
<version>1.74</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.71</version>
<version>1.74</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
Expand All @@ -149,7 +155,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/edu/washington/iam/registry/rp/DBMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ public List<RelyingParty> getRelyingPartyHistoryById(String id) throws RelyingPa
try {
rps = template.query(
"select * from metadata where group_id = ? and entity_id = ?" +
"order by start_time ASC",
" order by start_time ASC",
new Object[]{groupId, id},
new RelyingPartyMapper());
log.info("Got a response in getRelyingPartyHistoryById");
return rps;
}
catch (Exception e){
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, rps.size());
log.debug(errorMsg);
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, (rps == null) ? 0 : rps.size());
log.error(errorMsg, e);
throw new RelyingPartyException(errorMsg);
}

Expand All @@ -79,8 +80,8 @@ public RelyingParty getRelyingPartyById(String id) throws RelyingPartyException
return rps.get(0);
}
else {
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, rps.size());
log.debug(errorMsg);
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, (rps == null) ? 0 : rps.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional nit: Extract into a local variable.

It can help to minimize computations done in format statements, so that readers can focus on understanding the format string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to ignore this for now. This error message is almost never used; I made the smallest update possible to get it to not NullPointerException.

log.error(errorMsg);
throw new RelyingPartyException(errorMsg);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
<property name="dataSource" ref="postgresDataSource" />
</bean>

<bean id="postgresDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://${spreg.db.url}"/>
<property name="username" value="${spreg.db.username}"/>
<bean id="postgresDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="org.postgresql.Driver"/>
<property name="jdbcUrl" value="jdbc:postgresql://${spreg.db.host}/${spreg.db.name}?sslmode=verify-ca&amp;sslrootcert=${spreg.db.sslrootcert}&amp;sslcert=${spreg.db.sslcert}&amp;sslkey=${spreg.db.sslkey}"/>
<property name="user" value="${spreg.db.username}"/>
<property name="password" value="${spreg.db.password}"/>
<property name="testConnectionOnCheckout" value="true"/>
</bean>

</beans>
Loading