1313 *******************************************************************************/
1414package org .cloudfoundry .identity .uaa .approval ;
1515
16- import org .cloudfoundry .identity .uaa .util .UaaStringUtils ;
17- import org .slf4j .Logger ;
18- import org .slf4j .LoggerFactory ;
1916import org .cloudfoundry .identity .uaa .approval .Approval .ApprovalStatus ;
2017import org .cloudfoundry .identity .uaa .audit .event .ApprovalModifiedEvent ;
2118import org .cloudfoundry .identity .uaa .audit .event .SystemDeletable ;
19+ import org .cloudfoundry .identity .uaa .util .UaaStringUtils ;
20+ import org .slf4j .Logger ;
21+ import org .slf4j .LoggerFactory ;
2222import org .springframework .context .ApplicationEvent ;
2323import org .springframework .context .ApplicationEventPublisher ;
2424import org .springframework .context .ApplicationEventPublisherAware ;
@@ -79,7 +79,7 @@ public class JdbcApprovalStore implements ApprovalStore, ApplicationEventPublish
7979 private ApplicationEventPublisher applicationEventPublisher ;
8080
8181 public JdbcApprovalStore (JdbcTemplate jdbcTemplate ) {
82- Assert .notNull (jdbcTemplate );
82+ Assert .notNull (jdbcTemplate , "jdbcTemplate is required" );
8383 this .jdbcTemplate = jdbcTemplate ;
8484 }
8585
@@ -88,7 +88,9 @@ public void setHandleRevocationsAsExpiry(boolean handleRevocationsAsExpiry) {
8888 }
8989
9090 public boolean refreshApproval (final Approval approval , final String zoneId ) {
91- logger .debug ("refreshing approval: [{}]" , UaaStringUtils .getCleanedUserControlString (approval .toString ()));
91+ if (logger .isDebugEnabled ()) {
92+ logger .debug ("refreshing approval: [{}]" , UaaStringUtils .getCleanedUserControlString (approval .toString ()));
93+ }
9294 int refreshed = jdbcTemplate .update (REFRESH_AUTHZ_SQL , ps -> {
9395 ps .setTimestamp (1 , new Timestamp (approval .getLastUpdatedAt ().getTime ()));
9496 ps .setTimestamp (2 , new Timestamp (approval .getExpiresAt ().getTime ()));
@@ -106,7 +108,9 @@ public boolean refreshApproval(final Approval approval, final String zoneId) {
106108
107109 @ Override
108110 public boolean addApproval (final Approval approval , final String zoneId ) {
109- logger .debug ("adding approval: [{}]" , UaaStringUtils .getCleanedUserControlString (approval .toString ()));
111+ if (logger .isDebugEnabled ()) {
112+ logger .debug ("adding approval: [{}]" , UaaStringUtils .getCleanedUserControlString (approval .toString ()));
113+ }
110114 try {
111115 refreshApproval (approval , zoneId ); // try to refresh the approval
112116 } catch (DataIntegrityViolationException ex ) { // could not find the
@@ -184,10 +188,10 @@ public boolean purgeExpiredApprovals() {
184188 logger .debug ("Purging expired approvals from database" );
185189 try {
186190 int deleted = jdbcTemplate .update (DELETE_AUTHZ_SQL + " where expiresAt <= ?" ,
187- ps -> { //PreparedStatementSetter
188- ps .setTimestamp (1 , new Timestamp (new Date ().getTime ()));
189- } );
190- logger .debug (deleted + " expired approvals deleted" );
191+ //PreparedStatementSetter
192+ ps -> ps .setTimestamp (1 , new Timestamp (new Date ().getTime ()))
193+ );
194+ logger .debug ("{} expired approvals deleted", deleted );
191195 } catch (DataAccessException ex ) {
192196 logger .error ("Error purging expired approvals" , ex );
193197 return false ;
@@ -252,28 +256,28 @@ public void publish(ApplicationEvent event) {
252256 @ Override
253257 public int deleteByIdentityZone (String zoneId ) {
254258 int approvalCount = jdbcTemplate .update (DELETE_ZONE_APPROVALS , zoneId );
255- getLogger ().debug ("Deleted zone approvals '%s ' and count:%s" . formatted ( zoneId , approvalCount ) );
259+ getLogger ().debug ("Deleted zone approvals '{} ' and count:{}" , zoneId , approvalCount );
256260 return approvalCount ;
257261 }
258262
259263 @ Override
260264 public int deleteByOrigin (String origin , String zoneId ) {
261265 int approvalCount = jdbcTemplate .update (DELETE_OF_USER_APPROVALS_BY_PROVIDER , origin , zoneId );
262- getLogger ().debug ("Deleted provider approvals '%s'/%s and count:%s" . formatted ( origin , zoneId , approvalCount ) );
266+ getLogger ().debug ("Deleted provider approvals '{}'/{} and count:{}" , origin , zoneId , approvalCount );
263267 return approvalCount ;
264268 }
265269
266270 @ Override
267271 public int deleteByClient (String clientId , String zoneId ) {
268272 int approvalCount = jdbcTemplate .update (DELETE_CLIENT_APPROVALS , clientId , zoneId );
269- getLogger ().debug ("Deleted client '%s ' and %s approvals" . formatted ( clientId , approvalCount ) );
273+ getLogger ().debug ("Deleted client '{} ' and {} approvals" , clientId , approvalCount );
270274 return approvalCount ;
271275 }
272276
273277 @ Override
274278 public int deleteByUser (String userId , String zoneId ) {
275279 int approvalCount = jdbcTemplate .update (DELETE_USER_APPROVALS , userId , zoneId );
276- getLogger ().debug ("Deleted user '%s ' and %s approvals" . formatted ( userId , approvalCount ) );
280+ getLogger ().debug ("Deleted user '{} ' and {} approvals" , userId , approvalCount );
277281 return approvalCount ;
278282 }
279283
@@ -283,7 +287,6 @@ public Logger getLogger() {
283287 }
284288
285289 private static class AuthorizationRowMapper implements RowMapper <Approval > {
286-
287290 @ Override
288291 public Approval mapRow (ResultSet rs , int rowNum ) throws SQLException {
289292 String userId = rs .getString (1 );
0 commit comments