Skip to content

Commit

Permalink
Issue161 (#169)
Browse files Browse the repository at this point in the history
* issue #161: made packages all lower case

* issue #161: replaced @RequestMapping with @GetMapping, @PostMapping, @PutMapping, @DeleteMapping

* issue #161: fixed log statements, squid:S3457

* issue #161: fixed some more easy sonar issues
  • Loading branch information
aabeling authored and Christoph-Meyer committed Dec 17, 2018
1 parent ecd5392 commit 36db4fb
Show file tree
Hide file tree
Showing 124 changed files with 643 additions and 596 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest;
package com.viadee.sonarquest;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.configurations;
package com.viadee.sonarquest.configurations;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.configurations;
package com.viadee.sonarquest.configurations;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.constants;
package com.viadee.sonarquest.constants;

public enum AdventureState {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.constants;
package com.viadee.sonarquest.constants;

public enum PermissionType {
URL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.constants;
package com.viadee.sonarquest.constants;

public enum QuestState {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.viadee.sonarQuest.constants;
package com.viadee.sonarquest.constants;

public enum SkillType {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
package com.viadee.sonarQuest.controllers;
package com.viadee.sonarquest.controllers;

import java.security.Principal;
import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.viadee.sonarQuest.constants.AdventureState;
import com.viadee.sonarQuest.entities.Adventure;
import com.viadee.sonarQuest.entities.Quest;
import com.viadee.sonarQuest.entities.User;
import com.viadee.sonarQuest.entities.World;
import com.viadee.sonarQuest.repositories.AdventureRepository;
import com.viadee.sonarQuest.repositories.QuestRepository;
import com.viadee.sonarQuest.repositories.WorldRepository;
import com.viadee.sonarQuest.services.AdventureService;
import com.viadee.sonarQuest.services.GratificationService;
import com.viadee.sonarQuest.services.UserService;
import com.viadee.sonarquest.constants.AdventureState;
import com.viadee.sonarquest.entities.Adventure;
import com.viadee.sonarquest.entities.Quest;
import com.viadee.sonarquest.entities.User;
import com.viadee.sonarquest.entities.World;
import com.viadee.sonarquest.repositories.AdventureRepository;
import com.viadee.sonarquest.repositories.QuestRepository;
import com.viadee.sonarquest.repositories.WorldRepository;
import com.viadee.sonarquest.services.AdventureService;
import com.viadee.sonarquest.services.GratificationService;
import com.viadee.sonarquest.services.UserService;

@RestController
@RequestMapping("/adventure")
Expand All @@ -47,47 +50,47 @@ public class AdventureController {
@Autowired
private GratificationService gratificationService;

@RequestMapping(method = RequestMethod.GET)
@GetMapping
public List<Adventure> getAllAdventures() {
return adventureRepository.findAll();
}

@RequestMapping(value = "/world/{id}", method = RequestMethod.GET)
@GetMapping(value = "/world/{id}")
public List<Adventure> getAllAdventuresForWorld(@PathVariable(value = "id") final Long world_id) {
final World w = worldRepository.findOne(world_id);
return adventureRepository.findByWorld(w);
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@GetMapping(value = "/{id}")
public Adventure getAdventureById(@PathVariable(value = "id") final Long id) {
return adventureRepository.findOne(id);
}

@RequestMapping(value = "/getJoined/{world_id}", method = RequestMethod.GET)
@GetMapping(value = "/getJoined/{world_id}")
public List<Adventure> getJoinedAdventures(final Principal principal,
@PathVariable(value = "world_id") final Long world_id) {
final World w = worldRepository.findOne(world_id);
final User user = userService.findByUsername(principal.getName());
return adventureService.getJoinedAdventuresForUserInWorld(w, user);
}

@RequestMapping(value = "/getFree/{world_id}", method = RequestMethod.GET)
@GetMapping(value = "/getFree/{world_id}")
public List<Adventure> getFreeAdventures(final Principal principal,
@PathVariable(value = "world_id") final Long world_id) {
final World w = worldRepository.findOne(world_id);
final User user = userService.findByUsername(principal.getName());
return adventureService.getFreeAdventuresForUserInWorld(w, user);
}

@RequestMapping(method = RequestMethod.POST)
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Adventure createAdventure(@RequestBody final Adventure adventure) {
adventure.setStatus(AdventureState.OPEN);
adventure.setStartdate(new Date(System.currentTimeMillis()));
return adventureRepository.save(adventure);
}

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@PutMapping(value = "/{id}")
public Adventure updateAdventure(@PathVariable(value = "id") final Long id,
@RequestBody final Adventure data) {
Adventure adventure = adventureRepository.findOne(id);
Expand All @@ -102,15 +105,15 @@ public Adventure updateAdventure(@PathVariable(value = "id") final Long id,
return adventure;
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@DeleteMapping(value = "/{id}")
public void deleteAdventure(@PathVariable(value = "id") final Long id) {
final Adventure adventure = adventureRepository.findOne(id);
if (adventure != null) {
adventureRepository.delete(adventure);
}
}

@RequestMapping(value = "/{adventureId}/solveAdventure", method = RequestMethod.PUT)
@PutMapping(value = "/{adventureId}/solveAdventure")
public Adventure solveAdventure(@PathVariable(value = "adventureId") final Long adventureId) {
final Adventure adventure = adventureRepository.findOne(adventureId);
if (adventure != null) {
Expand All @@ -122,7 +125,7 @@ public Adventure solveAdventure(@PathVariable(value = "adventureId") final Long
return adventure;
}

@RequestMapping(value = "/{adventureId}/addQuest/{questId}", method = RequestMethod.POST)
@PostMapping(value = "/{adventureId}/addQuest/{questId}")
@ResponseStatus(HttpStatus.CREATED)
public Adventure addQuest(@PathVariable(value = "adventureId") final Long adventureId,
@PathVariable(value = "questId") final Long questId) {
Expand All @@ -140,7 +143,7 @@ public Adventure addQuest(@PathVariable(value = "adventureId") final Long advent
return adventure;
}

@RequestMapping(value = "/{adventureId}/join", method = RequestMethod.POST)
@PostMapping(value = "/{adventureId}/join")
@ResponseStatus(HttpStatus.CREATED)
public Adventure join(final Principal principal, @PathVariable(value = "adventureId") final Long adventureId) {
final String username = principal.getName();
Expand All @@ -156,7 +159,7 @@ public Adventure join(final Principal principal, @PathVariable(value = "adventur
* The id of the developer to remove
* @return Gives the adventure where the Developer was removed
*/
@RequestMapping(value = "/{adventureId}/leave", method = RequestMethod.POST)
@PostMapping(value = "/{adventureId}/leave")
public Adventure leave(final Principal principal,
@PathVariable(value = "adventureId") final Long adventureId) {
final String username = principal.getName();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.viadee.sonarQuest.controllers;
package com.viadee.sonarquest.controllers;

import java.security.Principal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.viadee.sonarQuest.entities.Artefact;
import com.viadee.sonarQuest.entities.User;
import com.viadee.sonarQuest.repositories.ArtefactRepository;
import com.viadee.sonarQuest.services.ArtefactService;
import com.viadee.sonarQuest.services.UserService;
import com.viadee.sonarquest.entities.Artefact;
import com.viadee.sonarquest.entities.User;
import com.viadee.sonarquest.repositories.ArtefactRepository;
import com.viadee.sonarquest.services.ArtefactService;
import com.viadee.sonarquest.services.UserService;

@RestController
@RequestMapping("/artefact")
Expand All @@ -31,42 +34,42 @@ public class ArtefactController {
@Autowired
private UserService userService;

@RequestMapping(method = RequestMethod.GET)
@GetMapping
public List<Artefact> getAllArtefacts() {
return artefactService.getArtefacts();
}

@RequestMapping(value = "/forMarketplace/", method = RequestMethod.GET)
@GetMapping(value = "/forMarketplace/")
public List<Artefact> getArtefactsforMarkteplace() {
return artefactService.getArtefactsforMarkteplace();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@GetMapping(value = "/{id}")
public Artefact getArtefactById(@PathVariable(value = "id") final Long id) {
return artefactService.getArtefact(id);
}

@RequestMapping(method = RequestMethod.POST)
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Artefact createArtefact(@RequestBody final Artefact artefact) {
return artefactService.createArtefact(artefact);
}

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@PutMapping(value = "/{id}")
public Artefact updateArtefact(@PathVariable(value = "id") final Long id,
@RequestBody final Artefact artefactDto) {
return artefactService.updateArtefact(id, artefactDto);
}

@RequestMapping(value = "/{artefact_id}/buy", method = RequestMethod.PUT)
@PutMapping(value = "/{artefact_id}/buy")
public boolean buyArtefact(final Principal principal, @PathVariable(value = "artefact_id") final Long artefact_id) {
final User user = userService.findByUsername(principal.getName());
final Artefact artefact = artefactRepository.findOne(artefact_id);

return artefactService.buyArtefact(artefact, user) != null;
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@DeleteMapping(value = "/{id}")
public void deleteArtefact(@PathVariable(value = "id") final Long id) {
if (artefactRepository.findOne(id) != null) {
artefactRepository.delete(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package com.viadee.sonarQuest.controllers;
package com.viadee.sonarquest.controllers;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.viadee.sonarQuest.entities.AvatarClass;
import com.viadee.sonarQuest.repositories.AvatarClassRepository;
import com.viadee.sonarquest.entities.AvatarClass;
import com.viadee.sonarquest.repositories.AvatarClassRepository;

@RestController
@RequestMapping("/avatarClass")
Expand All @@ -23,24 +26,24 @@ public AvatarClassController(final AvatarClassRepository avatarClassRepository)
this.avatarClassRepository = avatarClassRepository;
}

@RequestMapping(method = RequestMethod.GET)
@GetMapping
public List<AvatarClass> getAllAvatarClasses() {
return avatarClassRepository.findAll();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@GetMapping(value = "/{id}")
public AvatarClass getAvatarClassById(@PathVariable(value = "id") final Long id) {
return avatarClassRepository.findOne(id);
}

@RequestMapping(method = RequestMethod.POST)
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public AvatarClass createAvatarClass(@RequestBody final AvatarClass avatarClass) {
return avatarClassRepository.save(avatarClass);

}

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@PutMapping(value = "/{id}")
public AvatarClass updateAvatarClass(@PathVariable(value = "id") final Long id,
@RequestBody final AvatarClass data) {
AvatarClass avatarClass = avatarClassRepository.findOne(id);
Expand All @@ -52,7 +55,7 @@ public AvatarClass updateAvatarClass(@PathVariable(value = "id") final Long id,
return avatarClass;
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@DeleteMapping(value = "/{id}")
public void deleteAvatarClass(@PathVariable(value = "id") final Long id) {
final AvatarClass level = avatarClassRepository.findOne(id);
if (level != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package com.viadee.sonarQuest.controllers;
package com.viadee.sonarquest.controllers;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.viadee.sonarQuest.entities.AvatarRace;
import com.viadee.sonarQuest.repositories.AvatarRaceRepository;
import com.viadee.sonarquest.entities.AvatarRace;
import com.viadee.sonarquest.repositories.AvatarRaceRepository;

@RestController
@RequestMapping("/avatarRace")
Expand All @@ -23,24 +26,24 @@ public AvatarRaceController(final AvatarRaceRepository avatarRaceRepository) {
this.avatarRaceRepository = avatarRaceRepository;
}

@RequestMapping(method = RequestMethod.GET)
@GetMapping
public List<AvatarRace> getAllAvatarRaces() {
return avatarRaceRepository.findAll();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@GetMapping(value = "/{id}")
public AvatarRace getAvatarRaceById(@PathVariable(value = "id") final Long id) {
return avatarRaceRepository.findOne(id);
}

@RequestMapping(method = RequestMethod.POST)
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public AvatarRace createAvatarRace(@RequestBody final AvatarRace avatarRace) {
return avatarRaceRepository.save(avatarRace);

}

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@PutMapping(value = "/{id}")
public AvatarRace updateAvatarRace(@PathVariable(value = "id") final Long id, @RequestBody final AvatarRace data) {
AvatarRace avatarRace = avatarRaceRepository.findOne(id);
if (avatarRace != null) {
Expand All @@ -50,7 +53,7 @@ public AvatarRace updateAvatarRace(@PathVariable(value = "id") final Long id, @R
return avatarRace;
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@DeleteMapping(value = "/{id}")
public void deleteAvatarRace(@PathVariable(value = "id") final Long id) {
final AvatarRace level = avatarRaceRepository.findOne(id);
if (level != null) {
Expand Down
Loading

0 comments on commit 36db4fb

Please sign in to comment.