PAN-52 Updated logging formats
This commit is contained in:
+22
-22
@@ -40,8 +40,8 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Successfully completed query. Query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all accounts with size of " + listOfAccounts.size());
|
||||
LOG.debug("Successfully completed query. Query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all accounts with size of {}", listOfAccounts.size());
|
||||
|
||||
return new ResponseEntity<>(listOfAccounts, HttpStatus.OK);
|
||||
}
|
||||
@@ -49,13 +49,13 @@ public class AccountController {
|
||||
@GetMapping("/{id}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<AccountDto> getAccountById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to query for account with id " + id);
|
||||
LOG.info("Received request to query for account with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("ERROR: ID was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for account with id " + id);
|
||||
LOG.debug("Querying for account with id {}", id);
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
|
||||
@@ -63,13 +63,13 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
return account.map(accountDto -> {
|
||||
LOG.info("Returning account with id " + id);
|
||||
LOG.info("Returning account with id {}", id);
|
||||
return new ResponseEntity<>(accountDto, HttpStatus.OK);
|
||||
}).orElseGet(
|
||||
() -> {
|
||||
LOG.warn("No account was found with id " + id);
|
||||
LOG.warn("No account was found with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
);
|
||||
@@ -78,13 +78,13 @@ public class AccountController {
|
||||
@GetMapping("/{username}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<AccountDto> getAccountByUsername(@PathVariable("username") final String username) {
|
||||
LOG.info("Received request to query for account with username " + username);
|
||||
LOG.info("Received request to query for account with username {}", username);
|
||||
if (username == null) {
|
||||
LOG.error("ERROR: username was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for account with username " + username);
|
||||
LOG.debug("Querying for account with username {}", username);
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
|
||||
@@ -92,13 +92,13 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
return account.map(accountDto -> {
|
||||
LOG.info("Returning account with username " + username);
|
||||
LOG.info("Returning account with username {}", username);
|
||||
return new ResponseEntity<>(accountDto, HttpStatus.OK);
|
||||
}).orElseGet(
|
||||
() -> {
|
||||
LOG.warn("No account was found with username " + username);
|
||||
LOG.warn("No account was found with username {}", username);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
);
|
||||
@@ -144,7 +144,7 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning the newly created account");
|
||||
return new ResponseEntity<>(savedAccount, HttpStatus.CREATED);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class AccountController {
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Checking for existence of account with id " + id);
|
||||
LOG.debug("Checking for existence of account with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -179,18 +179,18 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
if (!existingAccount.isPresent()) {
|
||||
LOG.error("No account associated with id " + id);
|
||||
LOG.error("No account associated with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
PersistenceUtilities.copyNonNullProperties(accountDto, existingAccount.get());
|
||||
existingAccount.get().setVersion(existingAccount.get().getVersion()+ 1);
|
||||
|
||||
LOG.info("Updating account with id " + id);
|
||||
LOG.debug("Querying for account with ID " + id);
|
||||
LOG.info("Updating account with id {}", id);
|
||||
LOG.debug("Querying for account with id {}", id);
|
||||
|
||||
stopWatch.start();
|
||||
|
||||
@@ -198,20 +198,20 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(updatedAccount, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public @ResponseBody ResponseEntity<Void> deleteAccountById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to delete account with id " + id);
|
||||
LOG.info("Received request to delete account with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("Specified Id is null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Deleting account with id " + id);
|
||||
LOG.debug("Deleting account with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -220,7 +220,7 @@ public class AccountController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
+18
-18
@@ -37,8 +37,8 @@ public class DefinitionController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Successfully completed query. Query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all definition with size " + listOfDefinitions.size());
|
||||
LOG.debug("Successfully completed query. Query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all definition with size {}", listOfDefinitions.size());
|
||||
|
||||
return new ResponseEntity<>(listOfDefinitions, HttpStatus.OK);
|
||||
}
|
||||
@@ -46,13 +46,13 @@ public class DefinitionController {
|
||||
@GetMapping("/{id}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<DefinitionDto> getDefinitionById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to query for definition with id " + id);
|
||||
LOG.info("Received request to query for definition with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("ERROR: ID was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for definition with id " + id);
|
||||
LOG.debug("Querying for definition with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -61,13 +61,13 @@ public class DefinitionController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
return definition.map(definitionDto -> {
|
||||
LOG.info("Returning definition with id " + id);
|
||||
LOG.info("Returning definition with id {}", id);
|
||||
return new ResponseEntity<>(definitionDto, HttpStatus.OK);
|
||||
}).orElseGet(
|
||||
() -> {
|
||||
LOG.warn("No definition was found with id " + id);
|
||||
LOG.warn("No definition was found with id {}",id);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
});
|
||||
|
||||
@@ -97,9 +97,9 @@ public class DefinitionController {
|
||||
final DefinitionDto savedDefinition = definitionRepository.save(definitionDto);
|
||||
|
||||
stopWatch.stop();
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
LOG.info("Returning the newly created definition with id " + savedDefinition.getId());
|
||||
LOG.info("Returning the newly created definition with id {}", savedDefinition.getId());
|
||||
return new ResponseEntity<>(savedDefinition, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class DefinitionController {
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Checking for existence of definition with id " + id);
|
||||
LOG.debug("Checking for existence of definition with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -133,18 +133,18 @@ public class DefinitionController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
if (!existingDefinition.isPresent()) {
|
||||
LOG.error("No definition associated with id " + id);
|
||||
LOG.error("No definition associated with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
PersistenceUtilities.copyNonNullProperties(definitionDto, existingDefinition.get());
|
||||
existingDefinition.get().setVersion(existingDefinition.get().getVersion()+ 1);
|
||||
|
||||
LOG.info("Updating definition with id " + id);
|
||||
LOG.debug("Querying for definition with ID " + id);
|
||||
LOG.info("Updating definition with id {}", id);
|
||||
LOG.debug("Querying for definition with id {}", id);
|
||||
|
||||
stopWatch.start();
|
||||
|
||||
@@ -152,20 +152,20 @@ public class DefinitionController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(updatedDefinition, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public @ResponseBody ResponseEntity<Void> deleteDefinitionById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to delete definition with id " + id);
|
||||
LOG.info("Received request to delete definition with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("Specified id is null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Deleting definition with id " + id);
|
||||
LOG.debug("Deleting definition with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -174,7 +174,7 @@ public class DefinitionController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
+14
-14
@@ -37,8 +37,8 @@ public class ProofController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Successfully completed query. Query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all theorems with size " + listOfProofs.size());
|
||||
LOG.debug("Successfully completed query. Query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all theorems with size {}", listOfProofs.size());
|
||||
|
||||
return new ResponseEntity<>(listOfProofs, HttpStatus.OK);
|
||||
}
|
||||
@@ -46,13 +46,13 @@ public class ProofController {
|
||||
@GetMapping("/{id}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ProofDto> getProofById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to query for proof with id " + id);
|
||||
LOG.info("Received request to query for proof with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("ERROR: ID was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for proof with id " + id);
|
||||
LOG.debug("Querying for proof with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -61,13 +61,13 @@ public class ProofController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
return proof.map(proofDto -> {
|
||||
LOG.info("Returning proof with id " + id);
|
||||
LOG.info("Returning proof with id {}", id);
|
||||
return new ResponseEntity<>(proofDto, HttpStatus.OK);
|
||||
}).orElseGet(
|
||||
() -> {
|
||||
LOG.warn("No proof was found with id " + id);
|
||||
LOG.warn("No proof was found with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
});
|
||||
|
||||
@@ -76,13 +76,13 @@ public class ProofController {
|
||||
@GetMapping("/{branch}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<List<ProofDto>> getAllProofsByBranch(@PathVariable("branch") final String branch) {
|
||||
LOG.info("Received request to query for proofs related to the " + branch + " branch of mathematics");
|
||||
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
|
||||
if (branch == null) {
|
||||
LOG.error("ERROR: branch was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for proofs with branch " + branch);
|
||||
LOG.debug("Querying for proofs with branch {}", branch);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -91,8 +91,8 @@ public class ProofController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all proofs with size " + listOfProofs.size());
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all proofs with size {}", listOfProofs.size());
|
||||
|
||||
if (listOfProofs.isEmpty()) {
|
||||
LOG.warn("No proofs were found for branch {}", branch);
|
||||
@@ -121,8 +121,8 @@ public class ProofController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all proofs with size " + listOfProofs.size());
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all proofs with size {}", listOfProofs.size());
|
||||
|
||||
if (listOfProofs.isEmpty()) {
|
||||
LOG.warn("No proofs were found of the theorem {}", theoremName);
|
||||
@@ -184,7 +184,7 @@ public class ProofController {
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Checking for existence of proof with id " + id);
|
||||
LOG.debug("Checking for existence of proof with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
|
||||
+30
-30
@@ -37,8 +37,8 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Successfully completed query. Query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||
LOG.debug("Successfully completed query. Query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all theorems with size {}", listOfTheorems.size());
|
||||
|
||||
return new ResponseEntity<>(listOfTheorems, HttpStatus.OK);
|
||||
}
|
||||
@@ -46,13 +46,13 @@ public class TheoremController {
|
||||
@GetMapping("/{branch}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByBranch(@PathVariable("branch") final String branch) {
|
||||
LOG.info("Received request to query for theorems related to the " + branch + " branch of mathematics");
|
||||
LOG.info("Received request to query for theorems related to the {} branch of mathematics", branch);
|
||||
if (branch == null) {
|
||||
LOG.error("ERROR: branch was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for theorems with branch " + branch);
|
||||
LOG.debug("Querying for theorems with branch {}", branch);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -61,8 +61,8 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all theorems with size {}", listOfTheorems.size());
|
||||
|
||||
if (listOfTheorems.isEmpty()) {
|
||||
LOG.warn("No theorems were found for branch {}", branch);
|
||||
@@ -76,13 +76,13 @@ public class TheoremController {
|
||||
@GetMapping("/{proven_status}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByProvenStatus(@PathVariable("proven_status") final Boolean provenStatus) {
|
||||
LOG.info("Received request to query for theorems whose proven status is " + provenStatus);
|
||||
LOG.info("Received request to query for theorems whose proven status is {}", provenStatus);
|
||||
if (provenStatus == null) {
|
||||
LOG.error("ERROR: status was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for theorems with proven status " + provenStatus);
|
||||
LOG.debug("Querying for theorems with proven status {}", provenStatus);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -91,8 +91,8 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all theorems with size {}", listOfTheorems.size());
|
||||
|
||||
if (listOfTheorems.isEmpty()) {
|
||||
LOG.warn("No theorems were found for proven status {}", provenStatus);
|
||||
@@ -106,13 +106,13 @@ public class TheoremController {
|
||||
@GetMapping("/{name}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByName(@PathVariable("name") final String name) {
|
||||
LOG.info("Received request to query for theorems whose name is " + name);
|
||||
LOG.info("Received request to query for theorems whose name is {}", name);
|
||||
if (name == null) {
|
||||
LOG.error("ERROR: name was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for theorems with name " + name);
|
||||
LOG.debug("Querying for theorems with name {}", name);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -121,8 +121,8 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
LOG.info("Returning list of all theorems with size {}", listOfTheorems.size());
|
||||
|
||||
if (listOfTheorems.isEmpty()) {
|
||||
LOG.warn("No theorems were found with name {}", name);
|
||||
@@ -136,13 +136,13 @@ public class TheoremController {
|
||||
@GetMapping("/{id}")
|
||||
public @ResponseBody
|
||||
ResponseEntity<TheoremDto> getTheoremById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to query for theorem with id " + id);
|
||||
LOG.info("Received request to query for theorem with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("ERROR: ID was null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Querying for theorem with id " + id);
|
||||
LOG.debug("Querying for theorem with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -151,13 +151,13 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
return theorem.map(theoremDto -> {
|
||||
LOG.info("Returning theorem with id " + id);
|
||||
LOG.info("Returning theorem with id {}", id);
|
||||
return new ResponseEntity<>(theoremDto, HttpStatus.OK);
|
||||
}).orElseGet(
|
||||
() -> {
|
||||
LOG.warn("No theorem was found with id " + id);
|
||||
LOG.warn("No theorem was found with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
});
|
||||
|
||||
@@ -187,9 +187,9 @@ public class TheoremController {
|
||||
final TheoremDto savedTheorem = theoremRepository.save(theoremDto);
|
||||
|
||||
stopWatch.stop();
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
LOG.info("Returning the newly created theorem with id " + savedTheorem.getId());
|
||||
LOG.info("Returning the newly created theorem with id {}", savedTheorem.getId());
|
||||
return new ResponseEntity<>(savedTheorem, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class TheoremController {
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Checking for existence of theorem with id " + id);
|
||||
LOG.debug("Checking for existence of theorem with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -223,18 +223,18 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
if (!existingTheorem.isPresent()) {
|
||||
LOG.error("No theorem associated with id " + id);
|
||||
LOG.error("No theorem associated with id {}", id);
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
PersistenceUtilities.copyNonNullProperties(theoremDto, existingTheorem.get());
|
||||
existingTheorem.get().setVersion(existingTheorem.get().getVersion()+ 1);
|
||||
|
||||
LOG.info("Updating theorem with id " + id);
|
||||
LOG.debug("Querying for theorem with ID " + id);
|
||||
LOG.info("Updating theorem with id {}", id);
|
||||
LOG.debug("Querying for theorem with id {}", id);
|
||||
|
||||
stopWatch.start();
|
||||
|
||||
@@ -242,20 +242,20 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(updatedTheorem, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public @ResponseBody ResponseEntity<Void> deleteTheoremById(@PathVariable("id") final Integer id) {
|
||||
LOG.info("Received request to delete theorem with id " + id);
|
||||
LOG.info("Received request to delete theorem with id {}", id);
|
||||
if (id == null) {
|
||||
LOG.error("Specified id is null");
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
LOG.debug("Deleting theorem with id " + id);
|
||||
LOG.debug("Deleting theorem with id {}", id);
|
||||
|
||||
final StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
@@ -264,7 +264,7 @@ public class TheoremController {
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user