Skip to content

Commit

Permalink
#140 Fix transaction handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bukajsytlos committed Jul 24, 2018
1 parent 1285338 commit da72a0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/inttest/resources/sql/prepDefaultUser.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ DELETE FROM login;

INSERT INTO oauth_clients (id, name, client_secret, client_type, redirect_uris, default_redirect_uri, default_scope)
VALUES
('test', 'test', 'test', 'public', 'http://localhost https://www.getpostman.com/oauth2/callback ', 'http://localhost',
('test', 'test', '{noop}test', 'public', 'http://localhost https://www.getpostman.com/oauth2/callback ',
'http://localhost',
'read_events read_achievements upload_map upload_mod upload_avatar write_account_data vote');

INSERT INTO login (id, login, email, password, steamid)
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/faforever/api/data/DataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -41,11 +40,11 @@ private static Object getPrincipal(final Authentication authentication) {
return authentication != null ? authentication.getPrincipal() : null;
}

//!!! No @Transactional - transactions are being handled by Elide
@RequestMapping(
method = RequestMethod.GET,
produces = JSON_API_MEDIA_TYPE,
value = {"/{entity}", "/{entity}/{id}/relationships/{entity2}", "/{entity}/{id}/{child}", "/{entity}/{id}"})
@Transactional(readOnly = true)
@Cacheable(cacheResolver = "elideCacheResolver", keyGenerator = GetCacheKeyGenerator.NAME)
public ResponseEntity<String> get(@RequestParam final Map<String, String> allRequestParams,
final HttpServletRequest request,
Expand All @@ -58,11 +57,11 @@ public ResponseEntity<String> get(@RequestParam final Map<String, String> allReq
return wrapResponse(response);
}

//!!! No @Transactional - transactions are being handled by Elide
@RequestMapping(
method = RequestMethod.POST,
produces = JSON_API_MEDIA_TYPE,
value = {"/{entity}", "/{entity}/{id}/relationships/{entity2}", "/{entity}/{id}/{child}", "/{entity}/{id}"})
@Transactional
@Cacheable(cacheResolver = "elideCacheResolver")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<String> post(@RequestBody final String body,
Expand All @@ -76,11 +75,11 @@ public ResponseEntity<String> post(@RequestBody final String body,
return wrapResponse(response);
}

//!!! No @Transactional - transactions are being handled by Elide
@RequestMapping(
method = RequestMethod.PATCH,
produces = JSON_API_MEDIA_TYPE,
value = {"/{entity}/{id}", "/{entity}/{id}/relationships/{entity2}"})
@Transactional
@PreAuthorize("hasRole('USER')")
public ResponseEntity<String> patch(@RequestBody final String body,
final HttpServletRequest request,
Expand All @@ -94,11 +93,11 @@ public ResponseEntity<String> patch(@RequestBody final String body,
return wrapResponse(response);
}

//!!! No @Transactional - transactions are being handled by Elide
@RequestMapping(
method = RequestMethod.DELETE,
produces = JSON_API_MEDIA_TYPE,
value = {"/{entity}/{id}", "/{entity}/{id}/relationships/{entity2}"})
@Transactional
@PreAuthorize("hasRole('USER')")
public ResponseEntity<String> delete(final HttpServletRequest request,
final Authentication authentication) {
Expand Down

0 comments on commit da72a0c

Please sign in to comment.