Skip to content

Commit 2dd9680

Browse files
committed
Fix warnings in CountryRetController
1 parent 420beff commit 2dd9680

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/main/java/cc/altius/FASP/rest/controller/CountryRestController.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public class CountryRestController {
6666
)
6767
@ApiResponse(content = @Content(mediaType = "text/json", array = @ArraySchema(schema = @Schema(implementation = Country.class))), responseCode = "200", description = "Returns the list of active countries")
6868
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "500", description = "Internal error that prevented the retrieval of the country list")
69-
public ResponseEntity getCountryList(Authentication auth) {
69+
public ResponseEntity<Object> getCountryList(Authentication auth) {
7070
try {
7171
CustomUserDetails curUser = this.userService.getCustomUserByUserIdForApi(((CustomUserDetails) auth.getPrincipal()).getUserId(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getMethod(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRequestURI());
72-
return new ResponseEntity(this.countryService.getCountryList(true, curUser), HttpStatus.OK); // 200
72+
return new ResponseEntity<>(this.countryService.getCountryList(true, curUser), HttpStatus.OK); // 200
7373
} catch (Exception e) {
7474
logger.error("Error while getting country list", e);
75-
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
75+
return new ResponseEntity<>(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
7676
}
7777
}
7878

@@ -89,13 +89,13 @@ public ResponseEntity getCountryList(Authentication auth) {
8989
)
9090
@ApiResponse(content = @Content(mediaType = "text/json", array = @ArraySchema(schema = @Schema(implementation = Country.class))), responseCode = "200", description = "Returns the list of all countries")
9191
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "500", description = "Internal error that prevented the retrieval of the country list")
92-
public ResponseEntity getCountryListAll(Authentication auth) {
92+
public ResponseEntity<Object> getCountryListAll(Authentication auth) {
9393
try {
9494
CustomUserDetails curUser = this.userService.getCustomUserByUserIdForApi(((CustomUserDetails) auth.getPrincipal()).getUserId(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getMethod(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRequestURI());
95-
return new ResponseEntity(this.countryService.getCountryList(false, curUser), HttpStatus.OK); // 200
95+
return new ResponseEntity<>(this.countryService.getCountryList(false, curUser), HttpStatus.OK); // 200
9696
} catch (Exception e) {
9797
logger.error("Error while getting country list all", e);
98-
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
98+
return new ResponseEntity<>(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
9999
}
100100
}
101101

@@ -115,16 +115,16 @@ public ResponseEntity getCountryListAll(Authentication auth) {
115115
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = Country.class)), responseCode = "200", description = "Returns the country with the given ID")
116116
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "404", description = "Unable to find the country with the given ID")
117117
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "500", description = "Internal error that prevented the retrieval of the country")
118-
public ResponseEntity getCountryById(@PathVariable("countryId") int countryId, Authentication auth) {
118+
public ResponseEntity<Object> getCountryById(@PathVariable("countryId") int countryId, Authentication auth) {
119119
try {
120120
CustomUserDetails curUser = this.userService.getCustomUserByUserIdForApi(((CustomUserDetails) auth.getPrincipal()).getUserId(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getMethod(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRequestURI());
121-
return new ResponseEntity(this.countryService.getCountryById(countryId, curUser), HttpStatus.OK); // 200
121+
return new ResponseEntity<>(this.countryService.getCountryById(countryId, curUser), HttpStatus.OK); // 200
122122
} catch (EmptyResultDataAccessException er) {
123123
logger.error("Error while getting country id=" + countryId, er);
124-
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.NOT_FOUND); //404
124+
return new ResponseEntity<>(new ResponseCode("static.message.listFailed"), HttpStatus.NOT_FOUND); //404
125125
} catch (Exception e) {
126126
logger.error("Error while getting country id=" + countryId, e);
127-
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
127+
return new ResponseEntity<>(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
128128
}
129129
}
130130

@@ -148,22 +148,22 @@ public ResponseEntity getCountryById(@PathVariable("countryId") int countryId, A
148148
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "200", description = "Returns a success response")
149149
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "406", description = "The country already exists")
150150
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "500", description = "Internal error that prevented the creation of the country")
151-
public ResponseEntity addCountry(@RequestBody(required = true) Country country, Authentication auth) {
151+
public ResponseEntity<Object> addCountry(@RequestBody(required = true) Country country, Authentication auth) {
152152
try {
153153
CustomUserDetails curUser = this.userService.getCustomUserByUserIdForApi(((CustomUserDetails) auth.getPrincipal()).getUserId(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getMethod(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRequestURI());
154154
int countryId = this.countryService.addCountry(country, curUser);
155155
if (countryId > 0) {
156-
return new ResponseEntity(new ResponseCode("static.message.addSuccess"), HttpStatus.OK); // 200
156+
return new ResponseEntity<>(new ResponseCode("static.message.addSuccess"), HttpStatus.OK); // 200
157157
} else {
158158
logger.error("Error while adding country no Id returned");
159-
return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
159+
return new ResponseEntity<>(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
160160
}
161161
} catch (DuplicateKeyException e) {
162162
logger.error("Error while adding country", e);
163-
return new ResponseEntity(new ResponseCode("static.message.alreadyExists"), HttpStatus.NOT_ACCEPTABLE); // 406
163+
return new ResponseEntity<>(new ResponseCode("static.message.alreadyExists"), HttpStatus.NOT_ACCEPTABLE); // 406
164164
} catch (Exception e) {
165165
logger.error("Error while adding country", e);
166-
return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
166+
return new ResponseEntity<>(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
167167
}
168168

169169
}
@@ -188,22 +188,22 @@ public ResponseEntity addCountry(@RequestBody(required = true) Country country,
188188
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "200", description = "Returns a success message")
189189
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "406", description = "The country already exists")
190190
@ApiResponse(content = @Content(mediaType = "text/json", schema = @Schema(implementation = ResponseCode.class)), responseCode = "500", description = "Internal error that prevented the update of the country")
191-
public ResponseEntity editCountry(@RequestBody(required = true) Country country, Authentication auth) {
191+
public ResponseEntity<Object> editCountry(@RequestBody(required = true) Country country, Authentication auth) {
192192
try {
193193
CustomUserDetails curUser = this.userService.getCustomUserByUserIdForApi(((CustomUserDetails) auth.getPrincipal()).getUserId(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getMethod(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRequestURI());
194194
int updatedId = this.countryService.updateCountry(country, curUser);
195195
if (updatedId > 0) {
196-
return new ResponseEntity(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK); // 200
196+
return new ResponseEntity<>(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK); // 200
197197
} else {
198198
logger.error("Error while updating country, 0 rows updated");
199-
return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
199+
return new ResponseEntity<>(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
200200
}
201201
} catch (DuplicateKeyException e) {
202202
logger.error("Error while updating country", e);
203-
return new ResponseEntity(new ResponseCode("static.message.alreadyExists"), HttpStatus.NOT_ACCEPTABLE); // 406
203+
return new ResponseEntity<>(new ResponseCode("static.message.alreadyExists"), HttpStatus.NOT_ACCEPTABLE); // 406
204204
} catch (Exception e) {
205205
logger.error("Error while updating country", e);
206-
return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
206+
return new ResponseEntity<>(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR); // 500
207207
}
208208
}
209209

0 commit comments

Comments
 (0)