upgrade spring, add javadoc, formatting
This commit is contained in:
@@ -29,13 +29,12 @@ public class DebugController extends DebugLogger {
|
||||
/**
|
||||
* Debug.
|
||||
*
|
||||
* @param payload the payload
|
||||
* @param request the request
|
||||
* @param payload the payload
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
*/
|
||||
@RequestMapping("/**")
|
||||
public void debug(@RequestBody Optional<Object> payload, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
public void debug(@RequestBody Optional<Object> payload, HttpServletRequest request, HttpServletResponse response) {
|
||||
parteyApiAuthentication.authenticateRequest(request);
|
||||
|
||||
debugPrintRequest(request, payload);
|
||||
|
||||
@@ -38,8 +38,8 @@ public class MapController extends DebugLogger {
|
||||
/**
|
||||
* Gets the map data.
|
||||
*
|
||||
* @param playUri the play uri
|
||||
* @param request the request
|
||||
* @param playUri the play uri
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @return the map data
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ public class MapController extends DebugLogger {
|
||||
|
||||
Room room = parteyMapManager.parseRoom(playUri, request);
|
||||
mapData.setMapUrl(room.getMapUrl());
|
||||
|
||||
|
||||
if (room.getTags() != null) {
|
||||
mapData.setTags(room.getTags());
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ReportController extends DebugLogger {
|
||||
* Report.
|
||||
*
|
||||
* @param userReport the user report
|
||||
* @param request the request
|
||||
* @param request the request
|
||||
*/
|
||||
@PostMapping("")
|
||||
public void report(@RequestBody UserReport userReport, HttpServletRequest request) {
|
||||
|
||||
@@ -64,11 +64,11 @@ public class RoomController extends DebugLogger {
|
||||
/**
|
||||
* Access.
|
||||
*
|
||||
* @param userIdentifier the user identifier
|
||||
* @param roomId the room id
|
||||
* @param userIdentifier the user identifier
|
||||
* @param roomId the room id
|
||||
* @param characterLayers the character layers
|
||||
* @param ipAddress the ip address
|
||||
* @param request the request
|
||||
* @param ipAddress the ip address
|
||||
* @param request the request
|
||||
* @return the member data
|
||||
*/
|
||||
@GetMapping("/access")
|
||||
@@ -110,8 +110,7 @@ public class RoomController extends DebugLogger {
|
||||
if (user != null && permissionManager.isFullUser(user.getId())
|
||||
&& permissionManager.hasPermission(user.getId(), ParteyPermissions.PARTEY)) {
|
||||
|
||||
ParteyUserTextures parteyUserTextures = parteyUserTexturesManager
|
||||
.getByTarget(user.getId());
|
||||
ParteyUserTextures parteyUserTextures = parteyUserTexturesManager.getByTarget(user.getId());
|
||||
|
||||
if (characterLayers.isPresent()) {
|
||||
if (parteyUserTextures == null) {
|
||||
@@ -125,9 +124,8 @@ public class RoomController extends DebugLogger {
|
||||
parteyUserTextures.setTextures(Lists.newArrayList());
|
||||
}
|
||||
|
||||
if (parteyUserTextures.getTextures().size() != characterLayers.get().length
|
||||
|| !parteyUserTextures.getTextures()
|
||||
.containsAll(Lists.newArrayList(characterLayers.get()))) {
|
||||
if (parteyUserTextures.getTextures().size() != characterLayers.get().length || !parteyUserTextures
|
||||
.getTextures().containsAll(Lists.newArrayList(characterLayers.get()))) {
|
||||
parteyUserTextures.setTextures(Lists.newArrayList(characterLayers.get()));
|
||||
parteyUserTextures = parteyUserTexturesManager.save(parteyUserTextures);
|
||||
}
|
||||
@@ -151,8 +149,7 @@ public class RoomController extends DebugLogger {
|
||||
}
|
||||
}
|
||||
|
||||
for (ParteyUserTag parteyUserTag : parteyUserTagManager
|
||||
.getNonExpiredForUsername(user.getUsername())) {
|
||||
for (ParteyUserTag parteyUserTag : parteyUserTagManager.getNonExpiredForUsername(user.getUsername())) {
|
||||
memberData.getTags().add(parteyUserTag.getTag());
|
||||
}
|
||||
}
|
||||
@@ -179,8 +176,7 @@ public class RoomController extends DebugLogger {
|
||||
* @return the list
|
||||
*/
|
||||
@GetMapping("/sameWorld")
|
||||
public List<String> sameWorld(@RequestParam("roomUrl") String roomUrl,
|
||||
HttpServletRequest request) {
|
||||
public List<String> sameWorld(@RequestParam("roomUrl") String roomUrl, HttpServletRequest request) {
|
||||
parteyApiAuthentication.authenticateRequest(request);
|
||||
|
||||
debugPrintRequest(request);
|
||||
|
||||
@@ -39,8 +39,7 @@ public class WokaController extends DebugLogger {
|
||||
* @return the woka list
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Map<String, WokaLayer> getWokaList(@RequestParam("roomUrl") String roomUrl,
|
||||
HttpServletRequest request) {
|
||||
public Map<String, WokaLayer> getWokaList(@RequestParam("roomUrl") String roomUrl, HttpServletRequest request) {
|
||||
parteyApiAuthentication.authenticateRequest(request);
|
||||
debugPrintRequest(request);
|
||||
|
||||
|
||||
@@ -37,19 +37,13 @@ public class DebugLogger {
|
||||
* @param payload the payload
|
||||
*/
|
||||
public void debugPrintRequest(HttpServletRequest request, Optional<Object> payload) {
|
||||
logger.debug("Request: "
|
||||
+ request.getMethod().toUpperCase()
|
||||
+ " "
|
||||
+ request.getRequestURI());
|
||||
logger.debug("Request: " + request.getMethod().toUpperCase() + " " + request.getRequestURI());
|
||||
|
||||
logger.debug("Headers:");
|
||||
|
||||
for (Iterator<String> it = request.getHeaderNames().asIterator(); it.hasNext();) {
|
||||
String headerName = it.next();
|
||||
logger.debug("\t"
|
||||
+ headerName
|
||||
+ ": "
|
||||
+ request.getHeader(headerName));
|
||||
logger.debug("\t" + headerName + ": " + request.getHeader(headerName));
|
||||
}
|
||||
|
||||
if (!request.getParameterMap().isEmpty()) {
|
||||
@@ -57,10 +51,7 @@ public class DebugLogger {
|
||||
for (Iterator<String> it = request.getParameterNames().asIterator(); it.hasNext();) {
|
||||
String parameterName = it.next();
|
||||
for (String value : request.getParameterValues(parameterName)) {
|
||||
logger.debug("\t"
|
||||
+ parameterName
|
||||
+ ": "
|
||||
+ value);
|
||||
logger.debug("\t" + parameterName + ": " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,12 +68,11 @@ public class DebugLogger {
|
||||
* Debug print response.
|
||||
*
|
||||
* @param response the response
|
||||
* @param payload the payload
|
||||
* @param payload the payload
|
||||
*/
|
||||
public void debugPrintResponse(HttpServletRequest response, Optional<Object> payload) {
|
||||
if (payload.isPresent()) {
|
||||
logger.debug("Response: "
|
||||
+ response.getRequestURI());
|
||||
logger.debug("Response: " + response.getRequestURI());
|
||||
logger.debug("Body:");
|
||||
logger.debug(gson.toJson(payload.get()));
|
||||
logger.debug("");
|
||||
|
||||
@@ -42,9 +42,7 @@ public class WokaListManager implements SmartInitializingSingleton {
|
||||
}.getType();
|
||||
|
||||
/*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#
|
||||
* afterSingletonsInstantiated()
|
||||
*/
|
||||
@@ -55,8 +53,7 @@ public class WokaListManager implements SmartInitializingSingleton {
|
||||
Resource resource = resourceLoader.getResource("classpath:woka.json");
|
||||
|
||||
if (resource.exists()) {
|
||||
wokaList = gson.fromJson(new InputStreamReader(resource.getInputStream()),
|
||||
wokaListType);
|
||||
wokaList = gson.fromJson(new InputStreamReader(resource.getInputStream()), wokaListType);
|
||||
systemPropertyManager.add("partey.woka.list", gson.toJson(wokaList));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,7 @@ public class ParteyApiAuthentication {
|
||||
*/
|
||||
public void authenticateRequest(HttpServletRequest request) {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null && auth.isAuthenticated()
|
||||
&& auth.getPrincipal() instanceof LocalUserDetails) {
|
||||
if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof LocalUserDetails) {
|
||||
LocalUserDetails details = (LocalUserDetails) auth.getPrincipal();
|
||||
if (!permissionManager.hasPermission(details.getUserId(), Permissions.ROLE_ADMIN)) {
|
||||
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||
|
||||
@@ -55,9 +55,9 @@ public class ParteyMapManager {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ public class ParteyMapManager {
|
||||
/**
|
||||
* Parses the room.
|
||||
*
|
||||
* @param url the url
|
||||
* @param url the url
|
||||
* @param request the request
|
||||
* @return the room
|
||||
*/
|
||||
|
||||
@@ -31,9 +31,9 @@ public class ParteyUserReportManager {
|
||||
* Creates the.
|
||||
*
|
||||
* @param reporter the reporter
|
||||
* @param user the user
|
||||
* @param comment the comment
|
||||
* @param world the world
|
||||
* @param user the user
|
||||
* @param comment the comment
|
||||
* @param world the world
|
||||
* @return the partey user report
|
||||
*/
|
||||
public ParteyUserReport create(Long reporter, Long user, String comment, String world) {
|
||||
@@ -55,9 +55,9 @@ public class ParteyUserReportManager {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
@@ -100,8 +100,8 @@ public class ParteyUserReportManager {
|
||||
* @param before the before
|
||||
*/
|
||||
public void deleteAllBefore(Instant before) {
|
||||
parteyUserReportRepository.deleteAll(
|
||||
parteyUserReportRepository.findAll(qParteyUserReport.created.before(before)));
|
||||
parteyUserReportRepository
|
||||
.deleteAll(parteyUserReportRepository.findAll(qParteyUserReport.created.before(before)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-7
@@ -42,14 +42,13 @@ public class ParteyUserReportModeratorManager {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
public Page<ParteyUserReportModerator> get(int page, int size, String sortBy,
|
||||
boolean descending) {
|
||||
public Page<ParteyUserReportModerator> get(int page, int size, String sortBy, boolean descending) {
|
||||
PageRequest pageRequest = PageRequest.of(page, size,
|
||||
descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending());
|
||||
|
||||
@@ -79,8 +78,7 @@ public class ParteyUserReportModeratorManager {
|
||||
User user = userManager.get(parteyUserReport.getUser());
|
||||
|
||||
String text = String.format(textTemplate, reporter.getUsername(), user.getUsername(),
|
||||
parteyUserReport.getWorld(), parteyUserReport.getCreated(),
|
||||
parteyUserReport.getComment());
|
||||
parteyUserReport.getWorld(), parteyUserReport.getCreated(), parteyUserReport.getComment());
|
||||
|
||||
List<String> bcc = Lists.newArrayList();
|
||||
for (ParteyUserReportModerator parteyUserReportModerator : parteyUserReportModeratorRepository
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the all.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the all
|
||||
*/
|
||||
@@ -60,8 +60,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @return the all by user id
|
||||
*/
|
||||
public List<ParteyUserTag> getAllByUserId(Long userId) {
|
||||
return Lists
|
||||
.newArrayList(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(userId)));
|
||||
return Lists.newArrayList(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(userId)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +76,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the non expired by user id.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param userId the user id
|
||||
* @param upcoming the upcoming
|
||||
* @return the non expired by user id
|
||||
*/
|
||||
@@ -88,8 +87,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now())));
|
||||
|
||||
if (!upcoming) {
|
||||
query.and(
|
||||
qParteyUserTag.starts.isNull().or(qParteyUserTag.starts.before(Instant.now())));
|
||||
query.and(qParteyUserTag.starts.isNull().or(qParteyUserTag.starts.before(Instant.now())));
|
||||
}
|
||||
|
||||
return Lists.newArrayList(parteyUserTagRepository.findAll(query.getValue()));
|
||||
@@ -103,9 +101,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
*/
|
||||
public List<ParteyUserTag> getAllForUsername(String username) {
|
||||
User user = userManager.getByUsername(username);
|
||||
Assert.notNull(user, "invalid username: '"
|
||||
+ username
|
||||
+ "'!");
|
||||
Assert.notNull(user, "invalid username: '" + username + "'!");
|
||||
return getAllByUserId(user.getId());
|
||||
}
|
||||
|
||||
@@ -129,9 +125,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
*/
|
||||
public List<ParteyUserTag> getNonExpiredForUsername(String username, boolean upcoming) {
|
||||
User user = userManager.getByUsername(username);
|
||||
Assert.notNull(user, "invalid username: '"
|
||||
+ username
|
||||
+ "'!");
|
||||
Assert.notNull(user, "invalid username: '" + username + "'!");
|
||||
return getNonExpiredByUserId(user.getId(), upcoming);
|
||||
}
|
||||
|
||||
@@ -151,8 +145,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @param parteyUserTag the partey user tag
|
||||
*/
|
||||
public void delete(ParteyUserTag parteyUserTag) {
|
||||
parteyUserTagRepository
|
||||
.deleteById(new ParteyUserTagId(parteyUserTag.getTarget(), parteyUserTag.getTag()));
|
||||
parteyUserTagRepository.deleteById(new ParteyUserTagId(parteyUserTag.getTarget(), parteyUserTag.getTag()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +154,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @param target the target
|
||||
*/
|
||||
public void deleteAllForTarget(Long target) {
|
||||
parteyUserTagRepository
|
||||
.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(target)));
|
||||
parteyUserTagRepository.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(target)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-7
@@ -32,9 +32,9 @@ public class ParteyUserTexturesManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the all.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the all
|
||||
*/
|
||||
@@ -52,8 +52,7 @@ public class ParteyUserTexturesManager implements UserDataProvider {
|
||||
* @return the by target
|
||||
*/
|
||||
public ParteyUserTextures getByTarget(Long userId) {
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.target.eq(userId))
|
||||
.orElse(null);
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.target.eq(userId)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +62,7 @@ public class ParteyUserTexturesManager implements UserDataProvider {
|
||||
* @return the by username
|
||||
*/
|
||||
public ParteyUserTextures getByUsername(String username) {
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.username.eq(username))
|
||||
.orElse(null);
|
||||
return parteyUserTexturesRepository.findOne(qParteyUserTextures.username.eq(username)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,12 +46,11 @@ public class MapManagementController extends BaseController {
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping
|
||||
public Page<ParteyMap> getParteyMaps(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyMap> page = parteyMapManager.get(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("id"), descParameter.orElse(false));
|
||||
Page<ParteyMap> page = parteyMapManager.get(pageParameter.orElse(0), sizeParameter.orElse(10),
|
||||
sortParameter.orElse("id"), descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
|
||||
|
||||
+6
-10
@@ -43,14 +43,12 @@ public class UserReportManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping
|
||||
public Page<ParteyUserReport> getParteyUserReports(
|
||||
@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
public Page<ParteyUserReport> getParteyUserReports(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyUserReport> page = parteyUserReportManager.get(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("id"), descParameter.orElse(false));
|
||||
Page<ParteyUserReport> page = parteyUserReportManager.get(pageParameter.orElse(0), sizeParameter.orElse(10),
|
||||
sortParameter.orElse("id"), descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
|
||||
@@ -64,8 +62,7 @@ public class UserReportManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping
|
||||
public ParteyUserReport createOrUpdateParteyUserReport(
|
||||
@RequestBody ParteyUserReport parteyUserReport) {
|
||||
public ParteyUserReport createOrUpdateParteyUserReport(@RequestBody ParteyUserReport parteyUserReport) {
|
||||
return parteyUserReportManager.save(parteyUserReport);
|
||||
}
|
||||
|
||||
@@ -87,8 +84,7 @@ public class UserReportManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@DeleteMapping()
|
||||
public void deleteAllParteyUserReport(
|
||||
@RequestParam("before") Optional<Instant> beforeParameter) {
|
||||
public void deleteAllParteyUserReport(@RequestParam("before") Optional<Instant> beforeParameter) {
|
||||
if (beforeParameter.isPresent()) {
|
||||
parteyUserReportManager.deleteAllBefore(beforeParameter.get());
|
||||
} else {
|
||||
|
||||
+3
-5
@@ -44,13 +44,11 @@ public class UserReportModeratorManagementController extends BaseController {
|
||||
@GetMapping
|
||||
public Page<ParteyUserReportModerator> getParteyUserReportModerators(
|
||||
@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyUserReportModerator> page = parteyUserReportModeratorManager.get(
|
||||
pageParameter.orElse(0), sizeParameter.orElse(10), sortParameter.orElse("id"),
|
||||
descParameter.orElse(false));
|
||||
Page<ParteyUserReportModerator> page = parteyUserReportModeratorManager.get(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("id"), descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
|
||||
|
||||
+7
-13
@@ -50,15 +50,12 @@ public class UserTagManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping
|
||||
public Page<ParteyUserTag> getParteyUserTags(
|
||||
@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
public Page<ParteyUserTag> getParteyUserTags(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("target"),
|
||||
descParameter.orElse(false));
|
||||
Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0), sizeParameter.orElse(10),
|
||||
sortParameter.orElse("target"), descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
}
|
||||
@@ -71,8 +68,7 @@ public class UserTagManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping("{username}")
|
||||
public List<ParteyUserTag> getParteyUserTagsForTarget(
|
||||
@PathVariable("username") String username) {
|
||||
public List<ParteyUserTag> getParteyUserTagsForTarget(@PathVariable("username") String username) {
|
||||
User user = userManager.getByUsername(username);
|
||||
|
||||
if (user == null) {
|
||||
@@ -90,8 +86,7 @@ public class UserTagManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping("{username}/active")
|
||||
public List<ParteyUserTag> getNonExpiredParteyUserTagsForTarget(
|
||||
@PathVariable("username") String username) {
|
||||
public List<ParteyUserTag> getNonExpiredParteyUserTagsForTarget(@PathVariable("username") String username) {
|
||||
User user = userManager.getByUsername(username);
|
||||
|
||||
if (user == null) {
|
||||
@@ -109,8 +104,7 @@ public class UserTagManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping("{username}/upcoming")
|
||||
public List<ParteyUserTag> getUpcomingParteyUserTagsForTarget(
|
||||
@PathVariable("username") String username) {
|
||||
public List<ParteyUserTag> getUpcomingParteyUserTagsForTarget(@PathVariable("username") String username) {
|
||||
User user = userManager.getByUsername(username);
|
||||
|
||||
if (user == null) {
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ParteyUserTag implements UserData {
|
||||
* Instantiates a new partey user tag id.
|
||||
*
|
||||
* @param target the target
|
||||
* @param tag the tag
|
||||
* @param tag the tag
|
||||
*/
|
||||
public ParteyUserTagId(Long target, String tag) {
|
||||
super();
|
||||
|
||||
@@ -13,6 +13,5 @@ import de.bstly.we.partey.model.ParteyMap;
|
||||
* The Interface ParteyMapRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface ParteyMapRepository
|
||||
extends JpaRepository<ParteyMap, String>, QuerydslPredicateExecutor<ParteyMap> {
|
||||
public interface ParteyMapRepository extends JpaRepository<ParteyMap, String>, QuerydslPredicateExecutor<ParteyMap> {
|
||||
}
|
||||
|
||||
+1
-2
@@ -14,6 +14,5 @@ import de.bstly.we.partey.model.ParteyUserReportModerator;
|
||||
*/
|
||||
@Repository
|
||||
public interface ParteyUserReportModeratorRepository
|
||||
extends JpaRepository<ParteyUserReportModerator, Long>,
|
||||
QuerydslPredicateExecutor<ParteyUserReportModerator> {
|
||||
extends JpaRepository<ParteyUserReportModerator, Long>, QuerydslPredicateExecutor<ParteyUserReportModerator> {
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
|
||||
* The Interface ParteyUserTagRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface ParteyUserTagRepository extends JpaRepository<ParteyUserTag, ParteyUserTagId>,
|
||||
QuerydslPredicateExecutor<ParteyUserTag> {
|
||||
public interface ParteyUserTagRepository
|
||||
extends JpaRepository<ParteyUserTag, ParteyUserTagId>, QuerydslPredicateExecutor<ParteyUserTag> {
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,6 +13,6 @@ import de.bstly.we.partey.model.ParteyUserTextures;
|
||||
* The Interface ParteyUserTexturesRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface ParteyUserTexturesRepository extends JpaRepository<ParteyUserTextures, Long>,
|
||||
QuerydslPredicateExecutor<ParteyUserTextures> {
|
||||
public interface ParteyUserTexturesRepository
|
||||
extends JpaRepository<ParteyUserTextures, Long>, QuerydslPredicateExecutor<ParteyUserTextures> {
|
||||
}
|
||||
|
||||
+17
-20
@@ -64,21 +64,20 @@ public class TimeslotManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param owner the owner
|
||||
* @param invertOwner the invert owner
|
||||
* @param after the after
|
||||
* @param type the type
|
||||
* @param visibility the visibility
|
||||
* @param search the search
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @param after the after
|
||||
* @param type the type
|
||||
* @param visibility the visibility
|
||||
* @param search the search
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type,
|
||||
Visibility visibility, String search, int page, int size, String sortBy,
|
||||
boolean descending) {
|
||||
public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type, Visibility visibility,
|
||||
String search, int page, int size, String sortBy, boolean descending) {
|
||||
|
||||
PageRequest pageRequest = PageRequest.of(page, size,
|
||||
descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending());
|
||||
@@ -106,8 +105,7 @@ public class TimeslotManager implements UserDataProvider {
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(search)) {
|
||||
query.and(qTimeslot.title.containsIgnoreCase(search)
|
||||
.or(qTimeslot.description.containsIgnoreCase(search)));
|
||||
query.and(qTimeslot.title.containsIgnoreCase(search).or(qTimeslot.description.containsIgnoreCase(search)));
|
||||
}
|
||||
|
||||
if (query.hasValue()) {
|
||||
@@ -124,8 +122,8 @@ public class TimeslotManager implements UserDataProvider {
|
||||
* @return the long
|
||||
*/
|
||||
public long quota(Long owner) {
|
||||
return timeslotRepository.count(qTimeslot.owner.eq(owner).and(
|
||||
qTimeslot.starts.after(Instant.now()).or(qTimeslot.ends.after(Instant.now()))));
|
||||
return timeslotRepository.count(qTimeslot.owner.eq(owner)
|
||||
.and(qTimeslot.starts.after(Instant.now()).or(qTimeslot.ends.after(Instant.now()))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,8 +133,7 @@ public class TimeslotManager implements UserDataProvider {
|
||||
* @return the timeslot
|
||||
*/
|
||||
public Timeslot save(Timeslot timeslot) {
|
||||
Assert.isTrue(timeslot.getStarts().isBefore(timeslot.getEnds()),
|
||||
"starts must be before ends.");
|
||||
Assert.isTrue(timeslot.getStarts().isBefore(timeslot.getEnds()), "starts must be before ends.");
|
||||
return timeslotRepository.save(timeslot);
|
||||
}
|
||||
|
||||
@@ -181,8 +178,8 @@ public class TimeslotManager implements UserDataProvider {
|
||||
*/
|
||||
@Scheduled(cron = "0 */5 * * * *")
|
||||
protected void clearEndedTimeslots() {
|
||||
timeslotRepository.deleteAll(timeslotRepository
|
||||
.findAll(qTimeslot.clearAfter.isTrue().and(qTimeslot.ends.before(Instant.now()))));
|
||||
timeslotRepository.deleteAll(
|
||||
timeslotRepository.findAll(qTimeslot.clearAfter.isTrue().and(qTimeslot.ends.before(Instant.now()))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-23
@@ -57,22 +57,21 @@ public class TimeslotController extends BaseController {
|
||||
/**
|
||||
* Gets the timeslots.
|
||||
*
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param visibilityParameter the visibility parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @return the timeslots
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping
|
||||
public Page<Timeslot> getTimeslots(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter,
|
||||
@RequestParam("owner") Optional<String> ownerParameter,
|
||||
@RequestParam("after") Optional<Instant> afterParameter,
|
||||
@@ -92,9 +91,8 @@ public class TimeslotController extends BaseController {
|
||||
}
|
||||
|
||||
Page<Timeslot> page = timeslotManager.get(ownerId,
|
||||
ownerParameter.isPresent() && "others".equals(ownerParameter.get()),
|
||||
afterParameter.orElse(null), typeParameter.orElse(null),
|
||||
visibilityParameter.orElse(null), searchParameter.orElse(null),
|
||||
ownerParameter.isPresent() && "others".equals(ownerParameter.get()), afterParameter.orElse(null),
|
||||
typeParameter.orElse(null), visibilityParameter.orElse(null), searchParameter.orElse(null),
|
||||
pageParameter.orElse(0), sizeParameter.orElse(10), sortParameter.orElse("id"),
|
||||
descParameter.orElse(false));
|
||||
|
||||
@@ -131,8 +129,7 @@ public class TimeslotController extends BaseController {
|
||||
@GetMapping("/quota")
|
||||
public long quota() {
|
||||
Quota timeslotQuota = quotaManager.get(getCurrentUserId(), ParteyQuotas.PARTEY_TIMESLOT);
|
||||
return timeslotQuota == null ? 0
|
||||
: timeslotQuota.getValue() - timeslotManager.quota(getCurrentUserId());
|
||||
return timeslotQuota == null ? 0 : timeslotQuota.getValue() - timeslotManager.quota(getCurrentUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,8 +147,7 @@ public class TimeslotController extends BaseController {
|
||||
}
|
||||
|
||||
Quota timeslotQuota = quotaManager.get(getCurrentUserId(), ParteyQuotas.PARTEY_TIMESLOT);
|
||||
if (timeslotQuota == null
|
||||
|| timeslotQuota.getValue() < timeslotManager.quota(getCurrentUserId())) {
|
||||
if (timeslotQuota == null || timeslotQuota.getValue() < timeslotManager.quota(getCurrentUserId())) {
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
@@ -201,12 +197,9 @@ public class TimeslotController extends BaseController {
|
||||
throw new EntityResponseStatusException(errors.getAllErrors(), HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
if (timeslot.getStarts().isAfter(Instant.now())
|
||||
|| timeslot.getEnds().isAfter(Instant.now())) {
|
||||
Quota timeslotQuota = quotaManager.get(getCurrentUserId(),
|
||||
ParteyQuotas.PARTEY_TIMESLOT);
|
||||
if (timeslotQuota == null
|
||||
|| timeslotQuota.getValue() < timeslotManager.quota(getCurrentUserId())) {
|
||||
if (timeslot.getStarts().isAfter(Instant.now()) || timeslot.getEnds().isAfter(Instant.now())) {
|
||||
Quota timeslotQuota = quotaManager.get(getCurrentUserId(), ParteyQuotas.PARTEY_TIMESLOT);
|
||||
if (timeslotQuota == null || timeslotQuota.getValue() < timeslotManager.quota(getCurrentUserId())) {
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-16
@@ -44,25 +44,23 @@ public class TimeslotManagementController extends BaseController {
|
||||
/**
|
||||
* Gets the timeslots.
|
||||
*
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @param invertOwnerParameter the invert owner parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param visibilityParameter the visibility parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param afterParameter the after parameter
|
||||
* @param typeParameter the type parameter
|
||||
* @param visibilityParameter the visibility parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @return the timeslots
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping
|
||||
public Page<Timeslot> getTimeslots(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter,
|
||||
@RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter,
|
||||
@RequestParam("owner") Optional<Long> ownerParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter, @RequestParam("sort") Optional<String> sortParameter,
|
||||
@RequestParam("desc") Optional<Boolean> descParameter, @RequestParam("owner") Optional<Long> ownerParameter,
|
||||
@RequestParam("owner-invert") Optional<Boolean> invertOwnerParameter,
|
||||
@RequestParam("after") Optional<Instant> afterParameter,
|
||||
@RequestParam("type") Optional<TimeslotType> typeParameter,
|
||||
@@ -70,9 +68,8 @@ public class TimeslotManagementController extends BaseController {
|
||||
@RequestParam("search") Optional<String> searchParameter) {
|
||||
|
||||
Page<Timeslot> page = timeslotManager.get(ownerParameter.orElse(null),
|
||||
invertOwnerParameter.isPresent() && invertOwnerParameter.get(),
|
||||
afterParameter.orElse(null), typeParameter.orElse(null),
|
||||
visibilityParameter.orElse(null), searchParameter.orElse(null),
|
||||
invertOwnerParameter.isPresent() && invertOwnerParameter.get(), afterParameter.orElse(null),
|
||||
typeParameter.orElse(null), visibilityParameter.orElse(null), searchParameter.orElse(null),
|
||||
pageParameter.orElse(0), sizeParameter.orElse(10), sortParameter.orElse("id"),
|
||||
descParameter.orElse(false));
|
||||
|
||||
|
||||
+17
-26
@@ -61,7 +61,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate time.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTime(Timeslot timeslot, Errors errors) {
|
||||
if (timeslot.getStarts() == null) {
|
||||
@@ -89,29 +89,23 @@ public class TimeslotValidator implements Validator {
|
||||
switch (timeslot.getType()) {
|
||||
case AUDIO:
|
||||
case AUDIO_STREAM:
|
||||
timeQuery.and(qTimeslot.type
|
||||
.in(Lists.newArrayList(TimeslotType.AUDIO, TimeslotType.AUDIO_STREAM)));
|
||||
timeQuery.and(qTimeslot.type.in(Lists.newArrayList(TimeslotType.AUDIO, TimeslotType.AUDIO_STREAM)));
|
||||
break;
|
||||
case VIDEO:
|
||||
case VIDEO_STREAM:
|
||||
timeQuery.and(qTimeslot.type
|
||||
.in(Lists.newArrayList(TimeslotType.VIDEO, TimeslotType.VIDEO_STREAM)));
|
||||
timeQuery.and(qTimeslot.type.in(Lists.newArrayList(TimeslotType.VIDEO, TimeslotType.VIDEO_STREAM)));
|
||||
break;
|
||||
}
|
||||
|
||||
// ends after start
|
||||
timeQuery
|
||||
.and(qTimeslot.ends.after(timeslot.getStarts()
|
||||
.minus(systemPropertyManager.getLong(TimeslotManager.TIMESLOT_TOLERANCE,
|
||||
TimeslotManager.TIMESLOT_TOLERANCE_DEFAULT),
|
||||
ChronoUnit.MINUTES)));
|
||||
timeQuery.and(qTimeslot.ends
|
||||
.after(timeslot.getStarts().minus(systemPropertyManager.getLong(TimeslotManager.TIMESLOT_TOLERANCE,
|
||||
TimeslotManager.TIMESLOT_TOLERANCE_DEFAULT), ChronoUnit.MINUTES)));
|
||||
|
||||
// starts before end
|
||||
timeQuery
|
||||
.and(qTimeslot.starts.before(timeslot.getEnds()
|
||||
.plus(systemPropertyManager.getLong(TimeslotManager.TIMESLOT_TOLERANCE,
|
||||
TimeslotManager.TIMESLOT_TOLERANCE_DEFAULT),
|
||||
ChronoUnit.MINUTES)));
|
||||
timeQuery.and(qTimeslot.starts
|
||||
.before(timeslot.getEnds().plus(systemPropertyManager.getLong(TimeslotManager.TIMESLOT_TOLERANCE,
|
||||
TimeslotManager.TIMESLOT_TOLERANCE_DEFAULT), ChronoUnit.MINUTES)));
|
||||
|
||||
if (timeslot.getId() != null && timeslotRepository.existsById(timeslot.getId())) {
|
||||
timeQuery.and(qTimeslot.id.ne(timeslot.getId()));
|
||||
@@ -120,14 +114,11 @@ public class TimeslotValidator implements Validator {
|
||||
if (timeslotRepository.exists(timeQuery.getValue())) {
|
||||
errors.rejectValue("starts", "ALREADY_EXISTS");
|
||||
errors.rejectValue("ends", "ALREADY_EXISTS");
|
||||
} else if (((timeslot.getEnds().getEpochSecond()
|
||||
- timeslot.getStarts().getEpochSecond()) / 60) > systemPropertyManager.getLong(
|
||||
TimeslotManager.TIMESLOT_MINUTES,
|
||||
} else if (((timeslot.getEnds().getEpochSecond() - timeslot.getStarts().getEpochSecond())
|
||||
/ 60) > systemPropertyManager.getLong(TimeslotManager.TIMESLOT_MINUTES,
|
||||
TimeslotManager.TIMESLOT_MINUTES_DEFAULT)) {
|
||||
errors.rejectValue("ends", "TOO_LONG",
|
||||
String.valueOf(
|
||||
systemPropertyManager.getLong(TimeslotManager.TIMESLOT_MINUTES,
|
||||
TimeslotManager.TIMESLOT_MINUTES_DEFAULT)));
|
||||
errors.rejectValue("ends", "TOO_LONG", String.valueOf(systemPropertyManager
|
||||
.getLong(TimeslotManager.TIMESLOT_MINUTES, TimeslotManager.TIMESLOT_MINUTES_DEFAULT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +127,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate type.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateType(Timeslot timeslot, Errors errors) {
|
||||
if (timeslot.getId() != null && timeslotRepository.existsById(timeslot.getId())) {
|
||||
@@ -165,7 +156,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate share.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateShare(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setStream(null);
|
||||
@@ -180,7 +171,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate type audio stream.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTypeAudioStream(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setStream(null);
|
||||
@@ -199,7 +190,7 @@ public class TimeslotValidator implements Validator {
|
||||
* Validate type video stream.
|
||||
*
|
||||
* @param timeslot the timeslot
|
||||
* @param errors the errors
|
||||
* @param errors the errors
|
||||
*/
|
||||
public void validateTypeVideoStream(Timeslot timeslot, Errors errors) {
|
||||
timeslot.setSecret(null);
|
||||
|
||||
@@ -13,6 +13,5 @@ import de.bstly.we.partey.timeslot.model.Timeslot;
|
||||
* The Interface TimeslotRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface TimeslotRepository
|
||||
extends JpaRepository<Timeslot, Long>, QuerydslPredicateExecutor<Timeslot> {
|
||||
public interface TimeslotRepository extends JpaRepository<Timeslot, Long>, QuerydslPredicateExecutor<Timeslot> {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user